effective_resources 2.0.2 → 2.0.4

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: aad99f05ab646eaf5777374411ea3cee95a7d6809a4dd1c9110ddd78b248e0a9
4
- data.tar.gz: 79a500fabc0110e16298f4031004655ba2d317413a1df90eb31390add344745f
3
+ metadata.gz: 5179c0bb8855a9265428e895d5ba520ca3c30fc4a0e4a5f08d2cbe026bf7801a
4
+ data.tar.gz: 9c5e6364e79d82e6f4419f114f24fffc77431ce2e793c241b387c0c97b38b542
5
5
  SHA512:
6
- metadata.gz: 211a18be0391a97797bab8d502ca0295c70cbe1d4a11da84e06fcf6f4187b1da9f027f85bda0cb513b6a4089d566f3698676ef973f4458ab7218bb2aebcb57ee
7
- data.tar.gz: 87612647fbde94ec96a736c2c462b22021c644ef7496aa3feb7b1da63f15baf83337ca002ebf9c920112e7c43caaf9b9351ff5b73712fefc8b62a61e723eba49
6
+ metadata.gz: 84c8b8610fe599ac1c1c7ee706bed4fe5b5575f7a66aef64f37b51a27ed589a49bb788fba3984870a078528af397ada56208629d1c51b558fd0e3e66385a701e
7
+ data.tar.gz: 8717b561cdf65de63cb5e3b7dc6a84c41ba9347bc08dfef01000ed91f2c2a6ad79708b6ca7554382d07a1da52ed99afb70e17b69463c2e9ea54ec8f8bbecfe79
@@ -8,6 +8,12 @@ module Admin
8
8
  def users
9
9
  collection = current_user.class.all
10
10
 
11
+ if collection.respond_to?(:to_select2)
12
+ collection = collection.to_select2
13
+ elsif collection.respond_to?(:sorted)
14
+ collection = collection.sorted
15
+ end
16
+
11
17
  respond_with_select2_ajax(collection) do |user|
12
18
  { id: user.to_param, text: user.try(:to_select2) || to_select2(user) }
13
19
  end
@@ -16,7 +22,7 @@ module Admin
16
22
  private
17
23
 
18
24
  def to_select2(user)
19
- "<span>#{user.first_name} #{user.last_name}</span> <small>#{user.email}</small>"
25
+ "<span>#{user}</span> <small>#{user.email}</small>"
20
26
  end
21
27
 
22
28
  end
@@ -200,6 +200,12 @@ module Effective
200
200
  return relation.where(klass.primary_key => maybe_id) if (maybe_id.to_i.to_s == maybe_id)
201
201
  end
202
202
 
203
+ # If the user specifies columns. Filter out invalid ones for this klass
204
+ if columns.present?
205
+ columns = Array(columns).map(&:to_s) - [nil, '']
206
+ columns = (columns & search_columns)
207
+ end
208
+
203
209
  # Otherwise, we fall back to a string/text search of all columns
204
210
  columns = Array(columns || search_columns).reject do |column|
205
211
  DO_NOT_SEARCH_EQUALS.any? { |value| column == value } ||
@@ -207,6 +213,8 @@ module Effective
207
213
  DO_NOT_SEARCH_END_WITH.any? { |value| column.end_with?(value) }
208
214
  end
209
215
 
216
+ return relation.none() if columns.blank?
217
+
210
218
  fuzzy = true unless fuzzy == false
211
219
 
212
220
  # Retval
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.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: 2022-10-05 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails