{% load i18n static suit_list admin_list admin_urls %}


{% if cl.search_fields %}
    <div id="toolbar">
        {% block object-tools %}
            {% block object-tools-items %}
                {% if has_add_permission %}
                  <ul class="object-tools">
                      <li>
                        {% url cl.opts|admin_urlname:'add' as add_url %}
                        <a href="{% add_preserved_filters add_url is_popup to_field %}" class="addlink">
                          {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                        </a>
                      </li>
                  </ul>
                {% endif %}
            {% endblock %}
        {% endblock %}
        <form id="changelist-search" method="get" class="form-inline">
            <div><!-- DIV needed for valid HTML -->
                <label for="searchbar"><img src="{% static "admin/img/search.svg" %}" alt="Search"/></label>
                <input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" autofocus/>

                {% if cl.has_filters %}
                    {% for spec in cl.filter_specs|suit_list_filter_horizontal:cl %}
                        {% suit_admin_list_filter cl spec %}
                    {% endfor %}
                {% endif %}

                <input type="submit" value="{% trans 'Search' %}"/>
                {% if show_result_count %}
                    <span class="small quiet">{% blocktrans count counter=cl.result_count %}{{ counter }} result
                        {% plural %}{{ counter }} results{% endblocktrans %} (<a
                            href="?{% if cl.is_popup %}_popup=1{% endif %}">{% if cl.show_full_result_count %}
                        {% blocktrans with full_result_count=cl.full_result_count %}{{ full_result_count }} total
                        {% endblocktrans %}{% else %}{% trans "Show all" %}{% endif %}</a>)</span>
                {% endif %}

                {% for pair in cl.params.items|suit_list_filter_horizontal_params:cl %}
                    {% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>
                    {% endif %}
                {% endfor %}
            </div>
        </form>
    </div>
{% endif %}
