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
|
// Clear session to discard all changes
|
||||||
$this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT);
|
$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');
|
$this->addFlash('success', 'Änderungen verworfen, Daten neu geladen');
|
||||||
|
|
||||||
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
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
|
* Draft is preserved so the user can continue editing later.
|
||||||
* POST: Clears session and redirects to bookings list
|
* Shows a flash message informing about the saved draft.
|
||||||
*/
|
*/
|
||||||
#[Route(
|
#[Route(
|
||||||
path: '/bookings/{id}/edit/cancel',
|
path: '/bookings/{id}/edit/cancel',
|
||||||
@@ -371,16 +376,19 @@ class IndexController extends AbstractController
|
|||||||
#[IsGranted('ROLE_USER')]
|
#[IsGranted('ROLE_USER')]
|
||||||
public function cancelEdit(int $id, Request $request): Response
|
public function cancelEdit(int $id, Request $request): Response
|
||||||
{
|
{
|
||||||
if (Request::METHOD_POST === $request->getMethod()) {
|
// Clear session state
|
||||||
// Clear session to discard dirty state
|
|
||||||
$this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT);
|
$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', [
|
return $this->redirectToRoute('app_bookings');
|
||||||
'bookingId' => $id,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,20 +85,10 @@
|
|||||||
{# Fixed footer #}
|
{# Fixed footer #}
|
||||||
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4 z-20">
|
<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="*">
|
<div class="flex justify-between" hx-disinherit="*">
|
||||||
{% if isDirty %}
|
<a href="{{ isDirty ? path('app_booking_edit_cancel', {id: bookingData.id}) : path('app_bookings') }}"
|
||||||
<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') }}"
|
|
||||||
class="inline-flex items-center justify-center bg-gray-200 rounded-md w-10 h-10">
|
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>
|
<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>
|
</a>
|
||||||
{% endif %}
|
|
||||||
{% if isDirty %}
|
{% if isDirty %}
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
{% if hasValidationErrors|default(false) %}
|
{% 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 %}
|
|
||||||
Reference in New Issue
Block a user