{#- Above the table: the search, one chip per filter, and the columns. Each filter opens a small form of its own, which carries the rest of the query along, so applying one filter never drops another. -#} {% import "adminsite/_icons.html" as icons %} {%- set kept = request.query_params.multi_items()|list -%}
{% if view.get_search_fields(request) %} {% endif %} {% if panels %} {% for panel in panels %} {% set name = panel.filter.name %} {% set panel_id = "filter-" ~ name|replace(".", "-") %} {% set remove = urls.here(**{name: None, "page": None, "after": None, "before": None}) %}
{% if panel.active %}
{{ icons.icon("x", 14) }}
{% else %} {% endif %}
{% for key, value in kept if key not in (name, "page", "after", "before") %} {% endfor %}
{{ panel.filter.label }} {% if panel.filter.template == "choice" %} {% set kind = "checkbox" if panel.filter.multiple else "radio" %}
{% for option in panel.options %} {% endfor %}
{% 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 %}
{% if panel.active %} {{ _('Clear') }} {% endif %}
{% endfor %} {% if chips %} {{ _('Clear all') }} {% endif %} {% endif %} {% include "adminsite/_list_menus.html" %} {% include "adminsite/_list_forms.html" %}