[Jifty-commit] jifty branch, setupwizard-refactor, updated. bcdf36d9ed994d68477a8dcb7cc0545bf23eb225
Jifty commits
jifty-commit at lists.jifty.org
Tue Jul 20 11:13:58 EDT 2010
The branch, setupwizard-refactor has been updated
via bcdf36d9ed994d68477a8dcb7cc0545bf23eb225 (commit)
from 036ec308babcadb2d4b5ebd9862ca8c47495c041 (commit)
Summary of changes:
lib/Jifty/Plugin/SetupWizard/View/Helpers.pm | 65 ++++++++++++++++++--------
1 files changed, 46 insertions(+), 19 deletions(-)
- Log -----------------------------------------------------------------
commit bcdf36d9ed994d68477a8dcb7cc0545bf23eb225
Author: Thomas Sibley <trs at bestpractical.com>
Date: Tue Jul 20 11:15:19 2010 -0400
Support optional titles for the step list
diff --git a/lib/Jifty/Plugin/SetupWizard/View/Helpers.pm b/lib/Jifty/Plugin/SetupWizard/View/Helpers.pm
index a71f9eb..f732a36 100644
--- a/lib/Jifty/Plugin/SetupWizard/View/Helpers.pm
+++ b/lib/Jifty/Plugin/SetupWizard/View/Helpers.pm
@@ -433,6 +433,10 @@ setup wizard.
The steps are expected to be template paths to display in the order given.
They need not be absolute paths.
+Optionally, you may specify an arrayref as a step, in which case the first
+element is taken to be the path and the second a step title. This helps
+generate a list of steps to present.
+
By default, it warns about misuse and returns an empty list.
=cut
@@ -452,7 +456,7 @@ there is none (i.e. the first step).
sub step_before {
my $self = shift;
- return $self->_step_for(shift, 'before');
+ return $self->step_for(shift, 'before')->[0];
}
=head2 step_after STEP
@@ -464,44 +468,67 @@ is none (i.e. the last step).
sub step_after {
my $self = shift;
- return $self->_step_for(shift, 'after');
+ return $self->step_for(shift, 'after')->[0];
}
-=head2 _step_for STEP, DIRECTION
+=head2 step_for STEP, DIRECTION
+
+This is the logic behind L<step_before> and L<step_after>. Returns the
+adjacent step in the DIRECTION given, or an empty arrayref if there is none.
+
+Direction may be C<before>, C<after>, or C<undef> to indicate you want the step
+specified by the name given.
-This is the logic behind L<step_before> and L<step_after>. Returns the name
-of the adjacent step in the DIRECTION given, or undef if there is none.
+All steps are normalized to an arrayref before being returned.
=cut
-sub _step_for {
+sub step_for {
my ($self, $step, $dir) = (@_);
my @steps = $self->steps;
my $new;
for (0..$#steps) {
- if ( $step eq $steps[$_] ) {
+ # Normalize into an arrayref
+ $steps[$_] = [ $steps[$_] ]
+ unless ref $steps[$_];
+
+ if ( $step eq $steps[$_][0] ) {
$new = $_;
last;
}
}
- if ( $dir eq 'before' ) {
- $new--;
- undef $new if $new < 0;
- }
- elsif ( $dir eq 'after' ) {
- $new++;
- undef $new if $new > $#steps;
- }
- else {
- # Huh?
- undef $new;
+ unless ( not defined $dir ) {
+ if ( $dir eq 'before' ) {
+ $new--;
+ undef $new if $new < 0;
+ }
+ elsif ( $dir eq 'after' ) {
+ $new++;
+ undef $new if $new > $#steps;
+ }
+ else {
+ # Huh?
+ undef $new;
+ }
}
- return defined $new ? $steps[$new] : undef;
+ return defined $new ? $steps[$new] : [];
}
+=head2 step_title STEP
+
+Returns the title of STEP, or undef if there is none.
+
+=cut
+
+sub step_title {
+ my $self = shift;
+ return $self->step_for(shift)->[1];
+}
+
+
1;
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list