{# @description One filterset field drawn in the list toolbar, in its compact form, by its kind: search, text, toggle, choice, sort, multichoice or a widget the developer chose. Each control is named by its filter's label and never shows the value chosen in it. Must sit inside the filter form; the sort may sit outside it, since its input names the form. #} {# @prop field:text | description:"The field as the list view's get_toolbar_field() describes it: kind, name, label and its value, choices, empty label, checked state or bound field." #} {# @prop size:select['xs','sm','md','lg','xl'] | description:"Size of the control's buttons and inputs, DaisyUI's default when left out. A developer's own widget keeps its own size." #} {% load i18n %} {% if field.kind == "widget" %} {% comment %} A widget the developer chose, drawn as it is at a fixed width. Whatever it is, list_view.js applies it when focus leaves it with a different value than focus found it with, so a control that opens a list applies once, on closing. {% endcomment %}
{{ field.bound }}
{% elif field.kind == "search" %} {# The search takes whatever room the row has left. #}
{% elif field.kind == "text" %} {% elif field.kind == "toggle" %} {% elif field.kind == "choice" or field.kind == "sort" %} {% comment %} A single choice applies the moment it is picked. The hidden input is what submits; it is disabled while nothing is chosen so the address stays clean. {% endcomment %} {% comment %} The button never shows what is chosen, so it keeps one width. A filter's value is on its chip under the toolbar, and the order in use is named beside the result count. {% endcomment %} {% if field.kind == "sort" %} {# Below sm the sort is its icon alone; the label is still its name to a screen reader. #} {{ field.label }} {% else %} {% endif %} {% if field.empty_label %} {% if not field.value %}{% endif %} {% endif %} {% for key, text, selected in field.choices %} {% if selected %}{% endif %} {% endfor %} {# form= so the sort can be drawn outside the form, at the end of the row. #} {% elif field.kind == "multichoice" %} {% comment %} Several values: the checkboxes are the inputs. list_view.js updates the list when focus leaves the dropdown with a different set chosen than it opened with. {% endcomment %}
{{ field.label }} {% for key, text, selected in field.choices %} {% endfor %}
{% endif %}