{% extends "wagtailadmin/generic/edit.html" %}
{% load i18n wagtailadmin_tags %}

{% block main_content %}
    <form action="{% block form_action %}{{ view.edit_url }}{% endblock %}"{% if is_multipart %} enctype="multipart/form-data"{% endif %} method="POST" novalidate>
        {% csrf_token %}

        <div class="w-form-width">
            {% block form %}{{ edit_handler.render_form_content }}{% endblock %}

            {% panel id="workflow-pages" icon="doc-empty-inverse" heading=_("Assign your workflow to pages") %}
                {% if workflow.active %}
                    <p class="help-block help-info">
                        {% icon name='help' %}
                        {% url 'wagtailadmin_workflows:usage' workflow.pk as workflow_pages_url %}
                        {% blocktrans trimmed %}
                            Workflows apply to child pages too. If you select a parent page here, its child pages will also use this workflow.
                            See <a href="{{ workflow_pages_url }}">the list of the pages</a> your workflow applies to.
                        {% endblocktrans %}
                    </p>

                    {% include "wagtailadmin/workflows/includes/workflow_pages_formset.html" with formset=pages_formset %}
                {% else %}
                    <p class="help-block help-info">
                        {% icon name='help' %}
                        {% trans "This workflow is disabled so it cannot be assigned to any pages." %}
                    </p>
                {% endif %}
            {% endpanel %}

            {% if has_workflow_enabled_models %}
                {% panel id="workflow-content-types" icon="snippet" heading=_("Assign your workflow to snippets") %}
                    {% if workflow.active %}
                        {% formattedfield field=content_type_form.content_types sr_only_label=True %}
                    {% else %}
                        <p class="help-block help-info">
                            {% icon name='help' %}
                            {% trans "This workflow is disabled so it cannot be assigned to any snippets." %}
                        </p>
                    {% endif %}
                {% endpanel %}
            {% endif %}
        </div>

        {% block footer %}
            <footer class="footer">
                <div class="actions footer__container w-flex">
                    {% block form_actions %}
                        {% fragment as button %}
                            <button
                                type="submit"
                                class="button action-save button-longrunning w-flex-grow"
                                data-controller="w-progress w-kbd"
                                data-action="w-progress#activate"
                                data-w-kbd-key-value="mod+s"
                                data-w-kbd-scope-value="global"
                                data-w-progress-active-value="{% trans 'Saving…' %}"
                            >
                                {% icon name="spinner" %}
                                <em data-w-progress-target="label">{% trans 'Save' %}</em>
                            </button>
                        {% endfragment %}
                        {% if can_enable or can_disable %}
                            {% dropdown_button button=button toggle_icon="arrow-up" %}
                                {% if can_enable %}
                                    <button
                                        class="button"
                                        data-controller="w-action"
                                        data-action="w-action#post"
                                        data-w-action-continue-value="true"
                                        data-w-action-url-value='{{ view.get_enable_url }}'
                                        type="submit"
                                    >
                                        {{ view.enable_item_label }}
                                    </button>
                                {% elif can_disable %}
                                    <a href="{{ view.get_delete_url }}" class="button">{{ view.delete_item_label }}</a>
                                {% endif %}
                            {% enddropdown_button %}
                        {% else %}
                            {{ button }}
                        {% endif %}
                    {% endblock %}
                </div>
            </footer>
        {% endblock %}
    </form>
{% endblock %}
