module Opale module SortableHelper def search_form_fields(table_name = nil, &block) searching_field = hidden_field_tag :searching, true table_name_field = hidden_field_tag :table_name, table_name unless table_name.nil? sort_field = hidden_field_tag :sort, params[:sort] || :updated_at direction_field = hidden_field_tag :direction, params[:direction] || :desc searching_field.concat(sort_field) searching_field.concat(direction_field) searching_field.concat(table_name_field) searching_field end def th(options, &block) css_class = options[:table_name] == sort_column ? "current #{sort_direction}" : nil # direction = options[:table_name] == sort_column && sort_direction == 'asc' ? 'desc' : 'asc' content_tag :th, class: options[:class], style: options[:style] do link_to '#', { class: css_class, onclick: "sortable(event, '#{options[:table_name]}')" } do block.call unless block.nil? end end end end end