{# Swappable results region: the table/card rows and the pagination footer. Included by media.html on initial load; returned standalone for htmx page turns (HX-Request). The surrounding form, action bar, and sort toolbar live outside this partial and are not replaced on page turn. Macros below are defined here (not just imported from media.html) so the partial renders correctly when returned standalone for htmx requests. When included from media.html the outer definitions shadow these, which is fine. #} {% from "fragments/_chips.html" import chip, needs_review_chip %} {% macro media_status(row) %} {%- if row.latest_run_id -%} {%- if row.unresolved_count -%} {{ needs_review_chip(row.unresolved_count) }} {%- elif row.latest_run_status == "completed" -%} {{ chip("reviewed") }} {%- else -%} {{ chip(humanize_status(row.latest_run_status)) }} {%- endif -%} {%- else -%}—{%- endif -%} {% endmacro %} {% macro file_missing_notice(row) %} {%- if row.id in missing_file_ids -%} Original file not found {{ row.current_path or row.source_path }} {%- endif -%} {% endmacro %} {% macro row_action(row) %} {%- if row.latest_run_id -%} {%- if row.latest_run_status == "awaiting_adjudication" -%} Review → {%- elif row.latest_run_status == "failed" -%} Retry → {%- else -%} Open → {%- endif -%} {%- endif -%} {% endmacro %} {% set filter_qs %}{% if search %}&q={{ search|urlencode }}{% endif %}{% if status %}&status={{ status }}{% endif %}{% endset %} {% macro media_card(row) %}
  • {{ format_duration(row.duration_seconds) }} {% if row.latest_run_id %} {{ friendly_media_label(row.source_title, row.source_path) }} {% else %} {{ friendly_media_label(row.source_title, row.source_path) }} {% endif %}
    {{ media_status(row) }} {{ file_missing_notice(row) }}

    {% if trashed and row.trashed_at %}{{ format_age(row.trashed_at, now=now) }} {% else %}{{ format_age(row.added_at, now=now) }}{% endif %}

  • {% endmacro %} {# OOB summary update: when htmx replaces this region, the command-bar summary (which lives outside #media-results in the page shell) needs the real total. An hx-swap-oob fragment patches it in place. #} {% if request.headers.get("HX-Request") %} {%- if not paginated and media_summary.folder_count %}{{ media_summary.folder_count }} folder{{ "s" if media_summary.folder_count != 1 else "" }} · {% endif -%} {{ total_count }} recording{{ "s" if total_count != 1 else "" }}{% if not paginated %} · {{ media_summary.total_hours }}{% endif %} {% endif %} {% if view == "table" %} {# ---- Table rows ---- #} {% if not paginated %} {# Folder-grouped rows (small library, everything fits on one page) #} {% for group in folder_groups %}
    {{ group.folder_path }} {% if not archived and not trashed %}{{ chip("watched") }}{% endif %} {{ group.item_count }} {{ format_compact_duration(group.total_duration_seconds) }} {% if group.failed_count %} {{ group.failed_count }} failed {% elif group.running_count %} {{ chip("transcribing") }} {% elif group.needs_review_count %} {{ group.needs_review_count }} need{{ "s" if group.needs_review_count == 1 else "" }} review {% elif group.completed_count == group.item_count and group.item_count > 0 %} {{ chip("all reviewed") }} {% else %} — {% endif %} {% if group.latest_date %}{{ format_age(group.latest_date, now=now) }}{% endif %} Open →
    {% for row in group.items %} {% endfor %} {% endfor %} {% endif %} {# Flat rows (paginated, or ungrouped items in non-paginated view) #} {% for row in ungrouped_items %}
    {{ friendly_media_label(row.source_title, row.source_path) }} {% if paginated and row.folder_path %} {{ row.folder_path }} {% endif %} {{ file_missing_notice(row) }} — {{ format_duration(row.duration_seconds) }} {{ media_status(row) }} {% if trashed and row.trashed_at %}{{ format_age(row.trashed_at, now=now) }} {% else %}{{ format_age(row.added_at, now=now) }}{% endif %} {{ row_action(row) }}
    {% endfor %} {% else %} {# ---- Cards rows ---- #} {% if active_folder is defined and active_folder %} {% for row in active_folder.items %}
    {{ friendly_media_label(row.source_title, row.source_path) }} {{ file_missing_notice(row) }} {{ format_duration(row.duration_seconds) }} {{ media_status(row) }} {{ row_action(row) }}
    {% else %}
    No recordings in this folder.
    {% endfor %} {% else %} {# Top-level cards: folder tiles + ungrouped #} {% if not paginated and folder_groups %} {% endif %} {% if ungrouped_items %} {% if not paginated and folder_groups %}

    Unfiled

    {% endif %}
    {% endif %} {% endif %} {% endif %} {# ---- Pagination footer ---- #} {% if next_url %}
    Next →
    {% endif %}