effective_cpd 0.1.7 → 0.1.12

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: fa00b7ca9d6039709adb5c4948137632b28eeb8d8c551b5b489d9c4070722b51
4
- data.tar.gz: b53448836a6adc80ad1430ad3c569b5ee4f19cb1bc10339dbc222b44998dd97c
3
+ metadata.gz: cde9eaf26a9942cdb7c819292ccd1613563d5dad01bd0f15c751e92b9779a90f
4
+ data.tar.gz: 4871cc82d92fbd1280fabc31a914a0e92d5c07f66e98bfae183da5de203deeed
5
5
  SHA512:
6
- metadata.gz: 9bbc1c8162e0c595d1c51ea8148caa59de3654993b5764a177a5c66eda39ed7f29554a2bb1cf2f31f3b1f2d8eeaf6373866e64bbbdcf00e3bf6f796b8e918ddb
7
- data.tar.gz: 3f1cfa5651851f517a697f9cf540d3319b0f17583557d0e5dcf0d2a1e32c9de49a96b421c82b458677191650f7e722bd5468e133a610844f55a5474313324e12
6
+ metadata.gz: 588c74b697e23bd1172f7ea9001a04771ea9c0a609fd90d43c4f446b7986d0d229e0d558b7154e0d8ccd7c7ec1492abb3389346725955b073ab3765523dbb038
7
+ data.tar.gz: 7310fd2ca81076bd23eddd5d9f276f685b6d479857123fd7799cd16719d30170b659578eb4cc681caf659bef8435bc1f07b2dfe1d5b837a0f23673183ed1a746
data/README.md CHANGED
@@ -197,11 +197,13 @@ if user.admin?
197
197
  can :manage, Effective::CpdCycle
198
198
  can :manage, Effective::CpdRule
199
199
 
200
+ can([:index, :show], Effective::CpdStatement)
201
+ can(:unsubmit, Effective::CpdStatement) { |statement| statement.completed? }
202
+
200
203
  can :manage, Effective::CpdAuditLevel
201
204
  can :manage, Effective::CpdAuditLevelSection
202
205
  can :manage, Effective::CpdAuditLevelQuestion
203
206
 
204
- can :manage, Effective::CpdStatement
205
207
  can :manage, Effective::CpdAudit
206
208
  can :manage, Effective::CpdAuditReview
207
209
  end
@@ -1,14 +1,8 @@
1
1
  const initialize_effective_cpd_activities = function() {
2
- const $obj = $('.cpd-statement-activities:not(.initialized)')
2
+ const $obj = $('#cpd-statement-activities,.cpd-statement-activities')
3
3
 
4
4
  if($obj.length > 0) {
5
- $(document).on('mousedown touchstart', function(event) { collapse_effective_cpd_activities() })
6
-
7
- // When we click outside the New Activity or Edit Activity
8
- $(document).on('mousedown touchstart', '.activities-new', function(event) { event.stopPropagation() });
9
- $(document).on('mousedown touchstart', '.statement-activity', function(event) { event.stopPropagation() });
10
-
11
- $obj.addClass('initialized')
5
+ $('body').addClass('effective-cpd-statement-activities')
12
6
  }
13
7
  };
14
8
 
@@ -50,6 +44,15 @@ $(document).on('click', '[data-cpd-collapse]', function(event) {
50
44
  collapse_effective_cpd_activities()
51
45
  });
52
46
 
47
+ // Click outside the activities anywehre on body
48
+ $(document).on('mousedown touchstart', 'body.effective-cpd-statement-activities', function(event) {
49
+ collapse_effective_cpd_activities()
50
+ });
51
+
52
+ // When we click outside the New Activity or Edit Activity
53
+ $(document).on('mousedown touchstart', 'body.effective-cpd-statement-activities .activities-new', function(event) { event.stopPropagation() });
54
+ $(document).on('mousedown touchstart', 'body.effective-cpd-statement-activities .statement-activity', function(event) { event.stopPropagation() });
55
+
53
56
  // Initializers
54
- $(document).ready(function() { initialize_effective_cpd_activities() });
55
- $(document).on('turbolinks:load', function() { initialize_effective_cpd_activities() });
57
+ $(document).ready(initialize_effective_cpd_activities);
58
+ $(document).on('turbolinks:load', initialize_effective_cpd_activities);
@@ -3,6 +3,8 @@
3
3
  .progress { height: 3px; }
4
4
  }
5
5
 
6
+ .cpd-statement-activity { padding: 0.5rem; }
7
+
6
8
  .statement-activity-content {
7
9
  a { color: inherit; }
8
10
  }
@@ -22,7 +22,7 @@ module Effective
22
22
  flash[:danger] = "You have already completed a statement for this #{cpd_cycle_label}."
23
23
  redirect_to(root_path)
24
24
  elsif existing.present?
25
- flash[:success] = "You have been redirected to the #{resource_wizard_step_title(existing.next_step)} step."
25
+ flash[:success] = "You have been redirected to the #{resource_wizard_step_title(existing, existing.next_step)} step."
26
26
  redirect_to effective_cpd.cpd_cycle_cpd_statement_build_path(existing.cpd_cycle, existing, existing.next_step)
27
27
  end
28
28
  end
@@ -94,7 +94,7 @@ module Effective
94
94
  started_at :datetime
95
95
  submitted_at :datetime
96
96
  reviewed_at :datetime
97
- audited_at :datetime # TODO: CHange to closed_at
97
+ closed_at :datetime
98
98
 
99
99
  # Acts as tokened
100
100
  token :string
@@ -79,6 +79,11 @@ module Effective
79
79
  update!(submitted_at: Time.zone.now)
80
80
  end
81
81
 
82
+ # Called by admin only. This is an exceptional action
83
+ def unsubmit!
84
+ update!(wizard_steps: {}, submitted_at: nil, confirm_readonly: nil)
85
+ end
86
+
82
87
  def in_progress?
83
88
  submitted_at.blank?
84
89
  end
@@ -86,6 +91,7 @@ module Effective
86
91
  def completed?
87
92
  submitted_at.present?
88
93
  end
94
+ alias_method :submitted?, :completed?
89
95
 
90
96
  def required_score
91
97
  required_by_cycle = cpd_cycle&.required_score
@@ -10,7 +10,7 @@
10
10
  %tbody
11
11
  %tr
12
12
  %td Opened
13
- %td= cpd_audit.opened_at.strftime('%F') || '-'
13
+ %td= cpd_audit.opened_at&.strftime('%F') || '-'
14
14
  %td #{icon('check', class: 'small-1')} Done
15
15
  %td
16
16
 
@@ -38,7 +38,7 @@
38
38
  - if cpd_audit.completed?
39
39
  %tr
40
40
  %th Submitted on
41
- %td= cpd_audit.submitted_at.strftime('%F')
41
+ %td= cpd_audit.submitted_at&.strftime('%F') || '-'
42
42
 
43
43
  %tr
44
44
  %th Status
@@ -2,6 +2,7 @@
2
2
  - cpd_activity = cpd_statement_activity.cpd_activity
3
3
  - rule = cpd_statement_activity.cpd_statement.cpd_cycle.rule_for(cpd_activity)
4
4
 
5
+ .float-right= link_to icon('x', class: 'small-1'), '#', 'data-cpd-collapse': true
5
6
  %p
6
7
  = cpd_statement_activity
7
8
  %br
@@ -21,13 +22,13 @@
21
22
  .row
22
23
  - if cpd_activity.amount_label.present?
23
24
  .col
24
- %strong #{cpd_activity.amount_label.titleize.pluralize}
25
+ %strong= cpd_activity.amount_label
25
26
  %br
26
27
  = cpd_statement_activity.amount
27
28
 
28
29
  - if cpd_activity.amount2_label.present?
29
30
  .col.text-center
30
- %strong #{cpd_activity.amount2_label.to_s.titleize.pluralize} Articles written
31
+ %strong= cpd_activity.amount2_label
31
32
  = cpd_statement_activity.amount2
32
33
 
33
34
  - if cpd_activity.amount_static?
@@ -41,10 +41,10 @@
41
41
  .row
42
42
  .col
43
43
  - if activity.amount_label.present?
44
- = f.number_field :amount, label: activity.amount_label.titleize.pluralize, required: true
44
+ = f.number_field :amount, label: activity.amount_label, required: true
45
45
 
46
46
  - if activity.amount2_label.present?
47
- = f.number_field :amount2, label: activity.amount2_label.titleize.pluralize, required: true
47
+ = f.number_field :amount2, label: activity.amount2_label, required: true
48
48
 
49
49
  - if activity.amount_static?
50
50
  = f.hidden_field :amount, value: 1
@@ -1,5 +1,5 @@
1
1
  .cpd-statement-activities
2
- .row{style: 'margin-top: -2rem'}
2
+ .row
3
3
  .col-8
4
4
  .col-2.score
5
5
  %strong= cpd_credits_label.titleize
data/config/routes.rb CHANGED
@@ -34,7 +34,9 @@ EffectiveCpd::Engine.routes.draw do
34
34
  resources :cpd_rules, only: [:index]
35
35
  resources :cpd_special_rules, except: [:show]
36
36
 
37
- resources :cpd_statements, only: [:index, :show]
37
+ resources :cpd_statements, only: [:index, :show] do
38
+ post :unsubmit, on: :member
39
+ end
38
40
 
39
41
  resources :cpd_audit_levels, except: [:show]
40
42
  resources :cpd_audit_level_questions, except: [:show]
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.12'
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: 0.1.7
4
+ version: 0.1.12
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-05-26 00:00:00.000000000 Z
11
+ date: 2021-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails