effective_organizations 0.0.5 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/effective_organizations_organization.rb +13 -9
- data/app/models/concerns/effective_organizations_user.rb +13 -9
- data/app/views/effective/organizations/_dashboard.html.haml +3 -3
- data/app/views/effective/organizations/_form_organization.html.haml +1 -1
- data/lib/effective_organizations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1251bb3a7cf64ab3a2cc1019031611b6e62bcde3e146026075ca9f3a09a4950
|
4
|
+
data.tar.gz: c240b5ef71a712a338ccf3153a91f06babde47008cb5b30990fc88049406ed6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444bb29c6c1ec54d698e10f4b0ba16cf418fccfede8aad5ef06fa59adc9ea3253f8f67bc5932e2d312fee608d609dc8bc9ef5ca5f9f832fadea700574bffe2d5
|
7
|
+
data.tar.gz: 2c0807e703a5bd3ff0db559de7d963e2f6ba3f772558543f16118063172cf1d4de3a6baba579adf054689b37e65a5149fa1ecc7a0a9ccfa19e7573edc2908715
|
@@ -6,11 +6,7 @@ module EffectiveOrganizationsOrganization
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
module Base
|
9
|
-
def effective_organizations_organization
|
10
|
-
@effective_organizations_organization_opts = {
|
11
|
-
users_source_type: users_source_type
|
12
|
-
}
|
13
|
-
|
9
|
+
def effective_organizations_organization
|
14
10
|
include ::EffectiveOrganizationsOrganization
|
15
11
|
end
|
16
12
|
end
|
@@ -32,8 +28,7 @@ module EffectiveOrganizationsOrganization
|
|
32
28
|
has_many :representatives, -> { Effective::Representative.sorted },
|
33
29
|
class_name: 'Effective::Representative', inverse_of: :organization, dependent: :delete_all
|
34
30
|
|
35
|
-
|
36
|
-
source_type: (@effective_organizations_organization_opts[:users_source_type] || (name.start_with?('Effective') ? '::User' : "#{name.split('::').first}::Organization"))
|
31
|
+
accepts_nested_attributes_for :representatives, allow_destroy: true
|
37
32
|
|
38
33
|
effective_resource do
|
39
34
|
title :string
|
@@ -54,8 +49,17 @@ module EffectiveOrganizationsOrganization
|
|
54
49
|
|
55
50
|
# Instance Methods
|
56
51
|
|
57
|
-
def
|
58
|
-
|
52
|
+
def representative(user:)
|
53
|
+
representatives.find { |rep| rep.user_id == user.id }
|
54
|
+
end
|
55
|
+
|
56
|
+
# Find or build
|
57
|
+
def build_representative(user:)
|
58
|
+
representative(user: user) || representatives.build(user: user)
|
59
|
+
end
|
60
|
+
|
61
|
+
def users
|
62
|
+
representatives.reject(&:marked_for_destruction?).map(&:user)
|
59
63
|
end
|
60
64
|
|
61
65
|
end
|
@@ -6,11 +6,7 @@ module EffectiveOrganizationsUser
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
module Base
|
9
|
-
def effective_organizations_user
|
10
|
-
@effective_organizations_user_opts = {
|
11
|
-
organizations_source_type: organizations_source_type
|
12
|
-
}
|
13
|
-
|
9
|
+
def effective_organizations_user
|
14
10
|
include ::EffectiveOrganizationsUser
|
15
11
|
end
|
16
12
|
end
|
@@ -20,17 +16,25 @@ module EffectiveOrganizationsUser
|
|
20
16
|
end
|
21
17
|
|
22
18
|
included do
|
23
|
-
# My teams
|
24
19
|
has_many :representatives, -> { Effective::Representative.sorted },
|
25
20
|
class_name: 'Effective::Representative', inverse_of: :user, dependent: :delete_all
|
26
21
|
|
27
|
-
|
28
|
-
has_many :organizations, through: :representatives,
|
29
|
-
source_type: @effective_organizations_user_opts[:organizations_source_type] || "#{name.split('::').first}::Organization"
|
22
|
+
accepts_nested_attributes_for :representatives, allow_destroy: true
|
30
23
|
end
|
31
24
|
|
25
|
+
# Instance Methods
|
26
|
+
|
32
27
|
def representative(organization:)
|
33
28
|
representatives.find { |rep| rep.organization_id == organization.id }
|
34
29
|
end
|
35
30
|
|
31
|
+
# Find or build
|
32
|
+
def build_representative(organization:)
|
33
|
+
representative(organization: organization) || representatives.build(organization: organization)
|
34
|
+
end
|
35
|
+
|
36
|
+
def organizations
|
37
|
+
representatives.reject(&:marked_for_destruction?).map(&:organization)
|
38
|
+
end
|
39
|
+
|
36
40
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
%h2 Organizations
|
2
2
|
|
3
3
|
- if current_user.organizations.present?
|
4
|
-
%p You
|
4
|
+
%p You are a representative for #{pluralize(current_user.organizations.length, 'organization')}.
|
5
5
|
|
6
6
|
- datatable = EffectiveResources.best('EffectiveOrganizationsDatatable').new(self, namespace: :effective)
|
7
|
-
= render_datatable(datatable)
|
7
|
+
= render_datatable(datatable, simple: true)
|
8
8
|
|
9
9
|
- else
|
10
|
-
%p You
|
10
|
+
%p You are not a representative. When you create an organization, or if someone else adds you to their organization, we'll show them here.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_organizations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
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: 2021-12-
|
11
|
+
date: 2021-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|