effective_organizations 0.0.4 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/effective_representatives_datatable.rb +15 -2
- 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 +1 -1
- 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: 71f3a2d048f4c02e6388c77579b8c0ba2f348eb08574fcb9137759dceb0b5caa
|
4
|
+
data.tar.gz: c5fe4918cf3116a728c6d0bb6ae0acd4146f4ebd2148b9012dc905041a70523e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92bac27ea6827e568a9ec4ca409feb38e8b162e4b213ea63c7451570be3bc51aa03ee6fd89a6c4ef85da4307e74f19b1157ceafbaa87a9ca1bb25d8f94ba1f4c
|
7
|
+
data.tar.gz: 1a1fd5f3e02af92f13f4c303c12e11e08226e7dfb4f4e244d22b6785f8409493254cbe2b7d5c96000d5c9bb1705215e10b9cd1914828ceecf63d5acb2c336d8c
|
@@ -11,11 +11,24 @@ class EffectiveRepresentativesDatatable < Effective::Datatable
|
|
11
11
|
|
12
12
|
col :roles, search: roles_collection
|
13
13
|
|
14
|
-
|
14
|
+
unless attributes[:actions] == false
|
15
|
+
actions_col
|
16
|
+
end
|
17
|
+
|
15
18
|
end
|
16
19
|
|
17
20
|
collection do
|
18
|
-
Effective::Representative.deep.all.where(organization: current_user.organizations)
|
21
|
+
scope = Effective::Representative.deep.all.where(organization: current_user.organizations)
|
22
|
+
|
23
|
+
if attributes[:organization_id]
|
24
|
+
scope = scope.where(organization_id: attributes[:organization_id])
|
25
|
+
end
|
26
|
+
|
27
|
+
if attributes[:user_id]
|
28
|
+
scope = scope.where(user_id: attributes[:user_id])
|
29
|
+
end
|
30
|
+
|
31
|
+
scope
|
19
32
|
end
|
20
33
|
|
21
34
|
def roles_collection
|
@@ -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
|
@@ -4,7 +4,7 @@
|
|
4
4
|
%p You belong to #{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
10
|
%p You do not belong to any organizations.
|
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.8
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|