Module: Telm::SortingHelper
- Defined in:
- app/helpers/telm/sorting_helper.rb
Instance Method Summary collapse
-
#telm_filter_params ⇒ Object
Already validated by Core::Query before any view renders.
- #telm_sort_indicator(column) ⇒ Object
-
#telm_sort_link(resource, column) ⇒ Object
Click cycles a column asc -> desc; clicking a new column starts asc.
Instance Method Details
#telm_filter_params ⇒ Object
Already validated by Core::Query before any view renders.
23 24 25 |
# File 'app/helpers/telm/sorting_helper.rb', line 23 def telm_filter_params params[:fk].present? ? { fk: params[:fk], fk_id: params[:fk_id] } : {} end |
#telm_sort_indicator(column) ⇒ Object
16 17 18 19 20 |
# File 'app/helpers/telm/sorting_helper.rb', line 16 def telm_sort_indicator(column) return unless params[:sort] == column.name tag.span(params[:dir] == "desc" ? "↓" : "↑", class: "telm-sort-indicator") end |
#telm_sort_link(resource, column) ⇒ Object
Click cycles a column asc -> desc; clicking a new column starts asc. Changing sort resets to page 1 by dropping the page param; an active FK filter is preserved.
8 9 10 11 12 13 14 |
# File 'app/helpers/telm/sorting_helper.rb', line 8 def telm_sort_link(resource, column, &) active = params[:sort] == column.name next_dir = active && params[:dir] != "desc" ? "desc" : "asc" link_to resource_path(resource.param, sort: column.name, dir: next_dir, **telm_filter_params), class: "telm-th-sort#{" is-active" if active}", & end |