[Bps-public-commit] rt-extension-formtools branch sort-items-in-showchoices created. 1.04-1-g0cf5fb4
BPS Git Server
git at git.bestpractical.com
Wed Feb 21 18:47:12 UTC 2024
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, sort-items-in-showchoices has been created
at 0cf5fb47d2ebd4cdad2514691ba40d3da1ba15bc (commit)
- Log -----------------------------------------------------------------
commit 0cf5fb47d2ebd4cdad2514691ba40d3da1ba15bc
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Feb 21 13:14:56 2024 -0500
Show visible fields in order for ShowChoices
diff --git a/html/FormTools/ShowChoices b/html/FormTools/ShowChoices
index ccaed49..c623d36 100644
--- a/html/FormTools/ShowChoices
+++ b/html/FormTools/ShowChoices
@@ -1,16 +1,43 @@
<%init>
my $queue = $m->notes('queue');
-my %all_fields = %$DECODED_ARGS;
+my @fields;
+
+my $pages = $DECODED_ARGS->{'form_config'}{'formtools-pages'};
+for my $page ( sort { $pages->{$a}{'sort_order'} <=> $pages->{$b}{'sort_order'} } keys %$pages ) {
+ my @elements = @{ $pages->{$page}{'content'} };
+ for my $element (@elements) {
+ my $input_name;
+ my $name;
+ if ( $name = $element->{'input-name'} ) {
+ next if ( $element->{'type'} // '' ) eq 'hidden';
+ $input_name = $name;
+ }
+ elsif ( $name = $element->{'arguments'}{'name'} ) {
+ next if ( $element->{'arguments'}{'render_as'} // '' ) eq 'hidden';
+ if ( RT::Extension::FormTools::is_core_field($name) ) {
+ $input_name = $name;
+ }
+ else {
+ my $cf = RT::CustomField->new( $session{'CurrentUser'} );
+ $cf->LoadByName( Name => $name, Queue => $queue->Id );
+ $cf->LoadByName( Name => $name, Queue => 0 ) unless $cf->Id;
+ if ( $cf->Id ) {
+ $input_name = GetCustomFieldInputName(
+ Object => RT::Ticket->new( $session{CurrentUser} ),
+ CustomField => $cf,
+ );
+ }
+ }
+ }
+
+ if ($input_name) {
+ push @fields, { name => $name, value => $DECODED_ARGS->{$input_name} };
+ }
+ }
+}
+
</%init>
-% foreach my $field (keys %all_fields) {
-% next if $field =~ /-Magic/;
-% my $cf = RT::CustomField->new($session{'CurrentUser'});
-% if ($field =~ /CustomField-(\d+)/) {
-% my $id = $1;
-%$cf->Load($id);
-<& /Elements/LabeledValue, Label => $cf->Name, ValueSpanClass => 'current-value', Value => ref ($all_fields{$field}) ? join(', ',@{$all_fields{$field}}) : $all_fields{$field} &>
-% } elsif (RT::Extension::FormTools::is_core_field($field)) {
-<& /Elements/LabeledValue, Label => loc("Content"), ValueSpanClass => 'current-value', Value => $all_fields{$field} &>
-%}
+% foreach my $field (@fields) {
+<& /Elements/LabeledValue, Label => loc($field->{name}), ValueSpanClass => 'current-value', Value => $field->{value} &>
% }
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-formtools
More information about the Bps-public-commit
mailing list