feat: remove cancel confirmation since obsolete because of drafts

This commit is contained in:
Björn Fromme
2026-01-06 10:44:30 +01:00
parent 60c1459902
commit 2a13a62291
3 changed files with 22 additions and 46 deletions
@@ -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
// 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');
}
/**
+1 -11
View File
@@ -85,20 +85,10 @@
{# Fixed footer #}
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4 z-20">
<div class="flex justify-between" hx-disinherit="*">
{% if isDirty %}
<button type="button"
hx-get="{{ path('app_booking_edit_cancel', {id: bookingData.id}) }}"
hx-target="body"
hx-swap="beforeend"
class="inline-flex items-center justify-center bg-gray-200 rounded-md w-10 h-10">
<svg class="w-8 h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><line x1="200" y1="56" x2="56" y2="200" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="200" y1="200" x2="56" y2="56" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
</button>
{% else %}
<a href="{{ path('app_bookings') }}"
<a href="{{ isDirty ? path('app_booking_edit_cancel', {id: bookingData.id}) : path('app_bookings') }}"
class="inline-flex items-center justify-center bg-gray-200 rounded-md w-10 h-10">
<svg class="w-8 h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><line x1="200" y1="56" x2="56" y2="200" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="200" y1="200" x2="56" y2="56" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
</a>
{% endif %}
{% if isDirty %}
<button type="submit"
{% if hasValidationErrors|default(false) %}
@@ -1,22 +0,0 @@
{% extends 'htmx_modal.html.twig' %}
{% block title %}Sicher?{% endblock %}
{% block content %}
<div class="pb-8">
Willst du die Bearbeitung wirklich abbrechen? Ungespeicherte Änderungen gehen verloren.
</div>
<div class="flex justify-between">
<button type="button"
hx-post="{{ path('app_booking_edit_cancel', {id: bookingId}) }}"
hx-target="body"
class="button button--primary">
Abbrechen
</button>
<button type="button"
{{ stimulus_action('modal', 'close') }}
class="button button--secondary">
Weiter
</button>
</div>
{% endblock %}