From b9c2d63a53653ac8731ef67fb9b4a3992b6bbc92 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Jan 2022 11:42:14 +0100 Subject: [PATCH] mes parcours page created --- .../UserAccompanyingPeriodController.php | 41 +++++++++++ .../Menu/UserMenuBuilder.php | 72 +++++++++++++++++++ .../user_periods_list.html.twig | 25 +++++++ .../ChillPersonBundle/config/routes.yaml | 4 ++ .../translations/messages.fr.yml | 3 + 5 files changed, 145 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php create mode 100644 src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php new file mode 100644 index 000000000..956849efc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -0,0 +1,41 @@ +accompanyingPeriodRepository = $accompanyingPeriodRepository; + } + + public function listAction(Request $request) + { + $userId = $this->getUser()->getId(); + + $accompanyingPeriods = []; + $accompanyingPeriods = $this->accompanyingPeriodRepository->findBy(['user' => $userId]); + + return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [ + 'accompanyingPeriods' => $accompanyingPeriods + ]); + + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php new file mode 100644 index 000000000..9030b9264 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php @@ -0,0 +1,72 @@ +counter = $counter; + $this->tokenStorage = $tokenStorage; + $this->translator = $translator; + $this->authorizationChecker = $authorizationChecker; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + if ($this->authorizationChecker->isGranted('ROLE_USER')) { + $menu->addChild('My accompanying periods', [ + 'route' => 'chill_person_accompanying_period_user', + ]) + ->setExtras([ + 'order' => 20, + 'icon' => 'tasks', + ]); + } + } + + public static function getMenuIds(): array + { + return ['user']; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig new file mode 100644 index 000000000..12faf739a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig @@ -0,0 +1,25 @@ +{% extends "@ChillMain/layout.html.twig" %} + +{% set activeRouteKey = 'chill_person_accompanying_period_user_list' %} + +{% block title %}{{ 'Accompanying period list'|trans }}{% endblock title %} + +{% macro recordAction(period) %} +
  • + +
  • +{% endmacro %} + + +{% block content %} + +

    {{ 'Accompanying period list'|trans }}

    + +
    + {% for period in accompanyingPeriods %} + {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, 'recordAction': _self.recordAction(period)} %} + {% endfor %} +
    + +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/routes.yaml b/src/Bundle/ChillPersonBundle/config/routes.yaml index 13d1c1227..13539f6c2 100644 --- a/src/Bundle/ChillPersonBundle/config/routes.yaml +++ b/src/Bundle/ChillPersonBundle/config/routes.yaml @@ -55,6 +55,10 @@ chill_person_accompanying_period_re_open: path: /{_locale}/person/{person_id}/accompanying-period/{period_id}/re-open controller: Chill\PersonBundle\Controller\AccompanyingPeriodController::reOpenAction +chill_person_accompanying_period_user: + path: /{_locale}/accompanying-periods + controller: Chill\PersonBundle\Controller\UserAccompanyingPeriodController::listAction + chill_person_resource_list: path: /{_locale}/person/{person_id}/resources/list controller: Chill\PersonBundle\Controller\PersonResourceController::listAction diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 90d8da5cf..fe904cec4 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -533,3 +533,6 @@ household_composition: # docgen Linked evaluations: Évaluations associées + +# Accompanying period per user +My accompanying periods: Mes parcours