[Rt-commit] rt branch 5.0/add-callback-cf-transaction-diff created. rt-5.0.2-275-g84116f5311

BPS Git Server git at git.bestpractical.com
Fri Jun 17 13:26:40 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/add-callback-cf-transaction-diff has been created
        at  84116f5311949ef52c6e969230fd09dc21bde617 (commit)

- Log -----------------------------------------------------------------
commit 84116f5311949ef52c6e969230fd09dc21bde617
Author: Brian Conry <bconry at bestpractical.com>
Date:   Thu Jun 16 13:00:53 2022 -0500

    Add callback for modifying which CFs are diffed
    
    In the ticket transaction display by default custom fields with a type
    that matches /text/ are show collapsed with a widget to expand and see a
    diff of the old and new contents.
    
    This change adds a callback, /Elements/ShowTransaction/ModifyShowCFDiff,
    that allows direct control over when custom fields are shown with a
    collapsed diff and when they are shown normally.

diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index 67ccc5882a..b18ef43bbc 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -88,7 +88,7 @@ $m->comp(
 %     my $cf = RT::CustomField->new( $session{CurrentUser} );
 %     $cf->SetContextObject( $Transaction->Object );
 %     $cf->Load( $Transaction->Field );
-%     if ($cf->Id && $cf->Type =~ /text/i) {
+%     if ($show_cf_diff) {
 %        $old = $Transaction->OldValue // loc('(no value)');
 %        $old = $m->comp('/Elements/ScrubHTML', Content => $old);
 %        $old =~ s|\n|<br />|g;
@@ -192,6 +192,7 @@ if ( $ShowBody && !$Attachments ) {
         foreach @{ $attachments->ItemsArrayRef };
 }
 
+my $show_cf_diff = 0;
 my @actions = ();
 my $txn_type = $Transaction->Type;
 if ( $txn_type =~ /EmailRecord$/ ) {
@@ -211,7 +212,21 @@ elsif ($txn_type eq 'CustomField' && $Transaction->Field) {
     my $cf = RT::CustomField->new( $session{CurrentUser} );
     $cf->SetContextObject( $Transaction->Object );
     $cf->Load( $Transaction->Field );
+
     if ($cf->Id && $cf->Type =~ /text/i) {
+        $show_cf_diff = 1;
+    }
+
+    $m->callback(
+        CallbackName => 'ModifyShowCFDiff',
+        Transaction  => $Transaction,
+        Object       => $Object,
+        CF           => $cf,
+        ShowDiff     => \$show_cf_diff,
+        ARGSRef      => \%ARGS,
+    );
+
+    if ($show_cf_diff) {
         push @actions, { class => 'toggle-txn-details', title => loc('Show Details'), path => '#' };
     }
 }

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list