effective_datatables 3.5.0 → 3.5.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: 6c10e95994f32935efe7f8c67dec2aad4d29b4b1
4
- data.tar.gz: 7fc0b0c12d2ec760b2c1ccb1dd50e207d6f822d3
3
+ metadata.gz: 9cd68beee734d563dfcd4ee9535e01aee6d121b3
4
+ data.tar.gz: 75255066db9a98a9da9d18534c402202670f84c1
5
5
  SHA512:
6
- metadata.gz: eb07bce27774287278e118c8020c9a86637dc0a165bea79f562b1e8655af7a2958eb907738219dca608306e2339df3d073f40302941073ff3aef6ffef5c0eaaa
7
- data.tar.gz: 31ca91bbd2d7d17156e120b9a06b2e285ff9acff6e461ffd2d34cc044909df32f057f36622ab662716240d61d041eef5bb586378c7900813f394540282773bb2
6
+ metadata.gz: ae954fd101983c833afc51e9ce27db3f92b904390ff26312b9bb4a791ea470bb49966f0a480c5111993ffea3999d897bf9f20b1fca67724c69ee5cc80e844339
7
+ data.tar.gz: 77de12778528a1d10fc9658d17e04cdacb74b6e16901df219f922a9522d579025c30fac329374272565499176131df3834e4832e71cd9e9b0fd3606641ef98a5
@@ -2,6 +2,7 @@ module Effective
2
2
  module EffectiveDatatable
3
3
  module Format
4
4
  BLANK = ''.freeze
5
+ NONVISIBLE = '...'.freeze
5
6
  SPACER = 'EFFECTIVEDATATABLESSPACER'.freeze
6
7
  SPACER_TEMPLATE = '/effective/datatables/spacer_template'.freeze
7
8
 
@@ -12,7 +13,9 @@ module Effective
12
13
  rendered = {}
13
14
 
14
15
  columns.each do |name, opts|
15
- if opts[:partial] && state[:visible][name]
16
+ next unless state[:visible][name]
17
+
18
+ if opts[:partial]
16
19
  locals = { datatable: self, column: columns[name] }.merge(resource_col_locals(opts))
17
20
 
18
21
  rendered[name] = (view.render(
@@ -24,10 +27,9 @@ module Effective
24
27
  spacer_template: SPACER_TEMPLATE
25
28
  ) || '').split(SPACER)
26
29
  elsif opts[:as] == :actions # This is actions_col and actions_col do .. end, but not actions_col partial: 'something'
27
- locals = { datatable: self, column: columns[name], spacer_template: SPACER_TEMPLATE }
28
-
29
30
  resources = collection.map { |row| row[opts[:index]] }
30
- atts = opts[:actions].merge(effective_resource: resource, locals: locals, partial: opts[:actions_partial])
31
+ locals = { datatable: self, column: opts, spacer_template: SPACER_TEMPLATE }
32
+ atts = { actions: actions_col_actions(opts), effective_resource: resource, locals: locals, partial: opts[:actions_partial] }.merge(opts[:actions])
31
33
 
32
34
  rendered[name] = (view.render_resource_actions(resources, atts, &opts[:format]) || '').split(SPACER)
33
35
  end
@@ -36,13 +38,13 @@ module Effective
36
38
 
37
39
  collection.each_with_index do |row, row_index|
38
40
  columns.each do |name, opts|
39
- next unless state[:visible][name]
40
-
41
41
  index = opts[:index]
42
42
  value = row[index]
43
43
 
44
44
  row[index] = (
45
- if opts[:as] == :actions
45
+ if state[:visible][name] == false
46
+ NONVISIBLE
47
+ elsif opts[:as] == :actions
46
48
  rendered[name][row_index]
47
49
  elsif opts[:format] && rendered.key?(name)
48
50
  dsl_tool.instance_exec(value, row, rendered[name][row_index], &opts[:format])
@@ -67,7 +69,8 @@ module Effective
67
69
 
68
70
  case column[:as]
69
71
  when :actions
70
- view.render_resource_actions(value, **column[:actions].merge(effective_resource: resource, partial: column[:actions_partial]))
72
+ atts = { actions: actions_col_actions(column), effective_resource: resource, partial: column[:actions_partial] }.merge(column[:actions])
73
+ (view.render_resource_actions(value, atts) || '')
71
74
  when :boolean
72
75
  case value
73
76
  when true ; 'Yes'
@@ -110,6 +113,12 @@ module Effective
110
113
  end
111
114
  end
112
115
 
116
+ # Takes all default resource actions
117
+ # Applies data-remote to anything that's data-method post or delete
118
+ def actions_col_actions(column)
119
+ resource.resource_actions
120
+ end
121
+
113
122
  def resource_col_locals(opts)
114
123
  return {} unless (resource = opts[:resource]).present?
115
124
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.5.0'.freeze
2
+ VERSION = '3.5.2'.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: 3.5.0
4
+ version: 3.5.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: 2018-09-03 00:00:00.000000000 Z
11
+ date: 2018-10-29 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.5.2.3
183
+ rubygems_version: 2.4.5.1
184
184
  signing_key:
185
185
  specification_version: 4
186
186
  summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord