effective_datatables 4.20.2 → 4.20.4

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
  SHA256:
3
- metadata.gz: 5bfbf37b105594f8effdd8c1ca01f55e377cb3a9b011acdb200c7feef5a7e3cf
4
- data.tar.gz: 8a72ea83642057838ecb2161693d2ce5f82ad194b6a47e6965df5f2dda48d902
3
+ metadata.gz: de9e67c1d5ddd3f19c322ea61f2bb1b50f9792e1ca6666607af4a14f11dc615d
4
+ data.tar.gz: ae1f07be260e375e21d4cf4520a1d55fb4c51787ea09f4f56acfc49168137f45
5
5
  SHA512:
6
- metadata.gz: 7d494134ece7fd837e979d2d4e5206745c756e1d89a1e8a521fb33f897cd7a60ea329636ca2e2ec5287d2f70c1359ec0fee413a6ee04466c88cb2974ab6c805e
7
- data.tar.gz: 0f55926b63825664257310ebe7de15a39b129a5a882439cf34f78fc0158b4f2bf64138f9fe3966950d9caa21e1f57a0cb3dbec8c88aa6e428d745dca167e3cfe
6
+ metadata.gz: 711ca1ee0f32fd3b91bcac59f294ac8d3822d364a7318ee89d68ed6a8d0de7147dab2934365abcc3e49ba1ea85142ba50f515207601e651677fc74f1cfdf5281
7
+ data.tar.gz: fd4a8536658314a46199c03aec85898365b992472b78e7e8592b468a25f6cc16ed914b2385f131b0e5f927963b5990a469b0a93e8e62697ec80c151e611ca7ba
@@ -127,9 +127,12 @@ module Effective
127
127
  else
128
128
  if values.all? { |v| v.kind_of?(ActiveRecord::Base) && v.respond_to?(name) }
129
129
  values = values.map { |v| (v[name] if opts[:sql_as_column]) || v.public_send(name) }
130
+ format_column(aggregate_column(values, opts, aggregate), opts)
131
+ elsif values.all? { |v| (v == true || v == false) }
132
+ aggregate_column(values, opts, aggregate)
133
+ else
134
+ format_column(aggregate_column(values, opts, aggregate), opts)
130
135
  end
131
-
132
- format_column(aggregate_column(values, opts, aggregate), opts)
133
136
  end || BLANK
134
137
  end.compact
135
138
  end
@@ -146,7 +146,7 @@ module Effective
146
146
 
147
147
  if csv
148
148
  value_to_s
149
- elsif value_to_s.starts_with?('<') && value_to_s.ends_with?('>')
149
+ elsif value_to_s.include?('<') && value_to_s.include?('>')
150
150
  view.sanitize(value_to_s)
151
151
  else
152
152
  view.simple_format(value_to_s)
@@ -156,7 +156,7 @@ module Effective
156
156
 
157
157
  if csv
158
158
  value_to_s
159
- elsif value_to_s.starts_with?('<') && value_to_s.ends_with?('>')
159
+ elsif value_to_s.include?('<') && value_to_s.include?('>')
160
160
  view.sanitize(value_to_s)
161
161
  else
162
162
  view.escape_once(value_to_s)
@@ -158,6 +158,8 @@ module Effective
158
158
 
159
159
  def load_resource_search!
160
160
  columns.each do |name, opts|
161
+ # Normalize the given opts[:search] into a Hash
162
+ # Take special note of the opts[:search] as we need to collapse it when an ActiveRecord::Relation
161
163
  case opts[:search]
162
164
  when false
163
165
  opts[:search] = { as: :null }; next
@@ -171,6 +173,7 @@ module Effective
171
173
  raise "column #{name} unexpected search value"
172
174
  end
173
175
 
176
+ # Now lets deal with the opts[:search] hash itself
174
177
  search = opts[:search]
175
178
 
176
179
  # Parameterize collection
@@ -189,11 +192,17 @@ module Effective
189
192
  search_resource = [opts[:resource], effective_resource, fallback_effective_resource].compact
190
193
  search_resource = search_resource.find { |res| res.klass.present? } || search_resource.first
191
194
 
192
- if array_collection? && opts[:resource].present?
193
- search.reverse_merge!(search_resource.search_form_field(name, collection.first[opts[:index]]))
195
+ # Assign search collections from effective_resources
196
+ if search[:as] == :string
197
+ # Nothing to do. We're just a string search.
194
198
  elsif search[:as] == :select && search[:collection].kind_of?(Array)
195
- # Nothing to do
196
- elsif search[:as] != :string
199
+ # Nothing to do. We already loaded the custom parameterized collection above.
200
+ elsif array_collection? && opts[:resource].present?
201
+ # Assigns { as: :select, collection: [...] }
202
+ search.reverse_merge!(search_resource.search_form_field(name, collection.first[opts[:index]]))
203
+ else
204
+ # Load the defaults from effective_resources
205
+ # Assigns { as: :string } or { as: :select, collection: [...] }
197
206
  search.reverse_merge!(search_resource.search_form_field(name, opts[:as]))
198
207
  end
199
208
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.20.2'.freeze
2
+ VERSION = '4.20.4'.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.20.2
4
+ version: 4.20.4
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-10-25 00:00:00.000000000 Z
11
+ date: 2023-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails