effective_datatables 4.1.1 → 4.2.0

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: ff455a937b6f6870cf7fa13018555eed202b443b
4
- data.tar.gz: f562a3ed7baea7156ed3dac22c6746d8c5a03ed8
3
+ metadata.gz: eafac19670114b90cdf9feeccfcc14b3e18e402c
4
+ data.tar.gz: 3d5bb7ff5c3195dc153b331ea2ee5b19d9448497
5
5
  SHA512:
6
- metadata.gz: 80d4d1f0bf4887f31fbd254826dc16adccd0723adbeaa892afe2a61b5aec951e9e07597c409daccc0e9159bc46e6deb1239687cda7ae0df1d4c0907ac9a4fa74
7
- data.tar.gz: 262562debebf67107139eeae352a71f212082878ae4ef0972160ebb0e68dafa77e6c58346ccb5d7ae8fdc16c05842554675985058a95baf3bd9e813da026d92f
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
- render_resource_actions(resource, post, edit: false, partial: :dropleft) do
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
- When the show, edit and destroy actions are `true` (default), the permission check will be made just once, authorizing the class.
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
- Use the block syntax to add additional actions. This helper comes from `effective_resources` gem.
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
- render_resource_actions(resource, post, edit: false, partial: :dropleft) do
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(show: nil, edit: nil, destroy: nil, col_class: nil, partial: nil, partial_as: nil, responsive: 5000, visible: true, &format)
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
- actions: { show: show, edit: edit, destroy: destroy, partial: :dropleft }.reject { |k, v| v.nil? }
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 default actions_col
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
- rendered[name] = (view.render_resource_actions(
30
- resource,
31
- collection.map { |row| row[opts[:index]] },
32
- opts[:actions].merge(locals: locals)
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[:format] && rendered.key?(name)
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(resource, value, **column[: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'
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.1.1'.freeze
2
+ VERSION = '4.2.0'.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.1.1
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-08-03 00:00:00.000000000 Z
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.4.5.1
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