108 lines
6.0 KiB
Twig
108 lines
6.0 KiB
Twig
{% extends 'layout_booking.html.twig' %}
|
|
|
|
{% set htmx_change_trigger = 'change delay:300ms' %}
|
|
|
|
{% block title %}Gutschein kaufen{% endblock %}
|
|
|
|
{% block content %}
|
|
{{ form_start(form, {
|
|
'attr': {
|
|
'class': 'flex-1 flex flex-col min-h-0',
|
|
'novalidate': 'novalidate'
|
|
}
|
|
}) }}
|
|
{# Pagination - mobile only (above summary) #}
|
|
<div class="lg:hidden">
|
|
{% include 'booking/_pagination.html.twig' with { current_step: 1, step_routes: stepRoutes } %}
|
|
</div>
|
|
<div class="flex-1 flex flex-col lg:grid lg:grid-cols-5 min-h-0 relative">
|
|
{% block voucher_summary %}
|
|
<div id="voucher-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|default(false) %}hx-swap-oob="true"{% endif %}>
|
|
{% include 'voucher/_summary.html.twig' %}
|
|
</div>
|
|
{% endblock %}
|
|
<div id="form-wrapper"
|
|
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-primary-bg flex flex-col min-h-0">
|
|
{% include '_partials/_flashes.html.twig' %}
|
|
{# Pagination - desktop only (fixed above scrollable content) #}
|
|
<div class="hidden lg:block shrink-0">
|
|
{% include 'booking/_pagination.html.twig' with { current_step: 1, step_routes: stepRoutes } %}
|
|
</div>
|
|
{# The preview button waits until the voucher fields would pass step 1's validation #}
|
|
<div class="flex-1 overflow-y-auto scroll-stable px-4 lg:px-8 py-8"
|
|
{{ stimulus_controller('field-validity') }}
|
|
data-action="input->field-validity#update change->field-validity#update">
|
|
{% set validatedFieldAttr = { 'data-field-validity-target': 'field' } %}
|
|
{% from '_partials/_validation_errors.html.twig' import validation_alert %}
|
|
{{ validation_alert(form, 'Bitte überprüfe deine Angaben', false) }}
|
|
|
|
{# Any change takes the input over unvalidated and refreshes the summary #}
|
|
<div hx-post="{{ path('app_voucher_step_1_refresh') }}"
|
|
hx-trigger="{{ htmx_change_trigger }}"
|
|
hx-include="closest form"
|
|
hx-swap="none">
|
|
<h2 class="pb-4">
|
|
Motiv
|
|
</h2>
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 pb-2">
|
|
{% for choice in form.template %}
|
|
<label for="{{ choice.vars.id }}"
|
|
class="block cursor-pointer bg-white rounded-md border-2 border-transparent p-2 has-[:checked]:border-primary-light">
|
|
{% set thumbnail = thumbnails[choice.vars.value] ?? null %}
|
|
{% if thumbnail %}
|
|
<img src="{{ asset(thumbnail) }}"
|
|
alt=""
|
|
loading="lazy"
|
|
class="block w-full h-auto mb-2">
|
|
{% endif %}
|
|
<span class="flex items-center gap-2 font-semibold">
|
|
{{ form_widget(choice, { attr: choice.vars.attr|merge(validatedFieldAttr) }) }}
|
|
{{ choice.vars.label }}
|
|
</span>
|
|
</label>
|
|
{% endfor %}
|
|
</div>
|
|
{% do form.template.setRendered %}
|
|
<div class="pb-6">{{ form_errors(form.template) }}</div>
|
|
|
|
<h2 class="pb-4">
|
|
Gutscheindaten
|
|
</h2>
|
|
{{ form_row(form.from, { attr: form.from.vars.attr|merge(validatedFieldAttr) }) }}
|
|
{{ form_row(form.to, { attr: form.to.vars.attr|merge(validatedFieldAttr) }) }}
|
|
{{ form_row(form.amount, {
|
|
attr: form.amount.vars.attr|merge(validatedFieldAttr),
|
|
help: 'Ganze Euro-Beträge von %s € bis %s €'|format(voucher.minAmount|number_format(0, ',', '.'), voucher.maxAmount|number_format(0, ',', '.'))
|
|
}) }}
|
|
</div>
|
|
|
|
<button type="button"
|
|
class="button button--secondary disabled:opacity-50 disabled:cursor-not-allowed"
|
|
title="Für die Vorschau bitte zuerst Motiv, Von, Für und Gutscheinwert angeben"
|
|
{{ stimulus_target('field-validity', 'button') }}
|
|
{% if not previewable %}disabled{% endif %}
|
|
hx-post="{{ path('app_voucher_preview') }}"
|
|
hx-include="closest form"
|
|
hx-target="body"
|
|
hx-swap="beforeend"
|
|
{{ qa_attribute('btn-preview') }}>
|
|
Vorschau anzeigen
|
|
</button>
|
|
</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" hx-disinherit="*">
|
|
{% include '_partials/_cancel_button.html.twig' with { cancel_url: path('app_voucher_cancel') } %}
|
|
<button type="submit" class="button button--primary" {{ qa_attribute('btn-submit') }}>
|
|
Weiter zu Schritt 2
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{{ form_rest(form) }}
|
|
{{ form_end(form) }}
|
|
{% endblock %}
|