effective_datatables 4.4.5 → 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +13 -3
- data/app/helpers/effective_datatables_private_helper.rb +13 -17
- data/app/models/effective/effective_datatable/dsl/filters.rb +2 -2
- data/app/views/effective/datatables/_filters.html.haml +1 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06f51c05dbf844ec08e797fc26723a9e680b7b01
|
4
|
+
data.tar.gz: f1c9c9e23fb8199df78cf2d5059d4d520fe42c77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0fc7e3f321ebb3c873ecdba4d4cba89d2590a449b5591ed42a7ac3a72a937e87d40c3f33ba00baac6d1221538aee48964ac9f9d1af3e9397ea8188b8f530874
|
7
|
+
data.tar.gz: 098d5a6eee6e134b024c9fd7ec588353071f0b94a4a7c7b62cfdb26e0f8cf03b40bbe7b7de67e753f5915b3c8bcd9e08b4eb5ff27d6eaaf2c46d7185eb8ef3bc
|
@@ -68,10 +68,20 @@ initializeDataTables = (target) ->
|
|
68
68
|
params['scope'] = $form.find("input[name='filters[scope]']:checked").val() || ''
|
69
69
|
params['filter'] = {}
|
70
70
|
|
71
|
-
$form.find("select,textarea,input:not([type=submit])
|
71
|
+
$form.find("select,textarea,input:not([type=submit])").each ->
|
72
72
|
$input = $(this)
|
73
|
-
|
74
|
-
|
73
|
+
|
74
|
+
if ['utf8', 'authenticity_token', 'filters[scope]'].includes($input.attr('name'))
|
75
|
+
# Skipped
|
76
|
+
else if $input.attr('type') == 'radio'
|
77
|
+
name = $input.attr('name')
|
78
|
+
filter_name = name.replace('filters[', '').substring(0, name.length-9)
|
79
|
+
|
80
|
+
params['filter'][filter_name] = $form.find("input[name='#{name}']:checked").val()
|
81
|
+
|
82
|
+
else if $input.attr('id')
|
83
|
+
filter_name = $input.attr('id').replace('filters_', '')
|
84
|
+
params['filter'][filter_name] = $input.val()
|
75
85
|
|
76
86
|
serverSide: true
|
77
87
|
scrollCollapse: true
|
@@ -114,44 +114,40 @@ module EffectiveDatatablesPrivateHelper
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def datatable_filter_tag(form, datatable, name, opts)
|
117
|
-
|
118
|
-
|
117
|
+
as = opts.delete(:as).to_s.chomp('_field').to_sym
|
119
118
|
collection = opts.delete(:collection)
|
120
119
|
value = datatable.state[:filter][name]
|
121
120
|
|
122
|
-
options =
|
121
|
+
options = {
|
123
122
|
autocomplete: 'off',
|
124
123
|
feedback: false,
|
125
124
|
label: false,
|
126
|
-
placeholder:
|
125
|
+
placeholder: (opts[:label] || name.to_s.titleize),
|
127
126
|
value: value,
|
128
127
|
wrapper: { class: 'form-group col-auto'}
|
129
|
-
)
|
128
|
+
}.merge(opts.except(:parse))
|
130
129
|
|
131
130
|
options[:name] = '' unless datatable._filters_form_required?
|
132
131
|
|
133
|
-
|
134
|
-
|
135
|
-
form.
|
136
|
-
|
137
|
-
form.
|
138
|
-
when :time
|
139
|
-
form.time_field name, options
|
140
|
-
when :select, :boolean
|
141
|
-
options[:input_js] = (options[:input_js] || {}).reverse_merge(placeholder: placeholder)
|
142
|
-
form.select name, collection, options
|
132
|
+
if collection.present?
|
133
|
+
options.delete(:name) unless as == :select
|
134
|
+
form.public_send(as, name, collection, options) # select, radios, checks
|
135
|
+
elsif form.respond_to?(as)
|
136
|
+
form.public_send(as, name, options) # check_box, text_area
|
143
137
|
else
|
144
|
-
form.
|
138
|
+
form.public_send("#{as}_field", name, options) # text_field, number_field, all the rest.
|
145
139
|
end
|
140
|
+
|
146
141
|
end
|
147
142
|
|
148
143
|
def datatable_scope_tag(form, datatable, opts = {})
|
149
144
|
collection = datatable._scopes.map { |name, opts| [opts[:label], name] }
|
145
|
+
value = datatable.state[:scope]
|
150
146
|
|
151
147
|
options = {
|
152
148
|
autocomplete: 'off',
|
153
149
|
buttons: true,
|
154
|
-
checked:
|
150
|
+
checked: value,
|
155
151
|
feedback: false,
|
156
152
|
label: false,
|
157
153
|
required: false,
|
@@ -25,11 +25,11 @@ module Effective
|
|
25
25
|
datatable._filters[name.to_sym] = {
|
26
26
|
value: value,
|
27
27
|
as: as,
|
28
|
-
label: label
|
28
|
+
label: label,
|
29
29
|
name: name.to_sym,
|
30
30
|
parse: parse,
|
31
31
|
required: required,
|
32
|
-
}.reverse_merge(input_html)
|
32
|
+
}.compact.reverse_merge(input_html)
|
33
33
|
end
|
34
34
|
|
35
35
|
def scope(name = nil, *args, default: nil, label: nil)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
.effective-datatables-filters{'aria-controls': datatable.to_param}
|
2
|
-
= effective_form_with(scope: :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb]) do |form|
|
2
|
+
= effective_form_with(scope: :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb], id: nil) do |form|
|
3
3
|
.form-row.align-items-center
|
4
4
|
- if datatable._scopes.present?
|
5
5
|
= datatable_scope_tag(form, datatable)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|