NAME
Zapp::Task::Action
VERSION
version 0.001
SYNOPSIS
package My::Task::Action;
use Mojo::Base 'Zapp::Task::Action', -signatures;
sub prepare( $self, $input ) {
# Notify user of input
...;
# Call superclass to show input form on run page
$self->SUPER::prepare( $self, $input );
}
sub action( $self, $task_input, $c, $form_input ) {
# Process form input
return $self->SUPER::action( $task_input, $c, $form_input );
}
sub run( $self, $task_input ) {
my $form_input = $self->info->{notes}{input};
# Do something with input
...;
# Call superclass to finish
$self->SUPER::run( $c, $task_input, $form_input );
}
1;
__DATA__
@@ action.html.ep
%# Display form for user input
DESCRIPTION
Actions are Task classes that prompt for user input and then wait. While they are waiting, Action classes may display a button, an input form, or other content on the run page.
Unlike regular Tasks, custom Actions have three steps:
- prepare
-
The prepare step is run by a Worker. This can be extended to perform any necessary notifications or setup. Once the action is prepared, the user may see the action_field on the Run page.
- action
-
The action step is run by the web application when a user interacts with the action field. The form input is stored in the
input
note (see "info" in Minion::Job). - run
-
The run step is run by the worker after the user has interacted with the action field. The default behavior is to simply finish the job successfully with the user's input. Override this for custom behavior.
SEE ALSO
Zapp::Task::Action::Confirm, Zapp::Task, Zapp
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.