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

{% block extrastyle %}
  {{ block.super }}
  {% if cl.formset %}
  {% 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 %}

{% if not is_popup %}
{% block breadcrumbs %}
  <div class="breadcrumbs">
    <div class="breadcrumbs-inner">
      <div class="row m-0">
        <div class="col-sm-4">
          <div class="page-header float-left">
            <div class="page-title">
              <h1>{% if title %}{{ title }}{% endif %}</h1>
            </div>
          </div>
        </div>
        <div class="col-sm-8">
          <div class="page-header float-right">
            <div class="page-title">
              <ol class="breadcrumb text-right">
                <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>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
{% endblock %}
{% endif %}

{% block search %}{% search_form cl %}{% endblock %}

{% block content %}
  <div class="content">
    <div class="animated">
      <div class="card">
        <div class="card-header">
          <strong class="card-title" v-if="headerText">{% block pretitle %}{% endblock %}</strong>
          <div class="pull-right">
            {% block object-tools-items %}
              {% if has_add_permission %}
                {% url cl.opts|admin_urlname:'add' as add_url %}
                <a href="{% add_preserved_filters add_url is_popup to_field %}" class="btn btn-outline-primary">
                  {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                </a>
              {% endif %}
            {% endblock %}
          </div>
        </div>
        <div class="card-body">
          {% 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="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
            {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

            <div class="row">
              <div class="{% if cl.has_filters %}col-md-9{% else %}col-md-12{% endif %}">
                <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 %}

                  {% block result_list %}
                    {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
                    {% 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>

              <div class="col-md-3">
                <div style="position: -webkit-sticky; position: sticky; top: 72px">
                  {% block filters %}
                    {% if cl.has_filters %}
                      <div class="card">
                        <div class="card-header">
                          <strong class="card-title mb-3">{% trans 'Filter' %}</strong>
                        </div>
                        <div class="card-body">
                        {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
                        </div>
                      </div>
                    {% endif %}
                  {% endblock %}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
{% endblock %}

{% block script %}
  <script>
    jQuery(document).ready(function($) {
      $('#searchModel').keypress(function (e) {
       var key = e.which;
       if(key == 13)  // the enter key code
        {
          // alert('hellloooo');
          $('#searchModelBtn').click();
          return false;  
        }
      });  
    });  // End of Document Ready 
  </script>
{% endblock %}