From 3004d30cc387bde2db2f06c646ce09c12edd68dc Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 26 Jul 2024 19:01:20 +0200 Subject: [PATCH] corrige deux/trois bricoles --- config/packages/stof_doctrine_extensions.yaml | 1 + migrations/Version20240726120017.php | 33 -------- src/Controller/ProjectController.php | 19 +++-- src/Controller/TaskController.php | 109 +++++++++++++++---------- src/DataFixtures/AppFixtures.php | 8 ++ src/Entity/Project.php | 32 ++++++++ src/Entity/Task.php | 84 +++++++++++++++++++ src/Entity/User.php | 80 ++++++++++++++++++ src/Service/GeoJsonManager.php | 2 +- templates/partials/_project-metadata.html.twig | 12 +++ templates/partials/_task-locking.html.twig | 20 +++++ templates/partials/_task-metadata.html.twig | 12 +++ templates/partials/_task-title.html.twig | 2 + templates/project/index.html.twig | 9 +- templates/project/show.html.twig | 31 ++++--- templates/task/create.html.twig | 4 +- templates/task/show.html.twig | 49 ++++++++--- templates/task/update.html.twig | 4 +- 18 files changed, 396 insertions(+), 115 deletions(-) delete mode 100644 migrations/Version20240726120017.php create mode 100644 templates/partials/_project-metadata.html.twig create mode 100644 templates/partials/_task-locking.html.twig create mode 100644 templates/partials/_task-metadata.html.twig create mode 100644 templates/partials/_task-title.html.twig diff --git a/config/packages/stof_doctrine_extensions.yaml b/config/packages/stof_doctrine_extensions.yaml index 32f6a27..b882f69 100644 --- a/config/packages/stof_doctrine_extensions.yaml +++ b/config/packages/stof_doctrine_extensions.yaml @@ -5,3 +5,4 @@ stof_doctrine_extensions: orm: default: sluggable: true + timestampable: true diff --git a/migrations/Version20240726120017.php b/migrations/Version20240726120017.php deleted file mode 100644 index d86b096..0000000 --- a/migrations/Version20240726120017.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json) - , osm_id INTEGER NOT NULL)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON user (username)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE user'); - } -} diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php index fb3a087..2fd5c0e 100644 --- a/src/Controller/ProjectController.php +++ b/src/Controller/ProjectController.php @@ -45,6 +45,7 @@ class ProjectController extends AbstractController $project = $createForm->getData(); try { + $project->setCreatedBy($this->getUser()); $entityManager->persist($project); $entityManager->flush(); @@ -67,10 +68,10 @@ class ProjectController extends AbstractController ]); } - #[Route('/show/{projectSlug}', name: 'app_project_show')] - public function show(EntityManagerInterface $entityManager, $projectSlug): Response + #[Route('/{slug}', name: 'app_project_show')] + public function show(EntityManagerInterface $entityManager, $slug): Response { - $project = $entityManager->getRepository(Project::class)->findOneBySlug($projectSlug); + $project = $entityManager->getRepository(Project::class)->findOneBySlug($slug); $tasks = $entityManager->getRepository(Task::class)->findByProjectPaginated($project); if (!$project) { @@ -94,11 +95,11 @@ class ProjectController extends AbstractController ]); } - #[Route('/update/{projectSlug}', name: 'app_project_update')] - public function update(Request $request, EntityManagerInterface $entityManager, $projectSlug): Response + #[Route('/{slug}/update', name: 'app_project_update')] + public function update(Request $request, EntityManagerInterface $entityManager, $slug): Response { $repository = $entityManager->getRepository(Project::class); - $project = $repository->findOneBySlug($projectSlug); + $project = $repository->findOneBySlug($slug); if (!$project) { $this->addFlash( @@ -142,11 +143,11 @@ class ProjectController extends AbstractController ]); } - #[Route('/remove/{projectSlug}', name: 'app_project_remove')] - public function remove(EntityManagerInterface $entityManager, $projectSlug): Response + #[Route('/{slug}/remove', name: 'app_project_remove')] + public function remove(EntityManagerInterface $entityManager, $slug): Response { $repository = $entityManager->getRepository(Project::class); - $project = $repository->findOneBySlug($projectSlug); + $project = $repository->findOneBySlug($slug); if (!$project) { $this->addFlash( diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php index 1eb2545..04a0496 100644 --- a/src/Controller/TaskController.php +++ b/src/Controller/TaskController.php @@ -20,11 +20,11 @@ use Symfony\Component\Workflow\WorkflowInterface; #[Route('/task')] class TaskController extends AbstractController { - #[Route('/{projectSlug}/create', name: 'app_task_create')] - public function create(Request $request, EntityManagerInterface $entityManager, $projectSlug): Response + #[Route('/create', name: 'app_task_create')] + public function create(Request $request, EntityManagerInterface $entityManager, $slug): Response { $repository = $entityManager->getRepository(Project::class); - $project = $repository->findOneBySlug($projectSlug); + $project = $repository->findOneBySlug($slug); if (!$project) { $this->addFlash( @@ -47,6 +47,7 @@ class TaskController extends AbstractController $task = $createForm->getData(); try { + $task->setCreatedBy($this->getUser()); $entityManager->persist($task); $entityManager->flush(); @@ -55,7 +56,7 @@ class TaskController extends AbstractController 'Tâche créée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirectToRoute('app_project_show', ['slug' => $slug]); } catch (\Exception $exception) { $this->addFlash( 'danger', @@ -71,11 +72,11 @@ class TaskController extends AbstractController ]); } - #[Route('/{projectSlug}/show/{taskSlug}', name: 'app_task_show')] - public function show(EntityManagerInterface $entityManager, GeoJsonManager $geoJsonManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}', name: 'app_task_show')] + public function show(Request $request, EntityManagerInterface $entityManager, GeoJsonManager $geoJsonManager, $slug): Response { $repository = $entityManager->getRepository(Task::class); - $task = $repository->findOneBySlug($taskSlug); + $task = $repository->findOneBySlug($slug); if (!$task) { $this->addFlash( @@ -83,12 +84,12 @@ class TaskController extends AbstractController 'Tâche non trouvée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirect($request->headers->get('Referer')); } $comment = new Comment(); $commentForm = $this->createForm(CommentType::class, $comment, [ - 'action' => $this->generateUrl('app_task_comment', ['projectSlug' => $projectSlug, 'taskSlug' => $taskSlug]), + 'action' => $this->generateUrl('app_task_comment', ['slug' => $slug]), ]); $commentForm->add('submit', SubmitType::class, [ 'label' => 'Commenter', @@ -101,11 +102,11 @@ class TaskController extends AbstractController ]); } - #[Route('/{projectSlug}/comment/{taskSlug}', name: 'app_task_comment')] - public function comment(Request $request, EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}/comment', name: 'app_task_comment')] + public function comment(Request $request, EntityManagerInterface $entityManager, $slug): Response { $repository = $entityManager->getRepository(Task::class); - $task = $repository->findOneBySlug($taskSlug); + $task = $repository->findOneBySlug($slug); if (!$task) { $this->addFlash( @@ -113,7 +114,7 @@ class TaskController extends AbstractController 'Tâche non trouvée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirect($request->headers->get('Referer')); } $comment = new Comment(); @@ -143,14 +144,14 @@ class TaskController extends AbstractController } } - return $this->redirectToRoute('app_task_show', ['projectSlug' => $projectSlug, 'taskSlug' => $taskSlug]); + return $this->redirectToRoute('app_task_show', ['slug' => $slug]); } - #[Route('/{projectSlug}/update/{taskSlug}', name: 'app_task_update')] - public function update(Request $request, EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}/update', name: 'app_task_update')] + public function update(Request $request, EntityManagerInterface $entityManager, $slug): Response { $repository = $entityManager->getRepository(Task::class); - $task = $repository->findOneBySlug($taskSlug); + $task = $repository->findOneBySlug($slug); if (!$task) { $this->addFlash( @@ -158,7 +159,7 @@ class TaskController extends AbstractController 'Tâche non trouvée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirect($request->headers->get('Referer')); } $updateForm = $this->createForm(TaskType::class, $task); @@ -179,7 +180,7 @@ class TaskController extends AbstractController 'Tâche modifiée !' ); - return $this->redirectToRoute('app_task_show', ['projectSlug' => $projectSlug, 'taskSlug' => $taskSlug]); + return $this->redirectToRoute('app_task_show', ['slug' => $slug]); } catch (\Exception $exception) { $this->addFlash( 'danger', @@ -195,21 +196,24 @@ class TaskController extends AbstractController ]); } - #[Route('/{projectSlug}/remove/{taskSlug}', name: 'app_task_remove')] - public function remove(EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}/remove', name: 'app_task_remove')] + public function remove(Request $request, EntityManagerInterface $entityManager, $slug): Response { $repository = $entityManager->getRepository(Task::class); - $task = $repository->findOneBySlug($taskSlug); + $task = $repository->findOneBySlug($slug); if (!$task) { $this->addFlash( 'warning', 'Tâche non trouvée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirect($request->headers->get('Referer')); } + $project = $task->getProject(); + try { + $entityManager->remove($task); $entityManager->flush(); @@ -218,7 +222,7 @@ class TaskController extends AbstractController 'Tâche supprimée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]); } catch (\Exception $exception) { $this->addFlash( 'danger', @@ -226,24 +230,41 @@ class TaskController extends AbstractController ); } - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirectToRoute('app_project_show', ['slug' => $slug]); } - private function transition(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $projectSlug, $taskSlug, $status): Response + private function transition(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug, $transitionName): Response { $repository = $entityManager->getRepository(Task::class); - $task = $repository->findOneBySlug($taskSlug); + $task = $repository->findOneBySlug($slug); if (!$task) { $this->addFlash( 'warning', 'Tâche non trouvée !' ); - return $this->redirectToRoute('app_project_show', ['projectSlug' => $projectSlug]); + return $this->redirectToRoute('app_project'); } try { - $taskLifecycleStateMachine->apply($task, $status); + // TODO on doit pouvoir faire mieux pour le verrouillage, notamment au niveau des règles de tansition du workflow… + $transitions = array_filter( + $taskLifecycleStateMachine->getDefinition()->getTransitions(), + function ($transition) use ($transitionName) { + return $transitionName === $transition->getName(); + } + ); + $transition = reset($transitions); + $shouldTransitionLock = $taskLifecycleStateMachine->getMetadataStore()->getTransitionMetadata($transition)['lock']; + $shouldTransitionUnlock = $taskLifecycleStateMachine->getMetadataStore()->getTransitionMetadata($transition)['unlock']; + + $taskLifecycleStateMachine->apply($task, $transitionName); + + if ($shouldTransitionLock) { + $task->lock($this->getUser()); + } elseif ($shouldTransitionUnlock) { + $task->unlock(); + } $entityManager->persist($task); $entityManager->flush(); @@ -259,31 +280,31 @@ class TaskController extends AbstractController ); } - return $this->redirectToRoute('app_task_show', ['projectSlug' => $projectSlug, 'taskSlug' => $taskSlug]); + return $this->redirectToRoute('app_task_show', ['slug' => $slug]); } - - #[Route('/{projectSlug}/start/{taskSlug}', name: 'app_task_start')] - public function start(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + + #[Route('/{slug}/start', name: 'app_task_start')] + public function start(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $projectSlug, $taskSlug, Task::TRANSITION_START); + return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_START); } - #[Route('/{projectSlug}/finish/{taskSlug}', name: 'app_task_finish')] - public function finish(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}/finish', name: 'app_task_finish')] + public function finish(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $projectSlug, $taskSlug, Task::TRANSITION_FINISH); + return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_FINISH); } - #[Route('/{projectSlug}/cancel/{taskSlug}', name: 'app_task_cancel')] - public function cancel(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}/cancel', name: 'app_task_cancel')] + public function cancel(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $projectSlug, $taskSlug, Task::TRANSITION_CANCEL); + return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_CANCEL); } - #[Route('/{projectSlug}/reset/{taskSlug}', name: 'app_task_reset')] - public function reset(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $projectSlug, $taskSlug): Response + #[Route('/{slug}/reset', name: 'app_task_reset')] + public function reset(WorkflowInterface $taskLifecycleStateMachine, EntityManagerInterface $entityManager, $slug): Response { - return $this->transition($taskLifecycleStateMachine, $entityManager, $projectSlug, $taskSlug, Task::TRANSITION_RESET); + return $this->transition($taskLifecycleStateMachine, $entityManager, $slug, Task::TRANSITION_RESET); } #[Route('/{slug}.geojson', name: 'app_task_geojson')] @@ -297,7 +318,7 @@ class TaskController extends AbstractController 'warning', 'Tâche non trouvée !' ); - return $this->redirect($request->headers->get('referer')); + return $this->redirect($request->headers->get('Referer')); } return JsonResponse::fromJsonString($task->getGeojson()); diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index 0cfe8e6..1ab590d 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -5,6 +5,7 @@ namespace App\DataFixtures; use App\Entity\Project; use App\Entity\Tag; use App\Entity\Task; +use App\Entity\User; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; @@ -12,11 +13,17 @@ class AppFixtures extends Fixture { public function load(ObjectManager $manager): void { + $user = new User(); + $user->setUsername('caboulot'); + $user->setOsmId(80638); + $manager->persist($user); + $tag = new Tag(); $tag->setName('test'); $manager->persist($tag); $task = new Task(); + $task->setCreatedBy($user); $task->setName('PR52 D’un canal à l’autre'); $task->setDescription('boucle au départ du port de Plaisance'); $task->setStatus(Task::STATUS_TODO); @@ -1428,6 +1435,7 @@ GEOJSON); $manager->persist($task); $project = new Project(); + $project->setCreatedBy($user); $project->setName('Sentiers PR Gard'); $project->setDescription('Cf '); $project->addTag($tag); diff --git a/src/Entity/Project.php b/src/Entity/Project.php index 8bc3383..d7468df 100644 --- a/src/Entity/Project.php +++ b/src/Entity/Project.php @@ -39,6 +39,14 @@ class Project #[ORM\OneToMany(targetEntity: Task::class, mappedBy: 'project', orphanRemoval: true)] private Collection $tasks; + #[ORM\ManyToOne(inversedBy: 'projects')] + #[ORM\JoinColumn(nullable: false)] + private ?User $createdBy = null; + + #[ORM\Column] + #[Gedmo\Timestampable(on: 'create')] + private ?\DateTimeImmutable $createdAt = null; + public function __construct() { $this->tags = new ArrayCollection(); @@ -133,4 +141,28 @@ class Project return $this; } + public function getCreatedBy(): ?User + { + return $this->createdBy; + } + + public function setCreatedBy(?User $createdBy): static + { + $this->createdBy = $createdBy; + + return $this; + } + + public function getCreatedAt(): ?\DateTimeImmutable + { + return $this->createdAt; + } + + public function setCreatedAt(\DateTimeImmutable $createdAt): static + { + $this->createdAt = $createdAt; + + return $this; + } + } diff --git a/src/Entity/Task.php b/src/Entity/Task.php index b324e5d..d307744 100644 --- a/src/Entity/Task.php +++ b/src/Entity/Task.php @@ -61,6 +61,20 @@ class Task #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; + #[ORM\ManyToOne(inversedBy: 'tasks')] + #[ORM\JoinColumn(nullable: false)] + private ?User $createdBy = null; + + #[ORM\Column] + #[Gedmo\Timestampable(on: 'create')] + private ?\DateTimeImmutable $createdAt = null; + + #[ORM\ManyToOne] + private ?User $lockedBy = null; + + #[ORM\Column(nullable: true)] + private ?\DateTimeImmutable $lockedAt = null; + public function __construct() { $this->comments = new ArrayCollection(); @@ -201,4 +215,74 @@ class Task return $this; } + + public function getCreatedBy(): ?User + { + return $this->createdBy; + } + + public function setCreatedBy(?User $createdBy): static + { + $this->createdBy = $createdBy; + + return $this; + } + + public function getCreatedAt(): ?\DateTimeImmutable + { + return $this->createdAt; + } + + public function setCreatedAt(\DateTimeImmutable $createdAt): static + { + $this->createdAt = $createdAt; + + return $this; + } + + public function getLockedBy(): ?User + { + return $this->lockedBy; + } + + public function setLockedBy(?User $lockedBy): static + { + $this->lockedBy = $lockedBy; + + return $this; + } + + public function getLockedAt(): ?\DateTimeImmutable + { + return $this->lockedAt; + } + + public function setLockedAt(?\DateTimeImmutable $lockedAt): static + { + $this->lockedAt = $lockedAt; + + return $this; + } + + public function isLocked(): bool + { + return is_null($this->lockedBy); + } + + public function lock(User $user): static + { + $this->setLockedBy($user); + $this->setLockedAt(new \DateTimeImmutable('now')); + + return $this; + } + + public function unlock(): static + { + $this->setLockedBy(null); + $this->setLockedAt(null); + + return $this; + } + } diff --git a/src/Entity/User.php b/src/Entity/User.php index 4052829..aecce87 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -3,6 +3,8 @@ namespace App\Entity; use App\Repository\UserRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Security\Core\User\UserInterface; @@ -27,6 +29,24 @@ class User implements UserInterface #[ORM\Column] private ?int $osmId = null; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Project::class, mappedBy: 'createdBy', orphanRemoval: true)] + private Collection $projects; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Task::class, mappedBy: 'createdBy', orphanRemoval: true)] + private Collection $tasks; + + public function __construct() + { + $this->projects = new ArrayCollection(); + $this->tasks = new ArrayCollection(); + } + public function getId(): ?int { return $this->id; @@ -98,4 +118,64 @@ class User implements UserInterface return $this; } + + /** + * @return Collection + */ + public function getProjects(): Collection + { + return $this->projects; + } + + public function addProject(Project $project): static + { + if (!$this->projects->contains($project)) { + $this->projects->add($project); + $project->setCreatedBy($this); + } + + return $this; + } + + public function removeProject(Project $project): static + { + if ($this->projects->removeElement($project)) { + // set the owning side to null (unless already changed) + if ($project->getCreatedBy() === $this) { + $project->setCreatedBy(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getTasks(): Collection + { + return $this->tasks; + } + + public function addTask(Task $task): static + { + if (!$this->tasks->contains($task)) { + $this->tasks->add($task); + $task->setCreatedBy($this); + } + + return $this; + } + + public function removeTask(Task $task): static + { + if ($this->tasks->removeElement($task)) { + // set the owning side to null (unless already changed) + if ($task->getCreatedBy() === $this) { + $task->setCreatedBy(null); + } + } + + return $this; + } } diff --git a/src/Service/GeoJsonManager.php b/src/Service/GeoJsonManager.php index 91788d8..b2a1033 100644 --- a/src/Service/GeoJsonManager.php +++ b/src/Service/GeoJsonManager.php @@ -22,7 +22,7 @@ class GeoJsonManager $data = json_decode($task->getGeojson(), true); $data['features'][0]['properties'] = array_merge($data['features'][0]['properties'], [ 'name' => $task->getName(), - 'url' => $this->router->generate('app_task_show', ['projectSlug' => $task->getProject()->getSlug(), 'taskSlug' => $task->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), + 'url' => $this->router->generate('app_task_show', ['slug' => $task->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), 'color' => $this->taskLifecycleStateMachine->getMetadataStore()->getPlaceMetadata($task->getStatus())['color'], ]); return $data; diff --git a/templates/partials/_project-metadata.html.twig b/templates/partials/_project-metadata.html.twig new file mode 100644 index 0000000..6addd82 --- /dev/null +++ b/templates/partials/_project-metadata.html.twig @@ -0,0 +1,12 @@ + + + + + {{ project.createdBy.username }} + + + + + + {{ project.createdAt|format_datetime('short', 'short', locale='fr') }} + diff --git a/templates/partials/_task-locking.html.twig b/templates/partials/_task-locking.html.twig new file mode 100644 index 0000000..37099b2 --- /dev/null +++ b/templates/partials/_task-locking.html.twig @@ -0,0 +1,20 @@ +{% if workflow_metadata(task, 'locking', task.status) %} + + + + + {{ task.lockedBy.username }} + + + + + + {{ task.createdAt|format_datetime('short', 'short', locale='fr') }} + +{% else %} + + + + + +{% endif %} diff --git a/templates/partials/_task-metadata.html.twig b/templates/partials/_task-metadata.html.twig new file mode 100644 index 0000000..d4cd8f3 --- /dev/null +++ b/templates/partials/_task-metadata.html.twig @@ -0,0 +1,12 @@ + + + + + {{ task.createdBy.username }} + + + + + + {{ task.createdAt|format_datetime('short', 'short', locale='fr') }} + diff --git a/templates/partials/_task-title.html.twig b/templates/partials/_task-title.html.twig new file mode 100644 index 0000000..0a41e8a --- /dev/null +++ b/templates/partials/_task-title.html.twig @@ -0,0 +1,2 @@ +{{ task.name }} +{{ workflow_metadata(task, 'title', task.status) }} diff --git a/templates/project/index.html.twig b/templates/project/index.html.twig index 01c41c7..42248ca 100644 --- a/templates/project/index.html.twig +++ b/templates/project/index.html.twig @@ -7,11 +7,15 @@ {% block page_title %}Projets{% endblock %} {% block page_content %} +{% if is_granted('IS_AUTHENTICATED_FULLY') %} +{% endif %} {% if projects is not empty %}
@@ -25,8 +29,9 @@ {{ tag.name }} {% endfor %} +

{% include 'partials/_project-metadata.html.twig' %}

{% if project.description %}

{{ project.description|markdown_to_html }}

{% endif %} - Voir + Voir le détail
diff --git a/templates/project/show.html.twig b/templates/project/show.html.twig index a7bd4d7..eefe445 100644 --- a/templates/project/show.html.twig +++ b/templates/project/show.html.twig @@ -3,7 +3,7 @@ {% block breadcrumb %} - + {% endblock %} {% block page_title %} @@ -16,10 +16,22 @@ {% block page_content %}
- Revenir aux projets - Modifier le projet - Supprimer le projet - Créer une tâche +
+ Revenir aux projets + {% if is_granted('IS_AUTHENTICATED_FULLY') %} + {% if app.user is same as(project.createdBy) %} + Modifier le projet + Supprimer le projet + {% endif %} + Créer une tâche + {% endif %} +
+
+
+ +
+
+

{% include 'partials/_project-metadata.html.twig' %}

@@ -37,6 +49,8 @@ {% if project.tasks is not empty %} +{% set dummy = tasks.setParam('_fragment', 'tasks') %} +

Tâches

@@ -50,13 +64,11 @@
-{% set dummy = tasks.setParam('_fragment', 'tasks') %} -
+
- @@ -66,8 +78,7 @@ {% for task in tasks %} - - + diff --git a/templates/task/create.html.twig b/templates/task/create.html.twig index 17170bf..8053269 100644 --- a/templates/task/create.html.twig +++ b/templates/task/create.html.twig @@ -2,8 +2,8 @@ {% block breadcrumb %} - - + + {% endblock %} {% block page_title %}Créer une nouvelle tâche{% endblock %} diff --git a/templates/task/show.html.twig b/templates/task/show.html.twig index 3fc603b..7a68937 100644 --- a/templates/task/show.html.twig +++ b/templates/task/show.html.twig @@ -3,26 +3,51 @@ {% block breadcrumb %} - - + + {% endblock %} {% block page_title %} - {{ task.name }} - {{ workflow_metadata(task, 'title', task.status) }} + {% include 'partials/_task-title.html.twig' %} {% endblock %} {% block page_content %}
- Revenir au projet - Modifier la tâche - Supprimer la tâche - Télécharger GeoJSON - {% for transition in workflow_transitions(task) %} - {{ workflow_metadata(task, 'title', transition) }} - {% endfor %} - +
+ Revenir au projet + {% if is_granted('IS_AUTHENTICATED_FULLY') %} + {% if app.user is same as(task.createdBy) %} + Modifier la tâche + Supprimer la tâche + {% endif %} + {% for transition in workflow_transitions(task) %} + {% if not workflow_metadata(task, 'locking', task.status) or app.user is same as(task.lockedBy) %} + {{ workflow_metadata(task, 'title', transition) }} + {% endif %} + {% endfor %} + {% if workflow_metadata(task, 'locking', task.status) and app.user is same as(task.lockedBy) %} +
+ + +
+ + {% endif %} + {% endif %} +
+
+
+ +
+
+

+ {% include 'partials/_task-metadata.html.twig' %} + {% include 'partials/_task-locking.html.twig' %} +

diff --git a/templates/task/update.html.twig b/templates/task/update.html.twig index f8606b1..c678b93 100644 --- a/templates/task/update.html.twig +++ b/templates/task/update.html.twig @@ -2,8 +2,8 @@ {% block breadcrumb %} - - + + {% endblock %} {% block page_title %}Modifier la tâche {{ task.name }}{% endblock %}
{{ macro.paginated(tasks, 'Identifiant', 't.id') }} {{ macro.paginated(tasks, 'Nom', 't.name') }} {{ macro.paginated(tasks, 'État', 't.status') }} {{ macro.paginated(tasks, 'Importance', 't.important') }}
{{ task.id }}{{ task.name }}{{ task.name }} {{ workflow_metadata(task, 'title', task.status) }} {{ task.important }} {{ task.urgent }}