From 74957154b1bebf26f34e50ab0adf266651c21e57 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 23 Aug 2021 09:11:08 +0200 Subject: [PATCH 01/24] rdv: pages by User --- .../Controller/CalendarController.php | 43 ++++++++++--------- ...firm_deleteByAccompanyingCourse.html.twig} | 0 .../Calendar/confirm_deleteByUser.html.twig | 18 ++++++++ .../Calendar/confirm_deletePerson.html.twig | 17 -------- .../Resources/views/Calendar/edit.html.twig | 8 ++-- ...wig => editByAccompanyingCourse.html.twig} | 2 +- .../views/Calendar/editByUser.html.twig | 36 ++++++++++++++++ .../Resources/views/Calendar/list.html.twig | 7 ++- .../views/Calendar/listByUser.html.twig | 9 ++++ .../Resources/views/Calendar/show.html.twig | 19 ++++++-- ...wig => showByAccompanyingCourse.html.twig} | 0 .../views/Calendar/showByUser.html.twig | 13 ++++++ .../translations/messages.fr.yml | 1 + 13 files changed, 127 insertions(+), 46 deletions(-) rename src/Bundle/ChillCalendarBundle/Resources/views/Calendar/{confirm_deleteAccompanyingCourse.html.twig => confirm_deleteByAccompanyingCourse.html.twig} (100%) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByUser.html.twig delete mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deletePerson.html.twig rename src/Bundle/ChillCalendarBundle/Resources/views/Calendar/{editAccompanyingCourse.html.twig => editByAccompanyingCourse.html.twig} (97%) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editByUser.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByUser.html.twig rename src/Bundle/ChillCalendarBundle/Resources/views/Calendar/{showAccompanyingCourse.html.twig => showByAccompanyingCourse.html.twig} (100%) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/showByUser.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index a894099e4..6e8dc624c 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -80,11 +80,10 @@ class CalendarController extends AbstractController if ($user instanceof User) { - // $calendar = $em->getRepository(Calendar::class) - // ->findByUser($user) - // ; - - // $view = 'ChillCalendarBundle:Calendar:listByUser.html.twig'; + $calendarItems = $em->getRepository(Calendar::class) + ->findByUser($user) + ; + $view = 'ChillCalendarBundle:Calendar:listByUser.html.twig'; } elseif ($accompanyingPeriod instanceof AccompanyingPeriod) { $calendarItems = $em->getRepository(Calendar::class)->findBy( ['accompanyingPeriod' => $accompanyingPeriod], @@ -174,11 +173,11 @@ class CalendarController extends AbstractController [$user, $accompanyingPeriod] = $this->getEntity($request); if ($accompanyingPeriod instanceof AccompanyingPeriod) { - $view = 'ChillCalendarBundle:Calendar:showAccompanyingCourse.html.twig'; + $view = 'ChillCalendarBundle:Calendar:showByAccompanyingCourse.html.twig'; } - // elseif ($person instanceof Person) { - // $view = 'ChillCalendarBundle:Calendar:showPerson.html.twig'; - // } + elseif ($user instanceof User) { + $view = 'ChillCalendarBundle:Calendar:showByUser.html.twig'; + } $entity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id); @@ -198,9 +197,9 @@ class CalendarController extends AbstractController } return $this->render($view, [ - //'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, + 'user' => $user //'delete_form' => $deleteForm->createView(), ]); } @@ -218,11 +217,11 @@ class CalendarController extends AbstractController [$user, $accompanyingPeriod] = $this->getEntity($request); if ($accompanyingPeriod instanceof AccompanyingPeriod) { - $view = 'ChillCalendarBundle:Calendar:editAccompanyingCourse.html.twig'; + $view = 'ChillCalendarBundle:Calendar:editByAccompanyingCourse.html.twig'; + } + elseif ($user instanceof User) { + $view = 'ChillCalendarBundle:Calendar:editByUser.html.twig'; } - // elseif ($person instanceof Person) { - // $view = 'ChillCalendarBundle:Calendar:editPerson.html.twig'; - // } $entity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id); @@ -259,6 +258,7 @@ class CalendarController extends AbstractController 'form' => $form->createView(), 'delete_form' => $deleteForm->createView(), 'accompanyingCourse' => $accompanyingPeriod, + 'user' => $user, 'entity_json' => $entity_array ]); } @@ -274,11 +274,11 @@ class CalendarController extends AbstractController [$user, $accompanyingPeriod] = $this->getEntity($request); if ($accompanyingPeriod instanceof AccompanyingPeriod) { - $view = 'ChillCalendarBundle:Calendar:confirm_deleteAccompanyingCourse.html.twig'; + $view = 'ChillCalendarBundle:Calendar:confirm_deleteByAccompanyingCourse.html.twig'; } - // elseif ($person instanceof Person) { - // $view = 'ChillCalendarBundle:Calendar:confirm_deletePerson.html.twig'; - // } + elseif ($user instanceof User) { + $view = 'ChillCalendarBundle:Calendar:confirm_deleteByUser.html.twig'; + } /* @var $entity Calendar */ $entity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id); @@ -324,9 +324,9 @@ class CalendarController extends AbstractController /** * Creates a form to delete a Calendar entity by id. */ - private function createDeleteForm(int $id, ?Person $person, ?AccompanyingPeriod $accompanyingPeriod): Form + private function createDeleteForm(int $id, ?User $user, ?AccompanyingPeriod $accompanyingPeriod): Form { - $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params = $this->buildParamsToUrl($user, $accompanyingPeriod); $params['id'] = $id; return $this->createFormBuilder() @@ -350,7 +350,8 @@ class CalendarController extends AbstractController throw $this->createNotFoundException('User not found'); } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $user); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $user); } elseif ($request->query->has('accompanying_period_id')) { $accompanying_period_id = $request->get('accompanying_period_id'); $accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($accompanying_period_id); diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByAccompanyingCourse.html.twig similarity index 100% rename from src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteAccompanyingCourse.html.twig rename to src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByAccompanyingCourse.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByUser.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByUser.html.twig new file mode 100644 index 000000000..4f1ad45e5 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByUser.html.twig @@ -0,0 +1,18 @@ +{% extends "@ChillMain/layout.html.twig" %} + +{% set user = calendar.user %} + +{% set activeRouteKey = 'chill_calendar_calendar' %} + +{% block title 'Remove activity'|trans %} + +{% block content %} +{{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove calendar item'|trans, + 'confirm_question' : 'Are you sure you want to remove the calendar item?'|trans, + 'cancel_route' : 'chill_calendar_calendar', + 'cancel_parameters' : { 'user_id' : calendar.user.id, 'id' : calendar.id }, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deletePerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deletePerson.html.twig deleted file mode 100644 index 9f8172bb4..000000000 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deletePerson.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% extends "@ChillPerson/Person/layout.html.twig" %} - -{% set activeRouteKey = 'chill_activity_activity_list' %} -{% set person = activity.person %} - -{% block title 'Remove activity'|trans %} - -{% block personcontent %} -{{ include('@ChillMain/Util/confirmation_template.html.twig', - { - 'title' : 'Remove activity'|trans, - 'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname } ), - 'cancel_route' : 'chill_activity_activity_list', - 'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id }, - 'form' : delete_form - } ) }} -{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig index f64e22353..4b4dca59b 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig @@ -48,15 +48,17 @@ {{ form_row(form.sendSMS) }} {% endif %} +
+