Module: QueriesHelper

Defined in:
app/helpers/queries_helper.rb

Overview

View helper: queries.

Instance Method Summary collapse

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/queries_helper.rb', line 13

def sort_link_helper(tab_options, text, order_by, initial_direction, nulls_option = nil, page_name = :page, ajaxify = false, ajax_controller = nil, ajax_action = nil, ajax_id = nil)
  tab_options ||= {}
  order_by_direction = initial_direction
  if params[:order_by] == order_by
    order_by_direction = "ASC" if params[:order_by_direction] == "DESC"
    order_by_direction = "DESC" if params[:order_by_direction] == "ASC"
  end

  standard_params = params.merge({ :order_by => order_by, :order_by_direction => order_by_direction, :tab => tab_options[:tab], :nulls_option => nulls_option, page_name => nil })

  url = if ajaxify == true
          url_for(standard_params.merge({ controller: ajax_controller, action: ajax_action, id: ajax_id }))
        else
          url_for(standard_params)
        end

  link_to(text, url, class: ajaxify == true ? "ajax_sort_link" : nil)
end

#sort_th_class_helper(order_by, _initial_direction) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/helpers/queries_helper.rb', line 4

def sort_th_class_helper(order_by, _initial_direction)
  result = ""
  if params[:order_by] == order_by
    result = "class='sortup'" if params[:order_by_direction] == "ASC"
    result = "class='sortdown'" if params[:order_by_direction] == "DESC"
  end
  result
end