{% extends "structure/base.html" %} {% from 'crud/_macros.html' import shown, sort_header, stack_role, keep_sort, file_display with context %} {% from 'crud/_actions.html' import action_control, bulk_select_all, bulk_select_row, bulk_bar, row_actions, row_entry_class, row_entry_content, row_entry_title, cell_link %} {% from 'components/_page_header.html' import page_header %} {% from 'components/_badge.html' import badge %} {% 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 header sits above the card, as on every page (the page_header macro, components/_page_header.html). A sort link replaces both: the search form's kept sort and "Create"'s "next" change with the sort just as the table and pagination do. The live-refresh marker does not. #} {%- set header_actions %} {#- 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') %} {#- With edit_in_panel the form opens beside the list, in the panel. #} {{ icon("add", size="sm") }} {{ construct.t_rec("crud-create-rec", view.name) }} {% endif %} {%- endset %} {#- show_count: how many records the list holds (or match its search or filter) as the header's subtitle. #} {%- set list_count = construct.t_count(view.name, total) if view.show_count and total is defined else none %} {{ page_header(construct.t(view.name, {'count': 2}), subtitle=list_count, actions=header_actions, id="fcu-crud-list-header", css_class="fcu-crud-header") }}
{#- The quick filter (quick_filter): in the card, so a sort swap redraws it with the new sort in its links. #} {%- if quick_filter %}
{{ quick_filter }}
{%- 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() }}
{#- list_narrow = "stack": rows become cards on a narrow screen, each value under its column's name (data-label); see stack_role. #} {%- set stack = rows.stack %}
{% if reorder %}{% endif %} {% if bulk_actions %}{{ bulk_select_all(construct, stack) }}{% endif %} {% for fld, type in fields %} {{ sort_header(construct, fld, type, sort.link(fld) if sort else none, "#fcu-crud-list-header, #fcu-crud-list", stack) }} {% endfor %} {% if reorder %}{% endif %} {% if bulk_actions %}{% endif %} {% for fld, type in fields %} {% 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 %} {% endfor %} {#- reorder_field: every row is a drop zone posting its place in the whole order; its grip posts to the dragged row's own move URL. The token sits here once rather than on every row. #} {% for row in data %} {#- Where the row opens: shared by its edit entry and the list_link_fields cells, so the two never disagree. #} {%- set key = row[primary_key] -%} {%- set may_edit = view.permits('edit', row) -%} {%- set may_view = view.permits('view', row) -%} {%- set in_panel = panel_open and panel_open == key|string -%} {%- set edit_href = view.panel_url(key) if view.edit_in_panel else url_for(view.endpoint + '.get', id=key) ~ '?next=' ~ (return_here | urlencode) -%} {%- set view_href = url_for(view.endpoint + '.view', id=key) ~ '?next=' ~ (return_here | urlencode) -%} {%- set edit_attrs %} up-follow up-target="#main-content"{% if view.edit_in_panel %} up-history="true" up-scroll="false"{% if in_panel %} data-fcu-panel-return{% endif %}{% endif %}{% endset -%} {%- set view_attrs %} up-follow up-target="#main-content"{% endset -%} {%- set first = fields[0] if fields else none -%} {%- set record = (first[1].format_value(first[0], row) if first else none) -%} {%- set record = record if record not in (none, "") else "#" ~ key -%} {%- set position = reorder.offset + loop.index0 if reorder else none -%} {%- set move_url = url_for(view.endpoint + '.move', id=key) if reorder and may_edit else none -%} {% if reorder %} {% endif %} {% if bulk_actions %}{{ bulk_select_row(construct, row, key, fields, stack) }}{% endif %} {% for field, type in fields %} {% endfor %} {% endfor %}
{{ construct.t(view.name, {'count': 2}) }}
{{ construct.t("crud-reorder-column") }}{{ construct.t("crud-action-title") }}
{{ icon("search", size="md", label=construct.t("crud-simple-search")) }}
{%- if move_url %} {#- Pointer only, so hidden from assistive technology: the Move up / Move down buttons are the way that works everywhere (WCAG 2.5.7). #} {%- endif %} {%- set cell %} {% 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", size="lg", cls="fcu-bool-icon fcu-bool-icon--true", label=construct.t("crud-bool-true")) }} {% else %} {{ icon("cancel", size="lg", cls="fcu-bool-icon fcu-bool-icon--false", 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 %} {{ badge(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 %} {{ badge(item) }} {% endfor %}
{% endif %} {% else %} {# Blank, not the word "None" — see `shown`. #} {{ shown(type.format_value(field,row)) }} {% endif %} {%- endset %} {%- if field in rows.link_fields -%} {{ cell_link(cell, edit_href if may_edit else (view_href if may_view else none), edit_attrs if may_edit else view_attrs, record) }} {%- else -%} {{ cell }} {%- endif %}
{%- call(variant) row_actions(construct, rows.menu, record, in_panel and may_edit and rows.edit_icon) %} {% if move_url %} {% for direction, possible in [("up", position > 0), ("down", position < reorder.total - 1)] if possible %} {%- set label = construct.t("crud-move-" ~ direction) %} {# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #}
{{ csrf_field() }}
{% endfor %} {% endif %} {% if may_edit and rows.edit_icon %} {{ row_entry_content("edit", construct.t("crud-edit-button"), variant) }} {% endif %} {% if may_view %} {{ row_entry_content("view", construct.t("crud-view-button"), variant) }} {% endif %} {% for action in list_actions %} {{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=key), variant, next=return_here) }} {% endfor %} {# 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 %} {%- endcall %}
{#- 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 %}
{#- The create/edit side panel (edit_in_panel). Below the breakpoint it renders in flow, so it goes after the list. #} {%- if side_panel %}{{ side_panel }}{% endif %} {% endblock content %}