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

{% block titletag %}{{ view.page_title }} {{ view.get_page_subtitle }}{% endblock %}

{% block content %}
    {% include "wagtailadmin/shared/header.html" with title=view.page_title subtitle=view.get_page_subtitle icon=view.header_icon %}

    <div class="nice-padding">
        {% if locale and not locale.language_code_is_valid %}
            <p class="help-block help-warning">
                {% trans "This locale's current language code is not supported. Please choose a new language or delete this locale." %}
            </p>
        {% endif %}

        <form method="POST" novalidate{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
            {% csrf_token %}

            {% block hidden_fields %}
                {% for field in form.hidden_fields %}{{ field }}{% endfor %}

                {% for component, component_instance, component_form in components %}
                    {% for field in component_form.hidden_fields %}
                        {{ field }}
                    {% endfor %}
                {% endfor %}
            {% endblock %}

            <ul class="fields">
                {% block visible_fields %}
                    {% for field in form.visible_fields %}
                        <li>{% include "wagtailadmin/shared/field.html" %}</li>
                    {% endfor %}
                {% endblock %}
            </ul>

            {% include "wagtail_localize/admin/_components.html" with components=components only %}

            <ul class="fields">
                <li>
                    {% block actions %}
                        <input type="submit" value="{% trans 'Save' %}" class="button" />
                        {% if can_delete %}
                            <a href="{{ view.get_delete_url }}" class="button button-secondary no">{{ view.delete_item_label }}</a>
                        {% endif %}
                    {% endblock %}
                </li>
            </ul>
        </form>
    </div>
{% endblock %}

{% block extra_js %}
    {{ block.super }}
    {{ form.media.js }}

    {% for component_model, component_instance, component_form in components %}
        {{ component_form.media.js }}
    {% endfor %}

    <script type="text/javascript" src="{% versioned_static 'wagtail_localize/js/wagtail-localize-component-form.js' %}"></script>
{% endblock %}

{% block extra_css %}
    {{ block.super }}
    {{ form.media.css }}

    {% for component_model, component_instance, component_form in components %}
        {{ component_form.media.css }}
    {% endfor %}

    <link rel="stylesheet" href="{% versioned_static 'wagtail_localize/css/wagtail-localize-component-form.css' %}" />
{% endblock %}
