{% extends "freeform/notifications/_layout" %}

{% block actionButton %}

    {% if currentUser.can("freeform-notificationsManage") %}
        <div class="buttons">
            <div class="btngroup submit">
                <a class="btn submit add icon" href="{{ url('freeform/notifications/wrappers/new') }}">
                    {{ "New Wrapper"|t('freeform') }}
                </a>
            </div>
        </div>
    {% endif %}

{% endblock %}

{% set crumbs = [
    { label: craft.freeform.name, url: url("freeform") },
    { label: "Notification Wrappers"|t("freeform"), url: url("freeform/notifications/wrappers") },
] %}

{% set content %}

    {% if list|length %}

        <div class="vue-admin-tablepane tablepane">
            <table data-file-templates class="data fullwidth collapsible">
                <thead>
                <th scope="col">{{ "ID"|t('freeform') }}</th>
                <th scope="col">{{ "Name"|t('freeform') }}</th>
                <th scope="col">{{ "Handle"|t('freeform') }}</th>
                <th scope="col">{{ "Description"|t('freeform') }}</th>
                <th class="thin"></th>
                </thead>
                <tbody>
                {# File based templates #}
                {% for wrapper in list %}
                    <tr data-id="{{ wrapper.id }}" data-name="{{ wrapper.name|t('freeform') }}">
                        <td class="thin">{{ wrapper.id }}</td>
                        <th scope="row" data-title="{{ 'Name'|t('freeform') }}">
                            {% if currentUser.can("freeform-notificationsManage") %}
                                <a href="{{ url('freeform/notifications/wrappers/' ~ wrapper.id) }}">
                                    {{ wrapper.name }}
                                </a>
                            {% else %}
                                {{ wrapper.name }}
                            {% endif %}
                        </th>
                        <td>
                            <span class="handle code">{{ wrapper.handle }}</span>
                        </td>
                        <td>
                            {{ wrapper.description }}
                        </td>
                        <td class="thin">
                            <div class='action-buttons'>
                                {% if currentUser.can("freeform-notificationsManage") %}
                                    <a class="clone icon" data-type="wrappers" data-id="{{ wrapper.id }}"
                                       title="{{ 'Duplicate'|t('freeform') }}" role="button"></a>
                                    <a class="delete icon" data-type="wrappers" data-id="{{ wrapper.id }}" title="{{ 'Delete'|t('freeform') }}" role="button"></a>
                                {% endif %}
                            </div>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

    {% else %}

        <div class="zilch">
            {{ "No email template wrappers exist yet."|t('freeform') }}
        </div>

    {% endif %}

{% endset %}


{% js %}
    var confirmDeleteMessage = '{{ "Are you sure you want to delete this email template wrapper?"|t('freeform') }}';
{% endjs %}
