Class: Blacklight::AdvancedSearchFormComponent

Inherits:
SearchBarComponent show all
Includes:
ContentAreasShim
Defined in:
app/components/blacklight/advanced_search_form_component.rb

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods included from ContentAreasShim

#with

Methods inherited from SearchBarComponent

#advanced_search_enabled?, #autocomplete_path, #autofocus

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(response:, **options) ⇒ AdvancedSearchFormComponent

Returns a new instance of AdvancedSearchFormComponent.



16
17
18
19
# File 'app/components/blacklight/advanced_search_form_component.rb', line 16

def initialize(response:, **options)
  super(**options)
  @response = response
end

Instance Method Details

#before_renderObject



21
22
23
24
25
# File 'app/components/blacklight/advanced_search_form_component.rb', line 21

def before_render
  initialize_search_field_controls if search_field_controls.blank?
  initialize_search_filter_controls if search_filter_controls.blank?
  initialize_constraints if constraints.blank?
end

#default_operator_menuObject



27
28
29
30
# File 'app/components/blacklight/advanced_search_form_component.rb', line 27

def default_operator_menu
  options_with_labels = [:must, :should].index_by { |op| t(op, scope: 'blacklight.advanced_search.op') }
  select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
end

#sort_fields_selectObject



32
33
34
35
36
37
# File 'app/components/blacklight/advanced_search_form_component.rb', line 32

def sort_fields_select
  options = sort_fields.values.map { |field_config| [helpers.sort_field_label(field_config.key), field_config.key] }
  return unless options.any?

  select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select w-auto")
end