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

{% block form_content %}
    {{ edit_handler.render_form_content }}

    <div class="w-form-width">
        {% panel id="workflow-pages" icon="doc-empty-inverse" heading=_("Assign your workflow to pages") attrs=pages_formset.attrs %}
            {% 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>
{% endblock %}

{% block extra_actions %}
    {% 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 %}
{% endblock %}
