Class: Inputs::EffectiveSelect::Input
Instance Method Summary
collapse
#field_name, #initialize, #value
Instance Method Details
#collection ⇒ Object
22
23
24
25
26
27
|
# File 'app/models/inputs/effective_select/input.rb', line 22
def collection
@collection ||= begin
collection = options.delete(:collection)
collection.respond_to?(:call) ? collection.call : collection.to_a
end
end
|
14
15
16
|
# File 'app/models/inputs/effective_select/input.rb', line 14
def default_input_html
{class: 'effective_select', placeholder: 'Please choose'}
end
|
10
11
12
|
# File 'app/models/inputs/effective_select/input.rb', line 10
def default_input_js
{theme: 'bootstrap', minimumResultsForSearch: 6, tokenSeparators: [',', ' '], width: 'style', placeholder: 'Please choose'}
end
|
#default_options ⇒ Object
6
7
8
|
# File 'app/models/inputs/effective_select/input.rb', line 6
def default_options
{:label_method => :to_s, :value_method => :to_s}
end
|
#html_options ⇒ Object
38
39
40
41
42
|
# File 'app/models/inputs/effective_select/input.rb', line 38
def html_options
super().tap do |html_options|
html_options[:multiple] = options[:multiple]
end
end
|
#js_options ⇒ Object
44
45
46
47
48
49
|
# File 'app/models/inputs/effective_select/input.rb', line 44
def js_options
super().tap do |js_options|
js_options[:allowClear] = (options[:multiple] != true)
js_options[:tags] = (options[:tags] == true)
end
end
|
#options ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/models/inputs/effective_select/input.rb', line 29
def options
super().tap do |options|
options[:selected] = value if value
options[:multiple] = true if (options[:tags] == true)
options[:include_blank] = (options[:multiple] != true)
end
end
|
#to_html ⇒ Object
18
19
20
|
# File 'app/models/inputs/effective_select/input.rb', line 18
def to_html
collection_select(@object_name, @method, collection, options[:value_method], options[:label_method], options, tag_options)
end
|