Module: LlmCostTracker::SortableTableHelper

Defined in:
app/helpers/llm_cost_tracker/sortable_table_helper.rb

Instance Method Summary collapse

Instance Method Details

#sortable_header(label, column, num: false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/llm_cost_tracker/sortable_table_helper.rb', line 5

def sortable_header(label, column, num: false)
  state = sortable_state(column, num: num)
  classes = ["lct-sortable"]
  classes << "lct-num" if num
  classes << "lct-sorted" if state[:active]

  href = dashboard_filter_path(current_query(sort: column, dir: state[:next_dir], page: nil))
  tag.th(class: classes.join(" "), "aria-sort": state[:aria_sort]) do
    link_to(href) { safe_join([label, " ", tag.span(state[:arrow], class: "lct-sort-ind")]) }
  end
end