{% import "adminsite/_icons.html" as icons %} {% import "adminsite/_values.html" as values %} {#- A reload brings new rows, none of them ticked, so it starts the selection the Actions menu reads again. -#}
{% if request.headers.get("hx-request") %} {% with oob = true %} {% include "adminsite/_records_total.html" %} {% include "adminsite/_filter_chips.html" %} {% if panels %} {% include "adminsite/_filters_count.html" %} {% include "adminsite/_filters_footer.html" %} {% endif %} {% include "adminsite/_bulk_actions.html" %} {% endwith %} {% endif %} {#- The rows come before their total, which this asks for once they are on screen. A table redrawn before the answer is back stops it, so a slow count never overwrites the newer table's. -#} {% if counting %} {% endif %}
{{ csrf_input | safe if csrf_input }} {#- Relative, so text kept for screen readers in a cell, such as "Not set", is placed inside this box, which scrolls. Placed against the list instead, it stretched the page around the table to the table's full size, and the page scrolled as well as the table. -#}
{% if actions %} {% endif %} {#- The row's menu comes first, where it is in reach however many columns the table has. -#} {% for path in columns %} {% set state = sort_state(request, path) %} {#- An amount lines up on the right; a key is a name for its record, not an amount, so it reads from the start like text. -#} {% set numeric = view._fields.field_for(path).widget == 'number' and path not in view._schema.primary_key %} {% endfor %} {% for row in page %} {% with upward = loop.revindex <= 3 and loop.length > 5 %}{% include "adminsite/_row.html" %}{% endwith %} {% else %} {% endfor %}
{{ view.label_plural }}
{{ _('Actions') }} {% if view._pages.sortable(path) %} {{ view._fields.label_for(path) }} {% if state == "asc" %}{% endif %} {% if state == "desc" %}{% endif %} {% else %} {{ view._fields.label_for(path) }} {% endif %}
{{ _("No {things} to show.", things=view.label_plural|lower) }}
{#- On a phone each row is a card: its first column and its first badge on top, the rest below with the first amount at the end. -#} {%- set layout = namespace(badge=none, amount=none) -%} {%- for path in columns[1:] -%} {%- set kind = view._fields.field_for(path).widget -%} {%- if layout.badge is none and kind in ("select", "checkbox") %}{% set layout.badge = path %}{% endif -%} {%- if layout.amount is none and kind == "number" %}{% set layout.amount = path %}{% endif -%} {%- endfor -%}
    {% for row in page %} {% set key = view._fields.identity_of(row) %} {% set first = columns[0] %} {% set text = view._fields.display(row, first) %} {% set is_key = view._fields.field_for(first).widget == "number" and first in view._schema.primary_key %} {% set shown = ("#" ~ text if is_key and text else (text or view.get_record_title(row))) %} {% set opens = urls.detail(view, key) if can_detail else (urls.edit(view, key) if can_edit else "") %} {% set rest = [] %} {% for path in columns[1:] if path not in (layout.badge, layout.amount) and view._fields.field_for(path).widget not in ("image", "file") %} {% set value = view._fields.display(row, path) %} {% if value %}{% set ignored = rest.append(value|string) %}{% endif %} {% endfor %}
  • <{{ "a" if opens else "div" }} {% if opens %}href="{{ opens }}"{% endif %} class="flex flex-col gap-1 px-4 py-3 active:bg-subtle"> {{ shown }} {% if layout.badge and view._fields.display(row, layout.badge) and not view._fields.hides(row, layout.badge) %} {{ values.badge(view._fields.field_for(layout.badge), view._fields.value_at(row, layout.badge), view._fields.display(row, layout.badge)) }} {% endif %} {{ rest|join(" ยท ") }} {% if layout.amount %} {{ view._fields.display(row, layout.amount) }} {% endif %}
  • {% else %}
  • {{ _("No {things} to show.", things=view.label_plural|lower) }}
  • {% endfor %}
{#- Each dialog is its own form, so a required input in one dialog never stops another action from submitting. On submit it copies the ticked rows across from the table. -#} {% for item in actions if item.needs_dialog %} {% endfor %} {% include "adminsite/_action_forms.html" %}
{% include "adminsite/_records_count.html" %} {% if page_sizes %} {% endif %} {% if page.keyset %} {% set previous = urls.here(page=None, after=None, before=page.previous_cursor or None) %} {% set next = urls.here(page=None, before=None, after=page.next_cursor or None) %} {% else %} {% set previous = urls.here(page=page_number - 1 if page_number > 2 else None) %} {% set next = urls.here(page=page_number + 1) %} {% endif %}