effective_datatables 4.37.1 → 4.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_datatables/charts.js.coffee +1 -1
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +3 -5
- data/app/assets/javascripts/effective_datatables/inline_crud.js.coffee +7 -5
- data/app/helpers/effective_datatables_helper.rb +9 -3
- data/app/helpers/effective_datatables_private_helper.rb +13 -8
- data/app/views/effective/datatables/_buttons.html.haml +3 -1
- data/app/views/effective/datatables/_filters.html.haml +2 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2cb4f5aadf82512130c0aa2284716798def7fbcbd1ce5442bca34d13892393cf
|
|
4
|
+
data.tar.gz: 6fb0fa42c091876ac52fdaddd9b94fc353825aa062a30e8f9bbb46fb18aab078
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4321d3f210de3bef8f4dceb5820c9f49ad8761273e5ba249ed56dbe8d60d430c57101edcbf28d83fe84aae2a90bcb3aa7b4f935459fbe70965bd2310ef3b201d
|
|
7
|
+
data.tar.gz: 1e5993a427b48a40bacaca8156dc93093a9609d8e8053c2ab8d8ca0147c86894b8e287c4669d1e764cf160a5c524c9b4fa2deda4ba191a03630c77c6c9a866a8
|
|
@@ -204,8 +204,6 @@ $ -> initializeDataTables()
|
|
|
204
204
|
$(document).on 'effective-datatables:initialize', (event) -> initializeDataTables(event.currentTarget)
|
|
205
205
|
|
|
206
206
|
$(document).on 'page:change', -> initializeDataTables()
|
|
207
|
-
$(document).on 'turbolinks:
|
|
208
|
-
$(document).on 'turbolinks:
|
|
209
|
-
$(document).on 'turbolinks:before-cache', -> destroyDataTables()
|
|
210
|
-
$(document).on 'turbo:load', -> initializeDataTables()
|
|
211
|
-
$(document).on 'turbo:before-cache', -> destroyDataTables()
|
|
207
|
+
$(document).on 'turbolinks:render turbo:render', -> initializeDataTables()
|
|
208
|
+
$(document).on 'turbolinks:load turbo:load', -> initializeDataTables()
|
|
209
|
+
$(document).on 'turbolinks:before-cache turbo:before-cache', -> destroyDataTables()
|
|
@@ -13,7 +13,7 @@ $(document).on 'ajax:before', '.dataTables_wrapper .col-actions', (event) ->
|
|
|
13
13
|
|
|
14
14
|
$params = $.param(
|
|
15
15
|
{
|
|
16
|
-
_datatable_id: $table.
|
|
16
|
+
_datatable_id: $table.data('datatable-id'),
|
|
17
17
|
_datatable_attributes: $table.data('attributes'),
|
|
18
18
|
_datatable_action: true
|
|
19
19
|
}
|
|
@@ -49,7 +49,9 @@ $(document).on 'ajax:success', '.dataTables_wrapper .col-actions', (event, data)
|
|
|
49
49
|
return true if ('' + $action.data('inline')) == 'false'
|
|
50
50
|
|
|
51
51
|
if data.length > 0
|
|
52
|
-
|
|
52
|
+
turbolinks_redirect = data.indexOf('Turbolinks.clearCache()') == 0 && data.includes("Turbolinks.visit(")
|
|
53
|
+
turbo_redirect = data.indexOf('Turbo.cache.clear()') == 0 && data.includes("Turbo.visit(")
|
|
54
|
+
return true if turbolinks_redirect || turbo_redirect
|
|
53
55
|
return true if data.indexOf('<html') >= 0
|
|
54
56
|
|
|
55
57
|
if ($action.data('method') || 'get') == 'get'
|
|
@@ -85,7 +87,7 @@ $(document).on 'ajax:before', '.dataTables_wrapper .col-inline-form', (event) ->
|
|
|
85
87
|
|
|
86
88
|
if $form.find('input[name=_datatable_id]').length == 0
|
|
87
89
|
$('<input>').attr(
|
|
88
|
-
{type: 'hidden', name: '_datatable_id', value: $table.
|
|
90
|
+
{type: 'hidden', name: '_datatable_id', value: $table.data('datatable-id')}
|
|
89
91
|
).appendTo($form)
|
|
90
92
|
|
|
91
93
|
if $form.find('input[name=_datatable_attributes]').length == 0
|
|
@@ -138,7 +140,7 @@ afterNew = ($action) ->
|
|
|
138
140
|
$table.children('tbody').prepend($tr)
|
|
139
141
|
|
|
140
142
|
expand($table)
|
|
141
|
-
$tr.trigger('
|
|
143
|
+
$tr.trigger('effective-bootstrap:initialize')
|
|
142
144
|
$tr.hide().fadeIn()
|
|
143
145
|
|
|
144
146
|
beforeEdit = ($action) ->
|
|
@@ -169,7 +171,7 @@ afterEdit = ($action) ->
|
|
|
169
171
|
$tr.addClass('effective-datatables-inline-row')
|
|
170
172
|
|
|
171
173
|
expand($table)
|
|
172
|
-
$tr.trigger('
|
|
174
|
+
$tr.trigger('effective-bootstrap:initialize')
|
|
173
175
|
$tr.hide().fadeIn()
|
|
174
176
|
|
|
175
177
|
# This is when one of the resource actions completes
|
|
@@ -42,6 +42,11 @@ module EffectiveDatatablesHelper
|
|
|
42
42
|
buttons = true; input_js[:buttons] = false
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
datatable_id = datatable.to_param
|
|
46
|
+
@_effective_datatable_ids ||= Hash.new(0)
|
|
47
|
+
@_effective_datatable_ids[datatable_id] += 1
|
|
48
|
+
dom_id = [datatable_id, (@_effective_datatable_ids[datatable_id] if @_effective_datatable_ids[datatable_id] > 1)].compact.join('-')
|
|
49
|
+
|
|
45
50
|
# Build the datatables DOM option
|
|
46
51
|
input_js[:dom] ||= [
|
|
47
52
|
("<'row'<'col-sm-12 dataTables_buttons'B>>" if buttons),
|
|
@@ -53,13 +58,14 @@ module EffectiveDatatablesHelper
|
|
|
53
58
|
].compact.join
|
|
54
59
|
|
|
55
60
|
effective_datatable_params = {
|
|
56
|
-
id:
|
|
61
|
+
id: dom_id,
|
|
57
62
|
class: html_class,
|
|
58
63
|
data: {
|
|
64
|
+
'datatable-id' => datatable_id,
|
|
59
65
|
'all-label' => I18n.t('effective_datatables.all'),
|
|
60
66
|
'attributes' => EffectiveDatatables.encrypt(datatable.attributes),
|
|
61
67
|
'authenticity-token' => form_authenticity_token,
|
|
62
|
-
'buttons-html' => datatable_buttons(datatable),
|
|
68
|
+
'buttons-html' => datatable_buttons(datatable, dom_id: dom_id),
|
|
63
69
|
'columns' => datatable_columns(datatable),
|
|
64
70
|
'default-visibility' => datatable.default_visibility.to_json,
|
|
65
71
|
'display-length' => datatable.display_length,
|
|
@@ -88,7 +94,7 @@ module EffectiveDatatablesHelper
|
|
|
88
94
|
end
|
|
89
95
|
|
|
90
96
|
if filters
|
|
91
|
-
output << render_datatable_filters(datatable)
|
|
97
|
+
output << render_datatable_filters(datatable, dom_id: dom_id)
|
|
92
98
|
end
|
|
93
99
|
|
|
94
100
|
output << render(partial: 'effective/datatables/datatable',
|
|
@@ -25,8 +25,8 @@ module EffectiveDatatablesPrivateHelper
|
|
|
25
25
|
((datatable.sortable? && datatable.order_index) ? [datatable.order_index, datatable.order_direction] : false).to_json.html_safe
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def datatable_buttons(datatable, search: true)
|
|
29
|
-
render('/effective/datatables/buttons', datatable: datatable, search: search).gsub("'", '"').html_safe
|
|
28
|
+
def datatable_buttons(datatable, search: true, dom_id: datatable.to_param)
|
|
29
|
+
render('/effective/datatables/buttons', datatable: datatable, search: search, dom_id: dom_id).gsub("'", '"').html_safe
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def datatable_length_menu(datatable)
|
|
@@ -47,11 +47,16 @@ module EffectiveDatatablesPrivateHelper
|
|
|
47
47
|
btn_class = EffectiveDatatables.new_action_button_class || 'btn-sm btn-success'
|
|
48
48
|
action = { action: :new, class: "btn #{btn_class}", 'data-remote': true }
|
|
49
49
|
|
|
50
|
+
# Pass actions_col(new: { label: 'New Thing' }) to override the button label on one datatable.
|
|
51
|
+
label = t('effective_datatables.new')
|
|
52
|
+
|
|
50
53
|
if column[:actions][:new].kind_of?(Hash) # This might be active_record_array_collection?
|
|
51
|
-
|
|
54
|
+
new_opts = column[:actions][:new]
|
|
55
|
+
label = new_opts[:label] if new_opts[:label].present?
|
|
56
|
+
action = action.merge(new_opts.except(:label, :klass))
|
|
52
57
|
|
|
53
58
|
effective_resource = (datatable.effective_resource || datatable.fallback_effective_resource)
|
|
54
|
-
klass = (
|
|
59
|
+
klass = (new_opts[:klass] || effective_resource&.klass || datatable.collection_class)
|
|
55
60
|
elsif Array(datatable.effective_resource&.actions).include?(:new)
|
|
56
61
|
effective_resource = datatable.effective_resource
|
|
57
62
|
klass = effective_resource.klass
|
|
@@ -60,7 +65,7 @@ module EffectiveDatatablesPrivateHelper
|
|
|
60
65
|
end
|
|
61
66
|
|
|
62
67
|
# Will only work if permitted
|
|
63
|
-
render_resource_actions(klass, actions: {
|
|
68
|
+
render_resource_actions(klass, actions: { label => action }, effective_resource: effective_resource)
|
|
64
69
|
end
|
|
65
70
|
|
|
66
71
|
def datatable_label_tag(datatable, name, opts)
|
|
@@ -140,16 +145,16 @@ module EffectiveDatatablesPrivateHelper
|
|
|
140
145
|
end
|
|
141
146
|
end
|
|
142
147
|
|
|
143
|
-
def render_datatable_filters(datatable)
|
|
148
|
+
def render_datatable_filters(datatable, dom_id: datatable.to_param)
|
|
144
149
|
raise 'expected datatable to be present' unless datatable
|
|
145
150
|
|
|
146
151
|
datatable.view ||= self
|
|
147
152
|
return unless datatable._scopes.present? || datatable._filters.present?
|
|
148
153
|
|
|
149
154
|
if datatable._filters_form_required?
|
|
150
|
-
render('effective/datatables/filters', datatable: datatable)
|
|
155
|
+
render('effective/datatables/filters', datatable: datatable, dom_id: dom_id)
|
|
151
156
|
else
|
|
152
|
-
render('effective/datatables/filters', datatable: datatable).gsub('<form', '<div').gsub('/form>', '/div>').html_safe
|
|
157
|
+
render('effective/datatables/filters', datatable: datatable, dom_id: dom_id).gsub('<form', '<div').gsub('/form>', '/div>').html_safe
|
|
153
158
|
end
|
|
154
159
|
|
|
155
160
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
- dom_id ||= datatable.to_param
|
|
2
|
+
|
|
1
3
|
- if datatable._bulk_actions.present?
|
|
2
4
|
= render('/effective/datatables/bulk_actions_dropdown', datatable: datatable)
|
|
3
5
|
|
|
@@ -10,5 +12,5 @@
|
|
|
10
12
|
%span= t('effective_datatables.reorder')
|
|
11
13
|
|
|
12
14
|
- if datatable.downloadable?
|
|
13
|
-
= link_to 'download.csv', class: 'btn btn-link btn-sm buttons-download', 'aria-controls':
|
|
15
|
+
= link_to 'download.csv', class: 'btn btn-link btn-sm buttons-download', 'aria-controls': dom_id do
|
|
14
16
|
%span= t('effective_datatables.download')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
- dom_id ||= datatable.to_param
|
|
2
|
+
.effective-datatables-filters{'aria-controls': dom_id}
|
|
2
3
|
|
|
3
4
|
= effective_form_with(model: datatable.filters_form, scope: :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb], id: nil, authenticity_token: datatable._filters_form_required?) do |form|
|
|
4
5
|
.form-row.align-items-center
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: effective_datatables
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.38.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Code and Effect
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -196,7 +195,6 @@ homepage: https://github.com/code-and-effect/effective_datatables
|
|
|
196
195
|
licenses:
|
|
197
196
|
- MIT
|
|
198
197
|
metadata: {}
|
|
199
|
-
post_install_message:
|
|
200
198
|
rdoc_options: []
|
|
201
199
|
require_paths:
|
|
202
200
|
- lib
|
|
@@ -211,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
211
209
|
- !ruby/object:Gem::Version
|
|
212
210
|
version: '0'
|
|
213
211
|
requirements: []
|
|
214
|
-
rubygems_version:
|
|
215
|
-
signing_key:
|
|
212
|
+
rubygems_version: 4.0.17
|
|
216
213
|
specification_version: 4
|
|
217
214
|
summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord
|
|
218
215
|
or Array collection as well as post-rendered content displayed as a frontend jQuery
|