Module: Warped::Controllers::Sortable::Ui

Extended by:
ActiveSupport::Concern
Includes:
Warped::Controllers::Sortable
Included in:
Tabulatable::Ui
Defined in:
lib/warped/controllers/sortable/ui.rb

Instance Method Summary collapse

Methods included from Warped::Controllers::Sortable

#current_action_sort_value

Instance Method Details

#sortObject



19
20
21
22
23
# File 'lib/warped/controllers/sortable/ui.rb', line 19

def sort(...)
  @sorted = true

  super
end

#sort_url_params(**options) ⇒ Hash

Returns The sort_url_params.

Returns:

  • (Hash)

    The sort_url_params



43
44
45
46
47
48
49
# File 'lib/warped/controllers/sortable/ui.rb', line 43

def sort_url_params(**options)
  url_params = {
    sort_key: current_action_sort_value.parameter_name,
    sort_direction: current_action_sort_value.direction
  }
  url_params.merge!(options)
end

#sortable_field?(parameter_name) ⇒ Boolean

Returns Whether the parameter_name is sortable.

Parameters:

  • parameter_name (String)

Returns:

  • (Boolean)

    Whether the parameter_name is sortable.



33
34
35
# File 'lib/warped/controllers/sortable/ui.rb', line 33

def sortable_field?(parameter_name)
  current_action_sorts.any? { |sort| sort.parameter_name == parameter_name.to_s }
end

#sorted?Boolean

Returns Whether the current action is sorted.

Returns:

  • (Boolean)

    Whether the current action is sorted.



38
39
40
# File 'lib/warped/controllers/sortable/ui.rb', line 38

def sorted?
  @sorted ||= false
end

#sorted_field?(parameter_name) ⇒ Boolean

Parameters:

  • parameter_name (String)

Returns:

  • (Boolean)


27
28
29
# File 'lib/warped/controllers/sortable/ui.rb', line 27

def sorted_field?(parameter_name)
  current_action_sort_value.parameter_name == parameter_name.to_s
end