{% extends "admin/base_site.html" %}

<!-- LOADING -->
{% load adminmedia admin_list i18n future grp_tags grp_csrf %}

<!-- STYLES -->
{% block extrastyle %}
    <link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/changelist.css" />
    {% if not actions_on_top and not actions_on_bottom %}
    <style>
        #changelist table thead th:first-child {width: inherit}
    </style>
    {% endif %}
{% endblock %}

<!-- JAVASCRIPTS -->
{% block javascripts %}
    {% url "admin:jsi18n" as jsi18nurl %}
    <script type="text/javascript" src="{{ jsi18nurl|default:"../../jsi18n/" }}"></script>
    {{ block.super }}
    {{ media|use_grappelli_media }}
    <script type="text/javascript" src="{% admin_media_prefix %}js/admin/Changelist.js"></script>
    {% if is_popup %}
    <script type="text/javascript">
        // HACK: REMOVE ACTIONS and LIST_EDITABLES FOR POPUPS
        $('div.actions').hide();
        $('p.submit-row').hide();
        $('input.action-select').parent().hide();
        $('input#action-toggle').parent().hide();
    </script>
    {% endif %}
        {% if action_form %}
        <script type="text/javascript" charset="utf-8">
            (function($) {
                $(document).ready(function() {
                    $("tr input.action-select").actions();
                });
            })(django.jQuery);
        </script>
    {% endif %}
{% endblock %}

<!-- COLTYPE/BODYCLASS-- >
{% block coltype %}flex{% endblock %}
{% block bodyclass %}change-list{% endblock %}

<!-- BREADCRUMBS -- >
{% block breadcrumbs %}
{% if not is_popup %}
    <div class="breadcrumbs">
        <a href="{% if request.session.grappelli.home %}{{ request.session.grappelli.home }}{% else %}{% get_admin_url %}{% endif %}">{% trans "Home" %}</a> &rsaquo;
        <a href="../">{{ app_label|capfirst }}</a> &rsaquo;
        {{ cl.opts.verbose_name_plural|capfirst }}
    </div>
{% endif %}
{% endblock %}

<!-- CONTENT -->
{% block content %}
    <div id="content-main">

        <!-- Object-Tools -->
        {% block object-tools %}
            {% if has_add_permission %}
                <ul class="object-tools">
                    {% block object-tools-items %}
                    <li>
                        <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="focus">
                            {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                        </a>
                    </li>
                    {% endblock %}
                </ul>
            {% endif %}
        {% endblock %}

        <!-- Errors -->
        {% if cl.formset.errors %}
            <p class="errornote">
            {% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
            </p>
            <ul class="errorlist">{% for error in cl.formset.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
        {% endif %}

        <!-- Changelist -->
        <div class="module{% if cl.has_filters or cl.search_fields or cl.date_hierarchy %} filtered{% endif %}" id="changelist">
            <div class="changelist-content">
                <form action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% grp_csrf_token %}

                <!-- Popup Hidden Field -->
                {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}

                <!-- Management Form -->
                {% if cl.formset %}
                    {{ cl.formset.management_form }}
                {% endif %}

                <!-- Results -->
                <div class="result-list-container">
                    {% block result_list %}
                        {% if action_form and actions_on_top and cl.full_result_count and cl.result_count %}{% admin_actions %}{% endif %}
                        {% result_list cl %}
                        {% if action_form and actions_on_bottom and cl.full_result_count and cl.result_count %}{% admin_actions %}{% endif %}
                    {% endblock %}
                    {% block pagination %}{% pagination cl %}{% endblock %}
                </div>

                <!-- Submit-Row -->
                {% if cl.formset and cl.result_count %}
                    <p class="submit-row">
                        <input type="submit" name="_save" class="default" value="{% trans 'Save' %}"/>
                    </p>
                {% endif %}
                </form>
            </div>

            <!-- Sidebar -->
            {% block filters %}
                {% if cl.has_filters or cl.search_fields or cl.date_hierarchy %}
                    <div id="changelist-filter">

                        <!-- Results -->
                        {% ifnotequal cl.result_count cl.full_result_count %}
                        <div class="module results">
                            <h2>{% trans 'Results' %}</h2>
                            <div class="form-row">
                                <p>{% blocktrans with cl.result_count as counter %}{{ counter }} found{% endblocktrans %}</p>
                                <a href="?{% if cl.is_popup %}pop=1{% endif %}">{% blocktrans with cl.full_result_count as full_result_count %}{{ full_result_count }} total{% endblocktrans %}</a>
                            </div>
                        </div>
                        {% endifnotequal %}

                        <!-- Search -->
                        {% block search %}{% search_form cl %}{% endblock %}

                        <!-- Date Hierarchy -->
                        {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

                        {% if cl.has_filters %}
                        <!-- Filter -->
                        <div class="module filter">
                            <h2>{% trans 'Filter' %}</h2>
                            {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
                        </div>
                        {% endif %}

                    </div>
                {% endif %}
            {% endblock %}
        </div>

    </div>
{% endblock %}
