effective_datatables 4.7.2 → 4.7.3

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
  SHA256:
3
- metadata.gz: 77051de30c4631f232f97e3124e475f7a6e5e0bd3570751184bda6602aa2ed48
4
- data.tar.gz: b2e28b7d4705f55bfd992d66fe9743c49f8c25741df298decd508f85f07ae7ca
3
+ metadata.gz: 4680722774df8a353220ea8430222cda0502291a23ac39c5ffb70b3f36c524bb
4
+ data.tar.gz: a68b88bb5b0d0bf60c175be105dc4483c3962fb40e0796eadf6c02d598789b60
5
5
  SHA512:
6
- metadata.gz: 0f7a190178e950221de01658a0030b428aeec82e539858fde8dca2f9e0e2db7781a8d8938bfcc464efd6626e6425c9e80968165a86afec582042ecf6b16d2aae
7
- data.tar.gz: bec0582aa79e41a0e73e04fe8b50910f7e1b007daf9a39b2a2cdbbb54a80247baabd313cf9e9c2ed2b6b0a3eb1dc6f0a92d48f49110433f630709c0a7f529496
6
+ metadata.gz: 0a9e0d639eb8d8407d6b7113714d90e408f9b41b32fb8841695cc61532559a5ddff0ccbaaa0032bba21bf70fe59bc774ca34e3917a1165b042bddf3f1aab7a76
7
+ data.tar.gz: e30c2c0bd9a14faef5569aa2c996d6159c89ff973868351b7e1182efdcf04eb1fee0f9537c4531a5894410e11b9ad8d3c4ca579bfd30161afffdb0716d198de6
data/README.md CHANGED
@@ -466,7 +466,7 @@ It accepts one optional block used to format the value after any search or sorti
466
466
  The following options are available:
467
467
 
468
468
  ```ruby
469
- action: :show|:edit|false # :resource and relation columns only. generate links to this action. edit -> show by default
469
+ action: :show|:edit|false # Render as a link to this action. edit -> show by default
470
470
  as: :string|:integer|etc # Sets the type of column initializing defaults for search, sort and format
471
471
  col_class: 'col-green' # Sets the html class to use on this column's td and th
472
472
  label: 'My label' # The label for this column
@@ -34,7 +34,7 @@ module Effective
34
34
  name = name.to_sym unless name.to_s.include?('.')
35
35
 
36
36
  datatable._columns[name] = Effective::DatatableColumn.new(
37
- action: action, # resource columns only
37
+ action: action,
38
38
  as: as,
39
39
  compute: nil,
40
40
  col_class: col_class,
@@ -62,7 +62,7 @@ module Effective
62
62
  name = name.to_sym unless name.to_s.include?('.')
63
63
 
64
64
  datatable._columns[name] = Effective::DatatableColumn.new(
65
- action: action, # Resource columns only
65
+ action: action,
66
66
  as: as,
67
67
  compute: (compute if block_given?),
68
68
  col_class: col_class,
@@ -143,8 +143,12 @@ module Effective
143
143
  return {} unless (resource = opts[:resource]).present?
144
144
 
145
145
  polymorphic = (opts[:as] == :belongs_to_polymorphic)
146
+ associated = resource.macros.include?(opts[:as])
146
147
 
147
- locals = { name: opts[:name], effective_resource: resource, show_action: false, edit_action: false }
148
+ resource_name = opts[:name] if associated
149
+ resource_to_s = opts[:name] unless associated || array_collection?
150
+
151
+ locals = { resource_name: resource_name, resource_to_s: resource_to_s, effective_resource: resource, show_action: false, edit_action: false }
148
152
 
149
153
  case opts[:action]
150
154
  when :edit
@@ -102,6 +102,10 @@ module Effective
102
102
  opts[:as] ||= :string
103
103
  opts[:as] = :email if (opts[:as] == :string && name.to_s.end_with?('email'))
104
104
 
105
+ if opts[:action]
106
+ opts[:resource] ||= resource
107
+ end
108
+
105
109
  if opts[:resource] && !opts[:resource_field] && opts[:as] != :effective_addresses
106
110
  opts[:partial] ||= '/effective/datatables/resource_column'
107
111
  end
@@ -1,8 +1,10 @@
1
- - Array(datatable.array_collection? ? resource : resource.send(name)).each do |resource|
1
+ - Array(local_assigns[:resource_name] ? resource.public_send(resource_name) : resource).each do |resource|
2
+ - resource_to_s = (local_assigns[:resource_to_s] ? resource.public_send(resource_to_s) : resource.to_s)
3
+
2
4
  .col-resource_item
3
5
  - if edit_action && EffectiveDatatables.authorized?(controller, :edit, resource) && (path = effective_resource.action_path(:edit, resource)).present?
4
- = link_to resource.to_s, path, title: resource.to_s
6
+ = link_to resource_to_s, path, title: resource_to_s
5
7
  - elsif show_action && EffectiveDatatables.authorized?(controller, :show, resource) && (path = effective_resource.action_path(:show, resource)).present?
6
- = link_to resource.to_s, path, title: resource.to_s
8
+ = link_to resource_to_s, path, title: resource_to_s
7
9
  - else
8
- = resource.to_s.html_safe
10
+ = resource_to_s.html_safe
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.7.2'.freeze
2
+ VERSION = '4.7.3'.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.7.2
4
+ version: 4.7.3
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: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2019-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails