[Bps-public-commit] rt-extension-formtools branch privileged-forms-listing updated. 0.53-55-g855cb9c
BPS Git Server
git at git.bestpractical.com
Mon Oct 16 19:14:08 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-formtools".
The branch, privileged-forms-listing has been updated
via 855cb9cf76f63506cacffde6b3d2d685089939dd (commit)
via 9c0d2ac849c424ed287d0579ea3f9a0b970e9a0a (commit)
from 7611d1c995ef3b0abc932a5d7ff22d82a9da1505 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 855cb9cf76f63506cacffde6b3d2d685089939dd
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Oct 16 15:14:00 2023 -0400
Add a Back button to form pages
diff --git a/html/Forms/dhandler b/html/Forms/dhandler
index c1c78c9..a6f19cc 100644
--- a/html/Forms/dhandler
+++ b/html/Forms/dhandler
@@ -32,7 +32,7 @@ foreach my $element ( @{$form_config->{'formtools-pages'}{$page}{'content'}} ) {
</%perl>
% if ( $form_config->{'formtools-pages'}{$page}{'next'} ) {
- <& /FormTools/Next, Label => $button_label &>
+ <& /FormTools/Next, Label => $button_label, Back => $show_back &>
% }
</&>
<%init>
@@ -98,6 +98,43 @@ $m->notes( page_title => $form_config->{'formtools-pages'}{$page}{'name'} );
my $base_path = '/Forms/';
$base_path = '/SelfService' . $base_path if $SelfService;
+my @form_pages
+ = sort { ( $form_config->{'formtools-pages'}{$a}{sort_order} || 0 ) <=> ( $form_config->{'formtools-pages'}{$b}{sort_order} || 0 ) }
+ keys %{ $form_config->{'formtools-pages'} };
+
+my $show_back = 0;
+my $index = 0;
+my $back_page;
+foreach my $page_index ( @form_pages ) {
+ if ( $page_index eq $page ) {
+ # Current page was "next" on submit, so we need to go back 2
+ $back_page = $form_pages[$index - 2];
+ last;
+ }
+ $index++;
+}
+
+# Don't show the back button on the first page
+$show_back = 1 if $index > 0;
+
+# Did the user click Back?
+if ( $ARGS{Back} and $ARGS{Back} eq 'Back' ) {
+
+ # Avoid trying to go back again
+ delete $ARGS{Back};
+
+ # Don't create a ticket when going back
+ delete $ARGS{'create_ticket'} if $ARGS{'create_ticket'};
+ $create_ticket = 0;
+
+ # Redirect to the previous page
+ MaybeRedirectForResults(
+ Path => $base_path . $form_name . '/' . $back_page,
+ Arguments => \%ARGS,
+ Force => 1,
+ );
+}
+
# Try to create a ticket if we're on the last page and
# "create_ticket" is submitted as an arg from the second-to-last
# page.
commit 9c0d2ac849c424ed287d0579ea3f9a0b970e9a0a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Oct 16 14:30:10 2023 -0400
Show Next for button label until Submmit page
diff --git a/html/Forms/dhandler b/html/Forms/dhandler
index 668ffa5..c1c78c9 100644
--- a/html/Forms/dhandler
+++ b/html/Forms/dhandler
@@ -9,6 +9,7 @@
<%perl>
# Build the current page here dyamically from config
+my $button_label = loc('Next');
foreach my $element ( @{$form_config->{'formtools-pages'}{$page}{'content'}} ) {
if ( $element->{type} eq 'raw_html' ) {
$m->out( $element->{html} );
@@ -20,11 +21,18 @@ foreach my $element ( @{$form_config->{'formtools-pages'}{$page}{'content'}} ) {
elsif ( $element->{type} eq 'component' ) {
$m->comp('/FormTools/' . $element->{comp_name}, %{$element->{arguments}});
}
+
+ if ( $element->{type} eq 'hidden'
+ and $element->{'input-name'} eq 'create_ticket' ) {
+
+ # This is the page that will submit, so change the button label
+ $button_label = loc('Submit');
+ }
}
</%perl>
% if ( $form_config->{'formtools-pages'}{$page}{'next'} ) {
- <& /FormTools/Next &>
+ <& /FormTools/Next, Label => $button_label &>
% }
</&>
<%init>
-----------------------------------------------------------------------
Summary of changes:
html/Forms/dhandler | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
hooks/post-receive
--
rt-extension-formtools
More information about the Bps-public-commit
mailing list