From 9b7a52064a1e7f40e236f3f08fa0ce6d53228480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 May 2021 22:15:04 +0200 Subject: [PATCH] page 'create a course' for draft accompanying course --- .../Menu/AccompanyingCourseMenuBuilder.php | 14 +++++++++++--- .../views/AccompanyingCourse/banner.html.twig | 16 +++++++--------- .../views/AccompanyingCourse/show.html.twig | 4 +++- .../translations/messages.fr.yml | 1 + 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 74052e87c..e9ce20b53 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -3,6 +3,7 @@ namespace Chill\PersonBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Knp\Menu\MenuItem; use Symfony\Contracts\Translation\TranslatorInterface; @@ -32,24 +33,31 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters): void { + $period = $parameters['accompanyingCourse']; + $menu->addChild($this->translator->trans('Resume Accompanying Course'), [ 'route' => 'chill_person_accompanying_course_index', 'routeParameters' => [ - 'accompanying_period_id' => $parameters['accompanyingCourse']->getId() + 'accompanying_period_id' => $period->getId() ]]) ->setExtras(['order' => 10]); $menu->addChild($this->translator->trans('Edit Accompanying Course'), [ 'route' => 'chill_person_accompanying_course_show', 'routeParameters' => [ - 'accompanying_period_id' => $parameters['accompanyingCourse']->getId() + 'accompanying_period_id' => $period->getId() ]]) ->setExtras(['order' => 20]); + if (AccompanyingPeriod::STEP_DRAFT === $period->getStep()) { + // no more menu items if the period is draft + return; + } + $menu->addChild($this->translator->trans('Accompanying Course Details'), [ 'route' => 'chill_person_accompanying_course_history', 'routeParameters' => [ - 'accompanying_period_id' => $parameters['accompanyingCourse']->getId() + 'accompanying_period_id' => $period->getId() ]]) ->setExtras(['order' => 30]); } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig index c8d566e84..94663e2f0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig @@ -12,19 +12,17 @@
-

- {{ 'Started on %date%'|trans({'%date%': accompanyingCourse.openingDate|format_date('short') } ) }}
- {% if accompanyingCourse.user is not null %} - par {{ accompanyingCourse.user.usernameCanonical }} + {% if 'DRAFT' == accompanyingCourse.getStep() %} + Brouillon + {% else %} + {{ 'Started on %date%'|trans({'%date%': accompanyingCourse.openingDate|format_date('short') } ) }}
+ {% if accompanyingCourse.user is not null %} + par {{ accompanyingCourse.user.username }} + {% endif %} {% endif %}

diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig index 427f5f0ac..7103e5eb8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig @@ -1,7 +1,9 @@ {% extends 'ChillPersonBundle:AccompanyingCourse:layout.html.twig' %} +{% set title = 'DRAFT' == accompanyingCourse.step ? 'New accompanying course' : 'Edit accompanying course' %} + {% block title %} - {{ 'Edit Accompanying Course'|trans }} + {{ title|trans }} {% endblock %} {% block content %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index cc3c8e93c..36c756e34 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -153,6 +153,7 @@ Update accompanying period: Mettre à jour une période d'accompagnement Any accompanying periods are open: Aucune période d'accompagnement ouverte An accompanying period is open: Une période d'accompagnement est ouverte Accompanying period list: Périodes d'accompagnement +New accompanying course: Nouveau parcours d'accompagnement Choose a motive: Motif de fermeture Re-open accompanying period: Ré-ouvrir Re-Open a period: Ré-ouvrir