effective_datatables 2.6.9 → 2.6.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfcfa607598e145978051831be4699b22abada93
4
- data.tar.gz: 7400ddc7374fa28e61c06f620d82780de069be75
3
+ metadata.gz: 07dc48d8a575df532cd92fd109900d5bc9ccb591
4
+ data.tar.gz: 752b4e40917ddf57d8b730301a2a7f64460d1158
5
5
  SHA512:
6
- metadata.gz: 008e48a5a8bb112d32a7b5c64df8c381d099371588af74321ff0ce30aae6ad9b95c14dbdb659b95469bdc9668a91d8bc217d27b44e8f3fcf6b5bda2e7cb0ed4b
7
- data.tar.gz: c9dcca53071f78e3ab100e69f82d675be3bcce35bd9c97b586161dce402823fed45c856433c247419df061af9cece2c1057b8affc7b89ee2770674285086ca29
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
- # Show Processing... and disable the Bulk Actions dropdown
45
- $table.siblings('.dataTables_processing').show()
46
- $wrapper.children().first().find('.buttons-bulk-actions').children('button').attr('disabled', 'disabled')
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
- $table.siblings('.dataTables_processing').html(success)
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
- completeBulkAction = ($table, selected) ->
96
- $table.find("input[data-role='bulk-actions-resource']").each (_, input) ->
97
- $input = $(input)
98
- $input.prop('checked', selected.indexOf($input.val()) > -1)
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
- $wrapper = $table.closest('.dataTables_wrapper')
101
- $wrapper.children().first().find('.buttons-bulk-actions').children('button').removeAttr('disabled')
102
- $table.siblings('.dataTables_processing').html('Processing...')
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)
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '2.6.9'.freeze
2
+ VERSION = '2.6.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.9
4
+ version: 2.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect