effective_datatables 3.7.7 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +32 -32
  4. data/app/assets/images/dataTables/sort-down.svg +1 -0
  5. data/app/assets/images/dataTables/sort-up.svg +1 -0
  6. data/app/assets/images/dataTables/sort.svg +1 -0
  7. data/app/assets/javascripts/dataTables/buttons/{buttons.bootstrap.js → buttons.bootstrap4.js} +7 -15
  8. data/app/assets/javascripts/dataTables/dataTables.bootstrap4.js +184 -0
  9. data/app/assets/javascripts/dataTables/responsive/dataTables.responsive.js +30 -11
  10. data/app/assets/javascripts/dataTables/responsive/{responsive.bootstrap.js → responsive.bootstrap4.js} +6 -6
  11. data/app/assets/javascripts/effective_datatables.js +4 -4
  12. data/app/assets/javascripts/effective_datatables/bulk_actions.js.coffee +43 -43
  13. data/app/assets/javascripts/effective_datatables/events.js.coffee +7 -4
  14. data/app/assets/javascripts/effective_datatables/filters.js.coffee +0 -1
  15. data/app/assets/javascripts/effective_datatables/initialize.js.coffee +45 -49
  16. data/app/assets/javascripts/effective_datatables/overrides.js +12 -0
  17. data/app/assets/javascripts/effective_datatables/reset.js.coffee +1 -1
  18. data/app/assets/stylesheets/dataTables/buttons/{buttons.bootstrap.scss → buttons.bootstrap4.css} +68 -1
  19. data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.scss → dataTables.bootstrap4.css} +44 -29
  20. data/app/assets/stylesheets/dataTables/responsive/{responsive.bootstrap.scss → responsive.bootstrap4.css} +3 -3
  21. data/app/assets/stylesheets/effective_datatables.scss +3 -4
  22. data/app/assets/stylesheets/effective_datatables/_overrides.scss +72 -152
  23. data/app/controllers/effective/datatables_controller.rb +6 -39
  24. data/app/helpers/effective_datatables_helper.rb +55 -50
  25. data/app/helpers/effective_datatables_private_helper.rb +47 -179
  26. data/app/models/effective/datatable.rb +16 -44
  27. data/app/models/effective/datatable_column.rb +0 -1
  28. data/app/models/effective/datatable_column_tool.rb +1 -1
  29. data/app/models/effective/datatable_dsl_tool.rb +3 -11
  30. data/app/models/effective/datatable_value_tool.rb +23 -23
  31. data/app/models/effective/effective_datatable/attributes.rb +13 -5
  32. data/app/models/effective/effective_datatable/collection.rb +3 -18
  33. data/app/models/effective/effective_datatable/compute.rb +6 -17
  34. data/app/models/effective/effective_datatable/cookie.rb +20 -19
  35. data/app/models/effective/effective_datatable/dsl.rb +3 -8
  36. data/app/models/effective/effective_datatable/dsl/bulk_actions.rb +25 -14
  37. data/app/models/effective/effective_datatable/dsl/datatable.rb +28 -70
  38. data/app/models/effective/effective_datatable/dsl/filters.rb +5 -5
  39. data/app/models/effective/effective_datatable/format.rb +50 -95
  40. data/app/models/effective/effective_datatable/params.rb +3 -8
  41. data/app/models/effective/effective_datatable/resource.rb +76 -137
  42. data/app/models/effective/effective_datatable/state.rb +15 -30
  43. data/app/views/effective/datatables/_actions_column.html.haml +8 -1
  44. data/app/views/effective/datatables/_bulk_actions_column.html.haml +1 -1
  45. data/app/views/effective/datatables/_filters.html.haml +11 -12
  46. data/app/views/effective/datatables/_resource_column.html.haml +8 -11
  47. data/config/effective_datatables.rb +14 -12
  48. data/config/routes.rb +0 -1
  49. data/lib/effective_datatables.rb +4 -57
  50. data/lib/effective_datatables/engine.rb +1 -1
  51. data/lib/effective_datatables/version.rb +1 -1
  52. metadata +20 -30
  53. data/app/assets/images/dataTables/sort_asc.png +0 -0
  54. data/app/assets/images/dataTables/sort_both.png +0 -0
  55. data/app/assets/images/dataTables/sort_desc.png +0 -0
  56. data/app/assets/javascripts/dataTables/dataTables.bootstrap.js +0 -182
  57. data/app/assets/javascripts/dataTables/locales/en.lang +0 -33
  58. data/app/assets/javascripts/dataTables/locales/es.lang +0 -36
  59. data/app/assets/javascripts/dataTables/locales/nl.lang +0 -30
  60. data/app/assets/javascripts/effective_datatables/flash.js.coffee +0 -31
  61. data/app/assets/javascripts/effective_datatables/inline_crud.js.coffee +0 -217
  62. data/app/assets/javascripts/effective_datatables/overrides.js.coffee +0 -7
  63. data/app/assets/javascripts/effective_datatables/reorder.js.coffee +0 -43
  64. data/app/assets/stylesheets/effective_datatables/_filters.scss +0 -7
  65. data/app/views/effective/datatables/_reorder_column.html.haml +0 -5
  66. data/config/locales/en.yml +0 -12
  67. data/config/locales/es.yml +0 -12
  68. data/config/locales/nl.yml +0 -12
@@ -1,11 +1,11 @@
1
- /*! Bootstrap integration for DataTables' Responsive
2
- * ©2015-2016 SpryMedia Ltd - datatables.net/license
1
+ /*! Bootstrap 4 integration for DataTables' Responsive
2
+ * ©2016 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  (function( factory ){
6
6
  if ( typeof define === 'function' && define.amd ) {
7
7
  // AMD
8
- define( ['jquery', 'datatables.net-bs', 'datatables.net-responsive'], function ( $ ) {
8
+ define( ['jquery', 'datatables.net-bs4', 'datatables.net-responsive'], function ( $ ) {
9
9
  return factory( $, window, document );
10
10
  } );
11
11
  }
@@ -17,7 +17,7 @@
17
17
  }
18
18
 
19
19
  if ( ! $ || ! $.fn.dataTable ) {
20
- $ = require('datatables.net-bs')(root, $).$;
20
+ $ = require('datatables.net-bs4')(root, $).$;
21
21
  }
22
22
 
23
23
  if ( ! $.fn.dataTable.Responsive ) {
@@ -61,11 +61,11 @@ _display.modal = function ( options ) {
61
61
  if ( options && options.header ) {
62
62
  var header = _modal.find('div.modal-header');
63
63
  var button = header.find('button').detach();
64
-
64
+
65
65
  header
66
66
  .empty()
67
67
  .append( '<h4 class="modal-title">'+options.header( row )+'</h4>' )
68
- .prepend( button );
68
+ .append( button );
69
69
  }
70
70
 
71
71
  _modal.find( 'div.modal-body' )
@@ -2,22 +2,22 @@
2
2
  //= require vendor/jquery.fileDownload
3
3
 
4
4
  //= require dataTables/jquery.dataTables
5
- //= require dataTables/dataTables.bootstrap
5
+ //= require dataTables/dataTables.bootstrap4
6
6
 
7
7
  //= require dataTables/buttons/dataTables.buttons
8
- //= require dataTables/buttons/buttons.bootstrap
8
+ //= require dataTables/buttons/buttons.bootstrap4
9
9
  //= require dataTables/buttons/buttons.colVis
10
10
  //= require dataTables/buttons/buttons.html5
11
11
  //= require dataTables/buttons/buttons.print
12
12
  //= require dataTables/responsive/dataTables.responsive
13
- //= require dataTables/responsive/responsive.bootstrap
13
+ //= require dataTables/responsive/responsive.bootstrap4
14
14
 
15
15
  //= require effective_datatables/bulk_actions
16
16
  //= require effective_datatables/events
17
17
  //= require effective_datatables/filters
18
- //= require effective_datatables/flash
19
18
  //= require effective_datatables/reset
20
19
  //= require effective_datatables/responsive
20
+ //= require effective_datatables/overrides
21
21
 
22
22
  //= require effective_datatables/charts
23
23
  //= require effective_datatables/initialize
@@ -1,66 +1,50 @@
1
1
  #### Checkbox toggling and Bulk Actions dropdown disabling
2
2
 
3
- $(document).on 'change', ".dataTables_wrapper input[data-role='bulk-action']", (event) ->
3
+ $(document).on 'change', "input[data-role='bulk-actions-resource']", (event) ->
4
4
  $wrapper = $(event.currentTarget).closest('.dataTables_wrapper')
5
5
 
6
- $wrapper.find("input[data-role='bulk-actions']").prop('checked', false)
7
- toggleDropdown($wrapper)
6
+ $wrapper.find("input[data-role='bulk-actions-all']").prop('checked', false)
7
+ toggleClosestBulkActionsButton($wrapper)
8
8
 
9
- $(document).on 'change', ".dataTables_wrapper input[data-role='bulk-actions']", (event) ->
9
+ $(document).on 'change', "input[data-role='bulk-actions-all']", (event) ->
10
10
  $wrapper = $(event.currentTarget).closest('.dataTables_wrapper')
11
- $resources = $wrapper.find("input[data-role='bulk-action']")
11
+ $resources = $wrapper.find("input[data-role='bulk-actions-resource']")
12
12
 
13
13
  if $(event.currentTarget).is(':checked')
14
14
  $resources.prop('checked', true)
15
15
  else
16
16
  $resources.prop('checked', false)
17
17
 
18
- toggleDropdown($wrapper)
18
+ toggleClosestBulkActionsButton($wrapper)
19
19
 
20
- toggleDropdown = ($wrapper) ->
20
+ toggleClosestBulkActionsButton = ($wrapper) ->
21
21
  $bulkActions = $wrapper.children().first().find('.buttons-bulk-actions').children('button')
22
22
 
23
- if $wrapper.find("input[data-role='bulk-action']:checked").length > 0
23
+ if $wrapper.find("input[data-role='bulk-actions-resource']:checked").length > 0
24
24
  $bulkActions.removeAttr('disabled')
25
25
  else
26
26
  $bulkActions.attr('disabled', 'disabled')
27
27
 
28
- restoreSelected = ($table, selected) ->
29
- $bulkActions = $table.closest('.dataTables_wrapper').children().first().find('.buttons-bulk-actions').children('button')
30
- present = false
31
-
32
- if selected && selected.length > 0
33
- $table.find("input[data-role='bulk-action']").each (_, input) ->
34
- $input = $(input)
35
-
36
- if selected.indexOf($input.val()) > -1
37
- $input.prop('checked', true)
38
- present = true
39
- else
40
- $input.prop('checked', false)
41
-
42
- if present then $bulkActions.removeAttr('disabled') else $bulkActions.attr('disabled', 'disabled')
43
28
 
44
29
  #### Bulk Action link behaviour
45
- $(document).on 'click', '.dataTables_wrapper .buttons-bulk-actions a', (event) ->
30
+ $(document).on 'click', '.buttons-bulk-actions a', (event) ->
46
31
  event.preventDefault() # prevent the click
47
32
 
48
33
  $bulkAction = $(event.currentTarget) # This is a regular <a href=...> tag
49
34
  $wrapper = $bulkAction.closest('.dataTables_wrapper')
50
35
  $table = $wrapper.find('table.dataTable').first()
51
36
  $processing = $table.siblings('.dataTables_processing').first()
52
- $selected = $table.find("input[data-role='bulk-action']:checked")
37
+ $selected = $table.find("input[data-role='bulk-actions-resource']:checked")
53
38
 
54
39
  url = $bulkAction.attr('href')
55
40
  title = $bulkAction.text()
56
- download = $bulkAction.data('bulk-download')
57
- token = $table.data('authenticity-token')
41
+ token = $bulkAction.parent('li').data('authenticity-token')
58
42
  values = $.map($selected, (input) -> input.getAttribute('value'))
59
- method = $bulkAction.data('ajax-method')
43
+ get_link = $bulkAction.data('bulk-actions-get')
60
44
 
61
45
  return unless url && values
62
46
 
63
- if method == 'GET'
47
+ if get_link
64
48
  if url.includes('?')
65
49
  window.location.assign(url + '&' + $.param({ids: values}))
66
50
  else
@@ -71,36 +55,52 @@ $(document).on 'click', '.dataTables_wrapper .buttons-bulk-actions a', (event) -
71
55
  # Disable the Bulk Actions dropdown, so only one can be run at a time
72
56
  $bulkAction.closest('button').attr('disabled', 'disabled')
73
57
 
74
- $table.dataTable().data('bulk-actions-restore-selected-values', values)
58
+ # Show Processing...
59
+ $processing.show().data('bulk-actions-processing', true)
75
60
 
76
- if download # This is a file download
61
+ if token # This is a file download
77
62
  $.fileDownload(url,
78
63
  httpMethod: 'POST',
79
64
  data: { ids: values, authenticity_token: token }
80
65
  successCallback: ->
81
66
  success = "Successfully completed #{title} bulk action"
82
- $table.one 'draw.dt', (e) -> $(e.target).DataTable().flash(success, 'success') and restoreSelected($(e.target), values)
67
+ $processing.html(success)
68
+ $table.dataTable().data('bulk-actions-restore-selected-values', values)
83
69
  $table.DataTable().draw()
84
70
  failCallback: ->
85
71
  error = "An error occured while attempting #{title} bulk action"
86
- $table.one 'draw.dt', (e) -> $(e.target).DataTable().flash(error, 'danger') and restoreSelected($(e.target), values)
72
+ $processing.html(error)
73
+ alert(error)
74
+ $table.dataTable().data('bulk-actions-restore-selected-values', values)
87
75
  $table.DataTable().draw()
88
76
  )
89
77
  else # Normal AJAX post
90
- $table.dataTable().data('bulk-actions-restore-selected-values', values)
91
-
92
- $.ajax(
93
- method: method,
94
- url: url,
95
- data: { ids: values, authenticity_token: token }
78
+ $.post(
79
+ url, { ids: values }
96
80
  ).done((response) ->
97
81
  success = response['message'] || "Successfully completed #{title} bulk action"
98
- $table.one 'draw.dt', (e) -> $(e.target).DataTable().flash(success, 'success') and restoreSelected($(e.target), values)
99
-
82
+ $processing.html(success)
100
83
  ).fail((response) ->
101
84
  error = response['message'] || "An error occured while attempting #{title} bulk action: #{response.statusText}"
102
- $table.one 'draw.dt', (e) -> $(e.target).DataTable().flash(error, 'danger') and restoreSelected($(e.target), values)
103
-
85
+ $processing.html(error)
86
+ alert(error)
104
87
  ).always((response) ->
88
+ $table.dataTable().data('bulk-actions-restore-selected-values', values)
105
89
  $table.DataTable().draw()
106
90
  )
91
+
92
+ # We borrow the Processing div for our bulk action success/error messages
93
+ # This makes sure that the message is displayed for 1500ms
94
+ $(document).on 'processing.dt', (event, settings, visible) ->
95
+ return if settings.bDestroying
96
+
97
+ $processing = $(event.target).siblings('.dataTables_processing').first()
98
+ return unless $processing.data('bulk-actions-processing')
99
+
100
+ timeout = $processing.show().data('timeout')
101
+ clearTimeout(timeout) if timeout
102
+ $processing.data('timeout', setTimeout( =>
103
+ $processing.html('Processing...').hide()
104
+ $processing.data('bulk-actions-processing', null)
105
+ , 1500)
106
+ )
@@ -8,13 +8,16 @@ $(document).on 'column-visibility.dt', (event, settings, index, state) ->
8
8
  clearTimeout(timeout) if timeout
9
9
  $table.data('timeout', setTimeout( =>
10
10
  $table.DataTable().draw()
11
- $.event.trigger('page:change')
11
+ $table.trigger('effective-bootstrap:initialize')
12
12
  , 700)
13
13
  )
14
+ true
14
15
 
15
16
  # Remove empty label (bulk actions) from ColVis dropdown
16
- $(document).on 'click.dtb-collection', (event) ->
17
- $colvis = $('.dt-button-collection:not(.initialized)')
17
+ $(document).on 'click', 'a.buttons-colvis:not(.initialized)', (event) ->
18
+ $colvis = $('.dt-button-collection')
18
19
  return if $colvis.length == 0
19
20
 
20
- $colvis.addClass('initialized').find('li > a:empty').each -> $(this).parent().remove()
21
+ $colvis.find('a > span:empty').each -> $(this).parent().remove()
22
+ $colvis.find('a.buttons-colvisGroup').first().before("<div class='dropdown-divider'></div>")
23
+ $(event.currentTarget).addClass('initialized')
@@ -1,4 +1,3 @@
1
- # Don't scope by .datatables_wrapper here, because it's out of the wrapper!
2
1
  $(document).on 'click', 'a[data-apply-effective-datatables-filters]', (event) ->
3
2
  event.preventDefault()
4
3
  $form = $(event.currentTarget).closest('.effective-datatables-filters')
@@ -1,9 +1,11 @@
1
- initializeDataTables = (target) ->
2
- $(target || document).find('table.effective-datatable:not(.initialized)').each ->
1
+ initializeDataTables = ->
2
+ $('table.effective-datatable').each ->
3
+ return if $.fn.DataTable.fnIsDataTable(this)
4
+
3
5
  datatable = $(this)
4
6
  options = datatable.data('options') || {}
5
7
  buttons_export_columns = options['buttons_export_columns'] || ':not(.col-actions)'
6
- reorder = datatable.data('reorder')
8
+ simple = ('' + datatable.data('simple') == 'true')
7
9
 
8
10
  if options['buttons'] == false
9
11
  options['buttons'] = []
@@ -14,10 +16,10 @@ initializeDataTables = (target) ->
14
16
  buttons: [
15
17
  {
16
18
  extend: 'colvis',
19
+ text: 'Show / Hide',
17
20
  postfixButtons: [
18
- { extend: 'colvisGroup', text: 'Show all', show: ':hidden', className: 'buttons-colvisGroup-first'},
19
- { extend: 'colvisGroup', text: 'Show none', hide: ':visible' },
20
- { extend: 'colvisGroup', text: 'Show default', hide: ':not(.colvis-default)', show: '.colvis-default' }
21
+ { extend: 'colvisGroup', text: 'Show all', show: ':hidden'},
22
+ { extend: 'colvisRestore', text: 'Show default'}
21
23
  ]
22
24
  },
23
25
  {
@@ -47,8 +49,9 @@ initializeDataTables = (target) ->
47
49
  deferLoading: [datatable.data('display-records'), datatable.data('total-records')]
48
50
  deferRender: true
49
51
  displayStart: datatable.data('display-start')
52
+ dom: "<'row'<'col-sm-12 dataTables_buttons'B>><'row'<'col-sm-12'tr>><'row'<'col-sm-6 dataTables_entries'il><'col-sm-6'p>>"
50
53
  iDisplayLength: datatable.data('display-length')
51
- language: datatable.data('language')
54
+ language: { 'lengthMenu': '&nbsp;with _MENU_ per page'}
52
55
  lengthMenu: [[5, 10, 25, 50, 100, 250, 500, 9999999], ['5', '10', '25', '50', '100', '250', '500', 'All']]
53
56
  order: datatable.data('display-order')
54
57
  processing: true
@@ -60,33 +63,23 @@ initializeDataTables = (target) ->
60
63
  $table = $(api.table().node())
61
64
  $form = $(".effective-datatables-filters[aria-controls='#{$table.attr('id')}']").first()
62
65
 
63
- params['attributes'] = $table.data('attributes')
64
- params['authenticity_token'] = $table.data('authenticity-token')
66
+ params['cookie'] = $table.data('cookie')
65
67
 
66
68
  if $form.length > 0
67
69
  params['scope'] = $form.find("input[name='filters[scope]']:checked").val() || ''
68
70
  params['filter'] = {}
69
71
 
70
- $form.find("select,textarea,input:not([type=submit])").each ->
72
+ $form.find("select,textarea,input:not([type=submit]):not([name='filters[scope]'])").each ->
71
73
  $input = $(this)
72
-
73
- if ['utf8', 'authenticity_token', 'filters[scope]'].includes($input.attr('name'))
74
- # Skipped
75
- else if $input.attr('type') == 'radio'
76
- name = $input.attr('name')
77
- filter_name = name.replace('filters[', '').substring(0, name.length-9)
78
-
79
- params['filter'][filter_name] = $form.find("input[name='#{name}']:checked").val()
80
-
81
- else if $input.attr('id')
82
- filter_name = $input.attr('id').replace('filters_', '')
83
- params['filter'][filter_name] = $input.val()
74
+ if $input.attr('id')
75
+ params['filter'][$input.attr('id').substring(8, $input.attr('id').length)] = $input.val()
84
76
 
85
77
  serverSide: true
86
78
  scrollCollapse: true
87
79
  pagingType: 'simple_numbers'
88
80
  initComplete: (settings) ->
89
- initializeButtons(this.api())
81
+ initializeReset(this.api())
82
+ initializeBulkActions(this.api())
90
83
  initializeSearch(this.api())
91
84
  drawCallback: (settings) ->
92
85
  $table = $(this.api().table().node())
@@ -102,21 +95,36 @@ initializeDataTables = (target) ->
102
95
  if settings['json']['charts']
103
96
  drawCharts($table, settings['json']['charts'])
104
97
 
105
- $table.children('tbody').trigger('effective-bootstrap:initialize')
98
+ drawBulkActions($table)
106
99
 
107
100
  # Copies the bulk actions html, stored in a data attribute on the table, into the buttons area
108
- initializeButtons = (api) ->
101
+ initializeBulkActions = (api) ->
102
+ $table = $(api.table().node())
103
+
104
+ if $table.data('bulk-actions')
105
+ $table.closest('.dataTables_wrapper').children().first().find('.dt-buttons').prepend($table.data('bulk-actions'))
106
+
107
+ initializeReset = (api) ->
109
108
  $table = $(api.table().node())
110
- $buttons = $table.closest('.dataTables_wrapper').children().first().find('.dt-buttons')
111
109
 
112
110
  if $table.data('reset')
113
- $buttons.prepend($table.data('reset'))
111
+ $table.closest('.dataTables_wrapper').children().first().find('.dt-buttons').prepend($table.data('reset'))
114
112
 
115
- if $table.data('reorder')
116
- $buttons.prepend($table.data('reorder'))
113
+ # After we perform a bulk action, we have to re-select the checkboxes manually and do a bit of house keeping
114
+ drawBulkActions = ($table) ->
115
+ selected = $table.data('bulk-actions-restore-selected-values')
117
116
 
118
- if $table.data('bulk-actions')
119
- $buttons.prepend($table.data('bulk-actions'))
117
+ $bulkActions = $table.closest('.dataTables_wrapper').children().first().find('.buttons-bulk-actions').children('button')
118
+
119
+ if selected && selected.length > 0
120
+ $table.find("input[data-role='bulk-actions-resource']").each (_, input) ->
121
+ $input = $(input)
122
+ $input.prop('checked', selected.indexOf($input.val()) > -1)
123
+
124
+ $bulkActions.removeAttr('disabled')
125
+ $table.data('bulk-actions-restore-selected-values', [])
126
+ else
127
+ $bulkActions.attr('disabled', 'disabled')
120
128
 
121
129
  drawAggregates = ($table, aggregates) ->
122
130
  $tfoot = $table.find('tfoot').first()
@@ -156,13 +164,11 @@ initializeDataTables = (target) ->
156
164
 
157
165
  $input.parent().on 'click', (event) -> false # Dont order columns when you click inside the input
158
166
  $input.parent().on 'mousedown', (event) -> event.stopPropagation() # Dont order columns when you click inside the input
159
- $input.parent().on 'keypress', (event) -> event.stopPropagation() # Don't order columns when you type inside the input
160
167
 
161
168
  if $input.is('select')
162
169
  $input.on 'change', (event) -> dataTableSearch($(event.currentTarget))
163
170
  else if $input.is('input')
164
171
  $input.delayedChange ($input) -> dataTableSearch($input)
165
- $input.on('paste', -> dataTableSearch($input))
166
172
 
167
173
  # Do the actual search
168
174
  dataTableSearch = ($input) -> # This is the function called by a select or input to run the search
@@ -171,32 +177,22 @@ initializeDataTables = (target) ->
171
177
  table = $input.closest('table.dataTable')
172
178
  table.DataTable().column("#{$input.data('column-name')}:name").search($input.val()).draw()
173
179
 
174
- if reorder
175
- init_options['rowReorder'] = { selector: 'td.col-_reorder', snapX: true, dataSrc: datatable.data('reorder-index') }
180
+ if simple
181
+ init_options['dom'] = "<'row'<'col-sm-12'tr>>" # Just show the table
182
+ datatable.addClass('simple')
176
183
 
177
184
  # Let's actually initialize the table now
178
185
  table = datatable.dataTable(jQuery.extend(init_options, options))
179
186
 
180
- # Fix a tabindex issue
181
- table.children('tbody').children('tr').children('td[tabindex]').removeAttr('tabindex')
182
-
183
187
  # Apply EffectiveFormInputs to the Show x per page dropdown
184
188
  try table.closest('.dataTables_wrapper').find('.dataTables_length select').removeAttr('name').select2(minimumResultsForSearch: 100)
185
189
 
186
- if reorder
187
- table.DataTable().on('row-reorder', (event, diff, edit) -> $(event.target).DataTable().reorder(event, diff, edit))
188
-
189
- table.addClass('initialized')
190
- table.children('thead').trigger('effective-bootstrap:initialize')
191
- true
192
-
193
190
  destroyDataTables = ->
194
- $('.effective-datatables-inline-expanded').removeClass('effective-datatables-inline-expanded')
195
- $('table.effective-datatable').each -> try $(this).removeClass('initialized').DataTable().destroy()
191
+ $('table.effective-datatable').each ->
192
+ if $.fn.DataTable.fnIsDataTable(this)
193
+ $(this).DataTable().destroy()
196
194
 
197
195
  $ -> initializeDataTables()
198
- $(document).on 'effective-datatables:initialize', (event) -> initializeDataTables(event.currentTarget)
199
-
200
196
  $(document).on 'page:change', -> initializeDataTables()
201
197
  $(document).on 'turbolinks:load', -> initializeDataTables()
202
198
  $(document).on 'turbolinks:render', -> initializeDataTables()
@@ -0,0 +1,12 @@
1
+ $.extend(true, $.fn.dataTable.Buttons.defaults, {
2
+ dom: {
3
+ button: {
4
+ className: 'btn btn-link btn-sm'
5
+ }
6
+ }
7
+ });
8
+
9
+ /* Default class modification */
10
+ $.extend($.fn.dataTable.ext.classes, {
11
+ sWrapper: 'dataTables_wrapper dt-bootstrap4', // Remove container-fluid
12
+ });
@@ -1,4 +1,4 @@
1
- $(document).on 'click', '.dataTables_wrapper a.buttons-reset-search', (event) ->
1
+ $(document).on 'click', 'a.buttons-reset-search', (event) ->
2
2
  event.preventDefault() # prevent the click
3
3
 
4
4
  $table = $(event.currentTarget).closest('.dataTables_wrapper').find('table.dataTable').first()
@@ -108,6 +108,73 @@ ul.dt-button-collection.dropdown-menu.four-column {
108
108
  -o-column-count: 4;
109
109
  column-count: 4;
110
110
  }
111
+ ul.dt-button-collection.dropdown-menu .dt-button {
112
+ border-radius: 0;
113
+ }
114
+
115
+ ul.dt-button-collection {
116
+ -webkit-column-gap: 8px;
117
+ -moz-column-gap: 8px;
118
+ -ms-column-gap: 8px;
119
+ -o-column-gap: 8px;
120
+ column-gap: 8px;
121
+ }
122
+ ul.dt-button-collection.fixed {
123
+ position: fixed;
124
+ top: 50%;
125
+ left: 50%;
126
+ margin-left: -75px;
127
+ border-radius: 0;
128
+ }
129
+ ul.dt-button-collection.fixed.two-column {
130
+ margin-left: -150px;
131
+ }
132
+ ul.dt-button-collection.fixed.three-column {
133
+ margin-left: -225px;
134
+ }
135
+ ul.dt-button-collection.fixed.four-column {
136
+ margin-left: -300px;
137
+ }
138
+ ul.dt-button-collection > * {
139
+ -webkit-column-break-inside: avoid;
140
+ break-inside: avoid;
141
+ }
142
+ ul.dt-button-collection.two-column {
143
+ width: 300px;
144
+ padding-bottom: 1px;
145
+ -webkit-column-count: 2;
146
+ -moz-column-count: 2;
147
+ -ms-column-count: 2;
148
+ -o-column-count: 2;
149
+ column-count: 2;
150
+ }
151
+ ul.dt-button-collection.three-column {
152
+ width: 450px;
153
+ padding-bottom: 1px;
154
+ -webkit-column-count: 3;
155
+ -moz-column-count: 3;
156
+ -ms-column-count: 3;
157
+ -o-column-count: 3;
158
+ column-count: 3;
159
+ }
160
+ ul.dt-button-collection.four-column {
161
+ width: 600px;
162
+ padding-bottom: 1px;
163
+ -webkit-column-count: 4;
164
+ -moz-column-count: 4;
165
+ -ms-column-count: 4;
166
+ -o-column-count: 4;
167
+ column-count: 4;
168
+ }
169
+ ul.dt-button-collection .dt-button {
170
+ border-radius: 0;
171
+ }
172
+ ul.dt-button-collection.fixed {
173
+ max-width: none;
174
+ }
175
+ ul.dt-button-collection.fixed:before, ul.dt-button-collection.fixed:after {
176
+ display: none;
177
+ }
111
178
 
112
179
  div.dt-button-background {
113
180
  position: fixed;
@@ -115,7 +182,7 @@ div.dt-button-background {
115
182
  left: 0;
116
183
  width: 100%;
117
184
  height: 100%;
118
- z-index: 2001;
185
+ z-index: 999;
119
186
  }
120
187
 
121
188
  @media screen and (max-width: 767px) {