wicked-focused 0.2.0 → 0.2.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.
- data/README.md +18 -4
- data/VERSION +1 -1
- data/lib/wicked/action.rb +1 -0
- data/lib/wicked/controller/concerns/steps.rb +13 -1
- data/lib/wicked/wizard.rb +8 -0
- data/test/dummy/app/controllers/bar_controller.rb +7 -2
- data/test/dummy/app/controllers/foo_controller.rb +10 -2
- data/test/dummy/app/controllers/jump_controller.rb +7 -2
- data/test/dummy/app/controllers/steps_controller.rb +6 -1
- data/test/integration/navigation_test.rb +6 -0
- data/wicked-focused.gemspec +2 -2
- metadata +3 -3
data/README.md
CHANGED
@@ -114,6 +114,12 @@ class AfterSignupController
|
|
114
114
|
steps :confirm_password, :confirm_profile, :find_friends
|
115
115
|
end
|
116
116
|
|
117
|
+
wizard_action :show do
|
118
|
+
wizard do
|
119
|
+
render_wizard
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
117
123
|
wizard_action :update do
|
118
124
|
wizard do
|
119
125
|
@user = current_user
|
@@ -149,7 +155,7 @@ In the controller if you find that you want to skip a step, you can do it simply
|
|
149
155
|
|
150
156
|
```ruby
|
151
157
|
|
152
|
-
|
158
|
+
show_wizard do
|
153
159
|
wizard do
|
154
160
|
@user = current_user
|
155
161
|
case step
|
@@ -180,11 +186,19 @@ Created the Focused Controller action base class, from which any Wizard Action c
|
|
180
186
|
|
181
187
|
`wizard_action name, &block`
|
182
188
|
|
183
|
-
Creates a Focused Controller action class inheriting from the base action class of the controller. The block contains the class definition.
|
189
|
+
Creates a Focused Controller action class inheriting from the base action class of the controller. The block contains the class definition. The wizard actions are `show` and `update`. To further abstract this, the shorthand macros: `show_wizard &block` and `update_wizard &block` are also available.
|
190
|
+
|
191
|
+
`wizard &block`
|
192
|
+
|
193
|
+
Creates a `#run` method as "required" by a Focused Controller action class.
|
194
|
+
|
195
|
+
The run method generated also:
|
184
196
|
|
185
|
-
`
|
197
|
+
* calls `super()` which calls `setup_wizard`
|
198
|
+
* auto-handles redirects to first or last step (*)
|
199
|
+
* skips step (*)
|
186
200
|
|
187
|
-
|
201
|
+
(*) if params indicate this is requested behavior
|
188
202
|
|
189
203
|
*View/URL Helpers*
|
190
204
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/wicked/action.rb
CHANGED
@@ -44,7 +44,7 @@ module Wicked::Controller::Concerns::Steps
|
|
44
44
|
end
|
45
45
|
|
46
46
|
module ClassMethods
|
47
|
-
attr_reader :wizard_steps
|
47
|
+
attr_reader :wizard_steps, :skip_steps
|
48
48
|
|
49
49
|
def steps(*args)
|
50
50
|
options = args.last.is_a?(Hash) ? callbacks.pop : {}
|
@@ -54,6 +54,11 @@ module Wicked::Controller::Concerns::Steps
|
|
54
54
|
self.steps = steps
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
def allow_skip_for(*args)
|
59
|
+
@skip_steps = args
|
60
|
+
end
|
61
|
+
alias :optional_steps :allow_skip_for
|
57
62
|
end
|
58
63
|
|
59
64
|
def steps=(wizard_steps)
|
@@ -66,6 +71,13 @@ module Wicked::Controller::Concerns::Steps
|
|
66
71
|
alias :wizard_steps :steps
|
67
72
|
alias :steps_list :steps
|
68
73
|
|
74
|
+
def skip_step?
|
75
|
+
return false unless params[:skip_step]
|
76
|
+
skip_steps = self.class.superclass.skip_steps
|
77
|
+
return true if skip_steps.blank?
|
78
|
+
skip_steps.include? step.to_sym
|
79
|
+
end
|
80
|
+
|
69
81
|
def previous_step(current_step = nil)
|
70
82
|
return previous_step if current_step == nil
|
71
83
|
index = steps.index(current_step)
|
data/lib/wicked/wizard.rb
CHANGED
@@ -21,6 +21,14 @@ module Wicked
|
|
21
21
|
def wizard_action action, &block
|
22
22
|
focused_action action, "#{self.name}::Action".constantize, &block
|
23
23
|
end
|
24
|
+
|
25
|
+
def show_wizard &block
|
26
|
+
focused_action :show, "#{self.name}::Action".constantize, &block
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_wizard &block
|
30
|
+
focused_action :update, "#{self.name}::Action".constantize, &block
|
31
|
+
end
|
24
32
|
end
|
25
33
|
end
|
26
34
|
end
|
@@ -9,10 +9,15 @@ module BarController
|
|
9
9
|
|
10
10
|
wizard_action :show do
|
11
11
|
wizard do
|
12
|
-
skip_step if
|
12
|
+
# skip_step if skip_step?
|
13
13
|
render_wizard
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
wizard_action :update do
|
18
|
+
wizard do
|
19
|
+
# update code here!
|
20
|
+
render_wizard
|
21
|
+
end
|
22
|
+
end
|
18
23
|
end
|
@@ -5,15 +5,23 @@ module FooController
|
|
5
5
|
include Wicked::Action
|
6
6
|
|
7
7
|
steps :first, :second, :last_step
|
8
|
+
|
9
|
+
# alias: allow_skip_for
|
10
|
+
optional_steps :first
|
8
11
|
end
|
9
12
|
include Wicked::Wizard
|
10
13
|
|
11
14
|
wizard_action :show do
|
12
15
|
wizard do
|
13
|
-
skip_step if
|
16
|
+
# skip_step if skip_step?
|
14
17
|
render_wizard
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
|
-
wizard_action :update
|
21
|
+
wizard_action :update do
|
22
|
+
wizard do
|
23
|
+
# update code here!
|
24
|
+
render_wizard
|
25
|
+
end
|
26
|
+
end
|
19
27
|
end
|
@@ -10,7 +10,7 @@ module JumpController
|
|
10
10
|
|
11
11
|
wizard_action :show do
|
12
12
|
wizard do
|
13
|
-
skip_step if
|
13
|
+
# skip_step if skip_step?
|
14
14
|
jump_to :last_step if params[:jump_to]
|
15
15
|
if params[:resource]
|
16
16
|
value = params[:resource][:save] == 'true'
|
@@ -22,5 +22,10 @@ module JumpController
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
wizard_action :update
|
25
|
+
wizard_action :update do
|
26
|
+
wizard do
|
27
|
+
# update code here!
|
28
|
+
render_wizard
|
29
|
+
end
|
30
|
+
end
|
26
31
|
end
|
@@ -25,6 +25,12 @@ class InheritNavigationTest < ActiveSupport::IntegrationCase
|
|
25
25
|
assert has_content?('second')
|
26
26
|
end
|
27
27
|
|
28
|
+
test 'not allowed to skip second' do
|
29
|
+
step = :second
|
30
|
+
visit(foo_path(step.to_s, :skip_step => 'true'))
|
31
|
+
assert has_content?('second')
|
32
|
+
end
|
33
|
+
|
28
34
|
test 'invalid step' do
|
29
35
|
step = :notastep
|
30
36
|
assert_raise(ActionView::MissingTemplate) do
|
data/wicked-focused.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wicked-focused"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kristianmandrup", "schneems"]
|
12
|
-
s.date = "2012-08-
|
12
|
+
s.date = "2012-08-07"
|
13
13
|
s.description = "Rails engine for producing Focused Controller based wizards"
|
14
14
|
s.email = "kmandrup@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicked-focused
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -254,7 +254,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
254
254
|
version: '0'
|
255
255
|
segments:
|
256
256
|
- 0
|
257
|
-
hash:
|
257
|
+
hash: 315033251613805856
|
258
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
259
|
none: false
|
260
260
|
requirements:
|