{% extends "structure/base.html" %} {% from 'crud/_macros.html' import shown, sort_header, keep_sort, file_display with context %} {% from 'crud/_actions.html' import action_control, bulk_select_all, bulk_select_row, bulk_bar %} {% block title %}{{ construct.compose_title(construct.t(view.name, {'count': 2})) }}{% endblock %} {# This view renders its own visible

, so suppress the layout default. #} {% block page_heading %}{% endblock %} {% block content %} {% set is_advanced_filter = request.args.get('advanced_filter') %} {% set return_here = request.full_path.rstrip('?') %} {% if view.refreshes('list') %}{{ live_refresh(topics=view.get_refresh_topics()) }}{% endif %} {# The card is what a sort link replaces: table, pagination and the header's "next" values all change with the sort; the heading above and the live-refresh marker do not. #}

{{ construct.t(view.name, {'count': 2}) }}

{#- Actions on the list as a whole (@page_action): a link, or a POST form that gets this page's URL as "next" so the handler can return to the same page, search and filters. A template set as the page's list_template can extend this block. #} {%- block list_header_actions scoped %} {%- if page_actions %}
{%- for action in page_actions %} {{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint), action.variant, target="#main-content", next=return_here) }} {%- endfor %}
{%- endif %} {%- endblock %} {% if view.trash_enabled is defined and view.trash_enabled() %} {{ icon("delete", size="sm") }} {{ construct.t("audit-trash") }} {% endif %} {% if view.permits('add') %} {{ icon("add", size="sm") }} {{ construct.t("crud-create-rec", {'recname': construct.t(view.name, {'count': 1}) }) }} {% endif %}
{# The advanced-filter form lives OUTSIDE the table: a
as a direct child of is invalid, and the parser hoists it out of the table, orphaning these inputs from it. Binding by `form=` keeps the controls in their cells while belonging to a well-formed form (same approach as components/grid.html). #} {{ keep_sort() }}
{% if bulk_actions %}{{ bulk_select_all(construct) }}{% endif %} {% for fld, type in fields %} {{ sort_header(construct, fld, type, sort.link(fld) if sort else none, "#fcu-crud-list") }} {% endfor %} {% if bulk_actions %}{% endif %} {% for fld, type in fields %} {% endfor %} {% for row in data %} {% if bulk_actions %}{{ bulk_select_row(construct, row, row[primary_key], fields) }}{% endif %} {% for field, type in fields %} {% endfor %} {% endfor %}
{{ construct.t(view.name, {'count': 2}) }}
{{ construct.t("crud-action-title") }}
{% if not type.skipfilter %} {% if type.field_type == 'enum' %} {% else %} {# placeholder is not an accessible name: it disappears as soon as the user types. #} {% endif %} {% endif %}
{{ icon("search", size="md", label=construct.t("crud-simple-search")) }}
{% if type.has_display_filter() %} {# An app display filter replaces the built-in rendering. #} {{ shown(type.display_value(field, row, "list")) }} {% elif type.field_type == 'bool' %} {# The glyph is the whole cell value, so it needs a text equivalent — colour alone does not distinguish it. #} {% if row[field] %} {{ icon("check", style="color: var(--fcu-success-fg); font-size: 20px; font-variation-settings: 'FILL' 1", label=construct.t("crud-bool-true")) }} {% else %} {{ icon("cancel", style="color: var(--fcu-danger-fg); font-size: 20px; font-variation-settings: 'FILL' 1", label=construct.t("crud-bool-false")) }} {% endif %} {% elif type.field_type == 'set' %} {% if row[field] %}
{% for item in row[field] %} {% if item in type.sets %} {{ construct.t(type.sets[item]) }} {% endif %} {% endfor %}
{% endif %} {% elif type.field_type in ('file', 'image') %} {{ file_display(construct, type.format_value(field, row), "list") }} {% elif type.field_type == 'manyrelated' %} {% set items = type.format_value(field, row) %} {% if items %}
{% for item in items %} {{ item }} {% endfor %}
{% endif %} {% else %} {# Blank, not the word "None" — see `shown`. #} {{ shown(type.format_value(field,row)) }} {% endif %}
{% if view.permits('edit', row) %} {{ icon("edit", label=construct.t("crud-edit-button")) }} {% endif %} {% if view.permits('view', row) %} {{ icon("view", label=construct.t("crud-view-button")) }} {% endif %} {% if list_actions %} {% for action in list_actions %} {{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=row[primary_key]), "row", next=return_here) }} {% endfor %} {% endif %} {# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #} {% if view.permits('delete', row) %}
{{ csrf_field() }}
{% endif %}
{#- Bulk actions (@bulk_action): one form for the row checkboxes above (they join it with form=) and a submit button per action, each posting to its own route with this page's URL as "next". #} {%- if bulk_actions %} {{ bulk_bar(construct, view, bulk_actions, return_here) }} {%- endif %} {% if pagination and pagination.pages > 1 %} {% endif %}
{% endblock content %}