effective_cpd 0.1.5 → 0.1.10

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: c655d5b1c2e948affbfee9558e51b7e66ca5cfd0e43fbf2a58fecc7a3b2d885f
4
- data.tar.gz: 06fe0a9add6534d48e5b51055343018c75723fa288f9051666fd29767fab0f86
3
+ metadata.gz: 42fb9cbcba6674433f77a1b274d2855000a94724aa34fe8ded25177eb9171046
4
+ data.tar.gz: 7c3fa8934b17b16a67b4fccbc2f29eba4b3af1beb66fb82b07706526dca8c60b
5
5
  SHA512:
6
- metadata.gz: bd95fa02fad56e41914ac568da4cdaf0b2413297a35fbccf4d8c32659d1e2e30c0e474871d33f124a03f7c962372a9136149cd587a520c6c41447e269692901a
7
- data.tar.gz: 212aaa715dcee4635d708a579fad03e18bdfd8b253515d2a3b3b2dcaf1419eb7237766c68260d83992c6520d802fc128ebd355537b820578ea823b9362101661
6
+ metadata.gz: 82101c275e55d097ced7a9f214758ae33886e319d38649be8997dae6cb62512239f78621ca3ab4e4be27738adc2c2ad2982b5f21a0fffed16a936526bb1aa9de
7
+ data.tar.gz: a22f3d126c721f109e0e2fb3e32a5b9bec21caa6e8bd3f9196c010088d0be3e4534e7a47ecaa707df1547c2393ba4503b4f0f39ce47458a4ca77714c2219f120
@@ -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
@@ -81,7 +81,7 @@ module Effective
81
81
  attributes = cycle.dup.attributes.except('title', 'token', 'start_at', 'end_at')
82
82
  assign_attributes(attributes)
83
83
 
84
- [:all_steps_content, :sidebar_content, :start_content, :activities_content, :submit_content, :complete_content].each do |rich_text|
84
+ [:all_steps_content, :sidebar_content, :start_content, :activities_content, :agreements_content, :submit_content, :complete_content].each do |rich_text|
85
85
  self.send("#{rich_text}=", cycle.send(rich_text))
86
86
  end
87
87
 
@@ -13,8 +13,8 @@ module Effective
13
13
  log_changes(to: :cpd_cycle)
14
14
  end
15
15
 
16
- # Only permit the words amount, amount2 and any charater 0-9 + - / * ( )
17
- INVALID_FORMULA_CHARS = /[^0-9\+\-\/\*\(\)]/
16
+ # Only permit the words amount, amount2 and any charater 0-9 + - / * . ( )
17
+ INVALID_FORMULA_CHARS = /[^0-9\+\-\.\/\*\(\)]/
18
18
 
19
19
  effective_resource do
20
20
  # A plaintext description of the formula
@@ -55,7 +55,7 @@ module Effective
55
55
 
56
56
  validate(if: -> { formula.present? }) do
57
57
  if formula.gsub('amount2', '').gsub('amount', '').gsub(' ', '').match(INVALID_FORMULA_CHARS).present?
58
- self.errors.add(:formula, "may only contain amount, amount2 and 0-9 + - / * ( ) characters")
58
+ self.errors.add(:formula, "may only contain amount, amount2 and 0-9 + - / * . ( ) characters")
59
59
  else
60
60
  begin
61
61
  eval_equation(amount: 0, amount2: 0)
@@ -118,7 +118,7 @@ module Effective
118
118
 
119
119
  def eval_equation(amount: nil, amount2: nil)
120
120
  equation = formula.gsub('amount2', amount2.to_s).gsub('amount', amount.to_s)
121
- eval(equation).to_i
121
+ eval(equation).round.to_i
122
122
  end
123
123
 
124
124
  end
@@ -1,4 +1,5 @@
1
1
  - edit_path = effective_cpd.edit_admin_cpd_category_path(cpd_category)
2
+ - cpd_rule = cpd_cycle.rule_for(cpd_category)
2
3
 
3
4
  = effective_form_with(model: [:admin, cpd_cycle], engine: true) do |f|
4
5
  %h2= cpd_category
@@ -22,40 +23,42 @@
22
23
 
23
24
  = f.submit
24
25
 
25
- = effective_form_with(model: [:admin, cpd_cycle], engine: true) do |f|
26
- %h2 Activities
27
- - rules = cpd_category.cpd_activities.map { |activity| cpd_cycle.rule_for(activity) }
26
+ - unless cpd_rule.unavailable?
28
27
 
29
- = f.fields_for :cpd_rules, rules do |fa|
30
- - activity = fa.object.ruleable
28
+ = effective_form_with(model: [:admin, cpd_cycle], engine: true) do |f|
29
+ %h2 Activities
30
+ - rules = cpd_category.cpd_activities.map { |activity| cpd_cycle.rule_for(activity) }
31
31
 
32
- = card do
33
- .row
34
- .col
35
- %h5.card-title= activity
36
- - if activity.body.present?
37
- %p= activity.body
32
+ = f.fields_for :cpd_rules, rules do |fa|
33
+ - activity = fa.object.ruleable
38
34
 
39
- %p= link_to 'Edit Activity', edit_path, target: '_blank'
35
+ = card do
36
+ .row
37
+ .col
38
+ %h5.card-title= activity
39
+ - if activity.body.present?
40
+ %p= activity.body
40
41
 
41
- = f.static_field :amount_label, value: activity.amount_label.presence || '-'
42
- = f.static_field :amount2_label, value: activity.amount2_label.presence || '-'
43
- = f.static_field :requires_upload_file, value: (activity.requires_upload_file ? 'Yes' : '-')
42
+ %p= link_to 'Edit Activity', edit_path, target: '_blank'
44
43
 
45
- .col
46
- = fa.text_field :formula, hint: cpd_rule_formula_hint(activity)
44
+ = f.static_field :amount_label, value: activity.amount_label.presence || '-'
45
+ = f.static_field :amount2_label, value: activity.amount2_label.presence || '-'
46
+ = f.static_field :requires_upload_file, value: (activity.requires_upload_file ? 'Yes' : '-')
47
47
 
48
- = fa.text_field :credit_description, label: "#{cpd_credits_label.titleize} description",
49
- hint: "A simple description of the formula and its #{cpd_credits_label} calculation"
48
+ .col
49
+ = fa.text_field :formula, hint: cpd_rule_formula_hint(activity)
50
50
 
51
- = fa.number_field :max_credits_per_cycle,
52
- label: "Max #{cpd_credits_label} per #{cpd_cycle_label}",
53
- hint: 'leave blank for no limit'
51
+ = fa.text_field :credit_description, label: "#{cpd_credits_label.titleize} description",
52
+ hint: "A simple description of the formula and its #{cpd_credits_label} calculation"
54
53
 
55
- = fa.number_field :max_cycles_can_carry_forward,
56
- label: "Max #{cpd_cycles_label} can carry forward",
57
- hint: "leave blank for no limit. enter zero for no carry forward."
54
+ = fa.number_field :max_credits_per_cycle,
55
+ label: "Max #{cpd_credits_label} per #{cpd_cycle_label}",
56
+ hint: 'leave blank for no limit'
58
57
 
59
- = fa.check_box :unavailable, label: "Unavailable in this #{cpd_cycle_label}"
58
+ = fa.number_field :max_cycles_can_carry_forward,
59
+ label: "Max #{cpd_cycles_label} can carry forward",
60
+ hint: "leave blank for no limit. enter zero for no carry forward."
60
61
 
61
- = f.submit
62
+ = fa.check_box :unavailable, label: "Unavailable in this #{cpd_cycle_label}"
63
+
64
+ = f.submit
@@ -21,13 +21,13 @@
21
21
  .row
22
22
  - if cpd_activity.amount_label.present?
23
23
  .col
24
- %strong #{cpd_activity.amount_label.titleize.pluralize}
24
+ %strong= cpd_activity.amount_label
25
25
  %br
26
26
  = cpd_statement_activity.amount
27
27
 
28
28
  - if cpd_activity.amount2_label.present?
29
29
  .col.text-center
30
- %strong #{cpd_activity.amount2_label.to_s.titleize.pluralize} Articles written
30
+ %strong= cpd_activity.amount2_label
31
31
  = cpd_statement_activity.amount2
32
32
 
33
33
  - 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
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.10'
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.5
4
+ version: 0.1.10
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-21 00:00:00.000000000 Z
11
+ date: 2021-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails