{% extends 'wagtailadmin/bulk_actions/confirmation/base.html' %}
{% load i18n wagtailusers_tags wagtailadmin_tags %}

{% block titletag %}
    {% if items|length == 1 %}
        {% blocktrans trimmed with snippet_type_name=model_opts.verbose_name %}Delete {{ snippet_type_name }}{% endblocktrans %} - {{ items.0.item }}
    {% else %}
        {{ items|length|intcomma }} {{ model_opts.verbose_name_plural|capfirst }}
    {% endif %}
{% endblock %}

{% block header %}
    {% trans "Delete " as delete_str %}
    {% if items|length == 1 %}
        {% include "wagtailadmin/shared/header.html" with title=delete_str subtitle=items.0.item icon=header_icon only %}
    {% else %}
        {% include "wagtailadmin/shared/header.html" with title=delete_str subtitle=model_opts.verbose_name_plural|capfirst icon=header_icon only %}
    {% endif %}
{% endblock header %}

{% block items_with_access %}
    {% if items %}
        {% if items|length == 1 %}
            <div class="usagecount">
                {% with usage_count_val=items.0.usage_count %}
                    <a href="{{ items.0.usage_url }}">{% blocktrans trimmed with usage_count=usage_count_val|intcomma count usage_count_val=usage_count_val %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
                {% endwith %}
            </div>
            <p>{% blocktrans trimmed with snippet_type_name=model_opts.verbose_name %}Are you sure you want to delete this {{ snippet_type_name }}?{% endblocktrans %}</p>
        {% else %}
            <p>{% blocktrans trimmed with snippet_type_name=model_opts.verbose_name_plural count=items|length|intcomma %}Are you sure you want to delete {{ count }} {{ snippet_type_name }}?{% endblocktrans %}</p>
            <ul>
                {% for snippet in items %}
                    <li>
                        <a href="{{ snippet.edit_url }}" target="_blank" rel="noreferrer">{{ snippet.item }}</a>
                    </li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endif %}
{% endblock items_with_access %}


{% block items_with_no_access %}
    {% if items_with_no_access|length == 1 %}
        {% blocktrans with snippet_type_name=model_opts.verbose_name trimmed asvar no_access_msg %}
            You don't have permission to delete this {{ snippet_type_name }}
        {% endblocktrans %}
    {% else %}
        {% blocktrans with snippet_plural_name=model_opts.verbose_name_plural trimmed asvar no_access_msg %}
            You don't have permission to delete these {{ snippet_plural_name }}
        {% endblocktrans %}
    {% endif %}
    {% include 'wagtailsnippets/bulk_actions/list_items_with_no_access.html' with items=items_with_no_access no_access_msg=no_access_msg %}
{% endblock items_with_no_access %}

{% block form_section %}
    {% if items %}
        {% trans 'Yes, delete' as action_button_text %}
        {% trans "No, don't delete" as no_action_button_text %}
        {% include 'wagtailadmin/bulk_actions/confirmation/form.html' with action_button_class="serious" %}
    {% else %}
        {% include 'wagtailadmin/bulk_actions/confirmation/go_back.html' %}
    {% endif %}
{% endblock form_section %}
