[Bps-public-commit] rt-extension-formtools branch privileged-forms-listing created. 0.53-55-g5650603
BPS Git Server
git at git.bestpractical.com
Mon Oct 16 19:17:04 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 created
at 5650603dfbaf522f908e4ac3d11bd7aa54198605 (commit)
- Log -----------------------------------------------------------------
commit 5650603dfbaf522f908e4ac3d11bd7aa54198605
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 f4f6ea00b5f6a972446f83fed6f64c8c37ff31f4
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Oct 16 14:30:10 2023 -0400
Show Next for button label until Submit 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>
commit 7611d1c995ef3b0abc932a5d7ff22d82a9da1505
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Oct 16 13:53:24 2023 -0400
Add a Forms Home page for privileged users
Sending privileged users to /SelfService/Forms.html caused
the SelfService menu to be displayed, which would be
confusing for privileged users.
diff --git a/html/Callbacks/FormTools/Elements/Tabs/Privileged b/html/Callbacks/FormTools/Elements/Tabs/Privileged
index ab2b30c..7c48c7b 100644
--- a/html/Callbacks/FormTools/Elements/Tabs/Privileged
+++ b/html/Callbacks/FormTools/Elements/Tabs/Privileged
@@ -30,6 +30,12 @@ if ( $m->request_path =~ m{^/Admin/FormTools/} ) {
}
}
+# Forms home page for all privileged users
+my $formtools = Menu->child('home')->child(
+ formtools => title => loc('Forms'),
+ path => '/Forms.html',
+);
+
</%init>
<%args>
$Path
diff --git a/html/Forms.html b/html/Forms.html
new file mode 100644
index 0000000..dc6cd3c
--- /dev/null
+++ b/html/Forms.html
@@ -0,0 +1,4 @@
+<& /Elements/Header, Title => loc("Forms Home") &>
+<& /Elements/Tabs &>
+
+<& /Elements/Forms/ListForms &>
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-formtools
More information about the Bps-public-commit
mailing list