Module: Spotlight::SearchConfigurationsHelper

Defined in:
app/helpers/spotlight/search_configurations_helper.rb

Overview

Search configurations helpers

Instance Method Summary collapse

Instance Method Details

#translate_sort_fields(sort_config) ⇒ Object

Translate a sort field configuration into a complete description of the sort



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/spotlight/search_configurations_helper.rb', line 10

def translate_sort_fields(sort_config)
  sort_description = sort_config[:sort_description] if sort_config[:sort_description]

  if sort_config[:sort]
    sort_description ||= sort_config[:sort].split(',').map do |sort|
      sort_field, sort_order = sort.split(' ')
      safe_join([
                  t(:"spotlight.search_configurations.sort.keys.#{sort_field.strip}", default: sort_field.humanize.downcase),
                  t(:"spotlight.search_configurations.sort.keys.#{sort_order.strip}", default: '')
                ], ' ')
    end.to_sentence
  end

  sort_description
end