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

{% 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 }}
{% endblock %}

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

{% if not is_popup %}
{% block breadcrumbs %}
<ul class="app-breadcrumb breadcrumb">
  <li class="breadcrumb-item"><a href="{% url 'admin:index' %}"><i class="fa fa-home fa-lg"></i>{% trans 'Home' %}</a></li>
  <li class="breadcrumb-item"><a href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ cl.opts.app_config.verbose_name }}</a></li>
  <li class="breadcrumb-item">{{ cl.opts.verbose_name_plural|capfirst }}</li>
</ul>
{% endblock %}
{% endif %}

{% block object-tools %}

    <div class="object-tools object-tools-mr" style="margin-right:16%">

      {% block object-tools-items %}
        {% if has_add_permission %}
          {% url cl.opts|admin_urlname:'add' as add_url %}
          <a class="btn btn-primary btn-sm" href="{% add_preserved_filters add_url is_popup to_field %}">
            <i class="fa fa-plus"></i>{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
          </a>
        {% endif %}
      {% endblock %}
    </div>
{% endblock %}

{% block coltype %}container{% endblock %}

{% block content %}
  <div id="content-main" class="row">

    {% if cl.formset.errors %}
        <p class="errornote">
        {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
        </p>
        {{ cl.formset.non_form_errors }}
    {% endif %}
    <div class="tile module{% if cl.has_filters %} filtered col-9{%else%} col{% endif %}" id="changelist">
      <div id="sampleTable_filter" class="dataTables_filter">
        {% block search %}{% search_form cl %}{% endblock %}
      </div>
      {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

      <form id="changelist-form" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %}
      {% if cl.formset %}
        <div>{{ cl.formset.management_form }}</div>
      {% endif %}
      <div class="tile-body">
        {% block result_list %}
        <div class="col" style="min-height:3rem">
            {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
        </div>
            {% result_list cl %}
        <div class="col">
            {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
        </div>

        {% endblock %}

      </div>
        {% block pagination %}{% pagination cl %}{% endblock %}
      </form>
    </div>
    {% block filters %}
        {% if cl.has_filters %}
          <div id="changelist-filter-1" class="col tile ml-4">
            <div class="tile-title"><h5>{% trans 'Filter' %}</h5></div>
            <div class="tile-body">
            {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
              </div>
          </div>
        {% endif %}
      {% endblock %}
  </div>
{% endblock %}
{% block extrafoot %}
{% endblock %}