33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/helpers/effective_datatables_private_helper.rb', line 33
def datatable_search_html(form, name, value, opts)
include_blank = opts[:search].key?(:include_blank) ? opts[:search][:include_blank] : opts[:label]
pattern = opts[:search][:pattern]
placeholder = opts[:search][:placeholder] || ''
title = opts[:search][:title] || opts[:label]
wrapper_html = { class: 'datatable_search' }
input_html = {
name: nil,
value: value,
title: title,
pattern: pattern,
data: {'column-name' => name, 'column-index' => opts[:index]}
}.delete_if { |k, v| v.blank? && k != :name }
case opts[:search][:as]
when :string, :text, :number
form.input name, label: false, required: false, value: value,
as: :string,
placeholder: placeholder,
wrapper_html: wrapper_html,
input_html: input_html
when :effective_obfuscation
input_html[:pattern] ||= '[0-9]{3}-?[0-9]{4}-?[0-9]{3}'
input_html[:title] = 'Expected format: XXX-XXXX-XXX'
form.input name, label: false, required: false, value: value,
as: :string,
placeholder: placeholder,
wrapper_html: wrapper_html,
input_html: input_html
when :date, :datetime
form.input name, label: false, required: false, value: value,
as: (ActionView::Helpers::FormBuilder.instance_methods.include?(:effective_date_picker) ? :effective_date_picker : :string),
placeholder: placeholder,
wrapper_html: wrapper_html,
input_group: false,
input_html: input_html,
date_linked: false,
input_js: { useStrict: true, keepInvalid: true }
when :select, :boolean
form.input name, label: false, required: false, value: value,
as: (ActionView::Helpers::FormBuilder.instance_methods.include?(:effective_select) ? :effective_select : :select),
collection: opts[:search][:collection],
selected: opts[:search][:value],
multiple: opts[:search][:multiple],
grouped: opts[:search][:grouped],
polymorphic: opts[:search][:polymorphic],
template: opts[:search][:template],
include_blank: include_blank,
wrapper_html: wrapper_html,
input_html: input_html,
input_js: { placeholder: placeholder }
when :bulk_actions
input_html[:data]['role'] = 'bulk-actions-all'
form.input name, label: false, required: false, value: nil,
as: :boolean,
input_html: input_html
end
end
|