effective_datatables 4.3.3 → 4.3.4

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: 4fe669a7536deb43686a84bb9fc15f93f76eaf84
4
- data.tar.gz: 86359d4b303b234f904c51b9bf0eeb846d924c57
3
+ metadata.gz: 4dabd6230608916ad4260f443412c2b81bb4ec80
4
+ data.tar.gz: 26a82f35207f348157706794fcb818a1b58e77db
5
5
  SHA512:
6
- metadata.gz: f76787e95bab3aa54d510e9dbb2d69215ec74bc9ef061ecc7eb692fecd98298af9053d3ec5196d39b537aca0f67713833418536563c97e67a4191bed0eca64d9
7
- data.tar.gz: 297ccbf127f6e1d4871c13294f67bef61ea2ddddeeafa89244d208b7b016c7517106b2999cca213361630de3c2185e5b7dab0c71678e4e03bb995c121840e0e0
6
+ metadata.gz: 17fd09f4caa9cfd14798fe9744a627e355f4f90504cb40a02943b35155fe25d15a4e7708bfab3d4a167b1acd3a9260ba2d8fa95117566cb085b21679099258de
7
+ data.tar.gz: b31833cadf5f81ba9e5e7cb69260891fb2498647b872243afd9cec216070ff8c9d40be2da3137b78b06ff60b21f766d2ea081cbc2f6c2dd77e3a10b68868dbaf
data/README.md CHANGED
@@ -545,6 +545,10 @@ actions_col do |post|
545
545
  end
546
546
  ```
547
547
 
548
+ Any `data-remote` actions will be hijacked and performed as inline ajax by datatables.
549
+
550
+ If you'd like to opt-out of this behavior, use `actions_col(inline: false)` or add `data-inline: false` to your action link.
551
+
548
552
  ### length
549
553
 
550
554
  Sets the default number of rows per page. Valid lengths are `5`, `10`, `25`, `50`, `100`, `250`, `500`, `:all`
@@ -2,10 +2,12 @@
2
2
  # This works with EffectiveForm.remote_form which is part of the effective_bootstrap gem.
3
3
 
4
4
  # About to do a resource action, or fetch a partial. Show loading.
5
- $(document).on 'ajax:beforeSend', '.dataTables_wrapper', (e, xhr, settings) ->
5
+ $(document).on 'ajax:beforeSend', '.dataTables_wrapper .col-actions', (e, xhr, settings) ->
6
6
  $action = $(e.target)
7
7
  $table = $(e.target).closest('table')
8
8
 
9
+ return true if ('' + $action.data('inline')) == 'false'
10
+
9
11
  $params = $.param({_datatable_id: $table.attr('id'), _datatable_cookie: $table.data('cookie') })
10
12
  settings.url += (if settings.url.indexOf('?') == -1 then '?' else '&') + $params
11
13
 
@@ -19,8 +21,10 @@ $(document).on 'ajax:beforeSend', '.dataTables_wrapper', (e, xhr, settings) ->
19
21
  true
20
22
 
21
23
  # We have either completed the resource action, or fetched the inline form to load.
22
- $(document).on 'ajax:success', '.dataTables_wrapper', (e) ->
23
- $action = $(e.target)
24
+ $(document).on 'ajax:success', '.dataTables_wrapper .col-actions', (event) ->
25
+ $action = $(event.target)
26
+
27
+ return true if ('' + $action.data('inline')) == 'false'
24
28
 
25
29
  if ($action.data('method') || 'get') == 'get'
26
30
  if $action.closest('tr').parent().prop('tagName') == 'THEAD' then afterNew($action) else afterEdit($action)
@@ -32,8 +36,10 @@ $(document).on 'ajax:success', '.dataTables_wrapper', (e) ->
32
36
  true
33
37
 
34
38
  # The inline form has been submitted successfully
35
- $(document).on '.dataTables_wrapper effective-form:success', (event, flash) ->
36
- $tr = $(event.target).closest('tr')
39
+ $(document).on '.dataTables_wrapper .col-inline-form effective-form:success', (event, flash) ->
40
+ $action = $(event.target)
41
+
42
+ $tr = $action.closest('tr')
37
43
  $table = $tr.closest('table')
38
44
 
39
45
  if $tr.hasClass('effective-datatables-new-resource')
@@ -48,8 +54,8 @@ $(document).on '.dataTables_wrapper effective-form:success', (event, flash) ->
48
54
  $tr.fadeOut('slow')
49
55
 
50
56
  # There was an error completing something
51
- $(document).on 'ajax:error', '.dataTables_wrapper', (e) ->
52
- $action = $(e.target)
57
+ $(document).on 'ajax:error', '.dataTables_wrapper .col-inline-form', (event) ->
58
+ $action = $(event.target)
53
59
  $table = $action.closest('table')
54
60
  $table.DataTable().flash('Error: unable to ' + ($action.attr('title') || 'complete action')).draw()
55
61
 
@@ -28,13 +28,4 @@ flash = (message) ->
28
28
 
29
29
  return @
30
30
 
31
- turboDestroy = ->
32
- @iterator('table', (settings) ->
33
- $(window).off('.DT-' + settings.sInstance)
34
-
35
- index = $.inArray(settings, $.fn.DataTable.settings)
36
- $.fn.DataTable.settings.splice(index, 1) if index > -1
37
- )
38
-
39
31
  $.fn.DataTable.Api.register('flash()', flash);
40
- $.fn.DataTable.Api.register('turboDestroy()', turboDestroy);
@@ -67,6 +67,7 @@ module EffectiveDatatablesPrivateHelper
67
67
  )
68
68
  when :select, :boolean
69
69
  options[:input_js] = (options[:input_js] || {}).reverse_merge(placeholder: '')
70
+
70
71
  form.select name, collection, options
71
72
  when :bulk_actions
72
73
  options[:data]['role'] = 'bulk-actions'
@@ -95,12 +96,12 @@ module EffectiveDatatablesPrivateHelper
95
96
  value = datatable.state[:filter][name]
96
97
 
97
98
  options = opts.except(:parse).merge(
98
- placeholder: placeholder,
99
+ autocomplete: 'off',
99
100
  feedback: false,
100
101
  label: false,
102
+ placeholder: placeholder,
101
103
  value: value,
102
- wrapper: { class: 'form-group col-auto'},
103
- autocomplete: 'off'
104
+ wrapper: { class: 'form-group col-auto'}
104
105
  )
105
106
 
106
107
  options[:name] = '' unless datatable._filters_form_required?
@@ -120,6 +121,22 @@ module EffectiveDatatablesPrivateHelper
120
121
  end
121
122
  end
122
123
 
124
+ def datatable_scope_tag(form, datatable, opts = {})
125
+ collection = datatable._scopes.map { |name, opts| [opts[:label], name] }
126
+
127
+ options = {
128
+ autocomplete: 'off',
129
+ buttons: true,
130
+ checked: datatable.state[:scope],
131
+ feedback: false,
132
+ label: false,
133
+ required: false,
134
+ wrapper: { class: 'form-group col-auto'}
135
+ }.merge(opts)
136
+
137
+ form.radios :scope, collection, options
138
+ end
139
+
123
140
  def render_datatable_charts(datatable)
124
141
  raise 'expected datatable to be present' unless datatable
125
142
 
@@ -2,9 +2,7 @@
2
2
  = effective_form_with(scope: :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb]) do |form|
3
3
  .form-row.align-items-center
4
4
  - if datatable._scopes.present?
5
- = form.radios :scope, datatable._scopes.map { |name, opts| [opts[:label], name] },
6
- label: false, required: false, checked: datatable.state[:scope], buttons: true,
7
- wrapper: { class: 'form-group col-auto' }
5
+ = datatable_scope_tag(form, datatable)
8
6
 
9
7
  - datatable._filters.each do |name, opts|
10
8
  = datatable_filter_tag(form, datatable, name, opts)
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.3.3'.freeze
2
+ VERSION = '4.3.4'.freeze
3
3
  end
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.3.3
4
+ version: 4.3.4
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: 2018-09-19 00:00:00.000000000 Z
11
+ date: 2018-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails