{% extends config.get('BASE_TEMPLATE') or config['KEGAUTH_BASE_TEMPLATE'] %}

{%- if _ is not defined -%}
    {% from 'keg_auth/i18n.j2' import gettext as _ %}
{%- endif -%}

{% block title %}{{ page_title }}{% endblock %}

{% block page_content %}
<h1>{{ page_heading }}</h1>

<section class="grid-body">
    {% block add_button %}
        {% if add_url %}
            <div class="grid-header-add-link">
                <a href="{{ add_url }}">
                    <span class="fas fa-plus-circle"></span>
                    {{ _('Create %(name)s') | format(name=object_name) }}
                </a>
            </div>
        {% endif %}
    {% endblock %}
    <div class="preamble">
        {% block preamble %}
        {% endblock %}
    </div>
    {{ grid.html() | safe}}
</section>

{% block confirm_delete_script %}
<script type="text/javascript">
    var els = document.getElementsByClassName('confirm-delete');

    for (var idx = 0; idx < els.length; idx++) {
        els[idx].addEventListener('click', function (event) {
            if (!confirm('Are you sure you want to delete this item?')) {
                event.preventDefault();
            }
        });
    }
</script>
{% endblock %}
{% endblock %}
