{#- Every filter at once, in a drawer the Filters button opens over the list. It is one form that applies as you pick and reloads only the table, so the list stays in view and changes as you go. On a phone it covers the screen, with a button at its foot that shows the list again. -#} {% import "adminsite/_icons.html" as icons %} {% import "adminsite/_option_count.html" as counts %} {%- set names = panels|map(attribute="filter.name")|list -%} {%- set kept = request.query_params.multi_items()|list -%} {%- set counted = panels|selectattr("counted")|list -%} {#- The counts beside the options follow the search, and come in a request of their own as the drawer opens: again only once the search has changed, so a list nobody filters never counts them. -#}
{% if counted %}{% endif %} {#- A box ticked, a shortcut picked or an end of a range typed applies the form; each of those is marked `data-applies`. The box that narrows a long list is not, nor is picking "between", which waits for its ends. A text filter applies itself once the typing stops. -#}
{% for key, value in kept if key not in names and key not in ("page", "after", "before") %} {% endfor %}

{{ _('Filters') }}

{% for panel in panels %} {% set name = panel.filter.name %}
{{ panel.filter.label }} {% if panel.filter.template == "choice" %} {% set kind = "checkbox" if panel.filter.multiple else "radio" %} {#- A long list gets a box above it that narrows it as you type. The box has no name, so the filter never sends what was typed. -#}
{% if panel.searchable %} {% endif %}
{% for option in panel.options %} {% endfor %}
{% if panel.searchable %}

{{ _('Nothing found.') }}

{% endif %}
{% elif panel.filter.template == "range" %} {#- A shortcut, or a value at each end. What is sent is one value, the shortcut's name or the two ends joined by a comma. -#} {% set current = panel.chosen[0] if panel.chosen else "" %} {% set presets = panel.options|map(attribute="value")|list %} {% set custom = current and current not in presets %} {% set ends = (current.split(",") if custom else []) + ["", ""] %} {% set kind = panel.filter.input_type|default("text") %}
{% if panel.options %}
{% for option in panel.options %} {% endfor %}
{% endif %}
{% else %} {% endif %}
{% endfor %}
{% include "adminsite/_filters_footer.html" %}