{% 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 %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ cl.opts.app_config.verbose_name }}</a>
&rsaquo; {{ cl.opts.verbose_name_plural|capfirst }}
</div>
{% endblock %}
{% endif %}

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

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

    {% if cl.formset and 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 %}

    {% comment %} Eric: 自定义filter样式1 {% endcomment %}
    {% comment %} <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist"> {% endcomment %}
    <div class="module" id="changelist">
    {% comment %} Eric: 自定义filter样式1 End {% endcomment %}

      {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %}

      <div id="custom-changelist-filter">
      {% block filters %}
        {% if cl.has_filters %}

          {% comment %} Eric: 自定义filter样式2 {% endcomment %}
          {% comment %}
          <div id="changelist-filter">
            <h2>{% trans 'Filter' %}</h2>
          {% endcomment %}
          {% comment %} Eric: 自定义filter样式2 End {% endcomment %}

            {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
        {% endif %}
      {% endblock %}
      {% block search %}{% search_form cl %}{% endblock %}

      {% comment %} Eric: 增加全部按钮 {% endcomment %}
      {% if cl.has_filters or cl.search_fields %}
      <a href="{{ request.path }}"><input type="submit" class="submit-btn" value="全部" style="height: 28px; padding:0 16px;"></input></a>
      {% endif %}
      {% comment %} Eric: 增加全部按钮 End {% endcomment %}

      </div>

      <form id="changelist-form" method="post"{% if cl.formset and 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 %}
          <div id="actions-and-object-tools">
          {% block object-tools %}
            <ul class="object-tools">
              {% block object-tools-items %}
                {% change_list_object_tools %}
              {% endblock %}
            </ul>
          {% endblock %}
          {% if list_tips %}<div style="margin:8px 0;padding:8px 6px;color:#447e9b;font-size:15px;font-weight:500;background:#f6f6f6;border-radius:4px;word-break:break-all;">
            {{ list_tips }}
          </div>
          {% endif %}
          {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
          </div>
          {% result_list cl %}
          {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
      {% endblock %}
      {% block pagination %}{% pagination cl %}{% endblock %}
      </form>
    </div>
    {% comment %} Eric: 修复一下content padding-top {% endcomment %}
    <script>
      document.getElementById("content").style.paddingTop = '0';
      (function ($) {
        {% for field, width in min_width_fields %}
        $(".field-{{ field }}").css('white-space', 'unset');
        $(".field-{{ field }}").css('word-break', 'break-all');
        $(".field-{{ field }}").css('min-width', '{{ width }}');
        {% endfor %}
        $(function () {
          $('table').floatThead({top: $(document).width() <= 1024 ? 0 : $("#x-header").height()});
        });
      })(django.jQuery)
    </script>
    {% comment %} Eric: 修复一下content padding-top End {% endcomment %}
  </div>
{% endblock %}
