[Bps-public-commit] rt-extension-formtools branch skip-hidden-in-showchoices created. 1.04-1-g86fd5ad

BPS Git Server git at git.bestpractical.com
Wed Feb 14 14:55:37 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, skip-hidden-in-showchoices has been created
        at  86fd5ad5566e682fda04f015104b36fa3bfd657f (commit)

- Log -----------------------------------------------------------------
commit 86fd5ad5566e682fda04f015104b36fa3bfd657f
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Wed Feb 14 09:53:15 2024 -0500

    Don't show hidden fields in ShowChoices display
    
    There were two problems with the existing implementation: hidden fields
    showed with a label of 'Content', and users being asked to confirm the
    value for a field they hadn't seen was confusing. It's better to just
    not show these at all.

diff --git a/html/FormTools/ShowChoices b/html/FormTools/ShowChoices
index ccaed49..a64eb18 100644
--- a/html/FormTools/ShowChoices
+++ b/html/FormTools/ShowChoices
@@ -1,7 +1,30 @@
 <%init>
 my $queue = $m->notes('queue');
 
-my %all_fields = %$DECODED_ARGS;
+our %all_fields = %$DECODED_ARGS;
+
+sub check_hidden_field {
+    my $check_name = shift;
+
+    my ( $name, $type );
+    my $pages = $all_fields{'form_config'}{'formtools-pages'};
+    foreach my $page ( keys %$pages ) {
+        my @elements = @{ $pages->{$page}{'content'} };
+        foreach my $element ( @elements ) {
+            if ( defined $element->{'input-name'} ) {
+                $name = $element->{'input-name'};
+                $type = $element->{'type'} // '';
+            } elsif ( defined $element->{'arguments'}{'name'} ) {
+                $name = $element->{'arguments'}{'name'};
+                $type = $element->{'arguments'}{'render_as'} // '';
+            }
+            if ( defined $name && $name eq $check_name ) {
+                return 1 if $type eq "hidden";
+            }
+        }
+    }
+    return 0;
+}
 </%init>
 % foreach my $field (keys %all_fields) {
 % next if $field =~ /-Magic/;
@@ -9,8 +32,10 @@ my %all_fields = %$DECODED_ARGS;
 % if ($field =~ /CustomField-(\d+)/) {
 % my $id = $1;
 %$cf->Load($id);
+% next if check_hidden_field( $cf->Name );
 <& /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)) {
+% next if check_hidden_field( $field );
 <& /Elements/LabeledValue, Label => loc("Content"), ValueSpanClass => 'current-value', Value => $all_fields{$field} &>
 %}
 % }

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt-extension-formtools


More information about the Bps-public-commit mailing list