feat: centralize create/edit flow contexts, extract edit submit service
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
{{ stimulus_controller('toggle', { 'open': false }, { 'closed': 'hidden', 'open': 'absolute inset-0 z-20', 'iconOpen': 'rotate-180' }) }}
|
||||
{% if htmx_oob_swap is defined and htmx_oob_swap %}hx-swap-oob="true"{% endif %}>
|
||||
{% include 'booking/_summary.html.twig' with {
|
||||
'bookingCreateDto': bookingDto,
|
||||
'summaryData': summaryData,
|
||||
'mutableData': mutableData|default(null)
|
||||
'bookingDto': bookingEditContext.bookingDto,
|
||||
'summaryData': bookingEditContext.summaryData,
|
||||
'mutableData': bookingEditContext.mutableData|default(null)
|
||||
} %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -30,9 +30,9 @@
|
||||
<h1 class="text-xl font-semibold uppercase">
|
||||
Buchung bearbeiten
|
||||
</h1>
|
||||
{% if isDirty %}
|
||||
{% if bookingEditContext.isDirty %}
|
||||
<button type="button"
|
||||
hx-get="{{ path('app_booking_edit_reload', {id: bookingData.id}) }}"
|
||||
hx-get="{{ path('app_booking_edit_reload', {id: bookingEditContext.bookingData.id}) }}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend"
|
||||
class="button button--small button--secondary">
|
||||
@@ -46,7 +46,7 @@
|
||||
{% block participant_cards %}
|
||||
<h2 class="pb-4">Teilnehmer:innen</h2>
|
||||
|
||||
{% if isDirty %}
|
||||
{% if bookingEditContext.isDirty %}
|
||||
{% include '_partials/_alert.html.twig' with {
|
||||
level: 'warning',
|
||||
title: 'Ungespeicherte Änderungen',
|
||||
@@ -55,7 +55,7 @@
|
||||
{% endif %}
|
||||
|
||||
{# Display validation errors #}
|
||||
{% if hasValidationErrors|default(false) %}
|
||||
{% if bookingEditContext.hasValidationErrors %}
|
||||
{% include '_partials/_alert.html.twig' with {
|
||||
level: 'error',
|
||||
title: 'Bitte überprüfe die Teilnehmerdaten',
|
||||
@@ -64,16 +64,16 @@
|
||||
{% endif %}
|
||||
|
||||
<div id="participant-cards-grid" class="space-y-4">
|
||||
{% for participant in bookingDto.participants %}
|
||||
{% set isCanceled = (bookingData.participantsStatus[loop.index0] ?? null) == 'S' %}
|
||||
{% for participant in bookingEditContext.bookingDto.participants %}
|
||||
{% set isCanceled = (bookingEditContext.bookingData.participantsStatus[loop.index0] ?? null) == 'S' %}
|
||||
{% include 'booking/_participant_card.html.twig' with {
|
||||
'cardData': cardsData[loop.index0],
|
||||
'cardData': bookingEditContext.cardsData[loop.index0],
|
||||
'index': loop.index0,
|
||||
'participantNumber': loop.index,
|
||||
'mode': 'edit',
|
||||
'bookingId': bookingData.id,
|
||||
'bookingId': bookingEditContext.bookingData.id,
|
||||
'isCanceled': isCanceled,
|
||||
'isSubmitted': isSubmitted,
|
||||
'isSubmitted': bookingEditContext.isSubmitted,
|
||||
} %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -85,17 +85,17 @@
|
||||
{# 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="*">
|
||||
<a href="{{ isDirty ? path('app_booking_edit_cancel', {id: bookingData.id}) : path('app_bookings') }}"
|
||||
<a href="{{ bookingEditContext.isDirty ? path('app_booking_edit_cancel', {id: bookingEditContext.bookingData.id}) : path('app_bookings') }}"
|
||||
class="inline-flex items-center justify-center bg-gray-200 rounded-md w-8 h-8 md:w-10 md:h-10">
|
||||
<svg class="w-6 h-6 md:w-8 md: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>
|
||||
{% if isDirty %}
|
||||
{% if bookingEditContext.isDirty %}
|
||||
<button type="submit"
|
||||
{% if hasValidationErrors|default(false) %}
|
||||
{% if bookingEditContext.hasValidationErrors %}
|
||||
disabled
|
||||
title="Bitte prüfe zuerst deine Eingaben"
|
||||
{% endif %}
|
||||
class="button button--primary {{ hasValidationErrors|default(false) ? 'opacity-50 cursor-not-allowed' : '' }}">
|
||||
class="button button--primary {{ bookingEditContext.hasValidationErrors ? 'opacity-50 cursor-not-allowed' : '' }}">
|
||||
Buchung aktualisieren
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
<div id="booking-summary"
|
||||
class="hidden lg:block lg:order-2 lg:flex-1 lg:min-h-0 lg:col-span-2">
|
||||
{% include 'booking/_summary.html.twig' with {
|
||||
'bookingCreateDto': bookingDto,
|
||||
'summaryData': summaryData,
|
||||
'mutableData': mutableData|default(null)
|
||||
'bookingDto': bookingEditContext.bookingDto,
|
||||
'summaryData': bookingEditContext.summaryData,
|
||||
'mutableData': bookingEditContext.mutableData|default(null)
|
||||
} %}
|
||||
</div>
|
||||
|
||||
@@ -27,13 +27,20 @@
|
||||
<div id="main-content" class="flex-1 overflow-y-auto px-4 lg:px-8 py-8">
|
||||
{# Flash messages - must be inside main-content for HTMX swap to display them #}
|
||||
{% include '_partials/_flashes.html.twig' %}
|
||||
{% include 'booking/_participant_form.html.twig' %}
|
||||
{% include 'booking/_participant_form.html.twig' with {
|
||||
'bookingEditContext': bookingEditContext,
|
||||
'participantIndex': participantIndex,
|
||||
'refreshRouteName': refreshRouteName,
|
||||
'refreshRouteParams': refreshRouteParams|default({}),
|
||||
'cancelRouteName': cancelRouteName|default('app_booking_edit'),
|
||||
'cancelRouteParams': cancelRouteParams|default({id: bookingEditContext.bookingData.id})
|
||||
} %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4 z-20">
|
||||
<div class="flex justify-between">
|
||||
<a href="{{ path('app_booking_edit', {id: bookingDto.booking.id}) }}"
|
||||
<a href="{{ path('app_booking_edit', {id: bookingEditContext.bookingData.id}) }}"
|
||||
class="inline-flex items-center justify-center bg-gray-200 rounded-md w-8 h-8 md:w-10 md:h-10"
|
||||
{{ qa_attribute('btn-cancel') }}>
|
||||
<svg class="w-6 h-6 md:w-8 md: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>
|
||||
|
||||
Reference in New Issue
Block a user