effective_committees 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/admin/effective_committee_members_datatable.rb +7 -0
- data/app/datatables/effective_committee_members_datatable.rb +3 -0
- data/app/datatables/effective_committees_datatable.rb +1 -0
- data/app/models/concerns/effective_committees_user.rb +1 -1
- data/app/models/effective/committee_member.rb +22 -2
- data/app/views/admin/committee_members/_form.html.haml +9 -2
- data/app/views/effective/committee_members/_form.html.haml +8 -0
- data/app/views/effective/committees/_committee.html.haml +1 -1
- data/config/locales/effective_committees.en.yml +11 -0
- data/db/migrate/01_create_effective_committees.rb.erb +3 -0
- data/lib/effective_committees/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd2e7e60e604c2c37d662cde5abd1d4823b4400762bed564e734b50c65f16a5f
|
4
|
+
data.tar.gz: 713486d3de4e2aa4412762f243f0f9f352f5c74f7786cddc89e1781ef2b49de6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b3e9bd523495fb20bde48fac897b64bffd58f5197ef458008e95a7b6b752b74959dc2b67196c5471d9ceba45e0b5565fb334dd05fe3ddd33a6f60d03083c0bf
|
7
|
+
data.tar.gz: e3c37293212b4fd74121f1ca3fe2aba2a1d776199484cafba8821a0fc40466622f7df8bf9c06375bb4c60a26171e51adbd15562845ec0d2eb9cf3bb312f07423
|
@@ -13,6 +13,13 @@ module Admin
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
col :start_on
|
17
|
+
col :end_on
|
18
|
+
|
19
|
+
col :expired do |committee_member|
|
20
|
+
badge('expired') if committee_member.expired?
|
21
|
+
end
|
22
|
+
|
16
23
|
if EffectiveCommittees.use_effective_roles
|
17
24
|
col :roles, search: roles_collection
|
18
25
|
end
|
@@ -18,6 +18,9 @@ module Effective
|
|
18
18
|
effective_resource do
|
19
19
|
roles_mask :integer
|
20
20
|
|
21
|
+
start_on :date
|
22
|
+
end_on :date
|
23
|
+
|
21
24
|
timestamps
|
22
25
|
end
|
23
26
|
|
@@ -34,13 +37,13 @@ module Effective
|
|
34
37
|
|
35
38
|
after_commit(if: -> { user_ids.present? }) do
|
36
39
|
additional = (user_ids - CommitteeMember.where(committee_id: committee_id, user_id: user_ids).pluck(:user_id))
|
37
|
-
additional = additional.map { |user_id| {committee_id: committee_id, committee_type: committee_type, user_id: user_id, user_type: user_type, roles_mask: roles_mask} }
|
40
|
+
additional = additional.map { |user_id| {committee_id: committee_id, committee_type: committee_type, user_id: user_id, user_type: user_type, roles_mask: roles_mask, start_on: start_on, end_on: end_on} }
|
38
41
|
CommitteeMember.insert_all(additional)
|
39
42
|
end
|
40
43
|
|
41
44
|
after_commit(if: -> { committee_ids.present? }) do
|
42
45
|
additional = (committee_ids - CommitteeMember.where(user_id: user_id, committee_id: committee_ids).pluck(:committee_id))
|
43
|
-
additional = additional.map { |committee_id| {committee_id: committee_id, committee_type: committee_type, user_id: user_id, user_type: user_type, roles_mask: roles_mask} }
|
46
|
+
additional = additional.map { |committee_id| {committee_id: committee_id, committee_type: committee_type, user_id: user_id, user_type: user_type, roles_mask: roles_mask, start_on: start_on, end_on: end_on} }
|
44
47
|
CommitteeMember.insert_all(additional)
|
45
48
|
end
|
46
49
|
|
@@ -50,10 +53,27 @@ module Effective
|
|
50
53
|
validates :user_id, if: -> { user_id && user_type && committee_id && committee_type },
|
51
54
|
uniqueness: { scope: [:committee_id, :committee_type], message: 'already belongs to this committee' }
|
52
55
|
|
56
|
+
validate(if: -> { start_on && end_on }) do
|
57
|
+
self.errors.add(:end_on, 'must be after start date') unless end_on > start_on
|
58
|
+
end
|
59
|
+
|
53
60
|
def to_s
|
54
61
|
user.to_s
|
55
62
|
end
|
56
63
|
|
64
|
+
def active?(date: nil)
|
65
|
+
return true if start_on.blank? && end_on.blank?
|
66
|
+
|
67
|
+
date ||= Time.zone.now
|
68
|
+
date = date.to_date if date.respond_to?(:to_date)
|
69
|
+
|
70
|
+
(start_on..end_on).cover?(date) # Endless ranges
|
71
|
+
end
|
72
|
+
|
73
|
+
def expired?(date: nil)
|
74
|
+
active?(date: date) == false
|
75
|
+
end
|
76
|
+
|
57
77
|
def user_ids
|
58
78
|
Array(@user_ids) - [nil, '']
|
59
79
|
end
|
@@ -10,21 +10,28 @@
|
|
10
10
|
= f.hidden_field :committee_type
|
11
11
|
= f.hidden_field :committee_id
|
12
12
|
|
13
|
+
- ajax_url = (@select2_ajax_path || effective_resources.users_admin_select2_ajax_index_path) unless Rails.env.test?
|
14
|
+
|
13
15
|
- if f.object.new_record?
|
14
16
|
- if inline_datatable? && inline_datatable.attributes[:committee_id].present?
|
15
|
-
= f.select :user_ids, current_user.class.sorted, label: 'Add user(s)', hint: 'Add one or more users'
|
17
|
+
= f.select :user_ids, current_user.class.sorted, label: 'Add user(s)', required: true, ajax_url: ajax_url, hint: 'Add one or more users'
|
16
18
|
|
17
19
|
- if inline_datatable? && inline_datatable.attributes[:user_id].present?
|
18
20
|
= f.select :committee_ids, committees, label: 'Add committee(s)', hint: 'Add one or more committees'
|
19
21
|
|
20
22
|
- unless inline_datatable?
|
21
23
|
= f.select :committee_id, committees, label: 'Committee'
|
22
|
-
|
24
|
+
|
25
|
+
= f.select :user_ids, current_user.class.sorted, label: 'User(s)', required: true, ajax_url: ajax_url, hint: 'Add one or more user at a time'
|
23
26
|
|
24
27
|
- if f.object.persisted?
|
25
28
|
= f.static_field :committee
|
26
29
|
= f.static_field :user, label: 'Committee Member'
|
27
30
|
|
31
|
+
.row
|
32
|
+
.col= f.date_field :start_on, hint: 'optional start date'
|
33
|
+
.col= f.date_field :end_on, hint: 'optional end date'
|
34
|
+
|
28
35
|
- if EffectiveCommittees.use_effective_roles
|
29
36
|
= f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
|
30
37
|
|
@@ -10,6 +10,10 @@
|
|
10
10
|
- unless inline_datatable? && inline_datatable.attributes[:committee_id].present?
|
11
11
|
= f.select :committee, { 'Committees' => Effective::Committee.sorted }, polymorphic: true
|
12
12
|
|
13
|
+
.row
|
14
|
+
.col= f.date_field :start_on, hint: 'optional start date'
|
15
|
+
.col= f.date_field :end_on, hint: 'optional end date'
|
16
|
+
|
13
17
|
- if EffectiveCommittees.use_effective_roles
|
14
18
|
= f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
|
15
19
|
|
@@ -26,6 +30,10 @@
|
|
26
30
|
- unless inline_datatable? && inline_datatable.attributes[:user_id].present?
|
27
31
|
= f.static_field :user
|
28
32
|
|
33
|
+
.row
|
34
|
+
.col= f.date_field :start_on, hint: 'optional start date'
|
35
|
+
.col= f.date_field :end_on, hint: 'optional end date'
|
36
|
+
|
29
37
|
- if EffectiveCommittees.use_effective_roles
|
30
38
|
= f.checks :roles, EffectiveRoles.roles_collection(f.object, skip_disabled: true)
|
31
39
|
|
@@ -18,6 +18,6 @@
|
|
18
18
|
%tr
|
19
19
|
%td= link_to(icon('folder') + folder, effective_committees.committee_committee_folder_path(committee, folder))
|
20
20
|
%td= pluralize(folder.committee_files.length, 'file')
|
21
|
-
%td= folder.body
|
21
|
+
%td= folder.body.to_s
|
22
22
|
|
23
23
|
%p Displaying #{pluralize(committee.committee_folders.length, 'folder')}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
en:
|
2
|
+
effective_committees:
|
3
|
+
name: 'Effective Committees'
|
4
|
+
acronym: 'Committees'
|
5
|
+
|
6
|
+
activerecord:
|
7
|
+
models:
|
8
|
+
effective/committee: 'Committee'
|
9
|
+
effective/committee_file: 'Committee File'
|
10
|
+
effective/committee_folder: 'Committee Folder'
|
11
|
+
effective/committee_member: 'Committee Member'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_committees
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
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:
|
11
|
+
date: 2023-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- app/views/effective/committees/_form_committee.html.haml
|
216
216
|
- app/views/effective/committees/index.html.haml
|
217
217
|
- config/effective_committees.rb
|
218
|
+
- config/locales/effective_committees.en.yml
|
218
219
|
- config/routes.rb
|
219
220
|
- db/migrate/01_create_effective_committees.rb.erb
|
220
221
|
- db/seeds.rb
|