Class: Spotlight::TagSelectorComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/spotlight/tag_selector_component.rb

Overview

Displays a tag selection input This uses a plain text input that acts-as-taggable-on expects.

Instance Method Summary collapse

Constructor Details

#initialize(field_name:, all_tags:, selected_tags_value: nil, form: nil) ⇒ TagSelectorComponent

selected_tags_value is a comma delimited string of tags



8
9
10
11
12
13
14
15
# File 'app/components/spotlight/tag_selector_component.rb', line 8

def initialize(field_name:, all_tags:, selected_tags_value: nil, form: nil)
  @form = form
  @field_name = field_name
  @selected_tags_value = selected_tags_value || ''
  @all_tags = all_tags&.sort_by { |tag| (tag.respond_to?(:name) ? tag.name : tag).downcase }

  super
end

Instance Method Details

#search_icon_svgObject



21
22
23
# File 'app/components/spotlight/tag_selector_component.rb', line 21

def search_icon_svg
  render Blacklight::Icons::SearchComponent.new
end

#selected_tagsObject



17
18
19
# File 'app/components/spotlight/tag_selector_component.rb', line 17

def selected_tags
  selected_tags_value.split(',').map(&:strip)
end