effective_resources 2.8.8 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_resources_wizard_helper.rb +18 -5
- data/app/models/concerns/acts_as_purchasable_wizard.rb +2 -0
- data/app/models/concerns/acts_as_statused.rb +37 -11
- data/app/models/effective/resources/paths.rb +9 -0
- data/lib/effective_resources/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: 10642ec990cb0ad6b2426415a997aead2f5d53bcdb8a932b3f276af5e9485af9
|
4
|
+
data.tar.gz: a971535ad4974d3931be497db3595f91e1baac7483f718e3197778e84674e525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8ee4692a6b49d21cfe3d591233f9991355cb1d4d3697d5317fceb7186eb9011db71edef3dc8b6ddedc8ba97d3d28b7c7cf80bf753c18a31b344c8cbc7393db1
|
7
|
+
data.tar.gz: 7cfa99b30169c1bb0bc316dafdc29bad35996b678affea7f21e9ab6fe469bdf4dd6a3fe013d028b8e8fb4cd4281aa809640477db683e3cb0d987bc40d62375b5
|
@@ -42,19 +42,32 @@ module EffectiveResourcesWizardHelper
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def render_wizard_resource_step(resource, step, as: nil, path: nil)
|
46
|
+
render_wizard_resource(resource, only: step, as: as, path: path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def render_wizard_resource(resource, only: [], except: [], as: nil, path: nil)
|
46
50
|
effective_resource = Effective::Resource.new(resource)
|
47
51
|
|
52
|
+
# Render path
|
48
53
|
as ||= effective_resource.name
|
49
|
-
path ||= effective_resource.
|
54
|
+
path ||= effective_resource.wizard_file_path(resource)
|
50
55
|
raise('expected a path') unless path.present?
|
51
56
|
|
52
57
|
resource.render_path = path.to_s.chomp('/')
|
53
58
|
|
54
|
-
|
55
|
-
|
59
|
+
# Render steps
|
60
|
+
only = Array(only)
|
61
|
+
except = Array(except)
|
62
|
+
|
63
|
+
steps = resource.render_steps
|
64
|
+
steps = (steps - except) if except.present?
|
65
|
+
steps = (steps & only) if only.present?
|
66
|
+
|
67
|
+
steps.map do |step|
|
68
|
+
resource.render_step = step
|
56
69
|
|
57
|
-
render_if_exists("#{path}/#{
|
70
|
+
render_if_exists("#{path}/#{step}", as.to_sym => resource) || render('effective/acts_as_wizard/wizard_step', resource: resource, resource_path: path)
|
58
71
|
end.join.html_safe
|
59
72
|
end
|
60
73
|
|
@@ -89,7 +89,9 @@ module ActsAsPurchasableWizard
|
|
89
89
|
raise('already has purchased submit fees') if fees.any?(&:purchased?)
|
90
90
|
|
91
91
|
order = find_or_build_submit_order()
|
92
|
+
raise('expected an Effective::Order') unless order.kind_of?(Effective::Order)
|
92
93
|
raise('already has purchased submit order') if order.purchased?
|
94
|
+
raise('unable to proceed with a voided submit order') if order.try(:voided?)
|
93
95
|
|
94
96
|
true
|
95
97
|
end
|
@@ -39,7 +39,7 @@ module ActsAsStatused
|
|
39
39
|
const_set(:STATUSES, acts_as_statused_options[:statuses])
|
40
40
|
|
41
41
|
before_validation do
|
42
|
-
self.status ||=
|
42
|
+
self.status ||= all_statuses.first
|
43
43
|
|
44
44
|
# Set an existing belongs_to automatically
|
45
45
|
if respond_to?("#{status}_by") && send("#{status}_by").blank?
|
@@ -132,25 +132,51 @@ module ActsAsStatused
|
|
132
132
|
end
|
133
133
|
|
134
134
|
# unapproved!
|
135
|
-
define_method("un#{sym}!") do
|
136
|
-
|
135
|
+
define_method("un#{sym}!") do |atts = {}|
|
136
|
+
raise 'expected a Hash of passed attributes' unless atts.kind_of?(Hash)
|
137
137
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
if respond_to?("#{sym}_by") && send("#{sym}_by").present?
|
143
|
-
self.send("#{sym}_by=", nil)
|
144
|
-
end
|
138
|
+
self.try("#{sym}_at=", nil)
|
139
|
+
self.try("#{sym}_by=", nil)
|
140
|
+
self.try("#{sym}_by_id=", nil)
|
141
|
+
self.try("#{sym}_by_type=", nil)
|
145
142
|
|
146
143
|
status_steps.delete(sym_at)
|
147
144
|
status_steps.delete(sym_by_id)
|
148
145
|
status_steps.delete(sym_by_type)
|
149
146
|
|
150
|
-
|
147
|
+
if status == sym.to_s # I was just this status
|
148
|
+
assign_attributes(status: last_completed_status || all_statuses.first)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Assign atts if present
|
152
|
+
assign_attributes(atts) if atts.present?
|
153
|
+
|
154
|
+
save!
|
151
155
|
end
|
156
|
+
end
|
152
157
|
|
158
|
+
# Regular instance methods
|
159
|
+
# Sort of matches acts_as_wizard
|
160
|
+
def status_keys
|
161
|
+
self.class.const_get(:STATUSES)
|
153
162
|
end
|
163
|
+
|
164
|
+
def all_statuses
|
165
|
+
status_keys
|
166
|
+
end
|
167
|
+
|
168
|
+
def completed_statuses
|
169
|
+
all_statuses.select { |status| has_completed_status?(status) }
|
170
|
+
end
|
171
|
+
|
172
|
+
def last_completed_status
|
173
|
+
all_statuses.reverse.find { |status| has_completed_status?(status) }
|
174
|
+
end
|
175
|
+
|
176
|
+
def has_completed_status?(status)
|
177
|
+
(errors.present? ? status_steps_was : status_steps)["#{status}_at".to_sym].present?
|
178
|
+
end
|
179
|
+
|
154
180
|
end
|
155
181
|
|
156
182
|
module ClassMethods
|
@@ -35,6 +35,15 @@ module Effective
|
|
35
35
|
File.join(*[tenant_path, 'app/datatables', namespace, "effective_#{plural_name}_datatable.rb"].compact)
|
36
36
|
end
|
37
37
|
|
38
|
+
# Wizards are kinda weird, we need some help for effective_memberships
|
39
|
+
def wizard_file_path(resource)
|
40
|
+
if resource.class.try(:effective_memberships_applicant?) || resource.class.try(:effective_memberships_applicant_review?)
|
41
|
+
File.join(*['effective', plural_name].compact)
|
42
|
+
else
|
43
|
+
view_file_path(nil)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
38
47
|
# Views
|
39
48
|
def view_file(action = :index, partial: false)
|
40
49
|
File.join(*[tenant_path, 'app/views', class_path, namespace, plural_name, "#{'_' if partial}#{action}.html.haml"].compact)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
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-08-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|