effective_datatables 3.3.5 → 3.3.6

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: 0d7792aa079e82cd58a5ee658a5a8454d3ac1301
4
- data.tar.gz: da718d66a6ca3389ece9b34391922dadae5b935f
3
+ metadata.gz: 80ef322422055559272f3145551bff1357ee74e5
4
+ data.tar.gz: 28bc97f374afb93abd7bf5a8007044a37afffef7
5
5
  SHA512:
6
- metadata.gz: b45cb2de1ee4a1b6c1ed15d1e048c612a70ec736b229bfa54f631ffa7960d00108b2dd84cadf48a336a9d2d07a09532ad81e7d1c62d556d38efaeb062971d6d3
7
- data.tar.gz: ee93bad3e2c85ba5b873e9fee967518dc2425cabe4d204d632cf661a9c8dcd9ef22589b050ea0ca5f42c5871cc9fddac4d48a884eb61ae990e69487eae7cc97a
6
+ metadata.gz: 8ca29bb7239a4e4b526b628053926b7308020b01c41b3d4ca557eaff74be562f6c90df91b356794ab88a9bcdb35125d473d5927d34f9340fcfb2e4fd466f34df
7
+ data.tar.gz: d5d5ed8d06bc00aae6a3bfd046830d9f7f2d428ce95d6b3893698d29ed18a0f6d7b999f5f1fcde49fe5d43209cd33c9bb366e0f2be9bc0c4475b5118cf981f2b
data/README.md CHANGED
@@ -705,7 +705,9 @@ Creates a link that becomes clickable when one or more checkbox/rows are selecte
705
705
 
706
706
  A controller action must be created to accept a POST with an array of selected ids, `params[:ids]`.
707
707
 
708
- This is a pass-through to `link_to` and accepts all the same options, except that the method `POST` is forced.
708
+ This is a pass-through to `link_to` and accepts all the same options, except that the method `POST` is used by default.
709
+
710
+ You can also specify `data-method: :get` to instead make a `GET` request with the selected ids and redirect the browser link a normal link.
709
711
 
710
712
  ```ruby
711
713
  bulk_actions do
@@ -742,17 +744,17 @@ end
742
744
  or if using [effective_resources](https://github.com/code-and-effect/effective_resources):
743
745
 
744
746
  ```ruby
745
- include Effective::CrudController
747
+ include Effective::CrudController
746
748
 
747
- collection_action :bulk_approve
749
+ collection_action :bulk_approve
748
750
  ```
749
751
 
750
752
  and in your model
751
753
 
752
754
  ```ruby
753
- def approve!
754
- update_attributes!(status: :approved)
755
- end
755
+ def approve!
756
+ update_attributes!(status: :approved)
757
+ end
756
758
  ```
757
759
 
758
760
  ### bulk_action_divider
@@ -38,11 +38,20 @@ $(document).on 'click', '.buttons-bulk-actions a', (event) ->
38
38
 
39
39
  url = $bulkAction.attr('href')
40
40
  title = $bulkAction.text()
41
- values = $.map($selected, (input) -> input.getAttribute('value'))
42
41
  token = $bulkAction.parent('li').data('authenticity-token')
42
+ values = $.map($selected, (input) -> input.getAttribute('value'))
43
+ get_link = $bulkAction.data('bulk-actions-get')
43
44
 
44
45
  return unless url && values
45
46
 
47
+ if get_link
48
+ if url.includes('?')
49
+ window.location.assign(url + '&' + $.param({ids: values}))
50
+ else
51
+ window.location.assign(url + '?' + $.param({ids: values}))
52
+
53
+ return
54
+
46
55
  # Disable the Bulk Actions dropdown, so only one can be run at a time
47
56
  $bulkAction.closest('button').attr('disabled', 'disabled')
48
57
 
@@ -187,6 +187,8 @@ table.dataTable {
187
187
  input[type='checkbox'] { margin-left: 1px; margin-right: 1px; }
188
188
  }
189
189
 
190
+ td.col-resource_item { word-break: keep-all; }
191
+
190
192
  td {
191
193
  p { margin-bottom: 0px; }
192
194
  }
@@ -4,11 +4,11 @@ module Effective
4
4
  module BulkActions
5
5
 
6
6
  def bulk_action(*args)
7
- datatable._bulk_actions.push(content_tag(:li, link_to(*args)))
7
+ datatable._bulk_actions.push(content_tag(:li, link_to_bulk_action(*args)))
8
8
  end
9
9
 
10
10
  def bulk_download(*args)
11
- datatable._bulk_actions.push(content_tag(:li, link_to(*args), 'data-authenticity-token' => form_authenticity_token))
11
+ datatable._bulk_actions.push(content_tag(:li, link_to_bulk_action(*args), 'data-authenticity-token' => form_authenticity_token))
12
12
  end
13
13
 
14
14
  def bulk_action_divider
@@ -19,6 +19,31 @@ module Effective
19
19
  datatable._bulk_actions.push(block.call)
20
20
  end
21
21
 
22
+ private
23
+
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(*args)
26
+ args.map! do |arg|
27
+ if arg.kind_of?(Hash)
28
+ data_method = (
29
+ arg.delete(:'data-method') ||
30
+ arg.delete('data-method') ||
31
+ (arg[:data] || {}).delete('method') ||
32
+ (arg[:data] || {}).delete(:method)
33
+ )
34
+
35
+ # But if the data-method was :get, we add bulk-actions-get-link = true
36
+ if data_method.to_s == 'get'
37
+ arg[:data].present? ? arg[:data]['bulk-actions-get'] = true : arg['data-bulk-actions-get'] = true
38
+ end
39
+ end
40
+
41
+ arg
42
+ end
43
+
44
+ link_to(*args)
45
+ end
46
+
22
47
  end
23
48
  end
24
49
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.3.5'.freeze
2
+ VERSION = '3.3.6'.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: 3.3.5
4
+ version: 3.3.6
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: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails