{% extends "base.html" %} {% block title %}{{ spec.label }}{% endblock %} {% block content %} {% set hue = groups.index(spec.group) % 6 if spec.group in groups else 0 %}
{{ spec.group }}

{{ spec.label }}

{% if spec.searchable or spec.exact_searchable or text_filters %}
{% if spec.searchable or spec.exact_searchable %} {# Submits on change, which covers Enter and leaving the field, so the toolbar needs no button of its own. #} {% endif %} {% for name in text_filters %} {# Too many distinct values to show, so typing is the honest control. #} {% endfor %} {% with skip = ["search"] + text_filters | list %}{% include "_view_fields.html" %}{% endwith %} {# Hidden, not absent: a browser will not implicitly submit a form with several text fields and no submit button, and this keeps the toolbar working with scripting off. #}
{% endif %} {% if spec.renders("create") %} New {% endif %} {% if spec.renders("export") %} Export CSV {% endif %}
{% if facets or range_filters %}
{% for name, choices in facets.items() %} {% set chosen = view.selected(name) %}
{{ name }} {# A segmented control: one object, the selected values filled, each segment carrying how many rows it would leave. Several may be on at once, which widens the filter rather than replacing it. #}
All {{ choices | sum(attribute="count") }} {% for choice in choices %} {% set on = view.has(name, choice.value) %} {% if choice.empty and not on %} {# Nothing to select: text rather than a link, so it holds its place in the control without offering an empty result. #} {{ choice.value }} 0 {% else %} {{ choice.value }} {{ choice.count }} {% endif %} {% endfor %}
{% endfor %} {% for name in range_filters %} {% set bounds = view.bounds_of(name) %} {% set matched = namespace(found=false) %}
{{ name }} {# The same segmented language as the value filters, because it answers the same kind of question. The spans a reader actually asks for are one click; anything else opens the two fields. #}
All {% for preset in range_presets %} {% if preset.matches(bounds) %}{% set matched.found = true %}{% endif %} {{ preset.label }} {% endfor %}
{# Open already when the current range is not one of the presets, so a custom span is never hidden behind a closed disclosure. #}
Custom
{% with skip = [name] %}{% include "_view_fields.html" %}{% endwith %} {% if bounds %} clear {% endif %}
{% endfor %}
{% endif %} {% if spec.exact_searchable %}
{{ spec.exact_searchable | join(", ") }} match in full only
{% endif %} {% if spec.selectable %}{% include "_bulk.html" %}{% endif %}
{% include "_table.html" %}
{% endblock %}