effective_datatables 2.6.9 → 2.6.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07dc48d8a575df532cd92fd109900d5bc9ccb591
|
4
|
+
data.tar.gz: 752b4e40917ddf57d8b730301a2a7f64460d1158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c751b3b44f38a9cdd3ae975900eaf90f81b7ef7ac7c7a2ff87e6561889df45b945463fa8cbc1d68877052887a174e86444e3f9c5accff29d86fae22e2335309
|
7
|
+
data.tar.gz: d989255c2d7aa3fc8043085628ba32e0bc59f5bc6b7de07ffb38cda89d03d957a1ead21f7b65ae9c0161e913f553da6dc5fb6561fbe3e929eaecc85ab09e5d3e
|
@@ -33,6 +33,7 @@ $(document).on 'click', '.buttons-bulk-actions a', (event) ->
|
|
33
33
|
$bulkAction = $(event.currentTarget) # This is a regular <a href=...> tag
|
34
34
|
$wrapper = $bulkAction.closest('.dataTables_wrapper')
|
35
35
|
$table = $wrapper.find('table.dataTable').first()
|
36
|
+
$processing = $table.siblings('.dataTables_processing').first()
|
36
37
|
$selected = $table.find("input[data-role='bulk-actions-resource']:checked")
|
37
38
|
|
38
39
|
url = $bulkAction.attr('href')
|
@@ -41,17 +42,20 @@ $(document).on 'click', '.buttons-bulk-actions a', (event) ->
|
|
41
42
|
|
42
43
|
return unless url && values
|
43
44
|
|
44
|
-
#
|
45
|
-
$
|
46
|
-
|
45
|
+
# Disable the Bulk Actions dropdown, so only one can be run at a time
|
46
|
+
$bulkAction.closest('button').attr('disabled', 'disabled')
|
47
|
+
|
48
|
+
# Show Processing...
|
49
|
+
$processing.show().data('bulk-actions-processing', true)
|
47
50
|
|
48
51
|
$.post(
|
49
52
|
url, { ids: values }
|
50
53
|
).done((response) ->
|
51
54
|
success = response['message'] || "Successfully completed #{title} bulk action"
|
52
|
-
$
|
55
|
+
$processing.html(success)
|
53
56
|
).fail((response) ->
|
54
57
|
error = response['message'] || "An error occured while attempting #{title} bulk action: #{response.statusText}"
|
58
|
+
$processing.html(error)
|
55
59
|
alert(error)
|
56
60
|
).always((response) ->
|
57
61
|
$table.dataTable().data('bulk-actions-restore-selected-values', values)
|
@@ -72,8 +72,6 @@ initializeDataTables = ->
|
|
72
72
|
initializeFilters(this.api())
|
73
73
|
drawCallback: (settings) ->
|
74
74
|
$table = $(this.api().table().node())
|
75
|
-
selected = $table.data('bulk-actions-restore-selected-values')
|
76
|
-
completeBulkAction($table, selected) if selected && selected.length > 0
|
77
75
|
|
78
76
|
if settings['json']
|
79
77
|
if settings['json']['aggregates']
|
@@ -82,6 +80,8 @@ initializeDataTables = ->
|
|
82
80
|
if settings['json']['charts']
|
83
81
|
drawCharts($table, settings['json']['charts'])
|
84
82
|
|
83
|
+
drawBulkActions($table)
|
84
|
+
|
85
85
|
# Copies the bulk actions html, stored in a data attribute on the table, into the buttons area
|
86
86
|
initializeBulkActions = (api) ->
|
87
87
|
$table = $(api.table().node())
|
@@ -92,14 +92,20 @@ initializeDataTables = ->
|
|
92
92
|
.find('.dt-buttons').first().prepend(bulkActions['dropdownHtml'])
|
93
93
|
|
94
94
|
# After we perform a bulk action, we have to re-select the checkboxes manually and do a bit of house keeping
|
95
|
-
|
96
|
-
$table.
|
97
|
-
|
98
|
-
|
95
|
+
drawBulkActions = ($table) ->
|
96
|
+
selected = $table.data('bulk-actions-restore-selected-values')
|
97
|
+
|
98
|
+
$bulkActions = $table.closest('.dataTables_wrapper').children().first().find('.buttons-bulk-actions').children('button')
|
99
|
+
|
100
|
+
if selected && selected.length > 0
|
101
|
+
$table.find("input[data-role='bulk-actions-resource']").each (_, input) ->
|
102
|
+
$input = $(input)
|
103
|
+
$input.prop('checked', selected.indexOf($input.val()) > -1)
|
99
104
|
|
100
|
-
|
101
|
-
|
102
|
-
|
105
|
+
$bulkActions.removeAttr('disabled')
|
106
|
+
$table.data('bulk-actions-restore-selected-values', [])
|
107
|
+
else
|
108
|
+
$bulkActions.attr('disabled', 'disabled')
|
103
109
|
|
104
110
|
drawAggregates = ($table, aggregates) ->
|
105
111
|
$tfoot = $table.find('tfoot').first()
|
@@ -174,6 +180,20 @@ initializeDataTables = ->
|
|
174
180
|
, 700)
|
175
181
|
)
|
176
182
|
|
183
|
+
# We borrow the Processing div for our bulk action success/error messages
|
184
|
+
# This makes sure that the message is displayed for 1500ms
|
185
|
+
datatable.on 'processing.dt', (event, settings, visible) ->
|
186
|
+
$processing = $(event.currentTarget).siblings('.dataTables_processing').first()
|
187
|
+
return unless $processing.data('bulk-actions-processing')
|
188
|
+
|
189
|
+
timeout = $processing.show().data('timeout')
|
190
|
+
clearTimeout(timeout) if timeout
|
191
|
+
$processing.data('timeout', setTimeout( =>
|
192
|
+
$processing.html('Processing...').hide()
|
193
|
+
$processing.data('bulk-actions-processing', null)
|
194
|
+
, 1500)
|
195
|
+
)
|
196
|
+
|
177
197
|
destroyDataTables = ->
|
178
198
|
$('table.effective-datatable').each ->
|
179
199
|
if $.fn.DataTable.fnIsDataTable(this)
|