From 2a13a622912b75484058a018600b286676f23a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 6 Jan 2026 10:44:30 +0100 Subject: [PATCH] feat: remove cancel confirmation since obsolete because of drafts --- .../Booking/Edit/IndexController.php | 28 ++++++++++++------- templates/booking/edit/index.html.twig | 18 +++--------- templates/booking/edit/modal_cancel.html.twig | 22 --------------- 3 files changed, 22 insertions(+), 46 deletions(-) delete mode 100644 templates/booking/edit/modal_cancel.html.twig diff --git a/src/Controller/Booking/Edit/IndexController.php b/src/Controller/Booking/Edit/IndexController.php index be29aaa..fbceca7 100644 --- a/src/Controller/Booking/Edit/IndexController.php +++ b/src/Controller/Booking/Edit/IndexController.php @@ -347,6 +347,11 @@ class IndexController extends AbstractController // Clear session to discard all changes $this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT); + // Delete draft since user explicitly chose to discard changes + /** @var User $user */ + $user = $this->getUser(); + $this->draftService->deleteDraft($user, $id); + $this->addFlash('success', 'Änderungen verworfen, Daten neu geladen'); return $this->redirectToRoute('app_booking_edit', ['id' => $id]); @@ -358,10 +363,10 @@ class IndexController extends AbstractController } /** - * Handles "Zurück" button - shows confirmation modal or clears session. + * Handles "Zurück" button - clears session and preserves draft. * - * GET: Returns modal HTML for confirmation - * POST: Clears session and redirects to bookings list + * Draft is preserved so the user can continue editing later. + * Shows a flash message informing about the saved draft. */ #[Route( path: '/bookings/{id}/edit/cancel', @@ -371,16 +376,19 @@ class IndexController extends AbstractController #[IsGranted('ROLE_USER')] public function cancelEdit(int $id, Request $request): Response { - if (Request::METHOD_POST === $request->getMethod()) { - // Clear session to discard dirty state - $this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT); + // Clear session state + $this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT); - return $this->redirectToRoute('app_bookings'); + // Check if a draft exists to show appropriate message + /** @var User $user */ + $user = $this->getUser(); + $draft = $this->draftService->findDraft($user, $id); + + if (null !== $draft) { + $this->addFlash('info', 'Deine Änderungen wurden als Entwurf gespeichert.'); } - return $this->render('booking/edit/modal_cancel.html.twig', [ - 'bookingId' => $id, - ]); + return $this->redirectToRoute('app_bookings'); } /** diff --git a/templates/booking/edit/index.html.twig b/templates/booking/edit/index.html.twig index 8fa5c28..1893aea 100644 --- a/templates/booking/edit/index.html.twig +++ b/templates/booking/edit/index.html.twig @@ -85,20 +85,10 @@ {# Fixed footer #}
- {% if isDirty %} - - {% else %} - - - - {% endif %} + + + {% if isDirty %}
-
- - -
-{% endblock %}