effective_organizations 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/organizations_controller.rb +1 -1
- data/app/models/concerns/effective_organizations_organization.rb +5 -12
- data/app/models/concerns/effective_organizations_user.rb +12 -10
- data/app/views/effective/organizations/_dashboard.html.haml +3 -3
- 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: 0ed8ea76f6be605f32e951431171d7be4d5c9885adf3adaa51ebd223ad2faa95
|
4
|
+
data.tar.gz: '08a0fa735dc997d95203d90abd6c5657855b6e957b00802800222cf8cfe00d5c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31c96c8af942654f9d314326363228f2cead96f47cd0f7e32f256d7a2362e7e5601bdeb35be78c5bf102c8bfa21d6adfe61664cb991e1d10effe2de937aeef36
|
7
|
+
data.tar.gz: 62ebff63f53a735bb6d185648611d40f717dd469ea03f7f5cb62be5c6027d0248f10f77a38fc8ae2f8bea82d3c2eac9887ead68d847c8fffecaf71032d83d399
|
@@ -6,7 +6,7 @@ module Admin
|
|
6
6
|
include Effective::CrudController
|
7
7
|
|
8
8
|
resource_scope -> { EffectiveOrganizations.Organization.deep.all }
|
9
|
-
datatable -> { Admin::EffectiveOrganizationsDatatable.new }
|
9
|
+
datatable -> { EffectiveResources.best('Admin::EffectiveOrganizationsDatatable').new }
|
10
10
|
|
11
11
|
private
|
12
12
|
|
@@ -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
|
@@ -34,9 +30,6 @@ module EffectiveOrganizationsOrganization
|
|
34
30
|
|
35
31
|
accepts_nested_attributes_for :representatives, allow_destroy: true
|
36
32
|
|
37
|
-
has_many :users, through: :representatives,
|
38
|
-
source_type: (@effective_organizations_organization_opts[:users_source_type] || (name.start_with?('Effective') ? '::User' : "#{name.split('::').first}::Organization"))
|
39
|
-
|
40
33
|
effective_resource do
|
41
34
|
title :string
|
42
35
|
category :string
|
@@ -56,10 +49,6 @@ module EffectiveOrganizationsOrganization
|
|
56
49
|
|
57
50
|
# Instance Methods
|
58
51
|
|
59
|
-
def to_s
|
60
|
-
title.presence || 'New Organization'
|
61
|
-
end
|
62
|
-
|
63
52
|
def representative(user:)
|
64
53
|
representatives.find { |rep| rep.user_id == user.id }
|
65
54
|
end
|
@@ -69,4 +58,8 @@ module EffectiveOrganizationsOrganization
|
|
69
58
|
representative(user: user) || representatives.build(user: user)
|
70
59
|
end
|
71
60
|
|
61
|
+
def users
|
62
|
+
representatives.reject(&:marked_for_destruction?).map(&:user)
|
63
|
+
end
|
64
|
+
|
72
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,19 +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
22
|
accepts_nested_attributes_for :representatives, allow_destroy: true
|
28
|
-
|
29
|
-
# App scoped
|
30
|
-
has_many :organizations, through: :representatives,
|
31
|
-
source_type: @effective_organizations_user_opts[:organizations_source_type] || "#{name.split('::').first}::Organization"
|
32
23
|
end
|
33
24
|
|
25
|
+
# Instance Methods
|
26
|
+
|
34
27
|
def representative(organization:)
|
35
28
|
representatives.find { |rep| rep.organization_id == organization.id }
|
36
29
|
end
|
37
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
|
+
|
38
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.1.0
|
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:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|