{% load i18n baton_tags %}
{% baton_config_value 'CHANGELIST_FILTERS_FORM' as filters_form %}
{% if not filters_form %}
    <script type="text/javascript">var go_from_select = function(opt) { window.location = window.location.pathname + opt };</script>
{% endif %}
<h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}</h3>
<ul class="admin-filter-{{ title|cut:' ' }}" style="padding-right: 15px;">
    {% if filters_form %}
        <li>
            <select class="form-select form-select-sm" style="width: 100% !important;" name="{{ spec.parameter_name }}">
        {% for choice in choices %}
            <option{% if choice.selected %} selected="selected"{% endif %}
                                            value="{{ choice.query_string|iriencode }}">{{ choice.display }} {{ choice.name }} {{ choice.value }}</option>
        {% endfor %}
        </select>
        </li>
    {% else %}
        {% if choices|slice:"3:" %}
            <li>
            <select class="form-select" style="width: 100% !important;"
                onchange="go_from_select(this.options[this.selectedIndex].value)">
            {% for choice in choices %}
                <option{% if choice.selected %} selected="selected"{% endif %}
                 value="{{ choice.query_string|iriencode }}">{{ choice.display }}</option>
            {% endfor %}
            </select>
            </li>
        {% else %}

            {% for choice in choices %}
                <li{% if choice.selected %} class="selected"{% endif %}>
                    <a href="{{ choice.query_string|iriencode }}">{{ choice.display }}</a>
                </li>
            {% endfor %}

        {% endif %}
    {% endif %}
</ul>
