effective_organizations 0.0.7 → 0.2.0

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: cacbee4a7dd40f4151038a00c39b0e7ef134f0ec739ee29753bc8aa34a73dc8c
4
- data.tar.gz: 38e3039961b2ff7ceff0b66090370c9ace3f54ab6f16c666cdc68ca82b699d03
3
+ metadata.gz: f389ae4c41e7cdfdad7b45438d609e856120588a41349f646d01642a05b201fe
4
+ data.tar.gz: 154421f7cf8f595dbd94e97e58d6518e7ee7669e6c2215772430387076b12650
5
5
  SHA512:
6
- metadata.gz: bd0fd64f099a8a15adb96f3d7d0be5952e4a371f33beddab08427491b818fdcfd12484c376fceb8f0b468ed88423cd47f95c39f8bd9d45e14d2f51c98071b7fa
7
- data.tar.gz: 5a69fcb0b32b336e92cfe714c4641e1f38b7a549080e11e20c27031320a9a661d02c06fb7567831f04e105c0f7b9f3c1f4ee003342d67b0a05e4348317feffd9
6
+ metadata.gz: cadde1ce5c1f15a34d597cdf4ad85d6c5db65f4cd4e4e91cb121d38d91a6c4a2acd445489619d0525e50d919c514127a8f222cdc26c11d997b971d18f25b847b
7
+ data.tar.gz: e79c2db21ecb241094104e5624c0d5816e2d4ddaab9009b2071678b3dfac5b47a99694b1d466bc83a883d3b96f88bff85bc5d8fefbbe8c5e90ef8bbae4e14e57
@@ -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
 
@@ -5,8 +5,10 @@ class EffectiveRepresentativesDatatable < Effective::Datatable
5
5
  col :organization
6
6
  col :user
7
7
 
8
- col :email do |representative|
9
- mail_to(representative.user.email)
8
+ unless attributes[:user_id]
9
+ col :email do |representative|
10
+ mail_to(representative.user.email)
11
+ end
10
12
  end
11
13
 
12
14
  col :roles, search: roles_collection
@@ -32,6 +32,8 @@ module EffectiveOrganizationsOrganization
32
32
 
33
33
  effective_resource do
34
34
  title :string
35
+ email :string
36
+
35
37
  category :string
36
38
 
37
39
  notes :text
@@ -26,6 +26,11 @@ module Effective
26
26
  user.password ||= SecureRandom.base64(12) + '!@#123abcABC-'
27
27
  end
28
28
 
29
+ after_commit(on: [:create, :destroy], if: -> { user.class.respond_to?(:effective_memberships_owner?) }) do
30
+ user.representatives.reload
31
+ user.update_member_role!
32
+ end
33
+
29
34
  validates :organization, presence: true
30
35
  validates :user, presence: true
31
36
 
@@ -5,5 +5,5 @@
5
5
 
6
6
  - if organization.persisted?
7
7
  %h2 Representatives
8
- - datatable = Admin::EffectiveRepresentativesDatatable.new(organization_id: organization.id, organization_type: organization.class.name)
8
+ - datatable = Admin::EffectiveRepresentativesDatatable.new(organization: organization)
9
9
  = render_inline_datatable(datatable)
@@ -1,10 +1,10 @@
1
1
  %h2 Organizations
2
2
 
3
3
  - if current_user.organizations.present?
4
- %p You belong to #{pluralize(current_user.organizations.length, 'organization')}
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 do not belong to any organizations.
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.
@@ -5,9 +5,11 @@ class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
5
5
  t.string :title
6
6
 
7
7
  t.string :category
8
+ t.string :email
8
9
  t.text :notes
9
10
 
10
- t.integer :representatives_count, default: 0
11
+ t.integer :roles_mask
12
+ t.integer :representatives_count, default: 0
11
13
 
12
14
  t.datetime :updated_at
13
15
  t.datetime :created_at
@@ -18,6 +20,7 @@ class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
18
20
  # Representatives
19
21
  create_table :representatives do |t|
20
22
  t.integer :organization_id
23
+ t.string :organization_type
21
24
 
22
25
  t.integer :user_id
23
26
  t.string :user_type
@@ -28,7 +31,7 @@ class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
28
31
  t.datetime :created_at
29
32
  end
30
33
 
31
- add_index :representatives, [:organization_id]
34
+ add_index :representatives, [:organization_id, :organization_type]
32
35
  add_index :representatives, [:user_id, :user_type]
33
36
 
34
37
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrganizations
2
- VERSION = '0.0.7'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.7
4
+ version: 0.2.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: 2021-12-21 00:00:00.000000000 Z
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails