effective_datatables 3.3.5 → 3.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/app/assets/javascripts/effective_datatables/bulk_actions.js.coffee +10 -1
- data/app/assets/stylesheets/effective_datatables/_overrides.scss +2 -0
- data/app/models/effective/effective_datatable/dsl/bulk_actions.rb +27 -2
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80ef322422055559272f3145551bff1357ee74e5
|
4
|
+
data.tar.gz: 28bc97f374afb93abd7bf5a8007044a37afffef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
747
|
+
include Effective::CrudController
|
746
748
|
|
747
|
-
|
749
|
+
collection_action :bulk_approve
|
748
750
|
```
|
749
751
|
|
750
752
|
and in your model
|
751
753
|
|
752
754
|
```ruby
|
753
|
-
|
754
|
-
|
755
|
-
|
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
|
|
@@ -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,
|
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,
|
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
|
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.
|
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-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|