From f4369f0e3cf719ed6c26f417c29921e593ddc33f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 12 Dec 2024 15:40:41 +0100 Subject: [PATCH] Initial setup of controller and templates --- .../Controller/CalendarController.php | 29 +++++++++++++++++++ .../Resources/views/Calendar/_list.html.twig | 4 +++ .../translations/messages.fr.yml | 1 + 3 files changed, 34 insertions(+) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 00d99426f..61b9c860b 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -158,6 +158,35 @@ class CalendarController extends AbstractController ]); } + #[Route(path: '/{_locale}/calendar/calendar/{id}/cancel', name: 'chill_calendar_calendar_cancel')] + + public function cancelAction(Calendar $calendar, Request $request): Response + { + $this->denyAccessUnlessGranted(CalendarVoter::EDIT, $calendar); + + [$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()]; + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = '@ChillCalendar/Calendar/cancelCalendarByAccompanyingCourse.html.twig'; +// $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]); + } elseif ($person instanceof Person) { + $view = '@ChillCalendar/Calendar/cancelCalendarByPerson.html.twig'; +// $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); + } else { + throw new \RuntimeException('nor person or accompanying period'); + } + + // Cancellation form + + + return $this->render($view, [ + 'calendar' => $calendar, +// 'delete_form' => $form->createView(), + 'accompanyingCourse' => $accompanyingPeriod, + 'person' => $person, + ]); + } + /** * Edit a calendar item. */ diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index 4023931e3..4d11497ee 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -235,6 +235,10 @@ class="btn btn-remove">{{ 'cancel'|trans }} {% endif %} +
  • + {{ 'cancel'|trans }} +
  • {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %}