{% extends "admin/base_site.html" %}
{% load i18n jet_tags static %}

{% if not is_popup %}
    {% block breadcrumbs %}
        <div class="breadcrumbs">
            <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
            {% if app %}
                &rsaquo; <a href="{{ app.app_url }}">{% if app.name != app.app_label|capfirst|escape %}{{ app.name }}{% else %}{% trans app.app_label as app_label %}{{ app_label|capfirst|escape }}{% endif %}</a>
            {% endif %}
            &rsaquo; {{ object.title|capfirst }}
        </div>
    {% endblock %}
{% endif %}

{% block bodyclass %}{{ block.super }} dashboard jet change-form{% endblock %}

{% block content %}
    <div id="content-main">
        {% block object-tools %}{% endblock %}

        <form action="" method="post" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
            <div>
                {% if form.errors or settings_form.errors %}
                    <p class="errornote">{% trans "Please correct the errors below." %}</p>
                {% endif %}

                {% block field_sets %}
                    <fieldset class="module aligned">
                        {% include "jet.dashboard/update_module_fieldset.html" with form=form wrap=False %}

                        {% if settings_form %}
                            {% include "jet.dashboard/update_module_fieldset.html" with form=settings_form wrap=False %}
                        {% endif %}
                    </fieldset>
                {% endblock %}

                {% block after_field_sets %}{% endblock %}

                {% block inline_field_sets %}
                    {% if children_formset %}
                        <div class="inline-group">
                            <fieldset class="module">
                                <h2>{{ child_name_plural }}</h2>

                                {{ children_formset.management_form }}
                                {{ children_formset.non_form_errors }}

                                {% for form in children_formset %}
                                    <div class="inline-related{% if forloop.last %} empty-form last-related{% else %} has_original{% endif %}">
                                        <h3>
                                            <b>{{ child_name|capfirst }}:</b>&nbsp;<span class="inline_label">#{{ forloop.counter }}</span>

                                            {% if forloop.last %}
                                                <span><a href="#" class="inline-deletelink">{% trans "Delete" %}</a></span>
                                            {% elif children_formset.can_delete %}
                                                <span class="delete"><label>{{ form.DELETE }} {% trans "Delete" %}</label></span>
                                            {% endif %}
                                        </h3>

                                        {% if form.non_field_errors %}{{ form.non_field_errors }}{% endif %}

                                        {% include "jet.dashboard/update_module_fieldset.html" with form=form %}
                                    </div>
                                {% endfor %}

                                {% with child_name as verbose_name %}
                                    <div class="add-row">
                                        <a href="#">{% blocktrans %}Add another {{ verbose_name }}{% endblocktrans %}</a>
                                    </div>
                                {% endwith %}
                            </fieldset>
                        </div>
                    {% endif %}
                {% endblock %}

                {% block after_related_objects %}{% endblock %}

                {% block submit_buttons_bottom %}
                    <div class="submit-row">
                        <input type="submit" value="{% trans 'Save' %}" class="default" name="_save" />
                    </div>
                {% endblock %}

                {% block admin_change_form_document_ready %}{% endblock %}
            </div>
        </form>
    </div>
{% endblock %}
