effective_datatables 4.5.0 → 4.5.1

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: 5a53e65ef62ff9d0a782a0080f6a9deadd22b609
4
- data.tar.gz: ac4e5578e12e9bef11b5093bff3fee1c7443a67d
3
+ metadata.gz: 31a344040059c64f97f81b5e6bab69a4e847ceb5
4
+ data.tar.gz: fc9adcb63f54ff31c7ed5f43f742f789bd7758f6
5
5
  SHA512:
6
- metadata.gz: 039ca9d10af887b4949882b743cfc60f76e4247374595f80400c2b43850892be2149d51b0fc66e357029006100d8f9734e347840bd61d76c3eaaa142092e56cf
7
- data.tar.gz: f7f922a6ec951c3f20b83c1b478f5cc580136c35dfc9d9c8a06fb4dd4947a2f7f25da6525c6fd87e2ff673bb649f3f125a594798daa8231e1348042cb4d25a0f
6
+ metadata.gz: 6c650bb8a060b85d5bc82fb03ba6da4bb9a11749f5065b5e990fc5480cbe27eed332f25ee6aa913caedfcd4167521d0009927d99f29a4b7dd6af1654b8eb2826
7
+ data.tar.gz: f5ef7aa35f0574428a6ddb7acf50c58e2b9ad471080c605e0ffb3d8895097cef601dc2216ada0dde25825c330dd06fd90ff620b4c6f6413ca152f6d8ff88d6ea
@@ -53,7 +53,7 @@ $(document).on 'click', '.dataTables_wrapper .buttons-bulk-actions a', (event) -
53
53
 
54
54
  url = $bulkAction.attr('href')
55
55
  title = $bulkAction.text()
56
- downloadToken = $bulkAction.parent('li').data('authenticity-token')
56
+ download = $bulkAction.data('bulk-download')
57
57
  token = $table.data('authenticity-token')
58
58
  values = $.map($selected, (input) -> input.getAttribute('value'))
59
59
  method = $bulkAction.data('ajax-method')
@@ -73,10 +73,10 @@ $(document).on 'click', '.dataTables_wrapper .buttons-bulk-actions a', (event) -
73
73
 
74
74
  $table.dataTable().data('bulk-actions-restore-selected-values', values)
75
75
 
76
- if downloadToken # This is a file download
76
+ if download # This is a file download
77
77
  $.fileDownload(url,
78
78
  httpMethod: 'POST',
79
- data: { ids: values, authenticity_token: downloadToken }
79
+ data: { ids: values, authenticity_token: token }
80
80
  successCallback: ->
81
81
  success = "Successfully completed #{title} bulk action"
82
82
  $table.one 'draw.dt', (e) -> $(e.target).DataTable().flash(success, 'success')
@@ -57,7 +57,7 @@ module EffectiveDatatablesHelper
57
57
  'simple' => simple.to_s,
58
58
  'spinner' => icon('spinner'), # effective_bootstrap
59
59
  'source' => effective_datatables.datatable_path(datatable, {format: 'json'}),
60
- 'total-records' => datatable.to_json[:recordsTotal],
60
+ 'total-records' => datatable.to_json[:recordsTotal]
61
61
  }
62
62
  }
63
63
 
@@ -114,8 +114,7 @@ module EffectiveDatatablesPrivateHelper
114
114
  end
115
115
 
116
116
  def datatable_filter_tag(form, datatable, name, opts)
117
- as = opts.delete(:as).to_s.chomp('_field').to_sym
118
- collection = opts.delete(:collection)
117
+ as = opts[:as].to_s.chomp('_field').to_sym
119
118
  value = datatable.state[:filter][name]
120
119
 
121
120
  options = {
@@ -125,13 +124,13 @@ module EffectiveDatatablesPrivateHelper
125
124
  placeholder: (opts[:label] || name.to_s.titleize),
126
125
  value: value,
127
126
  wrapper: { class: 'form-group col-auto'}
128
- }.merge(opts.except(:parse))
127
+ }.merge(opts.except(:as, :collection, :parse))
129
128
 
130
129
  options[:name] = '' unless datatable._filters_form_required?
131
130
 
132
- if collection.present?
131
+ if [:select, :radios, :checks].include?(as)
133
132
  options.delete(:name) unless as == :select
134
- form.public_send(as, name, collection, options) # select, radios, checks
133
+ form.public_send(as, name, opts[:collection], options) # select, radios, checks
135
134
  elsif form.respond_to?(as)
136
135
  form.public_send(as, name, options) # check_box, text_area
137
136
  else
@@ -3,12 +3,12 @@ module Effective
3
3
  module Dsl
4
4
  module BulkActions
5
5
 
6
- def bulk_action(*args)
7
- datatable._bulk_actions.push(link_to_bulk_action(*args))
6
+ def bulk_action(title, url, opts = {})
7
+ datatable._bulk_actions.push(link_to_bulk_action(title, url, opts))
8
8
  end
9
9
 
10
- def bulk_download(*args)
11
- datatable._bulk_actions.push(link_to_bulk_action(*args.merge('data-authenticity-token' => form_authenticity_token, 'data-method' => :post)))
10
+ def bulk_download(title, url, opts = {})
11
+ datatable._bulk_actions.push(link_to_bulk_action(title, url, opts.merge('data-bulk-download': true)))
12
12
  end
13
13
 
14
14
  def bulk_action_divider
@@ -22,7 +22,7 @@ module Effective
22
22
  private
23
23
 
24
24
  # We can't let any data-method be applied to the link, or jquery_ujs does the wrong thing with it
25
- def link_to_bulk_action(body, url, opts = {})
25
+ def link_to_bulk_action(title, url, opts = {})
26
26
 
27
27
  # Transform data: { ... } hash into 'data-' keys
28
28
  if (data = opts.delete(:data))
@@ -34,7 +34,7 @@ module Effective
34
34
 
35
35
  opts[:class] = [opts[:class], 'dropdown-item'].compact.join(' ')
36
36
 
37
- link_to(body, url, opts)
37
+ link_to(title, url, opts)
38
38
  end
39
39
 
40
40
  end
@@ -5,7 +5,7 @@ module Effective
5
5
  def filter(name = nil, value = :_no_value, as: nil, label: nil, parse: nil, required: false, **input_html)
6
6
  return datatable.filter if (name == nil && value == :_no_value) # This lets block methods call 'filter' and get the values
7
7
 
8
- raise 'expected second argument to be a value' if value == :_no_value
8
+ raise 'expected second argument to be a value. the default value for this filter.' if value == :_no_value
9
9
  raise 'parse must be a Proc' if parse.present? && !parse.kind_of?(Proc)
10
10
 
11
11
  # Merge search
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.5.0'.freeze
2
+ VERSION = '4.5.1'.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.5.0
4
+ version: 4.5.1
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: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2019-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails