{# Detail view component - displays entity fields as a definition list #} {% if detail %}
{# Header with actions #} {% block detail_header %}
← Back

{{ detail.title }}

{% if detail.edit_url %} Edit {% endif %} {% if detail.delete_url %} {% endif %}
{% endblock detail_header %} {# Transition buttons (state machine) #} {% block detail_transitions %} {% if detail.transitions %}
{% for transition in detail.transitions %} {% endfor %}
{% endif %} {% endblock detail_transitions %} {# External link actions #} {% block detail_external_links %} {% if detail.external_link_actions %}
{% for link in detail.external_link_actions %} {{ link.label }} {% endfor %}
{% endif %} {% endblock detail_external_links %} {# Integration action buttons (manual triggers) #} {% block detail_integration_actions %} {% if detail.integration_actions %}
{% for action in detail.integration_actions %} {% endfor %}
{% endif %} {% endblock detail_integration_actions %} {# Detail card #} {% block detail_fields %}
{% for field in detail.fields %} {% if field.visible | default(true) %} {% set value = detail.item.get(field.name, "") %}
{{ field.label }}
{% if field.type == "badge" %} {% include 'fragments/status_badge.html' %} {% elif field.type == "bool" or field.type == "checkbox" %} {{ value | bool_icon }} {% elif field.type == "date" %} {{ value | dateformat }} {% elif field.type == "currency" or field.type == "money" %} {{ value | currency(field.extra.get('currency_code', 'GBP') if field.extra else 'GBP') }} {% elif field.type == "file" %} {% if value %} {{ value | basename_or_url }} {% else %}—{% endif %} {% elif field.type == "ref" %} {# Try _display keys: relation_name_display (from _inject_display_names) or fk_field_display #} {% set rel_name = field.name.removesuffix("_id") if field.name.endswith("_id") else field.name %} {% set display_val = detail.item.get(rel_name ~ "_display", "") or detail.item.get(field.name ~ "_display", "") %} {% if display_val %}{{ display_val }}{% elif value is mapping %}{{ value.get("name") or value.get("title") or value.get("label") or value.get("email") or value.get("id", "—") }}{% elif value %}{{ value }}{% else %}—{% endif %} {% else %} {{ value | default("—") }} {% endif %}
{% endif %} {% endfor %}
{% endblock detail_fields %} {# Related entity tabs (hub-and-spoke, #301) #} {% if detail.related_tabs %} {% block detail_related_tabs %} {# Related tabs — uses Alpine for tab state #} {% set first_tab_id = detail.related_tabs[0].tab_id if detail.related_tabs else '' %}
{# Tab navigation with count badges #}
{% for tab in detail.related_tabs %} {% if tab.visible | default(true) %} {% endif %} {% endfor %}
{# Tab panels #} {% for tab in detail.related_tabs %} {% if tab.visible | default(true) %}
{% if tab.create_url %} {% endif %}
{% for col in tab.columns %} {% endfor %} {% if tab.rows %} {% for item in tab.rows %} {% for col in tab.columns %} {% endfor %} {% endfor %} {% else %} {% endif %}
{{ col.label }}
{% if col.type == "badge" %} {{ item[col.key] | default("") }} {% elif col.type == "bool" %} {{ item[col.key] | bool_icon }} {% elif col.type == "date" %} {{ item[col.key] | dateformat }} {% elif col.type == "currency" %} {{ item[col.key] | currency(col.currency_code or "GBP") }} {% else %} {{ item[col.key] | default("") | truncate_text }} {% endif %}
No {{ tab.label | lower }} found.
{% endif %} {% endfor %}
{% endblock detail_related_tabs %} {% endif %}
{% endif %}