Class: Blacklight::AdvancedSearchFormComponent

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

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

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.



14
15
16
17
# File 'app/components/blacklight/advanced_search_form_component.rb', line 14

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

Instance Method Details

#before_renderObject



19
20
21
22
23
# File 'app/components/blacklight/advanced_search_form_component.rb', line 19

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



25
26
27
28
# File 'app/components/blacklight/advanced_search_form_component.rb', line 25

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

#sort_fields_selectObject



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

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-select custom-select sort-select w-auto", aria: { labelledby: 'advanced-search-sort-label' })
end