feat: remove cancel confirmation since obsolete because of drafts
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user