{% extends "wagtailadmin/generic/form.html" %}
{% load i18n wagtailadmin_tags %}
{% block titletag %}{% blocktrans trimmed with query=query.query_string %}Editing {{ query }}{% endblocktrans %}{% endblock %}
{% block content %}
    {% trans "Editing" as editing_str %}
    {% include "wagtailadmin/shared/header.html" with title=editing_str subtitle=query.query_string icon="pick"  %}

    <form action="{% url 'wagtailsearchpromotions:edit' query.id %}" method="POST" class="nice-padding" novalidate>
        {% csrf_token %}

        <ul class="fields">
            <li>
                {% include "wagtailsearchpromotions/queries/chooser_field.html" with field=query_form.query_string only %}
            </li>
            <li>
                {% include "wagtailsearchpromotions/includes/searchpromotions_formset.html" with formset=searchpicks_formset only %}
            </li>
        </ul>

        {% block footer %}
            {{ block.super }}
        {% endblock %}
    </form>
{% endblock %}

{% block extra_actions %}
    {% comment %}
        The view hasn't extended from generic EditView, so we cannot use the new
        header buttons in the breadcrumbs for the Delete button. Instead, we'll
        add a Delete button to the footer actions.
    {% endcomment %}
    {% if can_delete %}
        <a href="{{ delete_url }}" class="button">{{ delete_item_label }}</a>
    {% endif %}
{% endblock %}

{% block extra_js %}
    {{ block.super }}
    <script src="{% versioned_static 'wagtailsearchpromotions/js/query-chooser-modal.js' %}"></script>

    <script type="text/javascript">
        {% include "wagtailsearchpromotions/includes/searchpromotions_formset.js" with formset=searchpicks_formset only  %}
        {% include "wagtailsearchpromotions/queries/chooser_field.js" only %}

        $(function() {
            createQueryChooser('{{ query_form.query_string.auto_id }}');
        });
    </script>
{% endblock %}
