Public method hooks for the order arrow defs
and inline the conditional.
This commit is contained in:
parent
c0dff3384c
commit
e489ca7789
|
@ -97,6 +97,14 @@ module Ransack
|
|||
@default_order = @options.delete :default_order
|
||||
end
|
||||
|
||||
def up_arrow
|
||||
'▼'.freeze
|
||||
end
|
||||
|
||||
def down_arrow
|
||||
'▲'.freeze
|
||||
end
|
||||
|
||||
def name
|
||||
[ERB::Util.h(@label_text), order_indicator]
|
||||
.compact
|
||||
|
@ -190,21 +198,17 @@ module Ransack
|
|||
|
||||
def order_indicator
|
||||
return if @hide_indicator || no_sort_direction_specified?
|
||||
direction_arrow
|
||||
if @current_dir == 'desc'.freeze
|
||||
up_arrow
|
||||
else
|
||||
down_arrow
|
||||
end
|
||||
end
|
||||
|
||||
def no_sort_direction_specified?(dir = @current_dir)
|
||||
!['asc'.freeze, 'desc'.freeze].freeze.include?(dir)
|
||||
end
|
||||
|
||||
def direction_arrow
|
||||
if @current_dir == 'desc'.freeze
|
||||
'▼'.freeze
|
||||
else
|
||||
'▲'.freeze
|
||||
end
|
||||
end
|
||||
|
||||
def direction_text(dir)
|
||||
return 'asc'.freeze if dir == 'desc'.freeze
|
||||
'desc'.freeze
|
||||
|
|
Loading…
Reference in New Issue