{% extends "crud/tab_view.html" %} {% from 'crud/_macros.html' import shown, add_label, sort_header, stack_role, keep_sort, file_display with context %} {% from 'crud/_actions.html' import action_control, row_actions, row_entry_class, row_entry_content, row_entry_title, cell_link %} {% from 'components/_badge.html' import badge %} {% block tab_content %} {%- set is_advanced_filter = request.args.get('advanced_filter') if filter_enabled else none -%} {%- set tab_list_url = url_for(view.endpoint + '.' + list_ep, id=parent_id) -%} {# Only the tab's own pane is re-rendered, from this list's URL. The marker sits inside it, so opening the tab's form swaps the marker away and the form is never refreshed under its reader. #} {% if rct.refreshes(view) %}{{ live_refresh(target=content_target, topics=rct.get_refresh_topics(view)) }}{% endif %}
{% if rct.permits('add', construct) %} {{ icon("add", size="sm") }} {{ add_label(construct, rct.record_name) }} {% else %}{% endif %} {%- if search_enabled %}
{{ keep_sort() }}
{%- if filter_enabled %} {{ icon("filter", size="md", label=construct.t("crud-advanced-filter")) }} {%- endif %}
{%- elif filter_enabled and not is_advanced_filter %} {{ icon("filter", size="md", label=construct.t("crud-advanced-filter")) }} {%- endif %}
{# The filter form sits outside the table (a
child of is invalid and gets hoisted out by the parser, orphaning these inputs). The controls stay in their cells and join it via `form=`. #} {%- if filter_enabled %} {{ keep_sort() }}
{%- endif %} {#- list_narrow = "stack": rows become cards on a narrow screen. #} {%- set stack = rows.stack %}
{% for fld, type in fields %} {{ sort_header(construct, fld, type, sort.link(fld) if sort else none, content_target, stack) }} {% endfor %} {%- if filter_enabled %} {% for fld, type in fields %} {% if not type.skipfilter %} {% if type.field_type == 'enum' %} {% else %} {% endif %} {% endif %} {% endfor %} {%- endif %} {% for row in data %} {#- Where the row opens: shared by its edit entry and the list_link_fields cells. #} {%- set key = row[primary_key] -%} {%- set may_edit = rct.permits('edit', construct, row) -%} {%- set may_view = rct.permits('view', construct, row) -%} {%- set edit_href = url_for(view.endpoint + '.' + edit_ep, id=parent_id, child_id=key) -%} {%- set view_href = url_for(view.endpoint + '.' + view_ep, id=parent_id, child_id=key) -%} {%- set open_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 -%} {% for field, type in fields %} {% endfor %} {% endfor %} {% if not data %} {% endif %}
{{ construct.t(rct.name, {'count': 2}) }}
{{ construct.t("crud-action-title") }}
{{ icon("search", size="md", label=construct.t("crud-simple-search")) }}
{%- set cell %} {% if type.has_display_filter() %} {# An app display filter replaces the built-in rendering. #} {{ shown(type.display_value(field, row, "related")) }} {% elif type.field_type == 'bool' %} {% if type.format_value(field, row) %} {{ 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' %} {% set val = type.format_value(field, row) %} {% if val %}
{% for item in val %} {% 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), "related") }} {% elif type.field_type == 'manyrelated' %}
{% for item in type.format_value(field, row) %} {{ badge(item) }} {% endfor %}
{% 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), open_attrs, record) }} {%- else -%} {{ cell }} {%- endif %}
{%- call(variant) row_actions(construct, rows.menu, record) %} {% 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=parent_id, child_id=key), variant, target=content_target, history=true) }} {% endfor %} {% if rct.permits('delete', construct, row) %} {# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #}
{{ csrf_field() }}
{% endif %} {%- endcall %}
{{ construct.t("crud-no-items-found") }}
{% if pagination and pagination.pages > 1 %}
{% endif %} {% endblock %}