This plugin provides same functionallity like Catalyst::Plugin::Wizard but in some more flexible and correct way.
Plain:
# create new wizard my $wizard = Catalyst::Wizard->new( $c ); # add steps for that wizard $wizard->add_steps( -detach => '/user/login', '/user/login_submit' ); $wizard->add_steps( -last => -redirect => '/user/logout' ); # mark step to go to next step after this action $wizard->goto_next; # perform step (calls redirect/detach/forward/whatever) $wizard->perform_step;
With Catalyst::Action::Wizard and CatalystX::Wizarded:
# just appending step $c->wizard( '/append_this_step' ); # just marking as goto_next # NOTE: wizards can either 'die' after this (like in detach) # or just mark wizard as 'goto_next' $c->wizard->goto_next; # adding -last action in wizard (only one added, other # '-last' actions ignored). synonym for -default in C::P::W $c->wizard( -last => -redirect => '/logout' )->goto_next; # make step back (in case some errors happen) $c->wizard->back_to( -redirect => '/append_this_step' ); # stash into wizard my $wizard_stash = $c->wizard->stash; $wizard_stash->{parameters} = { %{ $c->req->params } }; if ( $c->have_wizard ) { $c->wizard->goto_next; }
In TT: [% c.wizard.id_to_form IF c.have_wizard %]
[% # INCORRECT! may (and will) cause errors! c.wizard.id_to_form %]
In real application: See there.
This module is for general wizard'ed actions. It may be used with CatalystX::Wizarded and along in separate realization (for example in Controller base)
You can use it for creating mulitpart actions (wizards) in following cases:
When you need to move some items into another folder, you may:
keep current folders select in session (can have difficulties with duplicate selecting of same folder)
use it as wizard and keep that info in wizard's stash
Create wizard object, either new (empty, missing or equal to 'new' $wizard_id) or loaded from Catalyst::Wizard::wizard_storage.
$wizard_id
Note that $wizard_id can also contain step number (splited from wizard_id by _).
_
Making steps from input of @args, passed from add_steps. You can redefine following functions to make it behave different:
$self->_get_default_flags returns default flags
$self->_check_flags( \@args, \@new_steps, $step_ref, $flags ) to check flags
$self->_is_force_add_step( \@args, \@new_steps, $step_ref, $flags ) should return true if step should added with force (e.g. even if same already exists)
$self->_handle_$1_item( \@args, $step_ref, $flags ) to handle '-$1' items in \@args
Add steps from @args.
@args is an array of path for steps with specification of each step:
Redirect to path. If '-redirect' is given, then no action wizard id will be append to the redirect URL. Use this for last actions in wizard.
You can append any query parameters to 'path'.
Detaches to path.
Last step in wizard. Only one (first) '-last' step will be added, all others will be ignored. Note that -last => step should be last in ->add_steps call, elsewhere add_steps will throw exception.
Shift $shift_count steps, or 1 if no $shift_count is given.
Returns URI for next step in wizard (if that step is '-redirect').
Mark wizard step to be performed.
If $wizard->{die_for_goto} is true will act like detach, throwing $GOTO_NEXT exception.
Return to step 'path' which will be performed by original step type or by step type you set as argument.
Will do nothing if none 'path' step if found.
Perform step. Function to call when step performing should be done. (called, for instance, in Catalyst::Action::Wizard _END)
Stash accessor.
Get wizard id as <input> tag for <FORM>.
Loads wizard (by default just installs stash).
Save wizard into wizard_storage.
If $c have wizard_storage it will be called with two arguments: wizard id and wizard instance.
Elsewhere default (session) storage will be used.
Loads $wizard_id from wizard_storage, if can.
First checked if $c can 'wizard_storage'. If yes -- it will be called, else default (session) storage will be used.
Note also that this functions purges old wizards in session.
Prints current wizard info.
short_info omits steps on print.
Note that info will skip all the inherited methods ($self->SUPER::info call).
Catalyst::Plugin::Continuation, Catalyst Plugin Wizard (DEPRECATED)
Pavel Boldin <davinchi@cpan.org> for REG.RU.
To install Catalyst::Action::Wizard, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Action::Wizard
CPAN shell
perl -MCPAN -e shell install Catalyst::Action::Wizard
For more information on module installation, please visit the detailed CPAN module installation guide.