From 788b1e9eeb31df17f24f1df760c2ff1aa91e2aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Nov 2022 16:51:41 +0100 Subject: [PATCH] Fixed: [calendar] Fix picking calendar document templating, when adding document in person context --- .../Controller/CalendarDocController.php | 22 ++++++++---- ...ck_template_accompanying_period.html.twig} | 13 +++++++ .../pick_template_person.html.twig | 35 +++++++++++++++++++ 3 files changed, 64 insertions(+), 6 deletions(-) rename src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/{pick_template.html.twig => pick_template_accompanying_period.html.twig} (58%) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php index 2c9074488..cdadb65e5 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -72,11 +72,21 @@ class CalendarDocController ); } - return new Response( - $this->engine->render('@ChillCalendar/CalendarDoc/pick_template.html.twig', [ - 'calendar' => $calendar, - 'accompanyingCourse' => $calendar->getAccompanyingPeriod(), - ]) - ); + switch ($calendar->getContext()) { + case 'person': + return new Response( + $this->engine->render('@ChillCalendar/CalendarDoc/pick_template_person.html.twig', [ + 'calendar' => $calendar, + ]) + ); + case 'accompanying_period': + return new Response( + $this->engine->render('@ChillCalendar/CalendarDoc/pick_template_accompanying_period.html.twig', [ + 'calendar' => $calendar, + ]) + ); + default: + throw new \UnexpectedValueException("calendar context not expected : " . $calendar->getContext()); + } } } diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_accompanying_period.html.twig similarity index 58% rename from src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig rename to src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_accompanying_period.html.twig index 561f92f0c..8e5226faa 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_accompanying_period.html.twig @@ -5,6 +5,7 @@ {% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %} {% set user_id = null %} +{% set accompanyingCourse = calendar.accompanyingPeriod %} {% set accompanying_course_id = accompanyingCourse.id %} {% block js %} @@ -19,6 +20,18 @@ {% block content %} +

{{ 'chill_calendar.Add a document'|trans }}

+ +

+ {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('short', 'short') }} + {% else %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('none', 'short') }} + {% endif %} +

+
{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig new file mode 100644 index 000000000..a331f7fd7 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig @@ -0,0 +1,35 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = 'chill_calendar_calendar_list' %} + +{% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %} + +{% set person = calendar.person %} + +{% block js %} + {{ parent() }} + {{ encore_entry_script_tags('mod_docgen_picktemplate') }} +{% endblock %} + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('mod_docgen_picktemplate') }} +{% endblock %} + +{% block content %} + +

{{ 'chill_calendar.Add a document'|trans }}

+ +

+ {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('short', 'short') }} + {% else %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('none', 'short') }} + {% endif %} +

+ +
+ +{% endblock %}