effective_datatables 4.8.7 → 4.8.12
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 +2 -2
- data/app/assets/javascripts/effective_datatables/reorder.js.coffee +8 -2
- data/app/helpers/effective_datatables_helper.rb +1 -0
- data/app/helpers/effective_datatables_private_helper.rb +10 -8
- data/app/models/effective/effective_datatable/compute.rb +1 -0
- data/app/models/effective/effective_datatable/format.rb +9 -9
- data/app/models/effective/effective_datatable/resource.rb +5 -3
- data/config/effective_datatables.rb +4 -0
- data/config/locales/en.yml +2 -1
- data/config/locales/es.yml +2 -1
- data/config/locales/nl.yml +2 -1
- data/lib/effective_datatables.rb +4 -0
- data/lib/effective_datatables/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9039b9b9cc3e4d4b2f730788b5a82ee4b42f2062bf1ff420f5a0621187c1e536
|
4
|
+
data.tar.gz: 548d510b9909c6e7b12dce658e1dd14c173c930294d1684d4471f0750b7f4dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f2ca52ceda8df0e12f9d9fa1572685d8d11d93a49d665de77adeeb49ccfb2e74c11a85d89c150b14d7fdde13ed84a05c48b53c503f352d2e395da6ae014904
|
7
|
+
data.tar.gz: 44ed8ceb32afd06ffbd963d7620ecb848c9c8c3602f6276243498e9af9710a2afba7b4dcd99736d4717c04a1e2bc873143adc70d9c3a33dacc22da144a2ebbe3
|
@@ -52,7 +52,7 @@ initializeDataTables = (target) ->
|
|
52
52
|
displayStart: datatable.data('display-start')
|
53
53
|
iDisplayLength: datatable.data('display-length')
|
54
54
|
language: datatable.data('language')
|
55
|
-
lengthMenu: [[5, 10, 25, 50, 100, 250, 500, 9999999], ['5', '10', '25', '50', '100', '250', '500', '
|
55
|
+
lengthMenu: [[5, 10, 25, 50, 100, 250, 500, 9999999], ['5', '10', '25', '50', '100', '250', '500', datatable.data('all-label')]]
|
56
56
|
order: datatable.data('display-order')
|
57
57
|
processing: true
|
58
58
|
responsive: true
|
@@ -80,7 +80,7 @@ initializeDataTables = (target) ->
|
|
80
80
|
filter_name = name.replace('filters[', '').substring(0, name.length-9)
|
81
81
|
|
82
82
|
params['filter'][filter_name] = $form.find("input[name='#{name}']:checked").val()
|
83
|
-
|
83
|
+
|
84
84
|
else if $input.attr('id')
|
85
85
|
filter_name = $input.attr('id').replace('filters_', '')
|
86
86
|
params['filter'][filter_name] = $input.val()
|
@@ -8,7 +8,14 @@ reorder = (event, diff, edit) ->
|
|
8
8
|
return unless oldNode? && newNode?
|
9
9
|
|
10
10
|
url = @context[0].ajax.url.replace('.json', '/reorder.json')
|
11
|
-
|
11
|
+
|
12
|
+
data = {
|
13
|
+
'authenticity_token': $('head').find("meta[name='csrf-token']").attr('content'),
|
14
|
+
'reorder[id]': oldNode.data('reorder-resource'),
|
15
|
+
'reorder[old]': oldNode.val(),
|
16
|
+
'reorder[new]': newNode.val(),
|
17
|
+
'attributes': $table.data('attributes')
|
18
|
+
}
|
12
19
|
|
13
20
|
@context[0].rowreorder.c.enable = false
|
14
21
|
|
@@ -40,4 +47,3 @@ $(document).on 'click', '.dataTables_wrapper a.buttons-reorder', (event) ->
|
|
40
47
|
$table.addClass('reordering')
|
41
48
|
|
42
49
|
column.visible(!column.visible())
|
43
|
-
|
@@ -40,6 +40,7 @@ module EffectiveDatatablesHelper
|
|
40
40
|
id: datatable.to_param,
|
41
41
|
class: html_class,
|
42
42
|
data: {
|
43
|
+
'all-label' => I18n.t('effective_datatables.all'),
|
43
44
|
'attributes' => EffectiveDatatables.encrypt(datatable.attributes),
|
44
45
|
'authenticity-token' => form_authenticity_token,
|
45
46
|
'bulk-actions' => datatable_bulk_actions(datatable),
|
@@ -44,7 +44,7 @@ module EffectiveDatatablesPrivateHelper
|
|
44
44
|
action = { action: :new, class: ['btn', column[:btn_class].presence].compact.join(' '), 'data-remote': true }
|
45
45
|
|
46
46
|
if column[:actions][:new].kind_of?(Hash) # This might be active_record_array_collection?
|
47
|
-
action
|
47
|
+
action.merge!(column[:actions][:new])
|
48
48
|
|
49
49
|
effective_resource = (datatable.effective_resource || datatable.fallback_effective_resource)
|
50
50
|
klass = (column[:actions][:new][:klass] || effective_resource&.klass || datatable.collection_class)
|
@@ -84,7 +84,7 @@ module EffectiveDatatablesPrivateHelper
|
|
84
84
|
collection = opts[:search].delete(:collection)
|
85
85
|
value = datatable.state[:search][name]
|
86
86
|
|
87
|
-
options = opts[:search].
|
87
|
+
options = opts[:search].merge!(
|
88
88
|
name: nil,
|
89
89
|
feedback: false,
|
90
90
|
label: false,
|
@@ -92,24 +92,26 @@ module EffectiveDatatablesPrivateHelper
|
|
92
92
|
data: { 'column-name': name, 'column-index': opts[:index] }
|
93
93
|
)
|
94
94
|
|
95
|
+
options.delete(:fuzzy)
|
96
|
+
|
95
97
|
case options.delete(:as)
|
96
98
|
when :string, :text, :number
|
97
99
|
form.text_field name, options
|
98
100
|
when :date, :datetime
|
99
|
-
form.date_field name, options.reverse_merge(
|
101
|
+
form.date_field name, options.reverse_merge!(
|
100
102
|
date_linked: false, prepend: false, input_js: { useStrict: true, keepInvalid: true }
|
101
103
|
)
|
102
104
|
when :time
|
103
|
-
form.time_field name, options.reverse_merge(
|
105
|
+
form.time_field name, options.reverse_merge!(
|
104
106
|
date_linked: false, prepend: false, input_js: { useStrict: false, keepInvalid: true }
|
105
107
|
)
|
106
108
|
when :select, :boolean
|
107
|
-
options[:input_js] = (options[:input_js] || {}).reverse_merge(placeholder: '')
|
109
|
+
options[:input_js] = (options[:input_js] || {}).reverse_merge!(placeholder: '')
|
108
110
|
|
109
111
|
form.select name, collection, options
|
110
112
|
when :bulk_actions
|
111
113
|
options[:data]['role'] = 'bulk-actions'
|
112
|
-
form.check_box name, options.merge(label: ' ')
|
114
|
+
form.check_box name, options.merge!(label: ' ')
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
@@ -139,7 +141,7 @@ module EffectiveDatatablesPrivateHelper
|
|
139
141
|
placeholder: (opts[:label] || name.to_s.titleize),
|
140
142
|
value: value,
|
141
143
|
wrapper: { class: 'form-group col-auto'}
|
142
|
-
}.merge(opts.except(:as, :collection, :parse, :value))
|
144
|
+
}.merge!(opts.except(:as, :collection, :parse, :value))
|
143
145
|
|
144
146
|
options[:name] = '' unless datatable._filters_form_required?
|
145
147
|
|
@@ -171,7 +173,7 @@ module EffectiveDatatablesPrivateHelper
|
|
171
173
|
label: false,
|
172
174
|
required: false,
|
173
175
|
wrapper: { class: 'form-group col-auto'}
|
174
|
-
}.merge(opts.except(:checked, :value))
|
176
|
+
}.merge!(opts.except(:checked, :value))
|
175
177
|
|
176
178
|
form.radios :scope, collection, options
|
177
179
|
end
|
@@ -16,7 +16,7 @@ module Effective
|
|
16
16
|
next unless state[:visible][name]
|
17
17
|
|
18
18
|
if opts[:partial]
|
19
|
-
locals = { datatable: self, column: opts }.merge(resource_col_locals(opts))
|
19
|
+
locals = { datatable: self, column: opts }.merge!(resource_col_locals(opts))
|
20
20
|
|
21
21
|
rendered[name] = (view.render(
|
22
22
|
partial: opts[:partial],
|
@@ -27,7 +27,6 @@ module Effective
|
|
27
27
|
spacer_template: SPACER_TEMPLATE
|
28
28
|
) || '').split(SPACER)
|
29
29
|
elsif opts[:as] == :actions # This is actions_col and actions_col do .. end, but not actions_col partial: 'something'
|
30
|
-
resources = collection.map { |row| row[opts[:index]] }
|
31
30
|
locals = { datatable: self, column: opts, spacer_template: SPACER_TEMPLATE }
|
32
31
|
|
33
32
|
atts = {
|
@@ -36,16 +35,17 @@ module Effective
|
|
36
35
|
effective_resource: effective_resource,
|
37
36
|
locals: locals,
|
38
37
|
partial: opts[:actions_partial],
|
39
|
-
}.
|
38
|
+
}.merge!(opts[:actions]).tap(&:compact!)
|
40
39
|
|
41
40
|
rendered[name] = if effective_resource.blank?
|
42
|
-
|
41
|
+
collection.map { |row| row[opts[:index]] }.map do |resource|
|
43
42
|
polymorphic_resource = Effective::Resource.new(resource, namespace: controller_namespace)
|
44
43
|
(view.render_resource_actions(resource, atts.merge(effective_resource: polymorphic_resource), &opts[:format]) || '')
|
45
44
|
end
|
46
45
|
else
|
47
|
-
(view.render_resource_actions(
|
46
|
+
(view.render_resource_actions(collection.map { |row| row[opts[:index]] }, atts, &opts[:format]) || '').split(SPACER)
|
48
47
|
end
|
48
|
+
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -88,9 +88,9 @@ module Effective
|
|
88
88
|
when :currency
|
89
89
|
view.number_to_currency(value)
|
90
90
|
when :date
|
91
|
-
(value.strftime(
|
91
|
+
value.respond_to?(:strftime) ? value.strftime(EffectiveDatatables.format_date) : BLANK
|
92
92
|
when :datetime
|
93
|
-
(value.strftime(
|
93
|
+
value.respond_to?(:strftime) ? value.strftime(EffectiveDatatables.format_datetime) : BLANK
|
94
94
|
when :decimal
|
95
95
|
value
|
96
96
|
when :duration
|
@@ -116,7 +116,7 @@ module Effective
|
|
116
116
|
when Numeric ; view.number_to_currency(value)
|
117
117
|
end
|
118
118
|
when :time
|
119
|
-
(value.strftime(
|
119
|
+
value.respond_to?(:strftime) ? value.strftime(EffectiveDatatables.format_time) : BLANK
|
120
120
|
else
|
121
121
|
value.to_s
|
122
122
|
end
|
@@ -135,7 +135,7 @@ module Effective
|
|
135
135
|
end
|
136
136
|
|
137
137
|
# Merge local options. Special behaviour for remote: false
|
138
|
-
if column[:actions].
|
138
|
+
if column[:actions].present? && column[:actions].kind_of?(Hash)
|
139
139
|
column[:actions].each do |action, opts|
|
140
140
|
next unless opts.kind_of?(Hash)
|
141
141
|
|
@@ -98,9 +98,11 @@ module Effective
|
|
98
98
|
opts[:sql_as_column] = true if (effective_resource.table && effective_resource.column(name).blank?)
|
99
99
|
end
|
100
100
|
|
101
|
-
if opts[:sql_column].present?
|
102
|
-
opts[:
|
101
|
+
if opts[:sql_column].present?
|
102
|
+
sql_column = opts[:sql_column].to_s
|
103
|
+
opts[:sql_as_column] = true if AGGREGATE_SQL_FUNCTIONS.any? { |str| sql_column.start_with?(str) }
|
103
104
|
end
|
105
|
+
|
104
106
|
end
|
105
107
|
end
|
106
108
|
|
@@ -200,7 +202,7 @@ module Effective
|
|
200
202
|
|
201
203
|
def load_resource_belongs_tos!
|
202
204
|
return unless active_record_collection?
|
203
|
-
return unless @_collection_apply_belongs_to
|
205
|
+
return unless @_collection_apply_belongs_to
|
204
206
|
|
205
207
|
changed = attributes.select do |attribute, value|
|
206
208
|
attribute = attribute.to_s
|
@@ -39,4 +39,8 @@ EffectiveDatatables.setup do |config|
|
|
39
39
|
config.cookie_domain = :all # Should usually be :all
|
40
40
|
config.cookie_tld_length = nil # Leave nil to autodetect, or set to probably 2
|
41
41
|
|
42
|
+
# Date formatting
|
43
|
+
config.format_datetime = '%F %H:%M'
|
44
|
+
config.format_date = '%F'
|
45
|
+
config.format_time = '%H:%M'
|
42
46
|
end
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/lib/effective_datatables.rb
CHANGED
@@ -16,6 +16,10 @@ module EffectiveDatatables
|
|
16
16
|
mattr_accessor :cookie_domain
|
17
17
|
mattr_accessor :cookie_tld_length
|
18
18
|
|
19
|
+
mattr_accessor :format_datetime
|
20
|
+
mattr_accessor :format_date
|
21
|
+
mattr_accessor :format_time
|
22
|
+
|
19
23
|
mattr_accessor :debug
|
20
24
|
|
21
25
|
alias_method :max_cookie_size, :cookie_max_size
|
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.8.
|
4
|
+
version: 4.8.12
|
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: 2020-
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
rubygems_version: 3.1.
|
196
|
+
rubygems_version: 3.1.4
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord
|