[Rt-commit] rt branch 5.0/make-config-history-more-readable updated. rt-5.0.2-67-g5f803a2228

BPS Git Server git at git.bestpractical.com
Sun Mar 13 20:51:30 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/make-config-history-more-readable has been updated
       via  5f803a2228d316df73a3dd2c5b7393357ef3efa8 (commit)
       via  b698ace251af27359d117e2fc17a46178befce4f (commit)
       via  082e611b2621b62c469f7260377c3c9445afd3d0 (commit)
      from  2b3b5dd78abeb54b5654257ae92fc3968f1dc8e7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5f803a2228d316df73a3dd2c5b7393357ef3efa8
Author: Brad Embree <brad at bestpractical.com>
Date:   Sun Mar 13 13:39:37 2022 -0700

    Display new and old values over max lines in two divs
    
    When displaying the new and old values for a SetConfig or CustomField text transaction, split values that have more lines than the MaxLines parameter into two divs. One div displays the value truncated to the max number of lines and one div displays the full value. The divs use the bootstrap collapse class and collapse buttons to toggle display between the two divs.

diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index 3cddf17cf6..7045be73d9 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<div class="<% join ' ', @classes %>" data-transaction-id="<% $Transaction->id %>">
+<div class="<% join ' ', @classes %>" data-transaction-id="<% $Transaction->id %>" data-transaction-max-lines="<% $MaxLines %>">
   <div class="metadata">
 % if ( $actions ) {
     <span class="actions"><% $actions |n %></span>
@@ -131,13 +131,75 @@ $m->comp(
   </div>
 % }
 % else {
+%   # if the new or old value is more than $MaxLines show two divs
+%   # one with value truncated to $MaxLines and one with entire value
+%   # use bootstrap collapse class to toggle between divs
+%   my ( $short_old, $short_new );
+%   my @lines = split( /<br \/>/, $old );
+%   if ( scalar(@lines) > $MaxLines ) {
+%     $short_old = join '<br />', @lines[ 0 .. ( $MaxLines - 1 ) ];
+%   }
+%   @lines = split( /<br \/>/, $new );
+%   if ( scalar(@lines) > $MaxLines ) {
+%     $short_new = join '<br />', @lines[ 0 .. ( $MaxLines - 1 ) ];
+%   }
   <div class="form-row">
     <div class="label col-2"><% loc('From') %>:</div>
+%   if ( $short_old ) {
+%     my ( $class_old, $id_all_old, $id_less_old );
+%     $class_old   = "txn-collapse-old-" . $Transaction->Id;
+%     $id_all_old  = "txn-collapse-all-old-" . $Transaction->Id;
+%     $id_less_old = "txn-collapse-less-old-" . $Transaction->Id;
+    <div>
+      <div>
+        <div class="collapse show <% $class_old %>" id="<% $id_less_old %>">
+          <% $short_old |n %>
+          <p>
+            <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".<% $class_old %>" aria-expanded="false" aria-controls="<% $id_less_old %> <% $id_all_old %>"><% loc('Show all') %></button>
+          </p>
+        </div>
+      </div>
+      <div>
+        <div class="collapse <% $class_old %>" id="<% $id_all_old %>">
+          <% $old |n %>
+          <p>
+            <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".<% $class_old %>" aria-expanded="false" aria-controls="<% $id_less_old %> <% $id_all_old %>"><% loc('Show less') %></button>
+          </p>
+        </div>
+      </div>
+    </div>
+%   } else {
     <div class="value col-10"><% $old |n %></div>
+%   }
   </div>
   <div class="form-row">
     <div class="label col-2"><% loc('To') %>:</div>
+%   if ( $short_new ) {
+%     my ( $class_new, $id_all_new, $id_less_new );
+%     $class_new   = "txn-collapse-new-" . $Transaction->Id;
+%     $id_all_new  = "txn-collapse-all-new-" . $Transaction->Id;
+%     $id_less_new = "txn-collapse-less-new-" . $Transaction->Id;
+    <div>
+      <div>
+        <div class="collapse show <% $class_new %>" id="<% $id_less_new %>">
+          <% $short_new |n %>
+          <p>
+            <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".<% $class_new %>" aria-expanded="false" aria-controls="<% $id_less_new %> <% $id_all_new %>"><% loc('Show all') %></button>
+          </p>
+        </div>
+      </div>
+      <div>
+        <div class="collapse <% $class_new %>" id="<% $id_all_new %>">
+          <% $new |n %>
+          <p>
+            <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".<% $class_new %>" aria-expanded="false" aria-controls="<% $id_less_new %> <% $id_all_new %>"><% loc('Show less') %></button>
+          </p>
+        </div>
+      </div>
+    </div>
+%   } else {
     <div class="value col-10"><% $new |n %></div>
+%   }
   </div>
   <div class="form-row diff">
     <div class="label col-2"><% loc('Changes') %>:</div>
@@ -161,6 +223,7 @@ $HasTxnCFs => 1
 $ShowBody => 1
 $ShowActions => 1
 $RowNum => 1
+$MaxLines => 3
 
 $DisplayPath => undef
 $AttachmentPath => undef

commit b698ace251af27359d117e2fc17a46178befce4f
Author: Brad Embree <brad at bestpractical.com>
Date:   Sun Mar 13 13:35:05 2022 -0700

    Display diffs over max lines in two divs
    
    When displaying a diff, split diffs that have more lines than the MaxLines parameter into two divs. One div displays the value truncated to the max number of lines and one div displays the full value. The divs use the bootstrap collapse class and collapse buttons to toggle display between the two divs.

diff --git a/share/html/Helpers/TextDiff b/share/html/Helpers/TextDiff
index 536655d8c8..a5f0f12f86 100644
--- a/share/html/Helpers/TextDiff
+++ b/share/html/Helpers/TextDiff
@@ -45,6 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
+
 <%INIT>
 
 my ( $old, $new );
@@ -70,10 +71,44 @@ my $diff = word_diff( \$old, \$new, { STYLE => 'HTML' } );
 $diff = $m->comp( '/Elements/ScrubHTML', Content => $diff );
 $diff =~ s|\n|<br />|g;
 
+# if the diff is more than $MaxLines lines we have two divs
+# one with first 3 lines of the value and one with entire value
+# use bootstrap collapse class to toggle between divs
+my ( $short_diff, $class, $id_all, $id_less );
+my @lines = split( /<br \/>/, $diff );
+if ( scalar(@lines) > $MaxLines ) {
+    $short_diff = join '<br />', @lines[ 0 .. ( $MaxLines - 1 ) ];
+    $class      = "txn-collapse-$TransactionId";
+    $id_all     = "txn-collapse-all-$TransactionId";
+    $id_less    = "txn-collapse-less-$TransactionId";
+}
+
 </%INIT>
+% if ( $short_diff ) {
+<div>
+  <div>
+    <div class="collapse show <% $class %>" id="<% $id_less %>">
+      <% $short_diff |n %>
+      <p>
+        <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".<% $class %>" aria-expanded="false" aria-controls="<% $id_less %> <% $id_all %>"><% loc('Show all') %></button>
+      </p>
+    </div>
+  </div>
+  <div>
+    <div class="collapse <% $class %>" id="<% $id_all %>">
+      <% $diff |n %>
+      <p>
+        <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".<% $class %>" aria-expanded="false" aria-controls="<% $id_less %> <% $id_all %>"><% loc('Show less') %></button>
+      </p>
+    </div>
+  </div>
+</div>
+% } else {
 <% $diff |n %>
+% }
 % $m->abort();
 
 <%ARGS>
 $TransactionId => undef
+$MaxLines => 3
 </%ARGS>

commit 082e611b2621b62c469f7260377c3c9445afd3d0
Author: Brad Embree <brad at bestpractical.com>
Date:   Sun Mar 13 13:32:12 2022 -0700

    Add MaxLines parameter to TextDiff call

diff --git a/share/static/js/util.js b/share/static/js/util.js
index ddd122575f..aee97a4b17 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -1189,7 +1189,8 @@ function toggleTransactionDetails () {
     var diff = details_div.find('.diff div.value');
     if (!diff.children().length) {
         diff.load(RT.Config.WebHomePath + '/Helpers/TextDiff', {
-            TransactionId: txn_div.attr('data-transaction-id')
+            TransactionId: txn_div.attr('data-transaction-id'),
+            MaxLines: txn_div.attr('data-transaction-max-lines')
         });
     }
 

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

Summary of changes:
 share/html/Elements/ShowTransaction | 65 ++++++++++++++++++++++++++++++++++++-
 share/html/Helpers/TextDiff         | 35 ++++++++++++++++++++
 share/static/js/util.js             |  3 +-
 3 files changed, 101 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list