effective_resources 2.7.15 → 2.7.17

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: d09c8f004df1def2c6a2cebc8fd78ce3335138ccd5934b7803cc740663b94a84
4
- data.tar.gz: 45e2a292a727c4a810b959cc0880dff2d0a2ce150ae7afba7fcfed5715322c65
3
+ metadata.gz: 8d6b751ebab2af1f4b5ce1a6023628b4f71708c9201588827ca85b5463fddb94
4
+ data.tar.gz: 94016eb862f9a86023b4bbafc085ace95fe691b91a8d2306a7be8fd4496ce5dc
5
5
  SHA512:
6
- metadata.gz: a1e4d8ce6a7651ef6a75eb3d9e5db2f46b38bd2d6d399b26ad32d5c9cb1b38751cf2e0df139d916afdc0bf067ed07c67f8d3b3c7211faa6a7e82cb2189a8d7b7
7
- data.tar.gz: 3de7ab00c232373fc66c4254cdc49457b84c4bb32e53951ed50e94adab89f3819c8e659fd37ce88c8707b6f609877474d7c7da26cb70c8762b6ebe16c61c5abc
6
+ metadata.gz: 84623889aa71be0d8a29af1c09c03392543ba979a8d0c9c488b2cf50b2907df38ff0944bb75c8276a87542b645064ba6f69038c96d3a69dca36a0ab43eb06e1b
7
+ data.tar.gz: e211971173259ea986f4f9fabb7801b5d1f161ec121b71bcdcadc1ab2e7869e37f1d7b4847b4e6d14cfc8953fba3a421dc443a5f59cd82dedefc3d6a67328a32
@@ -19,10 +19,33 @@ module Admin
19
19
  end
20
20
  end
21
21
 
22
+ def organizations
23
+ raise('the effective memberships gem is required') unless defined?(EffectiveMemberships)
24
+
25
+ klass = EffectiveMemberships.Organization
26
+ raise('an EffectiveMemberships.Organization is required') unless klass.try(:effective_memberships_organization?)
27
+
28
+ collection = klass.all
29
+
30
+ if collection.respond_to?(:to_select2)
31
+ collection = collection.to_select2
32
+ elsif collection.respond_to?(:sorted)
33
+ collection = collection.sorted
34
+ end
35
+
36
+ respond_with_select2_ajax(collection) do |organization|
37
+ { id: organization.to_param, text: organization.try(:to_select2) || to_select2(organization) }
38
+ end
39
+ end
40
+
22
41
  private
23
42
 
24
- def to_select2(user)
25
- "<span>#{user}</span> <small>#{user.email}</small>"
43
+ def to_select2(resource)
44
+ if resource.try(:email).present?
45
+ "<span>#{resource}</span> <small>#{resource.email}</small>"
46
+ else
47
+ "<span>#{resource}</span>"
48
+ end
26
49
  end
27
50
 
28
51
  end
@@ -61,7 +61,7 @@ module Effective
61
61
  .order(Arel.sql("EXTRACT(hour from #{sql_column}) #{sql_direction}, EXTRACT(minute from #{sql_column}) #{sql_direction}"))
62
62
  else
63
63
  relation
64
- .order(Arel.sql("#{sql_column} #{sql_direction}"))
64
+ .order(Arel.sql(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column}='' ASC, #{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s))
65
65
  end
66
66
  end
67
67
 
data/config/routes.rb CHANGED
@@ -7,6 +7,7 @@ EffectiveResources::Engine.routes.draw do
7
7
  namespace :admin do
8
8
  resources :select2_ajax, only: [] do
9
9
  get :users, on: :collection
10
+ get :organizations, on: :collection
10
11
  end
11
12
  end
12
13
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.7.15'.freeze
2
+ VERSION = '2.7.17'.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.7.15
4
+ version: 2.7.17
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-05-31 00:00:00.000000000 Z
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails