effective_cpd 1.4.4 → 1.4.6
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_cpd_available_cycles_datatable.rb +1 -1
- data/app/models/concerns/effective_cpd_user.rb +15 -6
- data/app/models/effective/cpd_target.rb +4 -2
- data/app/views/admin/users/_form_cpd_targets.html.haml +3 -3
- data/lib/effective_cpd/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: 41c07110b8b5814d4ff968ffb44dc82d102ad50234907afb644ea887222a1992
|
4
|
+
data.tar.gz: 61546891dc6371599ade1e82e7ff75badab344d4eda831b96244131cf6347f88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c21fc17a84dab2f37c2c5429109e2a723525f7624236b60210360132c854365038e49a78b9fa57fb2737f5fa2e3b6bb9adc03d50c1fa1e7635157d23ae1956c1
|
7
|
+
data.tar.gz: 9da9b7474edd7e464f369b9e2c03517dc25f9b8bdeb5b6c986f018ba3387b7fc3f10d713828db62b0774270b390448c9fa5690689e5e40b48a0731e61af6e9c0
|
@@ -14,7 +14,7 @@ class EffectiveCpdAvailableCyclesDatatable < Effective::Datatable
|
|
14
14
|
end
|
15
15
|
|
16
16
|
actions_col(actions: []) do |cpd_cycle|
|
17
|
-
statement =
|
17
|
+
statement = current_user.cpd_statement(cpd_cycle: cpd_cycle)
|
18
18
|
|
19
19
|
if statement.blank?
|
20
20
|
dropdown_link_to('Start', effective_cpd.cpd_cycle_cpd_statement_build_path(cpd_cycle, :new, :start))
|
@@ -26,7 +26,7 @@ module EffectiveCpdUser
|
|
26
26
|
|
27
27
|
# Effective scoped
|
28
28
|
has_many :cpd_targets, -> { order(:cpd_cycle_id) }, inverse_of: :user, class_name: 'Effective::CpdTarget', dependent: :delete_all
|
29
|
-
accepts_nested_attributes_for :cpd_targets
|
29
|
+
accepts_nested_attributes_for :cpd_targets, reject_if: proc { |atts| atts['score'].blank? && atts['required_to_submit'].blank? }
|
30
30
|
|
31
31
|
# These two should not be sorted
|
32
32
|
scope :cpd_audit_auditees, -> { without_role(:cpd_audit_reviewer).without_role(:admin) }
|
@@ -43,11 +43,17 @@ module EffectiveCpdUser
|
|
43
43
|
}
|
44
44
|
end
|
45
45
|
|
46
|
+
# Requires for this user
|
46
47
|
def cpd_target_score(cpd_cycle:)
|
47
48
|
target = cpd_target(cpd_cycle: cpd_cycle)
|
48
49
|
return target.score if target&.score.present?
|
49
50
|
|
50
|
-
|
51
|
+
default_cpd_target_score(cpd_cycle: cpd_cycle)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Required for this user category without the targets
|
55
|
+
# Otherwise calculate default by membership category
|
56
|
+
def default_cpd_target_score(cpd_cycle:)
|
51
57
|
if self.class.try(:effective_memberships_user?)
|
52
58
|
category = membership_categories_on(cpd_cycle.start_at)&.first if cpd_cycle.start_at.present?
|
53
59
|
category ||= membership_categories_on(cpd_cycle.end_at)&.first if cpd_cycle.end_at.present?
|
@@ -73,19 +79,20 @@ module EffectiveCpdUser
|
|
73
79
|
end
|
74
80
|
|
75
81
|
def cpd_statement(cpd_cycle:)
|
76
|
-
raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:
|
82
|
+
raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cpd_cycle?)
|
77
83
|
cpd_statements.find { |cpd_statement| cpd_statement.cpd_cycle_id == cpd_cycle.id }
|
78
84
|
end
|
79
85
|
|
80
86
|
# Find or build
|
81
87
|
def build_cpd_statement(cpd_cycle:)
|
82
|
-
raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:
|
88
|
+
raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cpd_cycle?)
|
83
89
|
cpd_statement(cpd_cycle: cpd_cycle) || cpd_statements.build(cpd_cycle: cpd_cycle)
|
84
90
|
end
|
85
91
|
|
92
|
+
# Dont use IDs here
|
86
93
|
def cpd_target(cpd_cycle:)
|
87
94
|
raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cpd_cycle?)
|
88
|
-
cpd_targets.find { |cpd_target| cpd_target.
|
95
|
+
cpd_targets.find { |cpd_target| cpd_target.cpd_cycle == cpd_cycle }
|
89
96
|
end
|
90
97
|
|
91
98
|
# Find or build
|
@@ -96,7 +103,9 @@ module EffectiveCpdUser
|
|
96
103
|
|
97
104
|
# For the form
|
98
105
|
def build_cpd_targets
|
99
|
-
Effective::CpdCycle.sorted.all.each
|
106
|
+
Effective::CpdCycle.sorted.all.each do |cpd_cycle|
|
107
|
+
cpd_target(cpd_cycle: cpd_cycle) || cpd_targets.new(cpd_cycle: cpd_cycle)
|
108
|
+
end
|
100
109
|
cpd_targets.sort_by(&:cpd_cycle_id).reverse
|
101
110
|
end
|
102
111
|
|
@@ -20,8 +20,10 @@ module Effective
|
|
20
20
|
scope :deep, -> { includes(:user, :cpd_cycle) }
|
21
21
|
scope :sorted, -> { order(:cpd_cycle_id) }
|
22
22
|
|
23
|
-
validates :score, numericality: { greater_than_or_equal_to: 0
|
24
|
-
validates :
|
23
|
+
validates :score, numericality: { greater_than_or_equal_to: 0 }
|
24
|
+
validates :required_to_submit, inclusion: { in: [true, false], message: "can't be blank" }
|
25
|
+
|
26
|
+
validates :cpd_cycle_id, uniqueness: { scope: [:user_id, :user_type], message: 'target already exists' }
|
25
27
|
|
26
28
|
def to_s
|
27
29
|
score&.to_s || model_name.human
|
@@ -18,17 +18,17 @@
|
|
18
18
|
- collection = Effective::CpdTarget::REQUIRED_TO_SUBMIT
|
19
19
|
- cpd_cycle = ctf.object.cpd_cycle
|
20
20
|
- target = f.object.cpd_target_score(cpd_cycle: cpd_cycle)
|
21
|
+
- target_placeholder = f.object.default_cpd_target_score(cpd_cycle: cpd_cycle) || '-'
|
21
22
|
- required_to_submit = f.object.cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
|
22
23
|
- required_to_submit_placeholder = collection.find { |label, value| value == required_to_submit }.first
|
23
24
|
|
24
25
|
%tr
|
25
26
|
%td= link_to(cpd_cycle, effective_cpd.edit_admin_cpd_cycle_path(cpd_cycle), target: '_blank')
|
26
|
-
|
27
27
|
%td
|
28
28
|
.row
|
29
29
|
.col
|
30
|
-
= ctf.number_field :score, label: false, required: false, placeholder:
|
30
|
+
= ctf.number_field :score, label: false, required: false, placeholder: target_placeholder.to_s
|
31
31
|
.col
|
32
|
-
= ctf.select :required_to_submit, Effective::CpdTarget::REQUIRED_TO_SUBMIT, label: false, placeholder: required_to_submit_placeholder.to_s
|
32
|
+
= ctf.select :required_to_submit, Effective::CpdTarget::REQUIRED_TO_SUBMIT, label: false, required: false, placeholder: required_to_submit_placeholder.to_s
|
33
33
|
|
34
34
|
= f.save "Save #{cpd_targets_label}", 'data-confirm': "Really Save #{cpd_targets_label} for #{user}?"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_cpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6
|
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: 2023-03-
|
11
|
+
date: 2023-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|