effective_datatables 3.4.8 → 3.5.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: 6c10e95994f32935efe7f8c67dec2aad4d29b4b1
|
4
|
+
data.tar.gz: 7fc0b0c12d2ec760b2c1ccb1dd50e207d6f822d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb07bce27774287278e118c8020c9a86637dc0a165bea79f562b1e8655af7a2958eb907738219dca608306e2339df3d073f40302941073ff3aef6ffef5c0eaaa
|
7
|
+
data.tar.gz: 31ca91bbd2d7d17156e120b9a06b2e285ff9acff6e461ffd2d34cc044909df32f057f36622ab662716240d61d041eef5bb586378c7900813f394540282773bb2
|
data/README.md
CHANGED
@@ -237,10 +237,8 @@ class PostsDatatable < Effective::Datatable
|
|
237
237
|
# Puts links to show/edit/destroy actions, if authorized to those actions.
|
238
238
|
# Use the actions_col block to add additional actions
|
239
239
|
|
240
|
-
actions_col do |post|
|
241
|
-
|
242
|
-
glyphicon_to('print', print_post_path(post), title: 'Print')
|
243
|
-
end
|
240
|
+
actions_col(edit: false) do |post|
|
241
|
+
glyphicon_to('print', print_post_path(post), title: 'Print')
|
244
242
|
end
|
245
243
|
|
246
244
|
end
|
@@ -516,45 +514,36 @@ You can only have one `bulk_actions_col` per datatable.
|
|
516
514
|
|
517
515
|
### actions_col
|
518
516
|
|
519
|
-
When working with an ActiveRecord based collection, this column will consider the `current_user`'s authorization, and generate
|
520
|
-
glyphicon links to edit, show and destroy actions for any collection class.
|
517
|
+
When working with an ActiveRecord based collection, this column will consider the `current_user`'s authorization, and generate links to edit, show and destroy actions for any collection class.
|
521
518
|
|
522
519
|
The authorization method is configured via the `config/initializers/effective_datatables.rb` initializer file.
|
523
520
|
|
524
521
|
There are just a few options:
|
525
522
|
|
526
523
|
```ruby
|
527
|
-
show: true|false
|
528
|
-
edit: true|false
|
529
|
-
destroy: true|false
|
530
|
-
|
524
|
+
show: true|false
|
525
|
+
edit: true|false
|
526
|
+
destroy: true|false
|
531
527
|
visible: true|false
|
528
|
+
actions_partial: :glyphicons
|
532
529
|
```
|
533
530
|
|
534
|
-
|
535
|
-
When set to `:authorize`, permission to each individual object will be checked.
|
531
|
+
Each object is checked individually for authorization.
|
536
532
|
|
537
|
-
|
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).
|
538
534
|
|
539
|
-
|
540
|
-
actions_col show: false do |post|
|
541
|
-
(post.approved? ? link_to('Approve', approve_post_path(post)) : '') +
|
542
|
-
glyphicon_to('print', print_ticket_path(ticket), title: 'Print')
|
543
|
-
end
|
544
|
-
```
|
535
|
+
It's all very complicated.
|
545
536
|
|
546
|
-
|
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_form_inputs` gem.
|
547
540
|
|
548
541
|
```ruby
|
549
542
|
actions_col do |post|
|
550
|
-
|
551
|
-
glyphicon_to('print', print_post_path(post), title: 'Print')
|
552
|
-
end
|
543
|
+
glyphicon_to('print', print_post_path(post), title: 'Print')
|
553
544
|
end
|
554
545
|
```
|
555
546
|
|
556
|
-
The `glyphicon_to` helper is part of the [effective_resources](https://github.com/code-and-effect/effective_resources) gem, which is a dependency of this gem.
|
557
|
-
|
558
547
|
### length
|
559
548
|
|
560
549
|
Sets the default number of rows per page. Valid lengths are `5`, `10`, `25`, `50`, `100`, `250`, `500`, `:all`
|
@@ -9,7 +9,7 @@ module EffectiveDatatablesPrivateHelper
|
|
9
9
|
datatable.columns.map do |name, opts|
|
10
10
|
{
|
11
11
|
name: name,
|
12
|
-
title: content_tag(:span, opts[:label], class: 'search-label'),
|
12
|
+
title: content_tag(:span, (opts[:label] == false ? '' : opts[:label]), class: 'search-label'),
|
13
13
|
className: opts[:col_class],
|
14
14
|
searchHtml: (datatable_search_html(form, name, datatable.state[:search][name], opts) unless datatable.simple?),
|
15
15
|
responsivePriority: opts[:responsive],
|
@@ -31,7 +31,7 @@ module Effective
|
|
31
31
|
col_class: col_class,
|
32
32
|
format: (format if block_given?),
|
33
33
|
index: nil,
|
34
|
-
label: label
|
34
|
+
label: (label.nil? ? name.to_s.split('.').last.titleize : label),
|
35
35
|
name: name,
|
36
36
|
partial: partial,
|
37
37
|
partial_as: partial_as,
|
@@ -59,7 +59,7 @@ module Effective
|
|
59
59
|
col_class: col_class,
|
60
60
|
format: nil,
|
61
61
|
index: nil,
|
62
|
-
label: label
|
62
|
+
label: (label.nil? ? name.to_s.split('.').last.titleize : label),
|
63
63
|
name: name,
|
64
64
|
partial: partial,
|
65
65
|
partial_as: partial_as,
|
@@ -83,7 +83,7 @@ module Effective
|
|
83
83
|
col_class: col_class,
|
84
84
|
format: nil,
|
85
85
|
index: nil,
|
86
|
-
label:
|
86
|
+
label: false,
|
87
87
|
name: :bulk_actions,
|
88
88
|
partial: partial || '/effective/datatables/bulk_actions_column',
|
89
89
|
partial_as: partial_as,
|
@@ -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(
|
@@ -107,10 +107,11 @@ module Effective
|
|
107
107
|
col_class: col_class,
|
108
108
|
format: (format if block_given?),
|
109
109
|
index: nil,
|
110
|
-
label:
|
110
|
+
label: false,
|
111
111
|
name: :actions,
|
112
112
|
partial: partial,
|
113
113
|
partial_as: partial_as,
|
114
|
+
actions_partial: (actions_partial || :glyphicons),
|
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: 3.
|
4
|
+
version: 3.5.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
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
183
|
+
rubygems_version: 2.5.2.3
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord
|