From 26a13ae6dfa0ca7768736f969757e202262d6ad8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Nov 2021 09:46:24 +0100 Subject: [PATCH] badge adapted+ menu entry + persistance of object fixed --- .../Controller/AccompanyingCourseController.php | 14 +++++++++++--- .../Menu/AccompanyingCourseMenuBuilder.php | 8 ++++++++ .../vuejs/AccompanyingCourse/components/Banner.vue | 7 ++++++- .../public/vuejs/AccompanyingCourse/js/i18n.js | 3 ++- .../views/AccompanyingPeriod/_list.html.twig | 4 +++- .../Authorization/AccompanyingPeriodVoter.php | 10 +++++----- .../ChillPersonBundle/translations/messages.fr.yml | 2 ++ 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 43c516ca9..8eab36d03 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -99,7 +99,7 @@ class AccompanyingCourseController extends Controller public function indexAction(AccompanyingPeriod $accompanyingCourse): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); - + // compute some warnings // get persons without household $withoutHousehold = []; @@ -179,7 +179,9 @@ class AccompanyingCourseController extends Controller if ($form->isSubmitted() && $form->isValid()) { - $this->getDoctrine()->getManager()->flush(); + $em = $this->getDoctrine()->getManager(); + $em->persist($accompanyingCourse); + $workflow = $this->registry->get($accompanyingCourse); if ($workflow->can($accompanyingCourse, 'close')) { @@ -187,10 +189,16 @@ class AccompanyingCourseController extends Controller if( count($errors) > 0 ){ return $this->json($errors, 422); } - $workflow->apply($accompanyingCourse, 'close'); + $em->persist($accompanyingCourse); } + $em->flush(); + + return $this->redirectToRoute('chill_person_accompanying_course_index', [ + 'accompanying_period_id' => $accompanyingCourse->getId() + ]); + } return $this->render('@ChillPerson/AccompanyingCourse/close.html.twig', [ diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index df70b9e64..599bfb309 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -67,6 +67,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'id' => $period->getId() ]]) ->setExtras(['order' => 40]); + + $menu->addChild($this->translator->trans('Close Accompanying Course'), [ + 'route' => 'chill_person_accompanying_course_close', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId() + ]]) + ->setExtras(['order' => 50]); + } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue index 84e7fb2c6..d83196286 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue @@ -11,7 +11,7 @@ {{ $t('course.step.draft') }} - + {{ $t('course.step.active') }} @@ -26,6 +26,11 @@ + + + {{ $t('course.step.closed') }} + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index 10b656e4a..6cd255f8d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -20,7 +20,8 @@ const appMessages = { status: "État", step: { draft: "Brouillon", - active: "En file active" + active: "En file active", + closed: "Cloturé" }, open_at: "ouvert le ", by: "par ", diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig index c5797a4b2..af8657e28 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig @@ -21,8 +21,10 @@
{% if accompanying_period.step == 'DRAFT' %} {{- 'Draft'|trans|upper -}} - {% else %} + {% elseif accompanying_period.step == 'CONFIRMED' %} {{- 'Confirmed'|trans|upper -}} + {% else %} + {{- 'Closed'|trans|upper -}} {% endif %}
diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 49847d114..9daa9ad2e 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -78,11 +78,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole return false; } - if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { - if($this->security->isGranted(self::EDIT, $subject)) { - return false; - } - } + // if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { + // if($this->security->isGranted(self::EDIT, $subject)) { + // return false; + // } + // } // if confidential, only the referent can see it if ($subject->isConfidential()) { diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7f9527b91..77f988fa1 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -374,6 +374,7 @@ regular: régulier Confidential: confidentiel Draft: brouillon Confirmed: en file active +Closed: Cloturé # Accompanying Course Accompanying Course: Parcours d'accompagnement @@ -381,6 +382,7 @@ Accompanying Course History: Historique du parcours Resume Accompanying Course: Résumé du parcours Show Accompanying Course: Voir le parcours Edit Accompanying Course: Modifier le parcours +Close Accompanying Course: Clôturer le parcours Create Accompanying Course: Créer un nouveau parcours Drop Accompanying Course: Supprimer le parcours This course is located at a temporarily address. You should locate this course to an user: Le parcours est localisé à une adresse temporaire. Il devrait être localisé auprès d'une personne concernée.