[Rt-commit] rt branch 5.0/validate-group-cfs created. rt-5.0.4-236-g022c52b173

BPS Git Server git at git.bestpractical.com
Tue Oct 3 21:18: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".

The branch, 5.0/validate-group-cfs has been created
        at  022c52b173184d8c8f150c0836c1eee86475781d (commit)

- Log -----------------------------------------------------------------
commit 022c52b173184d8c8f150c0836c1eee86475781d
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Oct 3 13:56:02 2023 -0400

    Add CF validation to modify class page

diff --git a/share/html/Admin/Articles/Classes/Modify.html b/share/html/Admin/Articles/Classes/Modify.html
index 5d8f436552..63ae0d0680 100644
--- a/share/html/Admin/Articles/Classes/Modify.html
+++ b/share/html/Admin/Articles/Classes/Modify.html
@@ -150,12 +150,7 @@
 % my $CFs = $ClassObj->CustomFields;
 % if ($CFs->Count) {
 <h5 class="mt-3"><&|/l&>Class Custom Fields:</&></h5>
-% }
-% while (my $CF = $CFs->Next) {
-  <&| /Elements/LabeledValue, Label => $CF->Name, LabelSpanClass => ($CF->EntryHint ? 'prev-icon-helper' : '' ),
-  LabelTooltip =>  $CF->EntryHint &>
-    <& /Elements/EditCustomField, CustomField => $CF, Object => $ClassObj, &>
-  </&>
+<& /Elements/EditCustomFields, Object => $ClassObj &>
 % }
 
 %$m->callback( CallbackName => 'BeforeSubmit', CustomFields => $cfs, ClassObj => $ClassObj );
@@ -177,12 +172,42 @@
 
 my $ClassObj = RT::Class->new($session{'CurrentUser'});
 my  ($title, @results, $Disabled);
+my $skip_update = 0;
+
+my ( $val, $msg );
+if ( ($id && $id ne 'new') || ( $Name && not $id ) ) {
+    if ( $id ) {
+        ( $val, $msg ) = $ClassObj->Load($id);
+    }
+    else {
+        ( $val, $msg ) = $ClassObj->Load($Name);
+    }
+    if ( not $val ) {
+        RT->Logger->error("Unable to load class with id $id: $msg");
+        Abort(loc("Couldn't load class '[_1]'", $Name));
+    }
+}
+
+my $CustomFields = $ClassObj->CustomFields;
+
+my ($status, @msg) = $m->comp(
+    '/Elements/ValidateCustomFields',
+    Object       => $ClassObj,
+    CustomFields => $CustomFields,
+    ARGSRef      => \%ARGS,
+);
+unless ($status) {
+    push @results, @msg;
+    $skip_update = 1;
+    if ( $id && $id eq 'new' ) {
+        $Create = 1;
+    }
+}
 
 if ($Create) {
     $title = loc("Create a Class");
 } else {
-    my ( $val, $msg );
-    if ($id eq 'new') {
+    if ( $id && $id eq 'new' && not $skip_update ) {
         ($val, $msg) = $ClassObj->Create(Name => $Name);
         if ( $val ) {
             push @results, $msg;
@@ -190,12 +215,9 @@ if ($Create) {
         else {
             push @results, loc('Class could not be created: [_1]', $msg);
         }
-    } else {
-        $ClassObj->Load($id) || $ClassObj->Load($Name) || $m->comp("/Elements/Error", Why => "Couldn't load class '$Name'");
-        $val = $ClassObj->id;
     }
 
-    if ( $val ) {
+    if ( $ClassObj->Id ) {
         $title = loc('Modify the Class [_1]', $ClassObj->Name);
     }
     else {
@@ -204,7 +226,7 @@ if ($Create) {
     }
 }
 
-if ($ClassObj->Id()) {
+if ( $ClassObj->Id && not $skip_update ) {
 
     if ($ARGS{SubjectOverride}) {
         $ARGS{SubjectOverride} = $m->comp('/Widgets/Form/Select:Process',
@@ -236,7 +258,7 @@ my $subject_cfs = [];
 my $subject_cf_labels = {};
 
 my $cfs;
-if ( $ClassObj->id ) {
+if ( $ClassObj->Id && not $skip_update ) {
     $cfs = $ClassObj->ArticleCustomFields;
     while ( my $cf = $cfs->Next ) {
         $include{"CF-Title-".$cf->Id} = $include{"CF-Value-".$cf->Id} = 1;
@@ -245,7 +267,7 @@ if ( $ClassObj->id ) {
     }
 }
 
-if  ( $ClassObj->id && $Submitted ) {
+if  ( $ClassObj->id && $Submitted && not $skip_update ) {
     if ( $Disabled != $ClassObj->Disabled) {
         my  ($code, $msg) = $ClassObj->SetDisabled($Disabled);
         push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
@@ -261,11 +283,12 @@ if  ( $ClassObj->id && $Submitted ) {
 }
 
 # This code does automatic redirection if any updates happen.
-MaybeRedirectForResults(
-    Actions     => \@results,
-    Arguments   => { id => $ClassObj->Id },
-) if $ClassObj->id;
-
+unless ( $skip_update ) {
+    MaybeRedirectForResults(
+        Actions     => \@results,
+        Arguments   => { id => $ClassObj->Id },
+    ) if $ClassObj->id;
+}
 
 if ( $ClassObj->id ) {
     $include{$_} = not $ClassObj->FirstAttribute("Skip-$_") for keys %include;

commit 148bba44407003cfba86ffaa10aaca91b1aaa2b1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Oct 3 13:14:15 2023 -0400

    Add CF validation to modify queue page

diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index f47410290f..701828d81a 100644
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -114,14 +114,8 @@
         <input type="hidden" class="hidden" name="SetSLAEnabled" value="1" />
       </div>
   </&>
-% my $CFs = $QueueObj->CustomFields;
-% while (my $CF = $CFs->Next) {
-<&| /Elements/LabeledValue, Label => $CF->Name, LabelTooltip => $CF->EntryHint &>
 
-      <& /Elements/EditCustomField, CustomField => $CF,
-                                    Object => $QueueObj, &>
-</&>
-% }
+  <& /Elements/EditCustomFields, Object => $QueueObj &>
 
 % if ( RT->Config->Get('Crypt')->{'Enable'} ) {
   <&| /Elements/LabeledValue, Label => '' &>
@@ -203,24 +197,53 @@
 
 <%INIT>
 my ($title, @results, @no_redirect_results, $Disabled, $EnabledChecked);
+my $skip_update = 0;
+
 my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
-$QueueObj->Load( $id ) if !$id || $id eq 'new';
+
+my ( $ok, $msg );
+if ( ($id && $id ne 'new') || ( $Name && not $id ) ) {
+    if ( $id ) {
+        ( $ok, $msg ) = $QueueObj->Load($id);
+    }
+    else {
+        ( $ok, $msg ) = $QueueObj->Load($Name);
+    }
+    if ( not $ok ) {
+        RT->Logger->error("Unable to load queue with id $id: $msg");
+        Abort(loc("Couldn't load queue '[_1]'", $Name));
+    }
+}
+
+my $CustomFields = $QueueObj->CustomFields;
+
+my ($status, @msg) = $m->comp(
+    '/Elements/ValidateCustomFields',
+    Object       => $QueueObj,
+    CustomFields => $CustomFields,
+    ARGSRef      => \%ARGS,
+);
+unless ($status) {
+    push @results, @msg;
+    $skip_update = 1;
+    if ( $id && $id eq 'new' ) {
+        $Create = 1;
+    }
+}
 
 $EnabledChecked = 'checked="checked"';
 
 unless ($Create) {
-    if ( defined $id && $id eq 'new' ) {
+    if ( defined $id && $id eq 'new' && not $skip_update ) {
         my ($val, $msg) = $QueueObj->Create( Name => $Name );
         if (!$val) {
             $Create = 1; # Create failed, so bring us back to step 1
         }
         push @results, $msg;
-    } else {
-        $QueueObj->Load($id) || $QueueObj->Load($Name) || Abort(loc("Couldn't load queue '[_1]'", $Name));
     }
 }
 
-if ( $QueueObj->Id ) {
+if ( $QueueObj->Id && not $skip_update ) {
     $title = loc('Configuration for queue [_1]', $QueueObj->Name );
     my @attribs= qw(Description CorrespondAddress CommentAddress Name SortOrder
         Sign SignAuto Encrypt Lifecycle SubjectTag SLADisabled Disabled);
@@ -280,10 +303,12 @@ if ( $QueueObj->Id ) {
 my $InternalQueue = ($QueueObj->Id and $QueueObj->Disabled == 2);
 
 # This code does automatic redirection if any updates happen.
-MaybeRedirectForResults(
-    Actions   => \@results,
-    Arguments => { id => $QueueObj->Id },
-) if $QueueObj->id;
+unless ( $skip_update ) {
+    MaybeRedirectForResults(
+        Actions   => \@results,
+        Arguments => { id => $QueueObj->Id },
+    ) if $QueueObj->id;
+}
 
 push @results, @no_redirect_results;
 </%INIT>

commit 071781a0cc824f6bd231cd84c52b93e11bda0903
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Oct 3 12:40:08 2023 -0400

    Add CF validation to modify user page

diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 0bb2330e27..059f9b7cfe 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -255,9 +255,44 @@
 
 my $UserObj = RT::User->new($session{'CurrentUser'});
 my ($title, @results);
+my $skip_update = 0;
 
 my ($val, $msg);
 
+if ( ($id && $id ne 'new') || ( $ARGS{Name} && not $id ) ) {
+    if ( $id ) {
+        ( $val, $msg ) = $UserObj->Load($id);
+    }
+    else {
+        ( $val, $msg ) = $UserObj->Load($ARGS{Name});
+    }
+    if ( not $val ) {
+        RT->Logger->error("Unable to load user with id $id: $msg");
+        Abort(loc("Couldn't load user '[_1]'", ( $ARGS{Name} || '')));
+    }
+}
+
+# Handle case when Modify is called with no params
+if ( not $Create && $id ne 'new' ) {
+    Abort(loc("Couldn't load user '[_1]'", ( $ARGS{Name} || '')));
+}
+
+my $CustomFields = $UserObj->CustomFields;
+
+my ($status, @msg) = $m->comp(
+    '/Elements/ValidateCustomFields',
+    Object       => $UserObj,
+    CustomFields => $CustomFields,
+    ARGSRef      => \%ARGS,
+);
+unless ($status) {
+    push @results, @msg;
+    $skip_update = 1;
+    if ( $id && $id eq 'new' ) {
+        $Create = 1;
+    }
+}
+
 $ARGS{Privileged} = $ARGS{Privileged} ? 1 : 0;
 delete $ARGS{Privileged} unless $ARGS{SetPrivileged};
 
@@ -272,7 +307,7 @@ my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
 
 if ($Create) {
     $title = loc("Create a new user");
-} elsif ( defined $id && $id eq 'new') {
+} elsif ( defined $id && $id eq 'new' && not $skip_update ) {
     $m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, Fields => \@fields, Results => \@results );
     ( $val, $msg ) = $UserObj->Create(
         (map {($_ => $ARGS{$_})} @fields),
@@ -290,10 +325,8 @@ if ($Create) {
         $title = loc("Create a new user");
         $Create = 1;
     }
-} else {
-    $UserObj->Load($id) || $UserObj->Load($ARGS{Name})
-        || Abort("Couldn't load user '" . ( $ARGS{Name} || '') . "'");
-
+}
+elsif ( $UserObj->Id && not $skip_update ) {
     $title = loc("Modify the user [_1]", $UserObj->Name);
 
     $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
@@ -315,12 +348,12 @@ if ($Create) {
     }
 }
 
-if ( $ARGS{'Anonymize'} and $UserObj->Id ) {
+if ( $ARGS{'Anonymize'} and $UserObj->Id && not $skip_update ) {
     my ($ret, $msg) = $UserObj->AnonymizeUser(ClearCustomFields => $ARGS{'clear_customfields'});
     push @results, $msg;
 }
 
-if ( $UserObj->Id ) {
+if ( $UserObj->Id && not $skip_update ) {
     # Deal with Password field
     my ($status, $msg) = $UserObj->SafeSetPassword(
         Current      => $CurrentPass,
@@ -335,10 +368,12 @@ if ( $UserObj->Id ) {
 }
 
 # This code does automatic redirection if any updates happen.
-MaybeRedirectForResults(
-    Actions   => \@results,
-    Arguments => { id => $UserObj->Id },
-) if $UserObj->Id;
+unless ( $skip_update ) {
+    MaybeRedirectForResults(
+        Actions   => \@results,
+        Arguments => { id => $UserObj->Id },
+    ) if $UserObj->Id;
+}
 
 </%INIT>
 

commit 609f782b5aea2b5840a5f1cbbde1004e036546ca
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Oct 3 11:19:35 2023 -0400

    Add CF validation to modify group page

diff --git a/share/html/Admin/Groups/Modify.html b/share/html/Admin/Groups/Modify.html
index 659daa0eaa..673a3cbefc 100644
--- a/share/html/Admin/Groups/Modify.html
+++ b/share/html/Admin/Groups/Modify.html
@@ -92,13 +92,35 @@
 <%INIT>
 
 my  ($title, @results, @warnings, $Disabled, $EnabledChecked);
+my $skip_update = 0;
 
 my $Group = RT::Group->new($session{'CurrentUser'});
 
+if ( $id && $id ne 'new' ) {
+    my ( $ok,$msg ) = $Group->Load($id);
+    if ( not $ok ) {
+        RT->Logger->error("Unable to load group with id $id: $msg");
+        Abort('Could not load group');
+    }
+}
+
+my $CustomFields = $Group->CustomFields;
+
+my ($status, @msg) = $m->comp(
+    '/Elements/ValidateCustomFields',
+    Object       => $Group,
+    CustomFields => $CustomFields,
+    ARGSRef      => \%ARGS,
+);
+unless ($status) {
+    push @results, @msg;
+    $skip_update = 1;
+}
+
 if ($Create) {
     $title = loc("Create a new group");
 } else {
-    if ($id eq 'new' ) {
+    if ($id eq 'new' && not $skip_update ) {
         my ($create_id, $create_msg) = $Group->CreateUserDefinedGroup(Name => $Name );
         if ($create_id) {
             $id = $Group->Id;
@@ -107,8 +129,6 @@ if ($Create) {
         } else {
             push @results, loc("Group could not be created: [_1]", $create_msg);
         }
-    } else {
-        $Group->Load($id) || Abort('Could not load group');
     }
 
     if ($Group->Id) {
@@ -122,7 +142,7 @@ if ($Create) {
     }
 }
 
-if ($Group->Id) {
+if ( $Group->Id && not $skip_update ) {
     my @fields = qw(Description Name );
     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
                                             Object => $Group,
@@ -145,16 +165,18 @@ if (defined $Enabled && $Enabled == 1) {
 } else {
     $Disabled = 1;
 }
-if  ( $Group->Id and ($SetEnabled) and ( $Disabled != $Group->Disabled) ) {
+if  ( $Group->Id and (not $skip_update) and ($SetEnabled) and ( $Disabled != $Group->Disabled) ) {
     my  ($code, $msg) = $Group->SetDisabled($Disabled);
     push @results, $msg;
 }
 
 # This code does automatic redirection if any updates happen.
-MaybeRedirectForResults(
-    Actions     => \@results,
-    Arguments   => { id => $Group->id },
-) if $Group->Id;
+unless ( $skip_update ) {
+    MaybeRedirectForResults(
+        Actions     => \@results,
+        Arguments   => { id => $Group->id },
+    ) if $Group->Id;
+}
 
 push @results, @warnings;
 

commit 03c09abdec7b55e2c2a53150fae98a5cb30d80c0
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Mon Oct 2 13:49:30 2023 -0400

    Open results from chart table in new tab
    
    Clicking on a result from the chart table presently opens search results
    in the current tab; clicking on a result in the chart itself opens
    search results in a new tab. This change opens chart table results in a
    new tab, making the behavior between the two consistent.

diff --git a/share/html/Search/Elements/ChartTable b/share/html/Search/Elements/ChartTable
index 0a745d7ceb..cf13d2984d 100644
--- a/share/html/Search/Elements/ChartTable
+++ b/share/html/Search/Elements/ChartTable
@@ -99,7 +99,7 @@ foreach my $section (qw(thead tbody tfoot)) {
                                 )
                             )
                         )
-                        . '">'
+                        . '" target="_blank">'
                     );
                     $m->out( $eh->( $cell->{'value'} ) );
                     $m->out('</a>');

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list