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

{% block extra_js %}
    {{ block.super }}
    {% include "wagtailadmin/pages/_editor_js.html" %}
{% endblock %}

{% block content %}
    {% block header %}
        {{ block.super }}
    {% endblock %}

    <form action="{{ view.edit_url }}" enctype="multipart/form-data" method="POST" novalidate>
        {% csrf_token %}

        <ul class="fields nice-padding">
            {% for field in form %}
                {% if not field.is_hidden %}
                    <li>
                        {% include "wagtailadmin/shared/field.html" %}
                    </li>
                {% else %}
                    {{ field }}
                {% endif %}
            {% endfor %}
            <li>
                <div class="help-block help-info">
                    {% icon name='help' %}
                    {% for workflow in object.active_workflows %}
                        {% if forloop.first %}<strong>{% trans "Used on the following active workflows" %}:</strong> {% endif %}
                        <a href="{% url 'wagtailadmin_workflows:edit' workflow.pk %}">{{ workflow.name }}</a>{% if not forloop.last %}, {% endif %}
                    {% empty %}
                        {% trans "Not used" %}
                    {% endfor %}
                </div>
            </li>
        </ul>

        {% block footer %}
            <footer class="footer" role="contentinfo">
                <ul>
                    <li class="actions footer__container">
                        {% block form_actions %}
                            <div class="dropdown dropup dropdown-button match-width">
                                <button
                                    type="submit"
                                    class="button action-save button-longrunning"
                                    data-controller="w-progress"
                                    data-action="w-progress#activate"
                                    data-w-progress-active-value="{% trans 'Saving…' %}"
                                >
                                    {% icon name="spinner" %}
                                    <em data-w-progress-target="label">{% trans 'Save' %}</em>
                                </button>

                                <div class="dropdown-toggle">{% icon name="arrow-up" %}</div>
                                <ul>
                                    {% if can_enable %}
                                        <li>
                                            <button
                                                class="button no"
                                                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>
                                        </li>
                                    {% elif can_disable %}
                                        <li>
                                            <a href="{{ view.get_delete_url }}" class="button no">{{ view.delete_item_label }}</a>
                                        </li>
                                    {% endif %}
                                </ul>
                            </div>
                        {% endblock %}
                    </li>
                </ul>
            </footer>
        {% endblock %}
    </form>
{% endblock %}
