Class: CustomerPickerTomSelectInput

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

Overview

Tom Select version of CustomerPickerInput
Use as: :customer_picker_tom_select instead of :customer_picker
Supports remote search via /customers/lookup endpoint

Instance Method Summary collapse

Methods inherited from TomSelectInput

#input_html_classes

Instance Method Details

#collectionObject



13
14
15
16
17
# File 'app/inputs/customer_picker_tom_select_input.rb', line 13

def collection
  return [] unless selected_value

  Customer.where(id: selected_value).pluck(:full_name, :id)
end

#input(wrapper_options = nil) ⇒ Object



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

def input(wrapper_options = nil)
  input_html_options[:data] ||= {}
  input_html_options[:data]['tom-select-suggest-url-value'] = template.lookup_customers_path
  input_html_options[:data]['tom-select-min-chars-value'] = 0

  super
end