Class: TagsPickerInput

Inherits:
TomSelectInput
  • Object
show all
Defined in:
app/inputs/tags_picker_input.rb

Overview

SimpleForm input wrapper: image tags picker backed by remote lookup
(/images/tags_lookup) so the filter panel never embeds all ~4k tags.

Instance Method Summary collapse

Methods inherited from TomSelectInput

#input_html_classes

Instance Method Details

#collectionObject

Render only the currently-selected tags as options; remote search fills the rest.



15
16
17
18
# File 'app/inputs/tags_picker_input.rb', line 15

def collection
  values = Array(options[:selected]).presence || Array(selected_value)
  values.map { |tag| [tag, tag] }
end

#input(wrapper_options = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'app/inputs/tags_picker_input.rb', line 6

def input(wrapper_options = nil)
  input_html_options[:multiple] = true if input_html_options[:multiple].nil?
  input_html_options[:data] ||= {}
  input_html_options[:data]['tom-select-suggest-url-value'] = template.tags_lookup_images_path
  input_html_options[:data]['tom-select-min-chars-value'] = 1
  super
end