app/helpers/table_builder_helper.rb
# TODO: rename this after migration from `table_builder`
rename this after migration from `table_builder`
rename this after migration from ` table_builder `
def build_column_header(
        column,
        table_is_sortable,
        model,
        params
      )
    sort_on = sort_direction = nil
    if (order = @search.try(:order))
      sort_on, sort_direction = order.attributes.first
    end
    sort_on ||= params[:sort]
    sort_direction ||= params[:direction]
    sort_on = sort_on.to_s if sort_on
    sort_direction = sort_direction.to_s if sort_direction
    if !table_is_sortable || !column.sortable
      return column.header_label(model)
    end
    direction =  if sort_direction == 'desc'
        'asc'
      else
        'desc'
      end
    active = column.key.to_s == sort_on
    link_to(params.permit!.merge({direction: direction, sort: column.key})) do
      arrow_up = content_tag(
        :span,
        '',
        class: "fa fa-sort-up #{active && direction == 'desc' ? 'active' : ''}"
      )
      arrow_down = content_tag(
        :span,
        '',
        class: "fa fa-sort-down #{active && direction == 'asc' ? 'active' : ''}"
      )
      arrow_icons = content_tag :span, arrow_up + arrow_down, class: 'orderers'
      (
        column.header_label(model) +
        arrow_icons
      ).html_safe
    end
  end
def build_column_header ( column , table_is_sortable , model , params ) sort_on = sort_direction = nil if ( order = @search . try ( :order ) ) sort_on , sort_direction = order . attributes . first end sort_on ||= params [ :sort ] sort_direction ||= params [ :direction ] sort_on = sort_on . to_s if sort_on sort_direction = sort_direction . to_s if sort_direction if ! table_is_sortable || ! column . sortable return column . header_label ( model ) end direction = if sort_direction == 'desc' 'asc' else 'desc' end active = column . key . to_s == sort_on link_to ( params . permit! . merge ( { direction : direction , sort : column . key } ) ) do arrow_up = content_tag ( :span , '' , class : "fa fa-sort-up #{active && direction == 'desc' ? 'active' : ''}" ) arrow_down = content_tag ( :span , '' , class : "fa fa-sort-down #{active && direction == 'asc' ? 'active' : ''}" ) arrow_icons = content_tag :span , arrow_up + arrow_down , class : 'orderers' ( column . header_label ( model ) + arrow_icons ) . html_safe end end
TODO: rename this after migration from `table_builder`
TODO : rename this after migration from ` table_builder `
# Try to detect a current Search order # Legacy sort parameters # The following code only supports string values
column
table_is_sortable
model
params