effective_resources 1.10.0 → 1.12.1
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 +4 -4
- data/app/controllers/concerns/effective/wizard_controller/before_actions.rb +18 -0
- data/app/controllers/concerns/effective/wizard_controller/permitted_params.rb +19 -0
- data/app/controllers/concerns/effective/wizard_controller.rb +15 -0
- data/app/helpers/effective_resources_helper.rb +4 -0
- data/app/models/concerns/acts_as_wizard.rb +11 -0
- data/app/models/effective/after_commit.rb +4 -2
- data/config/effective_resources.rb +1 -1
- data/lib/effective_resources/version.rb +1 -1
- data/lib/effective_resources.rb +4 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3db298e3e7c154dc1aa2dbec87f22bcd2fe0c20b9ab565bea13a8305f6ba04f3
|
4
|
+
data.tar.gz: 6b79e28b6b7f8f7335313d769725e16f9f6deb799bdfa29fb0b1de6c5b459b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82f53749182dc5a0f9b86c92171c0dc36eebf49fbeb874789a466143354fe28143c4d83e8caefae4b4e42f7157608ec58400f5ce4322b3609616ccf115d2235c
|
7
|
+
data.tar.gz: c388f8c66074503b1d04874419b71a5d5054ececd383d33a45087f0a17f65007fbd3f9aeb7c457c5d61ac3c36d1931a6b734756ea55ef807bd54c827e5143884
|
@@ -35,6 +35,20 @@ module Effective
|
|
35
35
|
|
36
36
|
# setup_wizard from Wicked called now
|
37
37
|
|
38
|
+
# Allow only 1 in-progress wizard at a time
|
39
|
+
def redirect_if_existing
|
40
|
+
return if step == 'wicked_finish'
|
41
|
+
return if resource.blank?
|
42
|
+
return if resource.try(:done?)
|
43
|
+
return unless resource_scope.respond_to?(:in_progress)
|
44
|
+
|
45
|
+
existing = resource_scope.in_progress.where.not(id: resource).first
|
46
|
+
return unless existing.present?
|
47
|
+
|
48
|
+
flash[:success] = "You have been redirected to your in-progress wizard"
|
49
|
+
redirect_to resource_wizard_path(existing, existing.next_step)
|
50
|
+
end
|
51
|
+
|
38
52
|
# before_action :enforce_can_visit_step, only: [:show, :update]
|
39
53
|
# Make sure I have permission for this step
|
40
54
|
def enforce_can_visit_step
|
@@ -76,6 +90,10 @@ module Effective
|
|
76
90
|
resource.ready!
|
77
91
|
end
|
78
92
|
|
93
|
+
def clear_flash_success
|
94
|
+
@_delete_flash_success = true
|
95
|
+
end
|
96
|
+
|
79
97
|
end
|
80
98
|
end
|
81
99
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Effective
|
2
|
+
module WizardController
|
3
|
+
module PermittedParams
|
4
|
+
BLACKLIST = [
|
5
|
+
:created_at, :updated_at,
|
6
|
+
:token, :slug, :price,
|
7
|
+
:logged_change_ids, :orders, :purchased_order_id,
|
8
|
+
:status, :status_steps, :wizard_steps,
|
9
|
+
:submitted_at, :completed_at, :reviewed_at, :approved_at, :declined_at, :purchased_at,
|
10
|
+
:declined_reason
|
11
|
+
]
|
12
|
+
|
13
|
+
def resource_permitted_params
|
14
|
+
permitted_name = params.key?(effective_resource.name) ? effective_resource.name : effective_resource.resource_name
|
15
|
+
params.require(permitted_name).except(BLACKLIST).permit!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,9 +7,14 @@ module Effective
|
|
7
7
|
|
8
8
|
include Effective::WizardController::Actions
|
9
9
|
include Effective::WizardController::BeforeActions
|
10
|
+
include Effective::WizardController::PermittedParams
|
10
11
|
include Effective::WizardController::Save
|
11
12
|
include Effective::WizardController::WickedOverrides
|
12
13
|
|
14
|
+
module ClassMethods
|
15
|
+
def effective_wizard_controller?; true; end
|
16
|
+
end
|
17
|
+
|
13
18
|
included do
|
14
19
|
raise("please install gem 'wicked' to use Effective::WizardController") unless defined?(Wicked)
|
15
20
|
|
@@ -19,10 +24,14 @@ module Effective
|
|
19
24
|
before_action :assign_resource
|
20
25
|
before_action :authorize_resource
|
21
26
|
before_action :assign_required_steps
|
27
|
+
|
22
28
|
before_action :setup_wizard # Wicked
|
23
29
|
|
24
30
|
before_action :enforce_can_visit_step
|
25
31
|
|
32
|
+
before_action :redirect_if_existing, only: [:show, :new]
|
33
|
+
before_action :clear_flash_success, only: [:update]
|
34
|
+
|
26
35
|
before_action :assign_current_step
|
27
36
|
before_action :assign_page_title
|
28
37
|
|
@@ -38,6 +47,12 @@ module Effective
|
|
38
47
|
flash[:danger] = "Unknown step. You have been moved to the #{resource_wizard_steps.first} step."
|
39
48
|
redirect_to wizard_path(resource_wizard_steps.first)
|
40
49
|
end
|
50
|
+
|
51
|
+
# effective_resources on save callback
|
52
|
+
after_action do
|
53
|
+
flash.clear if @_delete_flash_success
|
54
|
+
end
|
55
|
+
|
41
56
|
end
|
42
57
|
|
43
58
|
def find_wizard_resource
|
@@ -244,4 +244,8 @@ module EffectiveResourcesHelper
|
|
244
244
|
simple_format(sanitize(value.to_s, tags: @format_resource_tags, attributes: @format_resource_atts), {}, sanitize: false)
|
245
245
|
end
|
246
246
|
|
247
|
+
def edit_effective_wizard?
|
248
|
+
controller.class.try(:effective_wizard_controller?) && defined?(resource) && resource.draft?
|
249
|
+
end
|
250
|
+
|
247
251
|
end
|
@@ -59,6 +59,12 @@ module ActsAsWizard
|
|
59
59
|
wizard_step_keys()
|
60
60
|
end
|
61
61
|
|
62
|
+
# For use in the summary partials. Does not include summary.
|
63
|
+
def render_steps
|
64
|
+
blacklist = [:start, :billing, :checkout, :submitted, :summary]
|
65
|
+
(required_steps - blacklist).select { |step| has_completed_step?(step) }
|
66
|
+
end
|
67
|
+
|
62
68
|
def wizard_step_title(step)
|
63
69
|
self.class.const_get(:WIZARD_STEPS).fetch(step)
|
64
70
|
end
|
@@ -134,6 +140,11 @@ module ActsAsWizard
|
|
134
140
|
|
135
141
|
module ClassMethods
|
136
142
|
def acts_as_wizard?; true; end
|
143
|
+
|
144
|
+
def all_wizard_steps
|
145
|
+
const_get(:WIZARD_STEPS).keys
|
146
|
+
end
|
147
|
+
|
137
148
|
end
|
138
149
|
|
139
150
|
end
|
@@ -28,8 +28,10 @@ module Effective
|
|
28
28
|
def self.register_callback(connection:, name:, callback:)
|
29
29
|
raise ArgumentError, "#{name} expected a block" unless callback
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
in_transaction = (connection.transaction_open? && connection.current_transaction.joinable?)
|
32
|
+
|
33
|
+
# Execute immediately when outside transaction
|
34
|
+
return callback.call unless in_transaction
|
33
35
|
|
34
36
|
after_commit = Effective::AfterCommit.new("#{name}": callback)
|
35
37
|
connection.add_transaction_record(after_commit)
|
@@ -38,7 +38,7 @@ EffectiveResources.setup do |config|
|
|
38
38
|
# config.parent_mailer = '::ApplicationMailer'
|
39
39
|
|
40
40
|
# Default deliver method
|
41
|
-
# config.deliver_method = :
|
41
|
+
# config.deliver_method = :deliver_later
|
42
42
|
|
43
43
|
# Default layout
|
44
44
|
# config.mailer_layout = 'effective_mailer_layout'
|
data/lib/effective_resources.rb
CHANGED
@@ -36,7 +36,10 @@ module EffectiveResources
|
|
36
36
|
|
37
37
|
# Email
|
38
38
|
def self.deliver_method
|
39
|
-
config[:deliver_method]
|
39
|
+
return config[:deliver_method] if config[:deliver_method].present?
|
40
|
+
|
41
|
+
rails = Rails.application.config
|
42
|
+
(rails.respond_to?(:active_job) && rails.active_job.queue_adapter) ? :deliver_later : :deliver_now
|
40
43
|
end
|
41
44
|
|
42
45
|
def self.mailer_layout
|
@@ -106,10 +109,6 @@ module EffectiveResources
|
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
109
|
-
def self.deliver_method
|
110
|
-
config = Rails.application.config
|
111
|
-
(config.respond_to?(:active_job) && config.active_job.queue_adapter) ? :deliver_later : :deliver_now
|
112
|
-
end
|
113
112
|
|
114
113
|
def self.advance_date(date, business_days: 1, holidays: [:ca, :observed])
|
115
114
|
raise('business_days must be an integer <= 365') unless business_days.kind_of?(Integer) && business_days <= 365
|
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: 1.
|
4
|
+
version: 1.12.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: 2022-01-
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- app/controllers/concerns/effective/wizard_controller.rb
|
146
146
|
- app/controllers/concerns/effective/wizard_controller/actions.rb
|
147
147
|
- app/controllers/concerns/effective/wizard_controller/before_actions.rb
|
148
|
+
- app/controllers/concerns/effective/wizard_controller/permitted_params.rb
|
148
149
|
- app/controllers/concerns/effective/wizard_controller/save.rb
|
149
150
|
- app/controllers/concerns/effective/wizard_controller/wicked_overrides.rb
|
150
151
|
- app/helpers/effective_acts_as_email_form_helper.rb
|