Class: AmazonBrowseNodePickerInput

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

Instance Method Summary collapse

Methods inherited from TomSelectInput

#input_html_classes

Instance Method Details

#collectionObject



12
13
14
# File 'app/inputs/amazon_browse_node_picker_input.rb', line 12

def collection
  AmazonBrowseNode.where(id: selected_value).map { |n| [n.to_s, n.id] }
end

#input(wrapper_options = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'app/inputs/amazon_browse_node_picker_input.rb', line 2

def input(wrapper_options = nil)
  params = {}
  params[:amazon_marketplace_id] = input_html_options.dig(:data, :amazon_marketplace_id).presence
  url = template.lookup_amazon_browse_nodes_path(params)
  input_html_options[:multiple] = false if input_html_options[:multiple].nil?
  input_html_options[:data] ||= {}
  input_html_options[:data]['tom-select-suggest-url-value'] = url
  super
end