effective_resources 1.11.0 → 1.12.0
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 +17 -0
- data/app/controllers/concerns/effective/wizard_controller/permitted_params.rb +19 -0
- data/app/controllers/concerns/effective/wizard_controller.rb +11 -0
- data/lib/effective_resources/version.rb +1 -1
- 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: 53d143a8c98a09dcf7d4d9806ef793e973d8222de8c26f5078c9921e2ce8fdb9
|
4
|
+
data.tar.gz: bb10ee364077d022fe04717f37e5eac64576077b6f9710313d1251ed252b39a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c89341875aec7a5520151b0ec922a54f8e309219a5f53b6ddd0a4092b1fb758dfd5f1ddee7222862e9e6406102f004ed30d4e03f72c4dc6d36821c9dc0c1cd58
|
7
|
+
data.tar.gz: 6782dbdbc803c7014e90a9b674cdd0c7be8920c1802203347e3046eaa5e07e05ac988e8a8c2dbbb78478c3caedfc5cb87ab9463cbf568d34ef654d714d8468c8
|
@@ -35,6 +35,19 @@ 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.done?
|
43
|
+
|
44
|
+
existing = resource_scope.in_progress.where.not(id: resource).first
|
45
|
+
return unless existing.present?
|
46
|
+
|
47
|
+
flash[:success] = "You have been redirected to your in-progress wizard"
|
48
|
+
redirect_to resource_wizard_path(existing, existing.next_step)
|
49
|
+
end
|
50
|
+
|
38
51
|
# before_action :enforce_can_visit_step, only: [:show, :update]
|
39
52
|
# Make sure I have permission for this step
|
40
53
|
def enforce_can_visit_step
|
@@ -76,6 +89,10 @@ module Effective
|
|
76
89
|
resource.ready!
|
77
90
|
end
|
78
91
|
|
92
|
+
def clear_flash_success
|
93
|
+
@_delete_flash_success = true
|
94
|
+
end
|
95
|
+
|
79
96
|
end
|
80
97
|
end
|
81
98
|
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,6 +7,7 @@ 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
|
|
@@ -23,10 +24,14 @@ module Effective
|
|
23
24
|
before_action :assign_resource
|
24
25
|
before_action :authorize_resource
|
25
26
|
before_action :assign_required_steps
|
27
|
+
|
26
28
|
before_action :setup_wizard # Wicked
|
27
29
|
|
28
30
|
before_action :enforce_can_visit_step
|
29
31
|
|
32
|
+
before_action :redirect_if_existing, only: [:show, :new]
|
33
|
+
before_action :clear_flash_success, only: [:update]
|
34
|
+
|
30
35
|
before_action :assign_current_step
|
31
36
|
before_action :assign_page_title
|
32
37
|
|
@@ -42,6 +47,12 @@ module Effective
|
|
42
47
|
flash[:danger] = "Unknown step. You have been moved to the #{resource_wizard_steps.first} step."
|
43
48
|
redirect_to wizard_path(resource_wizard_steps.first)
|
44
49
|
end
|
50
|
+
|
51
|
+
# effective_resources on save callback
|
52
|
+
after_action do
|
53
|
+
flash.clear if @_delete_flash_success
|
54
|
+
end
|
55
|
+
|
45
56
|
end
|
46
57
|
|
47
58
|
def find_wizard_resource
|
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.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: 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
|