[Rt-commit] rt branch, 4.6/reverse-trans-order, created. rt-4.4.4-74-g2fda5717c

Michel Rodriguez michel at bestpractical.com
Mon May 13 08:17:07 EDT 2019


The branch, 4.6/reverse-trans-order has been created
        at  2fda5717c427e25d310354149536cd1295d07787 (commit)

- Log -----------------------------------------------------------------
commit 2fda5717c427e25d310354149536cd1295d07787
Author: michel <michel at bestpractical.com>
Date:   Mon May 13 14:10:38 2019 +0200

    Add a control to reverse the time order on the current ticket
    
    Added the option in the template.
    Passed the new parameter through the variousi layers of templates.
    Added an option to SortedTransactions to change the original order

diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 0cc188463..b36bab287 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1729,13 +1729,19 @@ sub Transactions {
 Returns the result of L</Transactions> ordered per the
 I<OldestTransactionsFirst> preference/option.
 
+The second argument reverses the order if true, to 
+provide the "Reverse Transaction Order" feature.
+ 
 =cut
 
 sub SortedTransactions {
     my $self  = shift;
+    my $reverse_order = shift || 0;
+
     my $txns  = $self->Transactions;
-    my $order = RT->Config->Get("OldestTransactionsFirst", $self->CurrentUser)
-        ? 'ASC' : 'DESC';
+    # parens required because the priority of 'xor' is lower than the one of '='
+    my $order_param = ( RT->Config->Get("OldestTransactionsFirst", $self->CurrentUser) xor $reverse_order );
+    my $order = $order_param ? 'ASC' : 'DESC';
     $txns->OrderByCols(
         { FIELD => 'Created',   ORDER => $order },
         { FIELD => 'id',        ORDER => $order },
diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index 562264996..b157e3c8d 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -58,7 +58,8 @@
 </div>
 <%ARGS>
 $Object
-$Transactions      => $Object->SortedTransactions
+$ReverseTransactionOrder => 0
+$Transactions      => $Object->SortedTransactions( $ReverseTransactionOrder )
 $Attachments       => $Object->Attachments( WithHeaders => 1 )
 $AttachmentContent => $Object->TextAttachments
 
diff --git a/share/html/Elements/ShowHistoryHeader b/share/html/Elements/ShowHistoryHeader
index bf490b468..dcea42db9 100644
--- a/share/html/Elements/ShowHistoryHeader
+++ b/share/html/Elements/ShowHistoryHeader
@@ -51,6 +51,7 @@ $ShowHeaders       => 0
 $ShowTitle         => 1
 $ShowDisplayModes  => 1
 $ScrollShowHistory => 0
+$ReverseTransactionOrder => 0
 </%ARGS>
 <%INIT>
 my $record_type = $Object->RecordType;
@@ -94,6 +95,13 @@ if ( $ShowDisplayModes or $ShowTitle or $ScrollShowHistory ) {
                            loc("Show full headers") .
                            qq{</a>};
         }
+
+        my $switched_order = 1 - $ReverseTransactionOrder;
+        $titleright .= '—' if $titleright;
+        $titleright .= qq{<a href="?ReverseTransactionOrder=$switched_order;ForceShowHistory=1;ShowHeaders=$ShowHeaders;id=} .
+                           $Object->id.qq{#$histid">} .
+                           loc("Reverse transaction order") .
+                           qq{</a>};
     }
 
 </%perl>
diff --git a/share/html/Elements/ShowHistoryPage b/share/html/Elements/ShowHistoryPage
index 7f519e6fe..722ed9d3d 100644
--- a/share/html/Elements/ShowHistoryPage
+++ b/share/html/Elements/ShowHistoryPage
@@ -47,7 +47,8 @@
 %# END BPS TAGGED BLOCK }}}
 <%ARGS>
 $Object
-$Transactions      => $Object->SortedTransactions
+$ReverseTransactionOrder => 0
+$Transactions      => $Object->SortedTransactions( $ReverseTransactionOrder );
 $Attachments       => $Object->Attachments( WithHeaders => 1 )
 $AttachmentContent => $Object->TextAttachments
 
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 2681a3831..6636d0e85 100644
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -83,22 +83,26 @@ my $titleright = qq{<a href="$url_html" data-show-label="$show_label" data-hide-
     <& /Ticket/Elements/ScrollShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
+        ReverseTransactionOrder => $ReverseTransactionOrder,
     &>
 % } elsif ($ShowHistory eq "delay") {
     <& /Ticket/Elements/DelayShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
+        ReverseTransactionOrder => $ReverseTransactionOrder,
     &>
 % } elsif (not $ForceShowHistory and $ShowHistory eq "click") {
     <& /Ticket/Elements/ClickToShowHistory,
         Ticket => $TicketObj,
         ShowHeaders => $ARGS{'ShowHeaders'},
+        ReverseTransactionOrder => $ReverseTransactionOrder,
     &>
 % } else {
     <& /Elements/ShowHistory ,
           Object => $TicketObj,
           Transactions => $transactions,
           ShowHeaders => $ARGS{'ShowHeaders'},
+          ReverseTransactionOrder => $ReverseTransactionOrder,
           Attachments => $attachments,
           AttachmentContent => $attachment_content
     &>
@@ -116,6 +120,7 @@ $TicketObj => undef
 $ShowHeaders => 0
 $HideUnsetFields => RT->Config->Get('HideUnsetFieldsOnDisplay', $session{CurrentUser})
 $ForceShowHistory => 0
+$ReverseTransactionOrder => 0
 </%ARGS>
 
 <%INIT>
@@ -235,7 +240,7 @@ MaybeRedirectForResults(
     Arguments => { id => $TicketObj->id },
 );
 
-my $transactions = $TicketObj->SortedTransactions;
+my $transactions = $TicketObj->SortedTransactions( $ReverseTransactionOrder ); 
 my $attachments = $TicketObj->Attachments;
 my $attachment_content = $TicketObj->TextAttachments;
 
diff --git a/share/html/Ticket/Elements/ScrollShowHistory b/share/html/Ticket/Elements/ScrollShowHistory
index d2aca08a8..d16a399bc 100644
--- a/share/html/Ticket/Elements/ScrollShowHistory
+++ b/share/html/Ticket/Elements/ScrollShowHistory
@@ -58,6 +58,7 @@ 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{ReverseTransactionOrder} = $ARGS{ReverseTransactionOrder};
 
 $m->callback( CallbackName => 'ExtraShowHistoryArguments', Ticket => $Ticket, ExtraArgs => \%extra_args );
 

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


More information about the rt-commit mailing list