effective_datatables 4.1.1 → 4.2.0
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: eafac19670114b90cdf9feeccfcc14b3e18e402c
|
4
|
+
data.tar.gz: 3d5bb7ff5c3195dc153b331ea2ee5b19d9448497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4af14c97a3e1189d23deb9d80f6fdde8d90234e14f7c4c8151de5904feba8c082ae54b7b888a99e38a905364368ee695ffaa183e948ef8eae7f33dd743a8f903
|
7
|
+
data.tar.gz: 61c2923c00252fdaeed3d7a26b4a97c0a829e99a3a0bb5eae182f29a26ea4a1a727334c3109aa5efeb274e6ce6b9eb5ba43d5e8b43b9b95f4eb70b4cdd8c01fd
|
data/README.md
CHANGED
@@ -238,10 +238,8 @@ class PostsDatatable < Effective::Datatable
|
|
238
238
|
# Puts links to show/edit/destroy actions, if authorized to those actions.
|
239
239
|
# Use the actions_col block to add additional actions
|
240
240
|
|
241
|
-
actions_col do |post|
|
242
|
-
|
243
|
-
dropdown_link_to('Approve', approve_post_path(post) data: { method: :post, confirm: "Approve #{post}?"})
|
244
|
-
end
|
241
|
+
actions_col(edit: false) do |post|
|
242
|
+
dropdown_link_to('Approve', approve_post_path(post) data: { method: :post, confirm: "Approve #{post}?"})
|
245
243
|
end
|
246
244
|
end
|
247
245
|
|
@@ -527,17 +525,22 @@ show: true|false
|
|
527
525
|
edit: true|false
|
528
526
|
destroy: true|false
|
529
527
|
visible: true|false
|
528
|
+
actions_partial: :dropleft
|
530
529
|
```
|
531
530
|
|
532
|
-
|
531
|
+
Each object is checked individually for authorization.
|
532
|
+
|
533
|
+
The arguments to `actions_col` are passed through to the `effective_resource` gem's [render_resource_actions](https://github.com/code-and-effect/effective_resources/blob/master/app/helpers/effective_resources_helper.rb#L57).
|
534
|
+
|
535
|
+
It's all very complicated.
|
533
536
|
|
534
|
-
|
537
|
+
If you just want to override this entire column with your own actions implementation, you can pass `actions_col partial: 'my_partial'` and roll your own.
|
538
|
+
|
539
|
+
Otherwise, use the following block syntax to add additional actions. This helper comes from `effective_bootstrap` gem.
|
535
540
|
|
536
541
|
```ruby
|
537
542
|
actions_col do |post|
|
538
|
-
|
539
|
-
dropdown_link_to('Approve', approve_post_path(post) data: { method: :post, confirm: "Approve #{post}?"})
|
540
|
-
end
|
543
|
+
dropdown_link_to('Approve', approve_post_path(post) data: { method: :post, confirm: "Approve #{post}?"})
|
541
544
|
end
|
542
545
|
```
|
543
546
|
|
@@ -97,7 +97,7 @@ module Effective
|
|
97
97
|
)
|
98
98
|
end
|
99
99
|
|
100
|
-
def actions_col(
|
100
|
+
def actions_col(col_class: nil, partial: nil, partial_as: nil, actions_partial: nil, responsive: 5000, visible: true, **actions, &format)
|
101
101
|
raise 'You can only have one actions column' if datatable.columns[:_actions].present?
|
102
102
|
|
103
103
|
datatable._columns[:_actions] = Effective::DatatableColumn.new(
|
@@ -111,6 +111,7 @@ module Effective
|
|
111
111
|
name: :actions,
|
112
112
|
partial: partial,
|
113
113
|
partial_as: partial_as,
|
114
|
+
actions_partial: (actions_partial || :dropleft),
|
114
115
|
responsive: responsive,
|
115
116
|
search: false,
|
116
117
|
sort: false,
|
@@ -119,7 +120,8 @@ module Effective
|
|
119
120
|
th_append: nil,
|
120
121
|
visible: visible,
|
121
122
|
|
122
|
-
|
123
|
+
# { approve: false }. These args are passed to effective_resources render_resource_actions
|
124
|
+
actions: actions
|
123
125
|
)
|
124
126
|
end
|
125
127
|
|
@@ -23,14 +23,13 @@ module Effective
|
|
23
23
|
locals: locals,
|
24
24
|
spacer_template: SPACER_TEMPLATE
|
25
25
|
) || '').split(SPACER)
|
26
|
-
elsif opts[:as] == :actions # This is
|
26
|
+
elsif opts[:as] == :actions # This is actions_col and actions_col do .. end, but not actions_col partial: 'something'
|
27
27
|
locals = { datatable: self, column: columns[name], spacer_template: SPACER_TEMPLATE }
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
) || '').split(SPACER)
|
29
|
+
resources = collection.map { |row| row[opts[:index]] }
|
30
|
+
atts = opts[:actions].merge(effective_resource: resource, locals: locals, partial: opts[:actions_partial])
|
31
|
+
|
32
|
+
rendered[name] = (view.render_resource_actions(resources, atts, &opts[:format]) || '').split(SPACER)
|
34
33
|
end
|
35
34
|
|
36
35
|
end
|
@@ -43,14 +42,14 @@ module Effective
|
|
43
42
|
value = row[index]
|
44
43
|
|
45
44
|
row[index] = (
|
46
|
-
if opts[:
|
45
|
+
if opts[:as] == :actions
|
46
|
+
rendered[name][row_index]
|
47
|
+
elsif opts[:format] && rendered.key?(name)
|
47
48
|
dsl_tool.instance_exec(value, row, rendered[name][row_index], &opts[:format])
|
48
49
|
elsif opts[:format]
|
49
50
|
dsl_tool.instance_exec(value, row, &opts[:format])
|
50
51
|
elsif opts[:partial]
|
51
52
|
rendered[name][row_index]
|
52
|
-
elsif opts[:as] == :actions
|
53
|
-
rendered[name][row_index]
|
54
53
|
else
|
55
54
|
format_column(value, opts)
|
56
55
|
end
|
@@ -68,7 +67,7 @@ module Effective
|
|
68
67
|
|
69
68
|
case column[:as]
|
70
69
|
when :actions
|
71
|
-
view.render_resource_actions(
|
70
|
+
view.render_resource_actions(value, **column[:actions].merge(effective_resource: resource, partial: column[:actions_partial]))
|
72
71
|
when :boolean
|
73
72
|
case value
|
74
73
|
when true ; 'Yes'
|
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.
|
4
|
+
version: 4.2.0
|
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-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.5.2.3
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord
|