effective_cpd 1.4.8 → 1.5.1

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: b3d7a598e697af490599b28a4a41ed90dbd14dbcca2536f0338bd5719ac7d61d
4
- data.tar.gz: 5caeef24e8a9e7f7714e804b802bdeae0bbd279b06c0014339c11ad834706fed
3
+ metadata.gz: '007309633bd01dfa4ad2731f7c36f6d576c471c6de1f8ec21f355da5615a2b0d'
4
+ data.tar.gz: f1a0b42227c58dea846ad8e288bccec8472ce05a747b790ef4a6b83ee8ab0539
5
5
  SHA512:
6
- metadata.gz: 1cb5eccf8a74482a2b4042fbc02e22807114ff263ca265fd9c287c160a0f9325375ef5cf92c65a09ab64846b2e696b14bcb9481a7049db12de7974c15be4dd5f
7
- data.tar.gz: 54ea80bfe7a910fd76b0532de17d69214def0d86f22dcb7fc6a278c53731546d9733b09b0d8fab4b681de98f5b55b1624950b50a33b4969a2e534e83383e3c6c
6
+ metadata.gz: 99d7615012e34a640bd5e3009559a431638880894f819910cbc3d6df770316c6e4329bebb2dfdd28cf44d7c39abf2f63f1682205232f5a8bea5f43c9e7b25c73
7
+ data.tar.gz: 99e4617ac625fa40c15e60cbe535824be383edf62306ebd3337b01204c5a03d9f3b89c7c441045848f932fcdb1c21c564aa349c3334eddb2c2eee9c73a54631e
@@ -19,3 +19,9 @@
19
19
  }
20
20
 
21
21
  }
22
+
23
+ .table-cpd-audit-review-statements {
24
+ .cpd-statement-activity {
25
+ .float-right { display: none; }
26
+ }
27
+ }
@@ -582,6 +582,7 @@ module EffectiveCpdAudit
582
582
  return false unless was_submitted?
583
583
  return false unless completed?
584
584
  return false unless cpd_audit_reviews.present? && cpd_audit_reviews.all?(&:completed?)
585
+ return false if was_missing_info?
585
586
 
586
587
  review!
587
588
  end
@@ -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, reject_if: proc { |atts| atts['score'].blank? && atts['required_to_submit'].blank? }
29
+ accepts_nested_attributes_for :cpd_targets, reject_if: :reject_cpd_target_attributes, allow_destroy: true
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,7 +43,7 @@ module EffectiveCpdUser
43
43
  }
44
44
  end
45
45
 
46
- # Requires for this user
46
+ # The required or targeted number of credits for this user in this cycle
47
47
  def cpd_target_score(cpd_cycle:)
48
48
  target = cpd_target(cpd_cycle: cpd_cycle)
49
49
  return target.score if target&.score.present?
@@ -51,8 +51,15 @@ module EffectiveCpdUser
51
51
  default_cpd_target_score(cpd_cycle: cpd_cycle)
52
52
  end
53
53
 
54
- # Required for this user category without the targets
55
- # Otherwise calculate default by membership category
54
+ # Whether the user can submit a statement without the required number of credits
55
+ def cpd_target_score_required_to_submit?(cpd_cycle:)
56
+ target = cpd_target(cpd_cycle: cpd_cycle)
57
+ return target.required_to_submit? unless target&.required_to_submit.nil?
58
+
59
+ default_cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
60
+ end
61
+
62
+ # Required for this user category without the targets. Used to display defaults on admin form.
56
63
  def default_cpd_target_score(cpd_cycle:)
57
64
  if self.class.try(:effective_memberships_user?)
58
65
  category = membership_categories_on(cpd_cycle.start_at)&.first if cpd_cycle.start_at.present?
@@ -63,10 +70,8 @@ module EffectiveCpdUser
63
70
  end
64
71
  end
65
72
 
66
- def cpd_target_score_required_to_submit?(cpd_cycle:)
67
- target = cpd_target(cpd_cycle: cpd_cycle)
68
- return target.required_to_submit? unless target&.required_to_submit.nil?
69
-
73
+ # Required for this user category without the targets. Used to display defaults on admin form.
74
+ def default_cpd_target_score_required_to_submit?(cpd_cycle:)
70
75
  cpd_cycle.required_to_submit?
71
76
  end
72
77
 
@@ -103,10 +108,23 @@ module EffectiveCpdUser
103
108
 
104
109
  # For the form
105
110
  def build_cpd_targets
106
- Effective::CpdCycle.sorted.all.each do |cpd_cycle|
111
+ Effective::CpdCycle.sorted.all.map do |cpd_cycle|
107
112
  cpd_target(cpd_cycle: cpd_cycle) || cpd_targets.new(cpd_cycle: cpd_cycle)
113
+ end.sort_by(&:cpd_cycle_id).reverse
114
+ end
115
+
116
+ private
117
+
118
+ def reject_cpd_target_attributes(atts)
119
+ # Reject if new record and blank
120
+ return true if (atts['id'].blank? && atts['score'].blank? && atts['required_to_submit'].blank?)
121
+
122
+ # Delete when ID present and score and required to submit blank
123
+ if (atts['id'].present? && atts['score'].blank? && atts['required_to_submit'].blank?)
124
+ atts.merge!({:_destroy => 1})
108
125
  end
109
- cpd_targets.sort_by(&:cpd_cycle_id).reverse
126
+
127
+ false
110
128
  end
111
129
 
112
130
  end
@@ -20,7 +20,7 @@ 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 }
23
+ validates :score, presence: true, numericality: { greater_than_or_equal_to: 0 }
24
24
  validates :required_to_submit, inclusion: { in: [true, false], message: "can't be blank" }
25
25
 
26
26
  validates :cpd_cycle_id, uniqueness: { scope: [:user_id, :user_type], message: 'target already exists' }
@@ -1,10 +1,9 @@
1
- = card('Determination') do
2
- = effective_form_with(model: [:admin, cpd_audit], engine: true) do |f|
3
- %p This action will <strong>close</strong> this #{cpd_audit_label} with the following determination:
1
+ = effective_form_with(model: [:admin, cpd_audit], engine: true) do |f|
2
+ %p This action will <strong>close</strong> this #{cpd_audit_label} with the following determination:
4
3
 
5
- = f.select :determination, cpd_audit.cpd_audit_level.determinations
4
+ = f.select :determination, cpd_audit.cpd_audit_level.determinations
6
5
 
7
- %h2 Email to Send
8
- = email_form_fields(f, :cpd_audit_closed)
6
+ %h2 Email to Send
7
+ = email_form_fields(f, :cpd_audit_closed)
9
8
 
10
- = f.submit 'Close', center: true, 'data-confirm': "Really close #{cpd_audit}?"
9
+ = f.submit 'Close', center: true, 'data-confirm': "Really close #{cpd_audit}?"
@@ -43,7 +43,7 @@
43
43
  = render 'admin/cpd_audits/form_files', cpd_audit: cpd_audit
44
44
 
45
45
  - if cpd_audit.user_cpd_required?
46
- = tab(cpd_audit.cpd_audit_reviews) do
46
+ = tab(cpd_audit.user.cpd_statements) do
47
47
  - datatable = Admin::EffectiveCpdStatementsDatatable.new(user: cpd_audit.user)
48
48
  = render_datatable(datatable, inline: true, simple: true)
49
49
 
@@ -55,6 +55,6 @@
55
55
  = tab(cpd_audit.chats) do
56
56
  = render 'admin/cpd_audits/form_chat', cpd_audit: cpd_audit
57
57
 
58
- - if cpd_audit.respond_to?(:log_changes_datatable)
58
+ - if cpd_audit.respond_to?(:logs_datatable)
59
59
  = tab 'Logs' do
60
- = render_inline_datatable(cpd_audit.log_changes_datatable)
60
+ = render_inline_datatable(cpd_audit.logs_datatable)
@@ -1,12 +1,14 @@
1
1
  = effective_form_with model: [:admin, user] do |f|
2
2
  = f.hidden_field :id
3
3
 
4
- %p The default values are displayed as placeholders.
4
+ %p
5
+ #{cpd_targets_label} set the requirements checked when submitting a #{cpd_statement_label}
5
6
 
6
7
  %table.table
7
8
  %thead
8
9
  %th= cpd_cycle_label
9
- %th Target or Required #{cpd_credits_label}
10
+ %th Default Requirements
11
+ %th Requirements for #{f.object}
10
12
 
11
13
  %tbody
12
14
  = f.fields_for :cpd_targets, f.object.build_cpd_targets do |ctf|
@@ -17,18 +19,27 @@
17
19
 
18
20
  - collection = Effective::CpdTarget::REQUIRED_TO_SUBMIT
19
21
  - cpd_cycle = ctf.object.cpd_cycle
22
+
20
23
  - target = f.object.cpd_target_score(cpd_cycle: cpd_cycle)
21
- - target_placeholder = f.object.default_cpd_target_score(cpd_cycle: cpd_cycle) || '-'
22
24
  - required_to_submit = f.object.cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
23
- - required_to_submit_placeholder = collection.find { |label, value| value == required_to_submit }.first
25
+
26
+ - default_target = f.object.default_cpd_target_score(cpd_cycle: cpd_cycle) || 0
27
+ - default_required_to_submit = f.object.default_cpd_target_score_required_to_submit?(cpd_cycle: cpd_cycle)
24
28
 
25
29
  %tr
26
30
  %td= link_to(cpd_cycle, effective_cpd.edit_admin_cpd_cycle_path(cpd_cycle), target: '_blank')
31
+ %td
32
+ %p
33
+ = pluralize(default_target, cpd_credit_label.downcase)
34
+ = default_required_to_submit ? 'required' : 'targeted'
35
+ and
36
+ = collection.find { |value| value.last == default_required_to_submit }.first.downcase
37
+
27
38
  %td
28
39
  .row
29
40
  .col
30
- = ctf.number_field :score, label: false, required: false, placeholder: target_placeholder.to_s
41
+ = ctf.number_field :score, required: false, label: false
31
42
  .col
32
- = ctf.select :required_to_submit, Effective::CpdTarget::REQUIRED_TO_SUBMIT, label: false, required: false, placeholder: required_to_submit_placeholder.to_s
43
+ = ctf.select :required_to_submit, Effective::CpdTarget::REQUIRED_TO_SUBMIT, required: false, label: false
33
44
 
34
45
  = f.save "Save #{cpd_targets_label}", 'data-confirm': "Really Save #{cpd_targets_label} for #{user}?"
@@ -1,5 +1,5 @@
1
1
  = wizard_card(cpd_audit_review) do
2
- %table.table.table-hover
2
+ %table.table.table-hover.table-cpd-audit-review-statements
3
3
  %thead
4
4
  %th #{cpd_audit_review.cpd_audit.name}'s #{cpd_statement}
5
5
  %th #{cpd_audit_review.name}'s Review
@@ -21,8 +21,7 @@
21
21
  = link_to(cpd_audit_review.user, url)
22
22
  %br
23
23
  %small= mail_to cpd_audit_review.user.email
24
-
25
- - if cpd_audit_review.anonymous? == false
24
+ - elsif cpd_audit_review.anonymous? == false
26
25
  %p
27
26
  = cpd_audit_review.user
28
27
  %br
@@ -40,8 +39,7 @@
40
39
  = link_to(cpd_audit.user, url)
41
40
  %br
42
41
  %small= mail_to cpd_audit.user.email
43
-
44
- - if cpd_audit.anonymous? == false
42
+ - elsif cpd_audit.anonymous? == false
45
43
  %p
46
44
  = cpd_audit.user
47
45
  %br
@@ -13,7 +13,7 @@
13
13
  %h2 Review Activities
14
14
  %p Please review the following activities:
15
15
 
16
- %table.table.table-hover
16
+ %table.table.table-hover.table-cpd-audit-review-statements
17
17
  %thead
18
18
  %th #{resource.cpd_audit.user}'s #{cpd_statement}
19
19
  %th #{resource.user}'s Review
@@ -13,8 +13,7 @@
13
13
  = link_to(cpd_audit.user, url)
14
14
  %br
15
15
  %small= mail_to cpd_audit.user.email
16
-
17
- - if cpd_audit.anonymous? == false
16
+ - elsif cpd_audit.anonymous? == false
18
17
  %p
19
18
  = cpd_audit.user
20
19
  %br
@@ -33,8 +32,7 @@
33
32
  = link_to(cpd_audit_review.user, url)
34
33
  %br
35
34
  %small= mail_to cpd_audit_review.user.email
36
-
37
- - if cpd_audit_review.anonymous? == false
35
+ - elsif cpd_audit_review.anonymous? == false
38
36
  %p
39
37
  = cpd_audit_review.user
40
38
  %br
@@ -3,7 +3,7 @@
3
3
 
4
4
  - raise('expected a submitted cpd_statement') unless resource.submitted_at.present?
5
5
 
6
- .alert.alert-warning.mb-4
6
+ .alert.alert-success.mb-4
7
7
  Successfully submitted on #{resource.submitted_at.strftime('%F')}.
8
8
 
9
9
  - if resource.cpd_cycle.all_steps_content.present?
@@ -9,11 +9,11 @@ en:
9
9
  activerecord:
10
10
  models:
11
11
  # These ones might be app level
12
- app/cpd_audit: 'CPD Audit'
13
- app/cpd_audit_level: 'CPD Audit Level'
14
- app/cpd_audit_review: 'CPD Audit Review'
15
- app/cpd_bulk_audit: 'Bulk Create CPD Audit Review'
16
- app/cpd_statement: 'CPD Statement'
12
+ cpd_audit: 'CPD Audit'
13
+ cpd_audit_level: 'CPD Audit Level'
14
+ cpd_audit_review: 'CPD Audit Review'
15
+ cpd_bulk_audit: 'Bulk Create CPD Audit Review'
16
+ cpd_statement: 'CPD Statement'
17
17
 
18
18
  # These ones should stay effective
19
19
  effective/cpd_cycle: 'CPD Period'
@@ -23,10 +23,10 @@ en:
23
23
 
24
24
  attributes:
25
25
  # These ones might be app level
26
- app/cpd_audit:
26
+ cpd_audit:
27
27
  user: 'Auditee'
28
28
  cpd_audit_comments: 'Reviewer Notes'
29
29
 
30
- app/cpd_audit_review:
30
+ cpd_audit_review:
31
31
  user: 'Reviewer'
32
32
  comments: 'Reviewer Notes'
@@ -21,7 +21,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
21
21
  end
22
22
 
23
23
  create_table <%= @cpd_activities_table_name %> do |t|
24
- t.references :cpd_category
24
+ t.integer :cpd_category_id
25
25
 
26
26
  t.string :title
27
27
  t.integer :position
@@ -37,7 +37,8 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
37
37
  end
38
38
 
39
39
  create_table <%= @cpd_rules_table_name %> do |t|
40
- t.references :cpd_cycle
40
+ t.integer :cpd_cycle_id
41
+
41
42
  t.integer :ruleable_id
42
43
  t.string :ruleable_type
43
44
 
@@ -53,7 +54,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
53
54
  end
54
55
 
55
56
  create_table <%= @cpd_special_rules_table_name %> do |t|
56
- t.references :cpd_cycle
57
+ t.integer :cpd_cycle_id
57
58
 
58
59
  t.decimal :max_credits_per_cycle
59
60
  t.string :category
@@ -63,20 +64,22 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
63
64
  end
64
65
 
65
66
  create_table <%= @cpd_special_rule_mates_table_name %> do |t|
66
- t.references :cpd_rule
67
- t.references :cpd_special_rule
67
+ t.integer :cpd_rule_id
68
+ t.integer :cpd_special_rule_id
68
69
 
69
70
  t.datetime :updated_at
70
71
  t.datetime :created_at
71
72
  end
72
73
 
73
74
  create_table <%= @cpd_statement_activities_table_name %> do |t|
74
- t.references :cpd_statement
75
- t.references :cpd_activity
76
- t.references :cpd_category
77
- t.references :original
75
+ t.integer :cpd_statement_id
76
+ t.string :cpd_statement_type
77
+
78
+ t.integer :cpd_activity_id
79
+ t.integer :cpd_category_id
80
+ t.integer :original_id
81
+ t.integer :cpd_cycle_id
78
82
 
79
- t.references :cpd_cycle
80
83
  t.integer :user_id
81
84
  t.string :user_type
82
85
 
@@ -97,7 +100,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
97
100
  end
98
101
 
99
102
  create_table <%= @cpd_statements_table_name %> do |t|
100
- t.references :cpd_cycle
103
+ t.integer :cpd_cycle_id
101
104
 
102
105
  t.integer :user_id
103
106
  t.string :user_type
@@ -158,7 +161,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
158
161
  t.integer :cpd_audit_level_id
159
162
  t.string :cpd_audit_level_type
160
163
 
161
- t.references :cpd_audit_level_section
164
+ t.integer :cpd_audit_level_section_id
162
165
 
163
166
  t.text :title
164
167
  t.string :category
@@ -171,7 +174,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
171
174
  end
172
175
 
173
176
  create_table <%= @cpd_audit_level_question_options_table_name %> do |t|
174
- t.references :cpd_audit_level_question, index: false
177
+ t.integer :cpd_audit_level_question_id
175
178
 
176
179
  t.text :title
177
180
  t.integer :position
@@ -286,8 +289,8 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
286
289
  t.integer :cpd_audit_id
287
290
  t.string :cpd_audit_type
288
291
 
289
- t.references :cpd_audit_level_question
290
- t.references :cpd_audit_level_section
292
+ t.integer :cpd_audit_level_question_id
293
+ t.integer :cpd_audit_level_section_id
291
294
 
292
295
  t.date :date
293
296
  t.string :email
@@ -300,8 +303,8 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
300
303
  end
301
304
 
302
305
  create_table <%= @cpd_audit_response_options_table_name %> do |t|
303
- t.references :cpd_audit_response
304
- t.references :cpd_audit_level_question_option, index: false
306
+ t.integer :cpd_audit_response_id
307
+ t.integer :cpd_audit_level_question_option_id
305
308
 
306
309
  t.datetime :updated_at
307
310
  t.datetime :created_at
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '1.4.8'
2
+ VERSION = '1.5.1'
3
3
  end
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.8
4
+ version: 1.5.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: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails