effective_committees 0.1.1 → 0.2.0
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 +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_folders/_committee_folder.html.haml +1 -1
- data/app/views/effective/committee_members/_form.html.haml +8 -0
- data/app/views/effective/committees/_committee.html.haml +2 -2
- data/db/migrate/01_create_effective_committees.rb.erb +3 -0
- data/lib/effective_committees/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: df8c75f5e33b7cfb2d7776ba54655cdbdd88a307eaf8b0d817685743b6bd3a0f
|
4
|
+
data.tar.gz: 22e99e41a9473983068db1b470621a97fcde2cdf0106e0b9de0621e878c7016f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce05c9720c80bd99d4bce72f8e99143a12d625afea0feedc702179606cb49ef44908275c8cd6778a100045a4bb158d4124c06744a04a0c602afb8eec7cd11da6
|
7
|
+
data.tar.gz: f6ab66c124d105d761a83c0623ac24cd6792607efc3f4375669657c021640055bda8cfbb2ac1c59c59a2ef5b64d136a243c0e99bae5ba081e0e35362ca7b15b4
|
@@ -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
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
.effective-committee
|
7
7
|
- if committee.rich_text_body.present?
|
8
|
-
.mb-4= committee.rich_text_body
|
8
|
+
.mb-4= committee.rich_text_body.to_s
|
9
9
|
|
10
10
|
%table.table.table-striped
|
11
11
|
%thead
|
@@ -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')}
|
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.
|
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: 2022-
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|