[Rt-commit] rt branch 5.0/improve-asset-webconfig created. rt-5.0.2-113-gf14cb22478

BPS Git Server git at git.bestpractical.com
Wed Mar 23 21:29:32 UTC 2022


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".

The branch, 5.0/improve-asset-webconfig has been created
        at  f14cb2247887cf035cc888211033673cf05bf4ae (commit)

- Log -----------------------------------------------------------------
commit f14cb2247887cf035cc888211033673cf05bf4ae
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Feb 9 08:39:45 2022 -0600

    Warn on invalid result formants in Asset System Configuration
    
    The options AssetDefaultSearchResultFormat, AssetSimpleSearchFormat,
    AssetSummaryFormat, AssetSummaryRelatedTicketsFormat, and
    UserAssetExtraInfo are intended to contain search result format
    specifications for their respective obects for display in specific
    places.
    
    It is possible to inadvertantly introduce small, subtle, errors into
    these strings that prevent them from showing any useful information.
    While this can also happen when manually editing a search result format
    manually, the System Configuration pages don't (yet) have ways to
    quickly verify the formats.
    
    This change adds warnings to the update results when portions of a
    changed format don't appear to map to any field or attribute of the
    related object type.

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 2dec20fdaa..ac96501515 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1993,16 +1993,20 @@ our %META;
         },
     },
     AssetDefaultSearchResultFormat => {
-        Widget => '/Widgets/Form/MultilineString',
+        Widget      => '/Widgets/Form/MultilineString',
+        FormatClass => 'RT__Asset',
     },
     AssetSimpleSearchFormat => {
-        Widget => '/Widgets/Form/MultilineString',
+        Widget      => '/Widgets/Form/MultilineString',
+        FormatClass => 'RT__Asset',
     },
     AssetSummaryFormat => {
-        Widget => '/Widgets/Form/MultilineString',
+        Widget      => '/Widgets/Form/MultilineString',
+        FormatClass => 'RT__Asset',
     },
     AssetSummaryRelatedTicketsFormat => {
-        Widget => '/Widgets/Form/MultilineString',
+        Widget      => '/Widgets/Form/MultilineString',
+        FormatClass => 'RT__Ticket',
     },
     DefaultSearchResultFormat => {
         Widget => '/Widgets/Form/MultilineString',
@@ -2032,7 +2036,8 @@ our %META;
         Widget => '/Widgets/Form/MultilineString',
     },
     UserAssetExtraInfo => {
-        Widget => '/Widgets/Form/MultilineString',
+        Widget      => '/Widgets/Form/MultilineString',
+        FormatClass => 'RT__User',
     },
     UserDataResultFormat => {
         Widget => '/Widgets/Form/MultilineString',
diff --git a/share/html/Admin/Tools/EditConfig.html b/share/html/Admin/Tools/EditConfig.html
index bafaf8d405..0a810e4023 100644
--- a/share/html/Admin/Tools/EditConfig.html
+++ b/share/html/Admin/Tools/EditConfig.html
@@ -95,6 +95,7 @@ if (delete $ARGS{Update}) {
 
             my $val = $ARGS{$key};
             $val = '' if $val eq '__empty_value__';
+
             my $prev = $ARGS{$key . '-Current'};
             next if $val eq $prev;
 
@@ -109,6 +110,12 @@ if (delete $ARGS{Update}) {
                 next;
             }
 
+            if (exists $meta->{FormatClass}) {
+                foreach my $unmapped ($m->comp('/Elements/CollectionAsTable/CheckFormat', Class => $meta->{FormatClass}, Format => $val)) {
+                    push @results, loc("Warning: In format [_1], element '[_2]' does not map to an attribute", $key, $unmapped->{original_string});
+                }
+            }
+
             if ($is_json) {
                 my $json = $val;
                 ($val) = RT::Configuration->new( $session{CurrentUser} )->_DeJSONContent($json);
diff --git a/share/html/Elements/CollectionAsTable/CheckFormat b/share/html/Elements/CollectionAsTable/CheckFormat
new file mode 100644
index 0000000000..db2400ccf5
--- /dev/null
+++ b/share/html/Elements/CollectionAsTable/CheckFormat
@@ -0,0 +1,72 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2021 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
+$Class => 'RT__Ticket'
+$Format
+</%ARGS>
+
+<%init>
+my @orig;
+my @unmapped;
+foreach my $item ($m->comp('ParseFormat', Format => $Format)) {
+    push @orig, $item;
+    next if (exists $item->{title} and $item->{title} =~ /^(?:NEWLINE|NBSP)$/);
+    next if defined $m->comp('/Elements/ColumnMap', Class => $Class, Name => $item->{attribute}, Attr => 'attribute');
+
+    my @unmapped_subitems;
+    foreach my $subitem (@{$item->{output}}) {
+        next unless $subitem =~ /^__(.*)__$/;
+        next if defined $m->comp('/Elements/ColumnMap', Class => $Class, Name => $item->{attribute}, Attr => 'value');
+        push @unmapped_subitems, $subitem;
+        last;
+    }
+
+    push @unmapped, $item if @unmapped_subitems;
+}
+return(@unmapped);
+</%init>

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list