[Rt-commit] rt branch 4.4/cf-groupings-on-queue-default-values created. rt-4.4.5-102-g16c2b854c4

BPS Git Server git at git.bestpractical.com
Thu May 5 20:32:29 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, 4.4/cf-groupings-on-queue-default-values has been created
        at  16c2b854c4af96f634304a0996d697127a62955c (commit)

- Log -----------------------------------------------------------------
commit 16c2b854c4af96f634304a0996d697127a62955c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri May 6 04:12:06 2022 +0800

    Test custom field groupings on queue default values page

diff --git a/t/web/cf_groupings_per_queue.t b/t/web/cf_groupings_per_queue.t
index 19cfd3a5c4..abdc12ae7d 100644
--- a/t/web/cf_groupings_per_queue.t
+++ b/t/web/cf_groupings_per_queue.t
@@ -92,6 +92,25 @@ for my $queue ( $general, $foo ) {
             ok( !$m->find_link( url_regex => qr/#ticket-info-cfs-More$/, text => 'More' ), 'no "More" widget' );
         }
     }
+
+    {
+        $m->get_ok( '/Admin/Queues/DefaultValues.html?id=' . $queue->Id, 'default values page' );
+        my $prefix = 'Object-RT::Ticket--CustomField:';
+        my $dom    = $m->dom;
+        $m->form_name('ModifyDefaultValues');
+        for my $grouping (@groupings) {
+            my $input_name = $prefix . "$grouping-$CF{$grouping}-Value";
+            if ( $grouping eq 'More' && $queue == $foo ) {
+                $input_name =~ s!:More!!;
+            }
+            is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
+            ok $dom->at(qq{$location{$grouping} input[name="$input_name"]}), "CF is in the right place";
+            $m->field( $input_name, "Test" . $grouping . "Value" );
+        }
+        $m->submit_form_ok( { button => 'Update' } );
+        $m->text_contains('Default values changed from (no value) to Test' . $_ . 'Value') for @groupings;
+    }
+
 }
 
 done_testing;

commit 4d157cb5637d46a45c35645163dbae18e2c1825d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri May 6 03:30:14 2022 +0800

    Correctly handle custom field groupings on queue default values page
    
    This is an amendment of 46cc17adf2, which added category-level custom
    field groupings but didn't fully update code for queue default values
    page accordingly, which caused custom fields defined in "People" and
    "Links" groupings to wrongly show up in "Custom Fields" section,
    queue-level custom groupings were not respected either.

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 97f437ad64..2a3c545577 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1907,10 +1907,13 @@ sub UpdateOption {
 sub ObjectHasCustomFieldGrouping {
     my $self        = shift;
     my %args        = ( Object => undef, CategoryObj => undef, Grouping => undef, @_ );
-    my $object_type = RT::CustomField->_GroupingClass($args{Object}, $args{CategoryObj} ? $args{CategoryObj}->Name : () );
+    my ( $object_type, $category ) = RT::CustomField->_GroupingClass($args{Object}, $args{CategoryObj} ? $args{CategoryObj}->Name : () );
     my $groupings   = RT->Config->Get( 'CustomFieldGroupings' );
     return 0 unless $groupings;
-    return 1 if $groupings->{$object_type} && grep { $_ eq $args{Grouping} } @{ $groupings->{$object_type} };
+    return 1
+        if $groupings->{$object_type} && grep { $_ eq $args{Grouping} }
+        # Fall back to Default groupings if $category is undef or doesn't have specific groupings defined in config.
+        @{ $groupings->{$object_type}{$category // 'Default'} // $groupings->{$object_type}{Default} // [] };
     return 0;
 }
 
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
index 8ab8b6041d..ee663ae273 100644
--- a/share/html/Admin/Queues/DefaultValues.html
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -117,13 +117,18 @@
         CustomFields => $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes,
         Grouping => 'Links',
         InTable => 1,
+        CategoryObj => $queue,
     &>
     </table>
     </&>
 </div>
 % }
 
-<& /Elements/EditCustomFieldCustomGroupings, CustomFieldGenerator => sub { $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes }, Object => RT::Ticket->new($session{CurrentUser}) &>
+<& /Elements/EditCustomFieldCustomGroupings,
+    CustomFieldGenerator => sub { $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes },
+    Object => RT::Ticket->new($session{CurrentUser}),
+    CategoryObj => $queue,
+&>
 
 <div class="ticket-info-cfs">
     <&|/Widgets/TitleBox, title => loc("Transaction Custom Fields") &>

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list