Files
myep/templates/booking/edit/index.html.twig
T

124 lines
7.4 KiB
Twig

{% extends 'layout_booking.html.twig' %}
{% block content %}
{% include '_partials/_flashes.html.twig' %}
{{ form_start(form, {
'attr': {
'class': 'flex-1 flex flex-col min-h-0'
}
}) }}
<div class="flex-1 flex flex-col lg:grid lg:grid-cols-5 min-h-0 relative">
{# Sidebar summary #}
{% block booking_summary %}
<div id="booking-summary"
class="order-1 lg:order-2 lg:flex-1 lg:min-h-0 lg:col-span-2"
{{ 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 {
'bookingDto': bookingEditContext.bookingDto,
'summaryData': bookingEditContext.summaryData,
'mutableData': bookingEditContext.mutableData|default(null)
} %}
</div>
{% endblock %}
{# Main content area #}
<div id="main-content"
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-primary-bg flex flex-col min-h-0">
{# Header - desktop only #}
<div class="hidden lg:flex shrink-0 px-4 lg:px-8 h-16 items-center justify-between shadow-md relative z-10 bg-white">
<h1 class="text-xl font-semibold uppercase">
Buchung bearbeiten
</h1>
{% if bookingEditContext.isDirty %}
<button type="button"
hx-get="{{ path('app_booking_edit_reload', {bookingId: bookingEditContext.bookingData.id}) }}"
hx-target="body"
hx-swap="beforeend"
class="button button--small button--secondary">
Änderungen verwerfen
</button>
{% endif %}
</div>
{# Scrollable content #}
<div class="flex-1 overflow-y-auto scroll-stable px-4 lg:px-8 py-8">
{% block participant_cards %}
<h2 class="pb-4">Teilnehmer:innen</h2>
{% if app.session.flashBag.peek('booking_edit_notice')|length > 0 %}
{% include '_partials/_alert.html.twig' with {
level: 'info',
title: 'Hinweis',
messages: app.flashes('booking_edit_notice')
} %}
{% endif %}
{% if bookingEditContext.isDirty %}
{% include '_partials/_alert.html.twig' with {
level: 'warning',
title: 'Ungespeicherte Änderungen',
messages: ['Du hast Änderungen an der Buchung vorgenommen. Bitte denke daran, abschließend den \'Buchung aktualisieren\' Button zu klicken.']
} %}
{% endif %}
{# Display blocking issues first; otherwise show the attention scan as a calm warning #}
{% if bookingEditContext.hasBlockingValidationErrors %}
{% include '_partials/_alert.html.twig' with {
level: 'error',
title: 'Teilnehmerdaten prüfen',
messages: ['Die Daten einiger Teilnehmer:innen sind noch unvollständig oder fehlerhaft. Bitte bearbeite die markierten Teilnehmer.']
} %}
{% elseif bookingEditContext.missingValueLabelsByParticipantIndex|length > 0 %}
{% include '_partials/_alert.html.twig' with {
level: 'warning',
title: 'Teilnehmerdaten prüfen',
messages: ['Die Daten von ' ~ (bookingEditContext.missingValueLabelsByParticipantIndex|length) ~ ' Teilnehmer:innen sind noch unvollständig oder fehlerhaft. Bitte bearbeite die markierten Teilnehmer.']
} %}
{% endif %}
<div id="participant-cards-grid" class="divide-y divide-gray-200">
{% for participant in bookingEditContext.bookingDto.participants %}
{% set isCanceled = (bookingEditContext.bookingData.participantsStatus[loop.index0] ?? null) == 'S' %}
{% set attentionLabels = bookingEditContext.missingValueLabelsByParticipantIndex[loop.index0]|default([]) %}
{% include 'booking/_participant_card.html.twig' with {
'cardData': bookingEditContext.cardsData[loop.index0],
'index': loop.index0,
'participantNumber': loop.index,
'mode': 'edit',
'bookingId': bookingEditContext.bookingData.id,
'isCanceled': isCanceled,
'isSubmitted': bookingEditContext.isSubmitted,
'needsAttention': attentionLabels is not empty,
'attentionLabels': attentionLabels,
} %}
{% endfor %}
</div>
{% endblock %}
</div>
</div>
</div>
{# 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="{{ bookingEditContext.isDirty ? path('app_booking_edit_cancel', {bookingId: 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 bookingEditContext.isDirty or bookingEditContext.hasBlockingValidationErrors %}
<button type="submit"
{% if bookingEditContext.hasBlockingValidationErrors %}
disabled
title="Bitte prüfe zuerst deine Eingaben"
{% endif %}
class="button button--primary {{ bookingEditContext.hasBlockingValidationErrors ? 'opacity-50 cursor-not-allowed' : '' }}">
Buchung aktualisieren
</button>
{% endif %}
</div>
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% endblock %}