Module: Blacklight::ConfigurationHelperBehavior
- Included in:
 - CatalogHelperBehavior
 
- Defined in:
 - app/helpers/blacklight/configuration_helper_behavior.rb
 
Instance Method Summary collapse
- 
  
    
      #active_sort_fields  ⇒ Array<Blacklight::Configuration::Field> 
    
    
  
  
  
  
  
  
  
  
  
    
Return the available sort fields.
 - 
  
    
      #default_document_index_view_type  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Get the default index view type.
 - 
  
    
      #default_search_field?(selected_search_field)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Is the search form using the default search field (“all_fields” by default)?.
 - 
  
    
      #default_sort_field  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Default sort field.
 - 
  
    
      #document_index_view_controls  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
filter #document_index_views to just views that should display in the view type control.
 - #document_index_views ⇒ Hash<Symbol => Blacklight::Configuration::ViewConfig>
 - 
  
    
      #facet_field_label(field)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Look up the label for the facet field.
 - 
  
    
      #field_label(*i18n_keys)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Look up the label for a solr field.
 - 
  
    
      #label_for_search_field(key)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Shortcut for commonly needed operation, look up display label for the key specified.
 - #per_page_options_for_select ⇒ Object deprecated Deprecated.
 - 
  
    
      #should_render_field?(field_config, *args)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Determine whether to render a field by evaluating :if and :unless conditions.
 - #sort_field_label(key) ⇒ String
 
Instance Method Details
#active_sort_fields ⇒ Array<Blacklight::Configuration::Field>
Return the available sort fields
      7 8 9  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 7 def active_sort_fields blacklight_config.sort_fields.select { |_sort_key, field_config| should_render_field?(field_config) } end  | 
  
#default_document_index_view_type ⇒ Object
Get the default index view type
      84 85 86  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 84 def default_document_index_view_type document_index_views.select { |_k, config| config.respond_to?(:default) && config.default }.keys.first || document_index_views.keys.first end  | 
  
#default_search_field?(selected_search_field) ⇒ Boolean
Is the search form using the default search field (“all_fields” by default)?
      15 16 17  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 15 def default_search_field?(selected_search_field) selected_search_field.blank? || (blacklight_config.default_search_field && selected_search_field == blacklight_config.default_search_field[:key]) end  | 
  
#default_sort_field ⇒ Object
Default sort field
      90 91 92  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 90 def default_sort_field (active_sort_fields.find { |_k, config| config.respond_to?(:default) && config.default } || active_sort_fields.first)&.last end  | 
  
#document_index_view_controls ⇒ Object
filter #document_index_views to just views that should display in the view type control
      76 77 78 79 80  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 76 def document_index_view_controls document_index_views.select do |_k, config| config.display_control.nil? || blacklight_configuration_context.evaluate_configuration_conditional(config.display_control) end end  | 
  
#document_index_views ⇒ Hash<Symbol => Blacklight::Configuration::ViewConfig>
      69 70 71 72 73  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 69 def document_index_views blacklight_config.view.select do |_k, config| should_render_field? config end end  | 
  
#facet_field_label(field) ⇒ String
Look up the label for the facet field
      22 23 24 25 26 27  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 22 def facet_field_label field field_config = blacklight_config.facet_fields[field] field_config ||= Blacklight::Configuration::NullField.new(key: field) field_config.display_label('facet') end  | 
  
#label ⇒ String #label ⇒ String
Look up the label for a solr field.
      62 63 64 65 66  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 62 def field_label *i18n_keys first, *rest = i18n_keys.compact t(first, default: rest) end  | 
  
#label_for_search_field(key) ⇒ String
Shortcut for commonly needed operation, look up display label for the key specified.
      32 33 34 35 36 37 38 39  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 32 def label_for_search_field(key) field_config = blacklight_config.search_fields[key] return if key.nil? && field_config.nil? field_config ||= Blacklight::Configuration::NullField.new(key: key) field_config.display_label('search') end  | 
  
#per_page_options_for_select ⇒ Object
The available options for results per page, in the style of #options_for_select
      97 98 99 100 101 102 103  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 97 def return [] if blacklight_config.per_page.blank? blacklight_config.per_page.map do |count| [t(:'blacklight.search.per_page.label', count: count).html_safe, count] end end  | 
  
#should_render_field?(field_config, *args) ⇒ Boolean
Determine whether to render a field by evaluating :if and :unless conditions
      111 112 113  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 111 def should_render_field?(field_config, *args) blacklight_configuration_context.evaluate_if_unless_configuration field_config, *args end  | 
  
#sort_field_label(key) ⇒ String
      42 43 44 45 46 47  | 
    
      # File 'app/helpers/blacklight/configuration_helper_behavior.rb', line 42 def sort_field_label(key) field_config = blacklight_config.sort_fields[key] field_config ||= Blacklight::Configuration::NullField.new(key: key) field_config.display_label('sort') end  |