{% from "admin/components/field.html" import render_field_value with context %} {% from "admin/components/icons.html" import icon %} {# Table, ported from shadcn/ui: a bordered card wrapping a `w-full caption-bottom text-sm` table, muted uppercase headers, and rows that highlight on hover. Class strings come from ui('table', ...) so the dashboard's Table widget and tabular inlines match this one. Included, not a macro, so it shares list_content.html's ambient context (rows, list_display, model_admin, ordering, actions, permissions, base_path, reorderable). Row actions are one dropdown trigger rather than a row of icon buttons. Built inline instead of through a shared dropdown-menu partial: Delete needs hx-delete/hx-confirm on an item, which a data-only item list cannot express. Reorderable drag-and-drop is visual only: SortableJS reorders the
| {% endif %} {% if actions %} | {% endif %} {# The header is a dropdown offering Asc/Desc explicitly rather than a link that cycles: with a cycling link you cannot tell what a click will do until you try it. Both choices are real hrefs, so sorting works with JS off. #} {% for name in list_display %} {% set sorted_by = sort_controls[name] %} | {% if not sorted_by.sortable %} {# Outside sortable_by: a plain label, with no menu and no sort URLs to hand-type either -- the server drops them. #} {{ _(model_admin.get_field(name).label) }} {% else %} {% endif %} | {% endfor %}|
|---|---|---|---|
| {% endif %} {% if actions %} | {% endif %} {% for name in list_display %} | {% set rendered = render_field_value(model_admin.get_field(name), row.cells[name], model_admin.get_empty_value()) %} {#- A cell named by list_display_links links to the record, unless it already contains an anchor -- a relation, chiefly. Nesting in is invalid HTML that browsers silently restructure. -#} {% if permissions.can_view and name in linked_columns and "{{ rendered }} {%- else %}{{ rendered }}{% endif %} | {% endfor %}
{% if permissions.can_view or permissions.can_update or permissions.can_delete %}
{% if permissions.can_view %}
{{ icon("view", "w-4 h-4 shrink-0") }}{{ _("View") }}
{% endif %}
{% if permissions.can_update %}
{{ icon("edit", "w-4 h-4 shrink-0") }}{{ _("Edit") }}
{% endif %}
{% if permissions.can_delete %}
{% if previews_deletes %}
{# A previewing resource has something to say before the
delete, so the row leads to the page that says it. #}
{{ icon("delete", "w-4 h-4 shrink-0") }}{{ _("Delete") }}
{% else %}
{% endif %}
{% endif %}
|
{{ _("No records.") }}
{% endif %}