[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0alpha1-103-g2f8378a2c6

? sunnavy sunnavy at bestpractical.com
Fri Apr 10 13:31:40 EDT 2020


The branch, 5.0-trunk has been updated
       via  2f8378a2c6d44834841ca98b8534f414645debf7 (commit)
       via  bc58322ccf7b54b2146d9ceecae4db3bd6bc9cbe (commit)
       via  50fe3e9b1df6917272aa67c9ac932ba7e267ae1e (commit)
      from  9ba2d1c5d2b9c899d14b18c270add9992055268e (commit)

Summary of changes:
 lib/RT/Record.pm                             | 15 +++++++++++++--
 share/html/Elements/ShowHistoryHeader        | 20 ++++++++++++++++++++
 share/html/Elements/ShowHistoryPage          |  4 ++++
 share/html/Helpers/TicketHistory             |  1 +
 share/html/Ticket/Display.html               | 12 +++++++++++-
 share/html/Ticket/Elements/ScrollShowHistory | 10 ++++++++--
 share/html/Transaction/Display.html          |  2 +-
 7 files changed, 58 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 50fe3e9b1df6917272aa67c9ac932ba7e267ae1e
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Apr 10 09:39:32 2020 -0400

    Add an option to reverse the transaction history on ticket display
    
    The order of transactions on ticket display can be set globally
    and per user. This new option allows you to reverse the order
    on an individual ticket.

diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 5b2b8d2d31..99242eac13 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1729,13 +1729,24 @@ sub Transactions {
 Returns the result of L</Transactions> ordered per the
 I<OldestTransactionsFirst> preference/option.
 
+Pass an optional value 'ASC' or 'DESC' to force a specific
+order.
+
 =cut
 
 sub SortedTransactions {
     my $self  = shift;
+    my $order = shift || 0;
     my $txns  = $self->Transactions;
-    my $order = RT->Config->Get("OldestTransactionsFirst", $self->CurrentUser)
-        ? 'ASC' : 'DESC';
+
+    if ( $order && ( $order eq 'ASC' || $order eq 'DESC' ) ) {
+        # Use provided value
+    }
+    else {
+        $order = RT->Config->Get("OldestTransactionsFirst", $self->CurrentUser)
+            ? 'ASC' : 'DESC';
+    }
+
     $txns->OrderByCols(
         { FIELD => 'Created',   ORDER => $order },
         { FIELD => 'id',        ORDER => $order },
diff --git a/share/html/Elements/ShowHistoryHeader b/share/html/Elements/ShowHistoryHeader
index c12fce532e..78c0667cf8 100644
--- a/share/html/Elements/ShowHistoryHeader
+++ b/share/html/Elements/ShowHistoryHeader
@@ -55,6 +55,17 @@ $ScrollShowHistory => 0
 <%INIT>
 my $record_type = $Object->RecordType;
 my $histid      = "\L$record_type\E-" . $Object->id . "-history";
+
+my $reverse_txns = $ARGS{'ReverseTxns'};
+if ( $reverse_txns ) {
+    # If we got something, reverse it for the link
+    $reverse_txns = $reverse_txns eq 'ASC' ? 'DESC' : 'ASC';
+}
+else {
+    # Default the link to the opposite of the config setting
+    # Oldest Txns first is ASC, so reverse it for this option default
+    $reverse_txns = RT->Config->Get("OldestTransactionsFirst", $session{'CurrentUser'}) ? 'DESC' : 'ASC';
+}
 </%INIT>
 <div class="history <% lc $record_type %>" id="<% $histid %>">
 <%perl>
@@ -94,6 +105,11 @@ if ( $ShowDisplayModes or $ShowTitle or $ScrollShowHistory ) {
         }
     }
 
+    push( @elements, qq{<a href="?ForceShowHistory=1;ReverseTxns=$reverse_txns;id=} .
+                     $Object->id.qq{#$histid">} .
+                     loc("Reverse history order") .
+                     qq{</a>} );
+
     # build the new link
     my $alt = loc('Edit');
     my $titleright = qq{<div class="btn-group dropdown"><a id="history-dropdown" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="fas fa-cog icon-bordered fa-2x" alt="$alt" data-toggle="tooltip" data-placement="top" data-original-title="$alt"></span></a><ul class="dropdown-menu dropdown-menu-right">};
diff --git a/share/html/Elements/ShowHistoryPage b/share/html/Elements/ShowHistoryPage
index 51237de147..f87f9ab8f5 100644
--- a/share/html/Elements/ShowHistoryPage
+++ b/share/html/Elements/ShowHistoryPage
@@ -59,6 +59,10 @@ $PathPrefix        => ''
 my $trans_content = {};
 my $trans_attachments = {};
 
+if ( $ARGS{'ReverseTxns'} ) {
+    $Transactions = $Object->SortedTransactions($ARGS{'ReverseTxns'});
+}
+
 for my $content (@{$AttachmentContent->ItemsArrayRef()}) {
     $trans_content->{$content->TransactionId}->{$content->Id} = $content;
 }
diff --git a/share/html/Helpers/TicketHistory b/share/html/Helpers/TicketHistory
index 075598be12..be2d3faf9a 100644
--- a/share/html/Helpers/TicketHistory
+++ b/share/html/Helpers/TicketHistory
@@ -60,6 +60,7 @@ $m->callback( CallbackName => 'ExtraShowHistoryArguments', Ticket => $TicketObj,
 <& /Elements/ShowHistory,
     Object => $TicketObj,
     ShowHeaders => $ARGS{'ShowHeaders'},
+    ReverseTxns => $ARGS{'ReverseTxns'},
     Attachments => $attachments,
     AttachmentContent => $attachment_content,
     %extra_args,
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 1ad1d1c685..f6293e20bd 100644
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -93,22 +93,26 @@ my $titleright = qq{
     <& /Ticket/Elements/ScrollShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
+        ReverseTxns => $ARGS{'ReverseTxns'},
     &>
 % } elsif ($ShowHistory eq "delay") {
     <& /Ticket/Elements/DelayShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
+        ReverseTxns => $ARGS{'ReverseTxns'},
     &>
 % } elsif (not $ForceShowHistory and $ShowHistory eq "click") {
     <& /Ticket/Elements/ClickToShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
+        ReverseTxns => $ARGS{'ReverseTxns'},
     &>
 % } else {
     <& /Elements/ShowHistory ,
           Object => $TicketObj,
           Transactions => $transactions,
           ShowHeaders => $ARGS{'ShowHeaders'},
+          ReverseTxns => $ARGS{'ReverseTxns'},
           Attachments => $attachments,
           AttachmentContent => $attachment_content
     &>
@@ -267,7 +271,13 @@ MaybeRedirectForResults(
     Arguments => { id => $TicketObj->id },
 );
 
-my $transactions = $TicketObj->SortedTransactions;
+my $transactions;
+if ( $ARGS{'ReverseTxns'} ) {
+    $transactions = $TicketObj->SortedTransactions($ARGS{'ReverseTxns'});
+}
+else {
+    $transactions = $TicketObj->SortedTransactions;
+}
 my $attachments = $TicketObj->Attachments;
 my $attachment_content = $TicketObj->TextAttachments;
 
diff --git a/share/html/Ticket/Elements/ScrollShowHistory b/share/html/Ticket/Elements/ScrollShowHistory
index d2aca08a85..d62f488a8e 100644
--- a/share/html/Ticket/Elements/ScrollShowHistory
+++ b/share/html/Ticket/Elements/ScrollShowHistory
@@ -58,11 +58,17 @@ my $url = RT->Config->Get('WebPath') . "/Helpers/TicketHistoryPage?" .
 
 my %extra_args = map { $_ => $ARGS{$_} // 1 } qw/ShowDisplayModes ShowTitle ScrollShowHistory/;
 $extra_args{ShowHeaders} = $ARGS{ShowHeaders};
+$extra_args{ReverseTxns} = $ARGS{ReverseTxns};
 
 $m->callback( CallbackName => 'ExtraShowHistoryArguments', Ticket => $Ticket, ExtraArgs => \%extra_args );
 
-
-my $oldestTransactionsFirst = RT->Config->Get("OldestTransactionsFirst", $session{CurrentUser});
+my $oldestTransactionsFirst;
+if ( $ARGS{ReverseTxns} ) {
+    $oldestTransactionsFirst = $ARGS{ReverseTxns} eq 'ASC' ? 1 : 0;
+}
+else {
+    $oldestTransactionsFirst = RT->Config->Get("OldestTransactionsFirst", $session{CurrentUser});
+}
 </%INIT>
 
 <& /Elements/ShowHistoryHeader,

commit bc58322ccf7b54b2146d9ceecae4db3bd6bc9cbe
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Apr 10 11:22:13 2020 -0400

    Add a parameter to give context to history header
    
    ShowHistoryHeader can now be called from a full transaction
    history listing or an individual transaction. Add a flag
    to explicitly indicate the single transaction context and
    hide options that might not be applicable.

diff --git a/share/html/Elements/ShowHistoryHeader b/share/html/Elements/ShowHistoryHeader
index 78c0667cf8..2edd738761 100644
--- a/share/html/Elements/ShowHistoryHeader
+++ b/share/html/Elements/ShowHistoryHeader
@@ -51,6 +51,7 @@ $ShowHeaders       => 0
 $ShowTitle         => 1
 $ShowDisplayModes  => 1
 $ScrollShowHistory => 0
+$SingleTransaction => 0
 </%ARGS>
 <%INIT>
 my $record_type = $Object->RecordType;
@@ -105,10 +106,13 @@ if ( $ShowDisplayModes or $ShowTitle or $ScrollShowHistory ) {
         }
     }
 
-    push( @elements, qq{<a href="?ForceShowHistory=1;ReverseTxns=$reverse_txns;id=} .
-                     $Object->id.qq{#$histid">} .
-                     loc("Reverse history order") .
-                     qq{</a>} );
+    # Don't need to reverse history when showing a single transaction
+    unless ( $SingleTransaction ) {
+        push( @elements, qq{<a href="?ForceShowHistory=1;ReverseTxns=$reverse_txns;id=} .
+                         $Object->id.qq{#$histid">} .
+                         loc("Reverse history order") .
+                         qq{</a>} );
+    }
 
     # build the new link
     my $alt = loc('Edit');
diff --git a/share/html/Transaction/Display.html b/share/html/Transaction/Display.html
index 36686f6922..0ce1998e5a 100644
--- a/share/html/Transaction/Display.html
+++ b/share/html/Transaction/Display.html
@@ -48,7 +48,7 @@
 <& /Elements/Header, Title => loc('Transaction #[_1]', $id) &>
 <& /Elements/Tabs &>
 
-<& /Elements/ShowHistoryHeader, Object => $txn, %ARGS &>
+<& /Elements/ShowHistoryHeader, Object => $txn, SingleTransaction => 1, %ARGS &>
 
 <& /Elements/ShowTransaction, Transaction => $txn,
     DisplayPath     => RT->Config->Get('WebPath') . '/Ticket/Display.html',

commit 2f8378a2c6d44834841ca98b8534f414645debf7
Merge: 9ba2d1c5d2 bc58322ccf
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Apr 11 01:16:46 2020 +0800

    Merge branch '5.0/reverse-transaction-history' into 5.0-trunk


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


More information about the rt-commit mailing list