[Bps-public-commit] rt-extension-formtools branch self-service-forms-page created. 0.53-16-g99584f1
BPS Git Server
git at git.bestpractical.com
Fri Sep 22 20:36: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, self-service-forms-page has been created
at 99584f1d93e40808302e43fc70590ea0805d07a1 (commit)
- Log -----------------------------------------------------------------
commit 99584f1d93e40808302e43fc70590ea0805d07a1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Sep 22 16:35:54 2023 -0400
Initial version of self service Form home page
diff --git a/html/Admin/FormTools/Describe.html b/html/Admin/FormTools/Describe.html
new file mode 100644
index 0000000..4267f0c
--- /dev/null
+++ b/html/Admin/FormTools/Describe.html
@@ -0,0 +1,62 @@
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
+
+<&| /Widgets/TitleBox, title => '' &>
+ <p>Forms are shown to users on a page in the RT Self Service interface. Below you can manage how the form details will appear to end users.</p>
+ <form name="EditFormDescription" action="" method="post" enctype="multipart/form-data">
+ <input type="hidden" class="hidden" name="id" value="<% $id %>" />
+ <&| /Widgets/TitleBox, title => loc('Icon') &>
+ <p>Form to upload an icon</p>
+ </&>
+ <&| /Widgets/TitleBox, title => loc('Description') &>
+ <p>Describe what the form should be used for and include instructions to help users pick the correct form.</p>
+ <p>An HTML edit box for instructions</p>
+ <div class="form-row">
+ <div class="col-12">
+ <textarea autocomplete="off" class="form-control messagebox richtext" cols="80" rows="15" name="FormDescription"><%$form->{'form-description'}%></textarea>
+ </div>
+ </div>
+ </&>
+</&>
+<div class="form-row">
+ <div class="col-12">
+ <& /Elements/Submit, Label => loc('Save'), Name => 'SubmitDescription' &>
+ </div>
+</div>
+</form>
+<%init>
+
+# Handle id getting submitted twice and becoming an array
+my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
+$id = $id[0];
+Abort("No form id found") unless $id;
+
+my $form_attribute = RT::Attribute->new($session{'CurrentUser'});
+my ($ok, $msg) = $form_attribute->Load($id);
+
+unless ( $ok ) {
+ Abort("Unable to load form with id $id");
+}
+
+my $form = $form_attribute->Content;
+
+my ($title, @results);
+$title = loc("Description for form [_1]", $form_attribute->Description);
+
+if ( $ARGS{'SubmitDescription'} && $ARGS{'SubmitDescription'} eq 'Save' ) {
+ $form->{'form-description'} = $ARGS{'FormDescription'};
+
+
+ $form_attribute->SetContent($form);
+}
+
+MaybeRedirectForResults(
+ Actions => \@results,
+ Arguments => { id => $id },
+);
+
+</%init>
+<%args>
+$id => undef
+</%args>
diff --git a/html/Callbacks/FormTools/Elements/Tabs/Privileged b/html/Callbacks/FormTools/Elements/Tabs/Privileged
index 5c39b0b..4fff02e 100644
--- a/html/Callbacks/FormTools/Elements/Tabs/Privileged
+++ b/html/Callbacks/FormTools/Elements/Tabs/Privileged
@@ -11,8 +11,20 @@ if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'SuperUse
}
if ( $m->request_path =~ m{^/Admin/FormTools/} ) {
- my $page = PageMenu();
- $page->child( select => title => loc('Select'), path => "/Admin/FormTools/" );
+ if ( ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
+ my $id = $1;
+ my $form_attribute = RT::Attribute->new($session{'CurrentUser'});
+ my ($ok, $msg) = $form_attribute->Load($id);
+
+ unless ( $ok ) {
+ RT->Logger->error("Unable to load form with id $id");
+ }
+
+ my $page = PageMenu();
+ $page->child( select => title => loc('Select'), path => "/Admin/FormTools/index.html?id=" . $id );
+ $page->child( modify => title => loc('Modify'), path => "/Admin/FormTools/Modify.html?id=" . $id );
+ $page->child( description => title => loc('Description'), path => "/Admin/FormTools/Describe.html?id=" . $id );
+ }
}
</%init>
diff --git a/html/Callbacks/FormTools/Elements/Tabs/SelfService b/html/Callbacks/FormTools/Elements/Tabs/SelfService
new file mode 100644
index 0000000..35e70ab
--- /dev/null
+++ b/html/Callbacks/FormTools/Elements/Tabs/SelfService
@@ -0,0 +1,11 @@
+<%init>
+
+my $formtools = Menu->child('home')->child(
+ formtools => title => loc('Forms'),
+ path => '/SelfService/Forms.html',
+);
+
+</%init>
+<%args>
+$Path
+</%args>
diff --git a/html/Elements/Forms/ListForms b/html/Elements/Forms/ListForms
new file mode 100644
index 0000000..63dc6e2
--- /dev/null
+++ b/html/Elements/Forms/ListForms
@@ -0,0 +1,19 @@
+<&|/Widgets/TitleBox, title => '', class => 'fullwidth' &>
+% while ( my $form_attribute = $forms->Next ) {
+% my $form = $form_attribute->Content;
+<div class="row border border-primary">
+ <div class="col-4 text-center">
+ <p><% $form_attribute->Description %></p>
+ </div>
+ <div class="col-8 text-left">
+ <% $form->{'form-description'} %>
+ </div>
+</div>
+% }
+</&>
+<%init>
+my $forms = RT::Attributes->new( RT->SystemUser );
+$forms->Limit( FIELD => 'Name', VALUE => 'FormTools Form' );
+</%init>
+<%args>
+</%args>
diff --git a/html/SelfService/Forms.html b/html/SelfService/Forms.html
new file mode 100644
index 0000000..9932bbc
--- /dev/null
+++ b/html/SelfService/Forms.html
@@ -0,0 +1,4 @@
+
+<& /SelfService/Elements/Header, Title => loc('Forms Home') &>
+
+<& /Elements/Forms/ListForms &>
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-formtools
More information about the Bps-public-commit
mailing list