{# macros/table.html — Reusable table macros for list views #} {% macro table_header(columns, ordering, model_name, admin_path="/admin") %} {% for col in columns %} {% if not col.primary_key or columns | length > 1 %} {{ col.name | replace('_', ' ') | title }} {% if ordering == col.name %} {{ icon("chevron-right") }} {% elif ordering == '-' ~ col.name %} {{ icon("chevron-right", class="rotate-180") }} {% endif %} {% endif %} {% endfor %} Actions {% endmacro %} {% macro table_row(obj, columns, permissions, model_name, admin_path="/admin") %} {% for col in columns %} {% if not col.primary_key or columns | length > 1 %} {{ table_cell(obj, col) }} {% endif %} {% endfor %} {% if permissions.can_edit %} Edit {% endif %} {% if permissions.can_delete %} {% endif %} {% endmacro %} {% macro table_cell(obj, col) %} {% if col.display_fn is defined and col.display_fn %} {% set val = col.value(obj) %} {% else %} {% set val = attr(obj, col.name) | default('-') %} {% endif %} {% if col.boolean is defined and col.boolean %} {% if val is sameas true %} Active {% elif val is sameas false %} Inactive {% else %} {{ val }} {% endif %} {% elif val is sameas true %} Active {% elif val is sameas false %} Inactive {% elif val == '-' %} - {% else %} {{ val }} {% endif %} {% endmacro %} {% macro empty_state(model_name, verbose_name, can_create, admin_path="/admin") %} {{ icon("document-text", size="48px") }}

No {{ verbose_name | lower }} found

{% if can_create %} + Create your first {{ verbose_name | lower }} {% endif %} {% endmacro %}