effective_datatables 2.4.1 → 2.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd41f4b17a43b69b4164c73ec1c27333ff277423
|
4
|
+
data.tar.gz: ac99a8b3b030df212aef90af6600ce95545dede6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce3b38c75aefba7aaedcbe339ed6ec87f59c878a8cac244c4f197d711efee35391bcf3498f1c775261bf2ca3f18b0288cd9a4b036711fd9a796c2ff2bb8953a3
|
7
|
+
data.tar.gz: ae522ad82d750f286ffe766eb205ac8417fc908558b62c1d9ffed46a17769d85e0e4fcd8c8ab53c1704aaa829517626e5aacd21e0d68501d93b349362f583ab1
|
data/README.md
CHANGED
@@ -438,7 +438,7 @@ filterable # whether the dataTable is filterable
|
|
438
438
|
|
439
439
|
## actions_column
|
440
440
|
|
441
|
-
Creates a column with links to this resource's
|
441
|
+
Creates a column with links to this resource's `show`, `edit` and `destroy` actions.
|
442
442
|
|
443
443
|
Sets `responsivePriority: 0` so the column is last to collapse when the table is shrunk down.
|
444
444
|
|
@@ -448,7 +448,37 @@ Override the default actions by passing your own partial:
|
|
448
448
|
actions_column partial: 'admin/posts/actions'
|
449
449
|
```
|
450
450
|
|
451
|
-
|
451
|
+
### Showing action buttons
|
452
|
+
|
453
|
+
The show/edit/destroy action buttons can be configured to always show, always hide, or to consider the current_user's permission level.
|
454
|
+
|
455
|
+
To always show / hide:
|
456
|
+
|
457
|
+
```ruby
|
458
|
+
actions_column show: false, edit: true, destroy: true, unarchive: true
|
459
|
+
```
|
460
|
+
|
461
|
+
To authorize based on the current_user and the `config.authorization_method`:
|
462
|
+
|
463
|
+
```ruby
|
464
|
+
actions_column show: :authorize
|
465
|
+
```
|
466
|
+
|
467
|
+
The above will call the effective_datatables `config.authorization_method` just once to see if the current_user has permission to show/edit/destroy the collection class.
|
468
|
+
|
469
|
+
The action button will be displayed if `EffectiveDatatables.authorized?(controller, :edit, Post)` returns true.
|
470
|
+
|
471
|
+
To call authorize on each individual resource:
|
472
|
+
|
473
|
+
```ruby
|
474
|
+
actions_column show: :authorize_each
|
475
|
+
```
|
476
|
+
|
477
|
+
Or via a Proc:
|
478
|
+
|
479
|
+
```ruby
|
480
|
+
actions_column show: Proc.new { |resource| can?(:show, resource.parent) }
|
481
|
+
```
|
452
482
|
|
453
483
|
See the `config/initializers/effective_datatable.rb` file for more information.
|
454
484
|
|
@@ -1,3 +1,28 @@
|
|
1
|
+
:ruby
|
2
|
+
if show_action == :authorize_each
|
3
|
+
show_action = (EffectiveDatatables.authorized?(controller, :show, resource) rescue false)
|
4
|
+
elsif show_action.respond_to?(:call)
|
5
|
+
show_action = instance_exec(resource, &show_action)
|
6
|
+
end
|
7
|
+
|
8
|
+
if edit_action == :authorize_each
|
9
|
+
edit_action = (EffectiveDatatables.authorized?(controller, :edit, resource) rescue false)
|
10
|
+
elsif edit_action.respond_to?(:call)
|
11
|
+
edit_action = instance_exec(resource, &edit_action)
|
12
|
+
end
|
13
|
+
|
14
|
+
if destroy_action == :authorize_each
|
15
|
+
destroy_action = (EffectiveDatatables.authorized?(controller, :destroy, resource) rescue false)
|
16
|
+
elsif destroy_action.respond_to?(:call)
|
17
|
+
destroy_action = instance_exec(resource, &destroy_action)
|
18
|
+
end
|
19
|
+
|
20
|
+
if unarchive_action == :authorize_each
|
21
|
+
unarchive_action = (EffectiveDatatables.authorized?(controller, :unarchive, resource) rescue false)
|
22
|
+
elsif unarchive_action.respond_to?(:call)
|
23
|
+
unarchive_action = instance_exec(resource, &unarchive_action)
|
24
|
+
end
|
25
|
+
|
1
26
|
- if show_action
|
2
27
|
- url = (polymorphic_path([*controller_namespace, resource]) rescue nil) || (polymorphic_path(resource) rescue nil)
|
3
28
|
- if url.present?
|
@@ -41,14 +41,20 @@ EffectiveDatatables.setup do |config|
|
|
41
41
|
# Valid values for each action are:
|
42
42
|
# true (always include a link to this action)
|
43
43
|
# false (never include a link to this action)
|
44
|
-
# :authorize (include link only if authorized
|
44
|
+
# :authorize (include link only if authorized to show/edit/destroy the resource class)
|
45
|
+
# :authorize_each (include link only if authorized to show/edit/destroy the resource)
|
46
|
+
# Proc.new { |resource| can?(:edit, resource.parent) }
|
45
47
|
#
|
46
|
-
# When :authorize, a single check will be made via the above authorization_method
|
48
|
+
# When :authorize, a single check will be made via the above config.authorization_method
|
47
49
|
# to see if the current_user has permission to :show/:edit/:destroy the collection class, i.e. Post
|
48
50
|
# EffectiveDatatables.authorized? (:show || :edit || :destroy), Post
|
51
|
+
# This is a faster permission check, because it only checks the class once
|
49
52
|
#
|
50
|
-
#
|
51
|
-
#
|
53
|
+
# If you want to authorize each individual resource, use :authorize_each
|
54
|
+
# EffectiveDatatables.authorized? (:show || :edit || :destroy), Post.find(1)
|
55
|
+
#
|
56
|
+
# You can override these defaults on a per-table basis
|
57
|
+
# by calling `actions_column(show: false, edit: true, destroy: :authorize)`
|
52
58
|
config.actions_column = {
|
53
59
|
show: :authorize,
|
54
60
|
edit: :authorize,
|
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: 2.4.
|
4
|
+
version: 2.4.2
|
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: 2016-
|
11
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|