{% extends app.request.headers.get('turbo-frame') == 'slideover' ? '@FerienpassAdmin/layout/slideOverFrame.html.twig' : '@FerienpassAdmin/layout/base.html.twig' %}

{% trans_default_domain 'admin' %}
{% set translationPrefix = app.request.get('_route')|split('_')[1] %}
{% set action = (app.request.get('_route')|split('.')|first)|split('_')[2] %}


{% if pagination is defined %}
    {% set items = pagination.results %}
{% endif %}

{% set headline = "#{translationPrefix}.#{action}.title"|trans %}
{% set headline = (headline == "#{translationPrefix}.#{action}.title") ? "#{translationPrefix}.title"|trans : headline %}
{% if title is not defined %}
    {% set title = headline %}
{% endif %}

{% block main %}

    <div class="{{ app.request.headers.get('turbo-frame') == 'slideover' ? 'p-4 sm:p-6' : '' }}">

    {% block list %}
        {% embed '@FerienpassAdmin/components/list.html.twig' with { headline, exports, createUrl } %}
            {% block header %}
                {% include '@FerienpassAdmin/components/_list_header.html.twig' with { headline, exports, createUrl } %}
            {% endblock %}
        {% endembed %}
    {% endblock %}

    </div>

{% endblock %}

{% block deleted_stream %}
    {# This closes the modal by triggering the mutation observer #}
    <turbo-stream action="update" target="modal"></turbo-stream>

    {# The element with DOM ID "tr-XX" will be removed. #}
    <turbo-stream action="remove" target="tr-{{ id }}"></turbo-stream>
{% endblock %}
