{% extends "admin/base_site.html" %}
{% load i18n admin_urls admin_static admin_list suit_tags %}

{% block extrastyle %}
  {{ block.super }}
  {#  <link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" />#}
  {% if cl.formset %}
    {#    <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />#}
  {% endif %}
  {% if cl.formset or action_form %}
    <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
  {% endif %}
  {{ media.css }}
  {% if not actions_on_top and not actions_on_bottom %}
    <style>
      #changelist table thead th:first-child { width: inherit }
    </style>
  {% endif %}
{% endblock %}

{% block extrahead %}
  {{ block.super }}
  {{ media.js }}
  {% if action_form %}{% if actions_on_top or actions_on_bottom %}
    <script type="text/javascript">
      (function ($) {
        $(document).ready(function ($) {
          $("tr input.action-select").actions();
        });
      })(django.jQuery);
    </script>
  {% endif %}{% endif %}
{% endblock %}

{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %}


{% if not is_popup %}
  {% block breadcrumbs %}
    <ol class="breadcrumb">
      <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
      <li><a href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ cl.opts.app_config.verbose_name }}</a></li>
      <li class="active">{{ cl.opts.verbose_name_plural|capfirst }}</li>
    </ol>
  {% endblock %}
{% endif %}

{% block coltype %}flex{% endblock %}

{% block content %}
  <div id="content-main">
    {% if cl.formset.errors %}
      <div class="alert alert-danger errornote">
        {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
      </div>
      {{ cl.formset.non_form_errors }}
    {% endif %}

    {% suit_conf_value 'list_filters_position' cl.model_admin as FILTERS_POS %}
    <div class="row">
      <div class="module{% if cl.has_filters and FILTERS_POS == 'right' %} col-sm-8 col-md-10 filtered{% else %} col-xs-12{% endif %}" id="changelist">

        <div class="search-container clearfix">
          {% block object-tools %}
            {% if has_add_permission %}
              <div class="object-tools btn-toolbar pull-right">
                {% block object-tools-items %}
                  <div class="btn-group">
                    {% url cl.opts|admin_urlname:'add' as add_url %}
                    <a href="{% add_preserved_filters add_url is_popup to_field %}" class="addlink btn btn-success">
                      <span class="glyphicon glyphicon-plus-sign"></span>
                      {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                    </a>
                  </div>
                {% endblock %}
              </div>
            {% endif %}
          {% endblock %}
          {% block search %}{% search_form cl %}{% endblock %}
        </div>
        {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

        <form id="changelist-form" action="" method="post" class="form-horizontal"
          {% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %}
          {% if cl.formset %}
            <div>{{ cl.formset.management_form }}</div>
          {% endif %}

          {% block result_list %}
            {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
            {% result_list cl %}
            {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
          {% endblock %}
          {% block pagination %}{% pagination cl %}{% endblock %}
        </form>
      </div>

      {% block filters %}
        {% if cl.has_filters and FILTERS_POS == 'right' %}
          <div class="col-sm-4 col-md-2" id="changelist-filter">
            <h3>{% trans 'Filter' %}</h3>
            {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
          </div>
        {% endif %}
      {% endblock %}
    </div>
  </div>
{% endblock %}
