Class: LedgerCompanyAccountPickerTomSelectInput

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

Overview

Tom Select version of LedgerCompanyAccountPickerInput
Use as: :ledger_company_account_picker_tom_select
Supports remote search via /ledger_company_accounts/lookup endpoint
Pass company_id via query_params to filter by company

Instance Method Summary collapse

Methods inherited from TomSelectInput

#input_html_classes

Instance Method Details

#collectionObject



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

def collection
  return [] unless selected_value

  LedgerCompanyAccount.where(id: selected_value).map { |a| [a.identifier_and_name, a.id] }
end

#input(wrapper_options = nil) ⇒ Object



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

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

  super
end