effective_resources 2.7.15 → 2.7.16

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: d09c8f004df1def2c6a2cebc8fd78ce3335138ccd5934b7803cc740663b94a84
4
- data.tar.gz: 45e2a292a727c4a810b959cc0880dff2d0a2ce150ae7afba7fcfed5715322c65
3
+ metadata.gz: 3812994d8dd5978a7e5b6162cc1fa6f041b1a119a33d0688934d7eb5f73aeb42
4
+ data.tar.gz: 5f884447a4d2c02318a97cd966ae729613926c123a99282fee92a44a859a653b
5
5
  SHA512:
6
- metadata.gz: a1e4d8ce6a7651ef6a75eb3d9e5db2f46b38bd2d6d399b26ad32d5c9cb1b38751cf2e0df139d916afdc0bf067ed07c67f8d3b3c7211faa6a7e82cb2189a8d7b7
7
- data.tar.gz: 3de7ab00c232373fc66c4254cdc49457b84c4bb32e53951ed50e94adab89f3819c8e659fd37ce88c8707b6f609877474d7c7da26cb70c8762b6ebe16c61c5abc
6
+ metadata.gz: 47b4d0ff41beeb1743b510cec5e74f209fbe311999931c4381e68d6ef7298f1bd3285224273bbb83deb30880910d9214c5f1c1796a3153d1358a0da0eb2e75c7
7
+ data.tar.gz: 35dd5881060ea91a9254537aafac5ff3105fd250782f7e2fc009a97957b0158b03edd37bd1e56a53f636d7817493989b40ec474ee71e8b1957595c9e981bbe38
@@ -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
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.16'.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.16
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-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails