Skip to content

Commit

Permalink
Public method hooks for the order arrow defs
Browse files Browse the repository at this point in the history
and inline the conditional.
  • Loading branch information
jonatack committed Jul 23, 2016
1 parent c0dff33 commit e489ca7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/ransack/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def initialize(search, attribute, args, params)
@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
Expand Down Expand Up @@ -190,21 +198,17 @@ def default_sort_order(attr_name)

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
Expand Down

0 comments on commit e489ca7

Please sign in to comment.