feat: remove cancel confirmation since obsolete because of drafts

This commit is contained in:
Björn Fromme
2026-03-16 12:01:09 +01:00
parent 0b5c7af4be
commit db74b6049c
3 changed files with 22 additions and 46 deletions
+18 -10
View File
@@ -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');
}
/**