{% extends 'Admin/layout.html.twig' %}
{% set themeLight = true %}

{% block body %}
    <header class="header">
        <div class="header-wrapper">
            <h1 class="header-title">{{'action.preview.mail'|transchoice(form.mails|length, {}, 'action') }}</h1>
            <nav class="header-actions">
                <ul class="btns">
                    <li>
                        <input
                            class="btn"
                            form="form-preview"
                            type="submit"
                            value="{{ 'action.send.mail'|transchoice(form.vars.value.mails|length, {}, 'action') }}"
                        />
                    </li>
                </ul>
            </nav>
        </div>
        <nav>
            <ul class="nav nav-tabs">
                {% for key, mail in form.vars.value.mails %}
                    <li role="presentation">
                        <a
                            aria-controls="tabpane-{{ form.mails[key].vars.id }}"
                            {% if 0 == key %}
                                class="active"
                            {% endif %}
                            href="#tabpane-{{ form.mails[key].vars.id }}"
                            role="tab"
                        >{{ mail.description }}</a>
                    </li>
                {% endfor %}
            </ul>
        </nav>
    </header>

    <div class="tab-content">
        {{ form_start(form, {'attr': {'id': 'form-preview'}}) }}
            {% for key, mail in form.mails %}
                <div class="tabpane{{ 0 == key ? ' active' : ''}}" id="tabpane-{{ mail.vars.id }}" role="tabpanel">
                    {{ form_widget(mail) }}

                        {% if mail.vars.value.attachments|length > 0 %}
                            <ul class="attachments">
                                {% for document in mail.vars.value.attachments %}
                                    <li>
                                        <a
                                            href="{{ vich_uploader_asset(document, 'file') }}"
                                            target="_blank"
                                            title="{{ 'window.open.blank'|trans({}, 'helpers') }}"
                                        >{{ document.title }}</a>
                                    </li>
                                {% endfor %}
                            </ul>
                        {% endif %}
                </div>
            {% endfor %}
        {{ form_end(form) }}
    </div>
{% endblock body %}