effective_datatables 4.20.3 → 4.20.5

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: b290520f84f92726953ea0aef6cfa1e5c8d6acdafbc1701f6fb542357d077010
4
- data.tar.gz: 9f7a715b57a9edf9dc31b806bdc85287e505a3e7766957599f555073ea43e71e
3
+ metadata.gz: efe60765e3b15e6c05007e9bba964cb70d52e411ff5fe8eb7899c7289317c24d
4
+ data.tar.gz: ec684a2e94cb1955f657fe86f412302ac5ff44795e3f6f06217f22240cd27e33
5
5
  SHA512:
6
- metadata.gz: d8a92d42e7b7f79761f5ad4efec357071bf5f844797883139e248177a059f9b108d62080f7d45db5e3ffbbcbf7aee4383621462bcd6e14f75ffffcffcf0ff145
7
- data.tar.gz: e2315412cb5e63b24d5d554dfddfa69e99895ba7c30ee015d829eadfd6908e36d976cb6cb5e4151afbc7adf75ce7b54653e43e8d5c7a109796cf51364912ae87
6
+ metadata.gz: bf3517b19749fa82ff16a57cee12b778b88693e2519830e438af3f18752e771ed519fadd586c72d6cd155084fc9fd358a5e3fa4939a7c9c4a023db8348957619
7
+ data.tar.gz: db6d03253ce56d049b95992f382c41c4ea7f9d44f5e1919243430ec40eb3b927f1365960641eb1ac30343ad557c1842cd9267d6ca738af12610a9c2bad90bbf6
@@ -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,10 +173,13 @@ 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
177
- if search[:collection].kind_of?(ActiveRecord::Relation)
180
+ if attributes[:searchable] == false
181
+ # Nothing to do
182
+ elsif search[:collection].kind_of?(ActiveRecord::Relation)
178
183
  search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.id] }
179
184
  elsif search[:collection].kind_of?(Array) && search[:collection].first.kind_of?(ActiveRecord::Base)
180
185
  search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.id] }
@@ -189,11 +194,19 @@ module Effective
189
194
  search_resource = [opts[:resource], effective_resource, fallback_effective_resource].compact
190
195
  search_resource = search_resource.find { |res| res.klass.present? } || search_resource.first
191
196
 
192
- if array_collection? && opts[:resource].present?
193
- search.reverse_merge!(search_resource.search_form_field(name, collection.first[opts[:index]]))
194
- elsif search[:as] == :select && search[:collection].kind_of?(Array)
197
+ # Assign search collections from effective_resources
198
+ if attributes[:searchable] == false
195
199
  # Nothing to do
196
- elsif search[:as] != :string
200
+ elsif search[:as] == :string
201
+ # Nothing to do. We're just a string search.
202
+ elsif search[:as] == :select && search[:collection].kind_of?(Array)
203
+ # Nothing to do. We already loaded the custom parameterized collection above.
204
+ elsif array_collection? && opts[:resource].present?
205
+ # Assigns { as: :select, collection: [...] }
206
+ search.reverse_merge!(search_resource.search_form_field(name, collection.first[opts[:index]]))
207
+ else
208
+ # Load the defaults from effective_resources
209
+ # Assigns { as: :string } or { as: :select, collection: [...] }
197
210
  search.reverse_merge!(search_resource.search_form_field(name, opts[:as]))
198
211
  end
199
212
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.20.3'.freeze
2
+ VERSION = '4.20.5'.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.3
4
+ version: 4.20.5
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-11-08 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