Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

various updates

  • Loading branch information...
commit 9cc1d5bd4e84cd3028c2e69cf1d4d3da5c506cb8 1 parent 74953b9
@jeffp authored
View
27 app/controllers/generated_controller.rb
@@ -215,7 +215,7 @@ def complete_wizard(redirect = nil)
redirect_to redirect if (redirect && !self.performed?)
return if @wizard_completed_flag
_on_wizard_finish
- redirect_to '/main/finished' unless self.performed?
+ redirect_to('/main/finished') unless self.performed?
end
def build_wizard_model(params)
if (wizard_config.persist_model_per_page? && (model_id = params['id']))
@@ -284,14 +284,20 @@ def reset_wizard_session_vars
def check_action_for_button
button_id = nil
- #check if params[:commit] has returned a button from submit_tag
- unless (params[:commit] == nil)
- button_name = underscore_button_name(params[:commit])
- unless [:next, :finish].include?(button_id = button_name.to_sym)
- action_method_name = "_on_" + params[:action].to_s + "_form_" + button_name
+ case
+ when params[:commit]
+ button_name = params[:commit]
+ button_id = underscore_button_name(button_name).to_sym
+ when ((button = self.wizard_config.buttons.find{|k,b| params[b.id]}) && params[button.id] == button.name)
+ button_name = button.name
+ button_id = button.id
+ end
+ if button_id
+ unless [:next, :finish].include?(button_id)
+ action_method_name = "_on_" + params[:action].to_s + "_form_" + button_id.to_s
callback_performs_action?(action_method_name)
unless ((btn_obj = self.wizard_config.buttons[button_id]) == nil || btn_obj.user_defined?)
- method_name = "_on_wizard_" + button_name
+ method_name = "_on_wizard_" + button_id.to_s
if (self.method(method_name))
self.__send__(method_name)
else
@@ -300,7 +306,6 @@ def check_action_for_button
end
end
end
- #add other checks here or above
button_id
end
hide_action :check_action_for_button
@@ -334,6 +339,9 @@ def self.on_get(*args, &block)
def self.on_errors(*args, &block)
self._define_action_callback_macro('on_errors', '_on_invalid_%s_form', *args, &block)
end
+ def self.on_back(*args, &block)
+ self._define_action_callback_macro('on_back', '_on_%s_form_back', *args, &block)
+ end
def self.on_finish(*args, &block)
self._define_action_callback_macro('on_finish', '_on_%s_form_finish', *args, &block)
end
@@ -343,9 +351,6 @@ def self.on_cancel(*args, &block)
def self.on_skip(*args, &block)
self._define_action_callback_macro('on_skip', '_on_%s_form_skip', *args, &block)
end
- def self.on_back(*args, &block)
- self._define_action_callback_macro('on_back', '_on_%s_form_back', *args, &block)
- end
def self.on_next(*args, &block)
self._define_action_callback_macro('on_next', '_on_%s_form_next', *args, &block)
end
View
4 app/helpers/scaffold_test_helper.rb
@@ -6,7 +6,7 @@ def wizardly_submit
unless @@wizardly_submit[step_id]
buttons = @wizard.pages[@step].buttons
@@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
- io << submit_tag(button.name)
+ io << submit_tag(button.name, :name=>button.id.to_s)
end.string
end
@@wizardly_submit[step_id]
@@ -18,9 +18,9 @@ def wizardly_image_submit(asset_dir = nil, opts = {})
unless @@wizardly_image_submit[step_id]
asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
buttons = @wizard.pages[@step].buttons
- opts[:name] = 'commit'
@@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
opts[:value] = button.name
+ opts[:name] = button.id.to_s
io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
end.string
end
View
2  config/environment.rb
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
View
BIN  db/development.sqlite3
Binary file not shown
View
4 lib/generators/wizardly_scaffold/templates/helper.rb.erb
@@ -6,7 +6,7 @@ module <%=controller_name.camelize %>Helper
unless @@wizardly_submit[step_id]
buttons = @wizard.pages[@step].buttons
@@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
- io << submit_tag(button.name)
+ io << submit_tag(button.name, :name=>button.id.to_s)
end.string
end
@@wizardly_submit[step_id]
@@ -18,9 +18,9 @@ module <%=controller_name.camelize %>Helper
unless @@wizardly_image_submit[step_id]
asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
buttons = @wizard.pages[@step].buttons
- opts[:name] = 'commit'
@@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
opts[:value] = button.name
+ opts[:name] = button.id.to_s
io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
end.string
end
View
12 lib/wizardly/wizard/button.rb
@@ -16,14 +16,12 @@ def initialize(id, name=nil)
def user_defined?; @user_defined; end
#used in the dsl
- def name_to(name)
- if name.is_a?(String)
- @name = name.strip.squeeze(' ')
- @id = button_name_to_symbol(name)
- elsif name.is_a?(Symbol)
- @id = name
- @name = symbol_to_button_name(name)
+ def name_to(name, opts={})
+ case name
+ when String then @name = name.strip.squeeze(' ')
+ when Symbol then @name = symbol_to_button_name(name)
end
+ @id = opts[:id] if (opts[:id] && opts[:id].is_a?(Symbol))
end
end
View
21 lib/wizardly/wizard/configuration/methods.rb
@@ -279,7 +279,7 @@ def complete_wizard(redirect = nil)
redirect_to redirect if (redirect && !self.performed?)
return if @wizard_completed_flag
_on_wizard_#{finish_button}
- redirect_to #{Utils.formatted_redirect(self.completed_redirect)} unless self.performed?
+ redirect_to(#{Utils.formatted_redirect(self.completed_redirect)}) unless self.performed?
end
def build_wizard_model(params)
if (wizard_config.persist_model_per_page? && (model_id = params['id']))
@@ -348,14 +348,20 @@ def reset_wizard_session_vars
def check_action_for_button
button_id = nil
- #check if params[:commit] has returned a button from submit_tag
- unless (params[:commit] == nil)
- button_name = underscore_button_name(params[:commit])
- unless [:#{next_id}, :#{finish_id}].include?(button_id = button_name.to_sym)
- action_method_name = "_on_" + params[:action].to_s + "_form_" + button_name
+ case
+ when params[:commit]
+ button_name = params[:commit]
+ button_id = underscore_button_name(button_name).to_sym
+ when ((button = self.wizard_config.buttons.find{|k,b| params[b.id]}) && params[button.id] == button.name)
+ button_name = button.name
+ button_id = button.id
+ end
+ if button_id
+ unless [:#{next_id}, :#{finish_id}].include?(button_id)
+ action_method_name = "_on_" + params[:action].to_s + "_form_" + button_id.to_s
callback_performs_action?(action_method_name)
unless ((btn_obj = self.wizard_config.buttons[button_id]) == nil || btn_obj.user_defined?)
- method_name = "_on_wizard_" + button_name
+ method_name = "_on_wizard_" + button_id.to_s
if (self.method(method_name))
self.__send__(method_name)
else
@@ -364,7 +370,6 @@ def check_action_for_button
end
end
end
- #add other checks here or above
button_id
end
hide_action :check_action_for_button
View
4 rails_generators/wizardly_scaffold/templates/helper.rb.erb
@@ -6,7 +6,7 @@ module <%=controller_name.camelize %>Helper
unless @@wizardly_submit[step_id]
buttons = @wizard.pages[@step].buttons
@@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
- io << submit_tag(button.name)
+ io << submit_tag(button.name, :name=>button.id.to_s)
end.string
end
@@wizardly_submit[step_id]
@@ -18,9 +18,9 @@ module <%=controller_name.camelize %>Helper
unless @@wizardly_image_submit[step_id]
asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/"
buttons = @wizard.pages[@step].buttons
- opts[:name] = 'commit'
@@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button|
opts[:value] = button.name
+ opts[:name] = button.id.to_s
io << image_submit_tag("#{asset_dir}#{button.id}.png", opts)
end.string
end
View
2  spec/rcov.opts
@@ -1,2 +1,2 @@
---exclude "spec/*,gems/*"
+--exclude "spec/*,gems/*"
--rails

0 comments on commit 9cc1d5b

Please sign in to comment.
Something went wrong with that request. Please try again.