effective_organizations 0.0.8 → 0.2.1

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: 71f3a2d048f4c02e6388c77579b8c0ba2f348eb08574fcb9137759dceb0b5caa
4
- data.tar.gz: c5fe4918cf3116a728c6d0bb6ae0acd4146f4ebd2148b9012dc905041a70523e
3
+ metadata.gz: 3d52be5a66c34f0aa18c767a06ed30d2cd231b43ab13e1366cc7ef2a3531ef89
4
+ data.tar.gz: ba7b2680295717d510f5cc086c0588cb6048eab03afdc3d495974dbd4d8d57e8
5
5
  SHA512:
6
- metadata.gz: 92bac27ea6827e568a9ec4ca409feb38e8b162e4b213ea63c7451570be3bc51aa03ee6fd89a6c4ef85da4307e74f19b1157ceafbaa87a9ca1bb25d8f94ba1f4c
7
- data.tar.gz: 1a1fd5f3e02af92f13f4c303c12e11e08226e7dfb4f4e244d22b6785f8409493254cbe2b7d5c96000d5c9bb1705215e10b9cd1914828ceecf63d5acb2c336d8c
6
+ metadata.gz: eabee3b007990c185848082fe175b205ae8b666a9f5b183e377aead04285146e0efcbf4b7c9848cbd6b9f9ccca5aa26dbd6f9d4ce3902841c5add09d76df1a19
7
+ data.tar.gz: 5cc20f6f1370f40cd0c00c990df1c40deec55434b54726a780a7536a92b3c4116df8e59ad2818772b5f5d7108bb8ddb4aafb70cc1d3b8dcf24753e953b439763
@@ -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,10 +32,15 @@ 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
38
40
 
41
+ roles_mask :integer
42
+ archived :boolean
43
+
39
44
  representatives_count :integer # Counter cache
40
45
 
41
46
  timestamps
@@ -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
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.
@@ -6,7 +6,7 @@ EffectiveOrganizations.setup do |config|
6
6
  # Configure the Layout per controller, or all at once
7
7
  # config.layout = { application: 'application', admin: 'admin' }
8
8
 
9
- # Membership Categories Settings
9
+ # Organization Settings
10
10
  # Configure the class responsible for the organization.
11
11
  # config.organization_class_name = 'Effective::Organization'
12
12
  end
data/config/routes.rb CHANGED
@@ -12,7 +12,11 @@ EffectiveOrganizations::Engine.routes.draw do
12
12
  end
13
13
 
14
14
  namespace :admin do
15
- resources :organizations, except: [:show]
15
+ resources :organizations, except: [:show, :destroy] do
16
+ post :archive, on: :member
17
+ post :unarchive, on: :member
18
+ end
19
+
16
20
  resources :representatives, except: [:show]
17
21
  end
18
22
 
@@ -5,9 +5,13 @@ 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.boolean :archived, default: false
13
+
14
+ t.integer :representatives_count, default: 0
11
15
 
12
16
  t.datetime :updated_at
13
17
  t.datetime :created_at
@@ -18,6 +22,7 @@ class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
18
22
  # Representatives
19
23
  create_table :representatives do |t|
20
24
  t.integer :organization_id
25
+ t.string :organization_type
21
26
 
22
27
  t.integer :user_id
23
28
  t.string :user_type
@@ -28,7 +33,7 @@ class CreateEffectiveOrganizations < ActiveRecord::Migration[6.0]
28
33
  t.datetime :created_at
29
34
  end
30
35
 
31
- add_index :representatives, [:organization_id]
36
+ add_index :representatives, [:organization_id, :organization_type]
32
37
  add_index :representatives, [:user_id, :user_type]
33
38
 
34
39
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrganizations
2
- VERSION = '0.0.8'.freeze
2
+ VERSION = '0.2.1'.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.8
4
+ version: 0.2.1
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-22 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails