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

BPS Git Server git at git.bestpractical.com
Wed Mar 23 21:03:44 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  3716ec8ffbc71847acc9fc716a9495d4bfd77e99 (commit)

- Log -----------------------------------------------------------------
commit 3716ec8ffbc71847acc9fc716a9495d4bfd77e99
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);

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list