effective_datatables 4.19.0 → 4.20.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
  SHA256:
3
- metadata.gz: d9a3cae1554f2bcf9b6d73f51972eb1f8bc00c38a30d160c7f8910bf6e339a99
4
- data.tar.gz: 72193d4f4895fa60a933c6be50d2d5d6a9d32d5d09a7f60558b130c2042eee1a
3
+ metadata.gz: c5bf5141b655e975b0e158b2f33572d8b8acc1f13ffa50d25f761795c6cdeb25
4
+ data.tar.gz: 67c30d8895b19d093e43e6ae1b521a528a18ea8ca156ca90209e8c1c922248c2
5
5
  SHA512:
6
- metadata.gz: 321d799d2a21d4e3d19523ef8ae24d8ae62649bd1656afcc90223b26a77409d00dd8bd80a8f15bd40eb07476ea2b1f4a3eb7500f0f44a4a6b0b98553c873ba1d
7
- data.tar.gz: f35dc8eeabe695ded08c56d80d1f09cfb18ac1e9925cf55d43870ac121d357543e085e9fdeb14020f92a52f6419de45712a0a663cb4429029ee3edcd9f29e9b4
6
+ metadata.gz: 0d08c8f32b066240576a4e4ee4cdea3916999d6c26f44e9c4533b125625de29922ae49ceebfdbd9ce68ba6be5d7da81255f9b60e54af5a250b380ae9bab94952
7
+ data.tar.gz: e20da9812bae53fbcaf98fc18022d624c41fe918f544607ea6a7ad0c8d8d062b9f4c8dc89fe5ca067e3b9daf2e47e2537404ce40a50d0c514b475a06b9aa05b7
@@ -15,7 +15,7 @@ module Effective
15
15
  EffectiveDatatables.authorize!(self, :index, @datatable.collection_class)
16
16
 
17
17
  render json: @datatable.to_json
18
- rescue => e
18
+ rescue Exception => e
19
19
  EffectiveDatatables.authorized?(self, :index, @datatable.try(:collection_class))
20
20
  render json: error_json(e)
21
21
 
@@ -84,7 +84,7 @@ module Effective
84
84
  render status: :ok, body: :ok
85
85
  rescue Effective::AccessDenied => e
86
86
  render(status: :unauthorized, body: 'Access Denied')
87
- rescue => e
87
+ rescue Exception => e
88
88
  render(status: :error, body: 'Unexpected Error')
89
89
  end
90
90
 
@@ -24,20 +24,16 @@ module Effective
24
24
  raise "#{method} block must be declared outside the datatable do ... end block"
25
25
  end
26
26
 
27
- if datatable.respond_to?(method)
28
- if block_given?
29
- datatable.send(method, *args, **kwargs) { yield }
30
- else
31
- datatable.send(method, *args, **kwargs)
32
- end
33
- elsif view.respond_to?(method)
34
- if block_given?
35
- view.send(method, *args, **kwargs) { yield }
36
- else
37
- view.send(method, *args, **kwargs)
38
- end
27
+ subject = datatable if datatable.respond_to?(method)
28
+ subject ||= view if view.respond_to?(method)
29
+ subject ||= Tenant.helpers if defined?(Tenant) && Tenant.helpers.respond_to?(method)
30
+
31
+ return super unless subject
32
+
33
+ if block_given?
34
+ subject.send(method, *args, **kwargs) { yield }
39
35
  else
40
- super
36
+ subject.send(method, *args, **kwargs)
41
37
  end
42
38
  end
43
39
 
@@ -92,10 +92,6 @@ module Effective
92
92
  def format_column(value, column, csv: false)
93
93
  return if value.nil? || (column[:resource] && value.blank?)
94
94
 
95
- unless column[:as] == :email
96
- return value if value.kind_of?(String)
97
- end
98
-
99
95
  if value.kind_of?(Array) && column[:as] == :string
100
96
  if csv
101
97
  return value.map { |v| format_column(v, column, csv: csv) }.join("\n")
@@ -145,6 +141,16 @@ module Effective
145
141
  end
146
142
  when :time
147
143
  value.respond_to?(:strftime) ? value.strftime(EffectiveDatatables.format_time) : BLANK
144
+ when :text
145
+ if csv
146
+ value
147
+ elsif value.to_s.starts_with?('<') && value.ends_with?('>')
148
+ view.sanitize(value.to_s)
149
+ else
150
+ view.simple_format(value.to_s)
151
+ end
152
+ when :string
153
+ csv ? value : view.escape_once(value.to_s)
148
154
  else
149
155
  value.to_s
150
156
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.19.0'.freeze
2
+ VERSION = '4.20.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.19.0
4
+ version: 4.20.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: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails