{# Click-to-sort table header component.
Replaces the open-coded inline header markup that existed in
dashboard cost-drivers, opportunities table, failures table.
Parameters:
- col (str) sort key name (becomes ``?sort=
``)
- label (str) visible header text
- current_sort (str) the currently-active sort key
- current_dir (str) "asc" or "desc"
- align (str) ui-table-th alignment: "left" | "right" | "center"
- extra (str) extra Tailwind classes on the ``
``
- base_qs (str) optional query-string prefix to preserve
filter state (eg. pagination.
query_string_without_sort_or_page); when absent
the ``?sort=&direction=&page=1`` grammar matches
the dashboard convention.
- tooltip (str, optional) info-tooltip text for the header.
When set, the cell renders an info icon next to
the label and a hover-revealed tooltip - this is
how Query Cost / Slot Wasted columns explain
their derivation.
#}
{%- macro sort_header(col, label, current_sort, current_dir, align="left", extra="", base_qs="", tooltip=None) -%}
{%- set _is_active = (current_sort == col) -%}
{%- set _next_dir = "asc" if (_is_active and current_dir == "desc") else "desc" -%}
{%- set _arrow = "↓" if (_is_active and current_dir == "desc") else ("↑" if _is_active else "") -%}
{%- set _qs_prefix = (base_qs ~ "&") if base_qs else "" -%}
{%- set _href = "?" ~ _qs_prefix ~ "sort=" ~ col ~ "&direction=" ~ _next_dir ~ "&page=1" -%}