effective_datatables 4.32.3 → 4.33.1

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: a698faa322e964f9e59f527c958bbcba3b67af487e89656f057514169eabd222
4
- data.tar.gz: '085d9a598ed1f4a4cf40762a890a18bb24ec4e7af73f4bb2f64a242fe34880c5'
3
+ metadata.gz: 4cd8c154865bcef7dda9eb32691cab1b3b6d7e304b8ddff6813fa2df1394da5f
4
+ data.tar.gz: ab4471b5df4f1fabadfa418f1cb8f9b5a5846895653fd76fa9a03e9b8bcdd0dd
5
5
  SHA512:
6
- metadata.gz: b35b553118ec141057f13edb66b7e0d87b1afca3ab7df3e8ebed8c785fcbd06233cffa859b418aad9afb111b87aa73e86afc08041a1bc14aa09b341693551c68
7
- data.tar.gz: 3fc70e65b0e53942b8a9cc4270e16bd5f7a22bbec0cd49a204a402f3bf955fe5bd278d5bf405000e8d23a8d062916540b6e5006605d14fce345cf9b0bbaa43c5
6
+ metadata.gz: 8b9a8106584a864a1a11c315c07f0cc473847f7292fb07b21d1f915fda0aadaea1a64fb242fdd8f511bb2a931796be841c571c4967dcd846e829df06eaee3533
7
+ data.tar.gz: 05a640da917ab52ead1f88e91868152e20949143a975000ad838986b38dfdea67fa1087de69329f6aef7951090a729daa8019608fde69ade3ae360194fa445d8
@@ -160,9 +160,12 @@ module Effective
160
160
  columns.each do |name, opts|
161
161
  # Normalize the given opts[:search] into a Hash
162
162
  # Take special note of the opts[:search] as we need to collapse it when an ActiveRecord::Relation
163
- case opts[:search]
164
- when false
163
+
164
+ if opts[:search] == false || attributes[:searchable] == false
165
165
  opts[:search] = { as: :null }; next
166
+ end
167
+
168
+ case opts[:search]
166
169
  when Symbol
167
170
  opts[:search] = { as: opts[:search] }
168
171
  when Array, ActiveRecord::Relation
@@ -176,10 +179,12 @@ module Effective
176
179
  # Now lets deal with the opts[:search] hash itself
177
180
  search = opts[:search]
178
181
 
182
+ # Adjust based on shorthand search: :select syntax
183
+ search[:as] ||= :select if search.key?(:collection)
184
+ search[:value] ||= search.delete(:selected) if search.key?(:selected)
185
+
179
186
  # Parameterize collection
180
- if attributes[:searchable] == false
181
- # Nothing to do
182
- elsif search[:collection].kind_of?(ActiveRecord::Relation)
187
+ if search[:collection].kind_of?(ActiveRecord::Relation)
183
188
  search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.id] }
184
189
  elsif search[:collection].kind_of?(Array) && search[:collection].first.kind_of?(ActiveRecord::Base)
185
190
  search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.id] }
@@ -187,29 +192,28 @@ module Effective
187
192
  search[:collection] = search[:collection]
188
193
  end
189
194
 
190
- search[:as] ||= :select if search.key?(:collection)
191
- search[:value] ||= search.delete(:selected) if search.key?(:selected)
192
-
193
195
  # Merge with defaults
194
196
  search_resource = [opts[:resource], effective_resource, fallback_effective_resource].compact
195
197
  search_resource = search_resource.find { |res| res.klass.present? } || search_resource.first
196
198
 
197
- # Assign search collections from effective_resources
198
- if attributes[:searchable] == false
199
- # Nothing to do
200
- elsif search[:as] == :string
199
+ if search[:as] == :string
201
200
  # Nothing to do. We're just a string search.
202
201
  elsif search[:as] == :select && search[:collection].kind_of?(Array)
203
202
  # Nothing to do. We already loaded the custom parameterized collection above.
204
- elsif opts[:visible] && array_collection? && opts[:resource].present?
203
+ elsif search[:as] == :select && search[:collection].blank? && array_collection? && opts[:resource].present?
205
204
  # Assigns { as: :select, collection: [...] }
206
205
  search.reverse_merge!(search_resource.search_form_field(name, collection.first[opts[:index]]))
207
- elsif opts[:visible]
206
+ elsif search[:as] == :select && search[:collection].blank?
208
207
  # Load the defaults from effective_resources
209
208
  # Assigns { as: :string } or { as: :select, collection: [...] }
210
209
  search.reverse_merge!(search_resource.search_form_field(name, opts[:as]))
211
- else
210
+ elsif [:belongs_to, :belongs_to_polymorphic, :has_and_belongs_to_many, :has_many, :has_one].include?(opts[:as])
211
+ # Do not eager load the collection. Treat this as a string search.
212
212
  search.reverse_merge!({ as: :string })
213
+ else
214
+ # Load the defaults from effective_resources
215
+ # Assigns { as: :string } or { as: :select, collection: [...] }
216
+ search.reverse_merge!(search_resource.search_form_field(name, opts[:as]))
213
217
  end
214
218
 
215
219
  # Assign default search operation
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.32.3'.freeze
2
+ VERSION = '4.33.1'.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.32.3
4
+ version: 4.33.1
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: 2025-04-22 00:00:00.000000000 Z
11
+ date: 2025-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails