[Rt-commit] rt branch, 4.4/txn-text-cf-ui, created. rt-4.4.4-90-g657590414

? sunnavy sunnavy at bestpractical.com
Thu Mar 12 18:51:38 EDT 2020


The branch, 4.4/txn-text-cf-ui has been created
        at  65759041489c271c1024860a0676a2e3a805ece7 (commit)

- Log -----------------------------------------------------------------
commit 65759041489c271c1024860a0676a2e3a805ece7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Mar 13 06:06:23 2020 +0800

    Friendly transaction UI of text CF changes especially for large contents
    
    Previously the single-line description was hardly readable for large
    contents, e.g.
    
      intro RT is an enterprise-grade issue tracking system. It allows
      organizations to keep track of their to-do lists, who is working on
      which tasks, what's already been done, and when tasks were completed. It
      is available under the terms of version 2 of the GNU General Public
      License (GPL), so it doesn't cost anything to set up and use. changed to
      RT is commercially-supported software. To purchase support, training,
      custom development, or professional services, please get in touch with
      us at <sales at bestpractical.com>.
    
    Now it's like:
    
      intro changed
    
      From: RT is an enterprise-grade issue tracking system. It allows
            organizations to keep track of their to-do lists, who is working on
            which tasks, what's already been done, and when tasks were completed.
            It is available under the terms of version 2 of the GNU General
            Public License (GPL), so it doesn't cost anything to set up and use.
    
      To:   RT is commercially-supported software. To purchase support,
            training, custom development, or professional services, please get in
            touch with us at <sales at bestpractical.com>.
    
    Which is way more clear and friendly.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 914fe51ca..f4f47de6e 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1045,6 +1045,14 @@ sub _CanonicalizeRoleName {
                     $new = $date->AsString( Time => 0, Timezone => 'UTC' );
                 }
             }
+            elsif ( $cf->Type =~ /text/i ) {
+                if ( !defined($old) || $old eq '' ) {
+                    return ("[_1] added", $field);      #loc()
+                }
+                else {
+                    return ("[_1] changed", $field);    #loc()
+                }
+            }
         }
 
         if ( !defined($old) || $old eq '' ) {
diff --git a/share/html/Elements/JavascriptConfig b/share/html/Elements/JavascriptConfig
index 1254d838b..20fe3fb75 100644
--- a/share/html/Elements/JavascriptConfig
+++ b/share/html/Elements/JavascriptConfig
@@ -73,6 +73,8 @@ my $Catalog = {
     loading => "Loading...", #loc
     try_again => "Try again", #loc
     history_scroll_error => "Could not load ticket history. Reason:", #loc
+    show_details => "Show Details", #loc
+    hide_details => "Hide Details", #loc
 };
 $_ = loc($_) for values %$Catalog;
 
diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index 790d026b1..fdc881013 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -77,6 +77,28 @@ $m->comp(
     Parent => 0
 ) if $ShowBody;
 </%PERL>
+
+% if ( $old || $new ) {
+    <div class="details <% $ShowActions ? 'hidden' : '' %>" id="txn-<% $Transaction->Id %>-details">
+      <table>
+%   if ( $old eq loc('(no value)')  ) {
+        <tr>
+          <td class="value"><% $new |n %></td>
+        </tr>
+%   }
+%   else {
+        <tr>
+          <td class="label"><% loc('From') %>:</td>
+          <td class="value" ><% $old |n %></td>
+        </tr>
+        <tr>
+          <td class="label"><% loc('To') %>:</td>
+          <td class="value"><% $new |n %></td>
+        </tr>
+%   }
+      </table>
+    </div>
+% }
   </div>
 % $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterContent' );
 </div>
@@ -227,6 +249,33 @@ elsif ( %$Attachments && $ShowActions ) {
     }
 }
 
+my ( $old, $new );
+if ( $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 ) {
+        $old = $Transaction->OldValue // loc('(no value)');
+        $old = $m->comp('/Elements/ScrubHTML', Content => $old);
+        $old =~ s|\n|<br />|g;
+
+        $new = $Transaction->NewValue // loc('(no value)');
+        $new = $m->comp('/Elements/ScrubHTML', Content => $new);
+        $new =~ s|\n|<br />|g;
+
+        if ($ShowActions) {
+            my $id = $Transaction->Id;
+            push @actions,
+                {
+                class   => "toggle-txn-details",
+                title   => loc('Show Details'),
+                onclick => "return toggleTransactionDetails('txn-$id-details', this)",
+                path    => '#',
+                };
+        }
+    }
+}
+
 my $CreatorObj = $Transaction->CreatorObj;
 
 $m->callback(
@@ -258,6 +307,10 @@ if ( @actions ) {
                 ? ' class="'. $i->apply_escapes( $a->{'class'}, 'h' ) .'"'
                 : ''
             )
+            . ($a->{'onclick'}
+                ? ' onclick="'. $i->apply_escapes( $a->{'onclick'}, 'h' ) .'"'
+                : ''
+            )
             .'>'. $i->apply_escapes( $a->{'title'}, 'h' ) .'</a>'
         ;
     }
diff --git a/share/static/css/base/history.css b/share/static/css/base/history.css
index 7fa086737..bff1e93a8 100644
--- a/share/static/css/base/history.css
+++ b/share/static/css/base/history.css
@@ -164,3 +164,11 @@ padding-right:0.25em;
 .transaction .message-header-value.verify.done.trust-FULL      { color: #060; }
 .transaction .message-header-value.verify.done.trust-FULLY     { color: #060; }
 .transaction .message-header-value.verify.done.trust-ULTIMATE  { color: #060; }
+
+.transaction.other .content .details {
+  margin-top: 0.5em;
+}
+
+.transaction.other .content .details tr:not(:first-child) td.value {
+  border-top: 1px solid #ccc;
+}
diff --git a/share/static/css/rudder/history.css b/share/static/css/rudder/history.css
index b9949c39e..f271638a2 100644
--- a/share/static/css/rudder/history.css
+++ b/share/static/css/rudder/history.css
@@ -2,6 +2,7 @@ div.history-container {
     border: 0
 }
 
+.history .transaction.details div.content,
 .history .transaction.message div.content {
     padding-right: 0;
     padding-bottom: 3em;
diff --git a/share/static/css/rudder/misc.css b/share/static/css/rudder/misc.css
index dab61c7c5..fdf1bb768 100644
--- a/share/static/css/rudder/misc.css
+++ b/share/static/css/rudder/misc.css
@@ -25,6 +25,10 @@ td.labeltop {
     min-width: 6em;
 }
 
+.transaction.other .content .details td.label {
+    min-width: 0;
+}
+
 span.cflabel .type,
 td.cflabel .type {
     font-weight: normal;
diff --git a/share/static/js/util.js b/share/static/js/util.js
index d5bf84562..ea45cc473 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -591,3 +591,13 @@ function toggle_hide_unset(e) {
 
     return false;
 }
+
+function toggleTransactionDetails (id, link) {
+    hideshow(id);
+
+    if (link) {
+        jQuery(link).text(RT.I18N.Catalog[jQuery('#'+id).is(':visible') ? 'hide_details' : 'show_details']);
+    }
+
+    return false;
+}

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


More information about the rt-commit mailing list