Class: Arclight::SearchBarComponent
- Inherits:
-
Blacklight::SearchBarComponent
- Object
- Blacklight::SearchBarComponent
- Arclight::SearchBarComponent
- Defined in:
- app/components/arclight/search_bar_component.rb
Overview
Override Blacklight’s SearchBarComponent to add a dropdown for choosing the context of the search (within “this collection” or “all collections”). If a collection has not been chosen, it displays a dropdown with only “all collections” as the only selectable option.
Instance Method Summary collapse
- #collection_name ⇒ Object
-
#initialize(**kwargs) ⇒ SearchBarComponent
constructor
A new instance of SearchBarComponent.
- #within_collection_options ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ SearchBarComponent
Returns a new instance of SearchBarComponent.
9 10 11 12 13 |
# File 'app/components/arclight/search_bar_component.rb', line 9 def initialize(**kwargs) super @kwargs = kwargs end |
Instance Method Details
#collection_name ⇒ Object
27 28 29 30 |
# File 'app/components/arclight/search_bar_component.rb', line 27 def collection_name @collection_name ||= Array(@params.dig(:f, :collection)).reject(&:empty?).first || helpers.current_context_document&.collection_name end |
#within_collection_options ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/arclight/search_bar_component.rb', line 15 def value = collection_name || 'none-selected' ( [ [t('arclight.within_collection_dropdown.all_collections'), ''], [t('arclight.within_collection_dropdown.this_collection'), value] ], selected: collection_name, disabled: 'none-selected' ) end |