Initial setup of controller and templates

This commit is contained in:
Julie Lenaerts 2024-12-12 15:40:41 +01:00
parent 4ed3bec115
commit be532cb14c
5 changed files with 9 additions and 74 deletions

View File

@ -115,46 +115,29 @@ class CalendarController extends AbstractController
} }
#[Route(path: '/{_locale}/calendar/calendar/{id}/cancel', name: 'chill_calendar_calendar_cancel')] #[Route(path: '/{_locale}/calendar/calendar/{id}/cancel', name: 'chill_calendar_calendar_cancel')]
public function cancelAction(Calendar $calendar, Request $request): Response public function cancelAction(Calendar $calendar, Request $request): Response
{ {
$this->denyAccessUnlessGranted(CalendarVoter::EDIT, $calendar); $this->denyAccessUnlessGranted(CalendarVoter::EDIT, $calendar);
[$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()]; [$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()];
$form = $this->createForm(CancelType::class, $calendar);
$form->add('submit', SubmitType::class);
if ($accompanyingPeriod instanceof AccompanyingPeriod) { if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = '@ChillCalendar/Calendar/cancelCalendarByAccompanyingCourse.html.twig'; $view = '@ChillCalendar/Calendar/cancelCalendarByAccompanyingCourse.html.twig';
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]); // $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]);
} elseif ($person instanceof Person) { } elseif ($person instanceof Person) {
$view = '@ChillCalendar/Calendar/cancelCalendarByPerson.html.twig'; $view = '@ChillCalendar/Calendar/cancelCalendarByPerson.html.twig';
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); // $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
} else { } else {
throw new \RuntimeException('nor person or accompanying period'); throw new \RuntimeException('nor person or accompanying period');
} }
$form->handleRequest($request); // Cancellation form
if ($form->isSubmitted() && $form->isValid()) {
$this->logger->notice('A calendar event has been cancelled', [
'by_user' => $this->getUser()->getUsername(),
'calendar_id' => $calendar->getId(),
]);
$calendar->setStatus($calendar::STATUS_CANCELED);
$calendar->setSmsStatus($calendar::SMS_CANCEL_PENDING);
$this->em->flush();
$this->addFlash('success', $this->translator->trans('chill_calendar.calendar_canceled'));
return new RedirectResponse($redirectRoute);
}
return $this->render($view, [ return $this->render($view, [
'calendar' => $calendar, 'calendar' => $calendar,
'form' => $form->createView(), // 'delete_form' => $form->createView(),
'accompanyingCourse' => $accompanyingPeriod, 'accompanyingCourse' => $accompanyingPeriod,
'person' => $person, 'person' => $person,
]); ]);

View File

@ -235,7 +235,10 @@
class="btn btn-remove">{{ 'cancel'|trans }}</a> class="btn btn-remove">{{ 'cancel'|trans }}</a>
</li> </li>
{% endif %} {% endif %}
<li>
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_cancel', { 'id': calendar.id } ) }}"
class="btn btn-delete">{{ 'cancel'|trans }}</a>
</li>
{% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %} {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %}
<li> <li>
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_delete', { 'id': calendar.id } ) }}" <a href="{{ chill_path_add_return_path('chill_calendar_calendar_delete', { 'id': calendar.id } ) }}"

View File

@ -3,27 +3,3 @@
{% set activeRouteKey = 'chill_calendar_calendar_list' %} {% set activeRouteKey = 'chill_calendar_calendar_list' %}
{% block title 'chill_calendar.cancel_calendar_item'|trans %} {% block title 'chill_calendar.cancel_calendar_item'|trans %}
{% block content %}
{{ form_start(form) }}
{{ form_row(form.cancelReason) }}
<ul class="record_actions sticky-form-buttons">
<li class="save">
<a
class="btn btn-cancel"
href="{{ chill_return_path_or('chill_calendar_calendar_list', { 'id': accompanyingCourse.id } )}}"
>
{{ 'Cancel'|trans|chill_return_path_label }}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-save' }, 'label': 'Save' } ) }}
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -3,27 +3,3 @@
{% set activeRouteKey = 'chill_calendar_calendar_list' %} {% set activeRouteKey = 'chill_calendar_calendar_list' %}
{% block title 'chill_calendar.cancel_calendar_item'|trans %} {% block title 'chill_calendar.cancel_calendar_item'|trans %}
{% block content %}
{{ form_start(form) }}
{{ form_row(form.cancelReason) }}
<ul class="record_actions sticky-form-buttons">
<li class="save">
<a
class="btn btn-cancel"
href="{{ chill_return_path_or('chill_calendar_calendar_list', { 'id': person.id } )}}"
>
{{ 'Cancel'|trans|chill_return_path_label }}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-save' }, 'label': 'Save' } ) }}
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -45,7 +45,6 @@ crud:
chill_calendar: chill_calendar:
cancel_calendar_item: Annuler rendez-vous cancel_calendar_item: Annuler rendez-vous
calendar_canceled: Le rendez-vous a été annulé
Document: Document d'un rendez-vous Document: Document d'un rendez-vous
form: form:
The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement. The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement.
@ -67,8 +66,6 @@ chill_calendar:
Remove a calendar document: Supprimer un document d'un rendez-vous Remove a calendar document: Supprimer un document d'un rendez-vous
Are you sure you want to remove the doc?: Êtes-vous sûr·e de vouloir supprimer le document associé ? Are you sure you want to remove the doc?: Êtes-vous sûr·e de vouloir supprimer le document associé ?
Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document
cancel_reason: Raison d'annulation
canceled: Annulé
remote_ms_graph: remote_ms_graph:
freebusy_statuses: freebusy_statuses: