effective_cpd 0.1.4 → 0.1.9

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: 3f74220d92f6cb570ae692fae9610f7aa3c16435f025381cda0f1d76d37eb462
4
- data.tar.gz: 5370d91a541e895acccdfe6249e7fab92083bd2e7a39138a5f1c37fe0f6141f1
3
+ metadata.gz: 7162b54ab89371edc3ad2b153c3eb4aa2599ed991b644ec1afbb162bdd17f5b7
4
+ data.tar.gz: 73b6e124eeeaab16cbe56431138f7e318c3f9c03886efc150bc25f08aa7d5f7c
5
5
  SHA512:
6
- metadata.gz: 62863f2ebce7908df8170c7e981c026e2e16eff493376a2c21c00bfdeaeee1a2dd394713bfa5be6d1986452cd519ac6d94000f15c38ec8d5c3e561c4dd8eb297
7
- data.tar.gz: f039df8345571dc4812372211026330d2fb69bc20eb398110cb8e0a5831273c4940132770dfdcb85212867e8b1beb5c7761b81ea52ae6b803f4579d65c48e4f3
6
+ metadata.gz: 4d787b78e16b75081f3aafecc727f5f48f9427b7bca34c97dcc2ba70d8c1492dc834ce57617539385f35c6384845c96d034c6a6d2c92db5c5a21b8e1e1b7c1e3
7
+ data.tar.gz: 95bba087b9927c4910896b5bbdb46c34347a122f287d66932e3db70ea8cc3685caa3c971455552a2cb610eb22c39457056c0cb054cb322d795bd0717bb6ee8f4
@@ -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
 
@@ -94,6 +94,15 @@ module Effective
94
94
  end
95
95
  end
96
96
 
97
+ cycle.cpd_special_rules.each do |special_rule|
98
+ attributes = special_rule.dup.attributes.except('cpd_cycle_id')
99
+ cpd_special_rule = self.cpd_special_rules.build(attributes)
100
+
101
+ special_rule.ruleables.each do |ruleable|
102
+ cpd_special_rule.cpd_special_rule_mates.build(cpd_rule: self.rule_for(ruleable))
103
+ end
104
+ end
105
+
97
106
  self
98
107
  end
99
108
 
@@ -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
@@ -12,7 +13,7 @@
12
13
  label: "Max #{cpd_credits_label} per #{cpd_cycle_label}",
13
14
  hint: "The maximum number of #{cpd_credits_label} that may be earned in this category for this #{cpd_cycle_label}. Leave blank for no limit."
14
15
  .col
15
- = f.select :cpd_special_rule_ids, cpd_cycle.cpd_special_rules,
16
+ = fc.select :cpd_special_rule_ids, cpd_cycle.cpd_special_rules, multiple: true,
16
17
  label: 'Special Rules', hint: "Special rules operate on more than one category at a time"
17
18
 
18
19
  = fc.rich_text_area :category_credit_description,
@@ -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.4'
2
+ VERSION = '0.1.9'
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.4
4
+ version: 0.1.9
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