[Rt-commit] rt branch, 4.6/revert-transaction-order, created. rt-4.4.4-65-ge5291bb89

Michel Rodriguez michel at bestpractical.com
Fri May 10 14:32:50 EDT 2019


The branch, 4.6/revert-transaction-order has been created
        at  e5291bb8969a5388bb3e91b7f84c8445308f7760 (commit)

- Log -----------------------------------------------------------------
commit 89a65dd9844a0cfb0a4b527f99543f839e46eaf6
Merge: 9e0a58aba 4c55894d5
Author: michel <michel at bestpractical.com>
Date:   Tue Apr 9 20:28:25 2019 +0200

    Merge branch '4.4/recently-viewed-tickets-no-debug-message-for-shredded-tickets'
    
    remove debug message when the Recently Viewed Tickets list includes shredded messages
    
    These messages clog the logs unnecessarily, when any page is loaded.
    The template now calls an intermediate method (LoadAllowNonExistentTickets)
    and Load does not emit the message in this case


commit e5291bb8969a5388bb3e91b7f84c8445308f7760
Author: michel <michel at bestpractical.com>
Date:   Fri May 10 18:42:40 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..c5bd12d02 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1729,13 +1729,20 @@ 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..e4797ee37 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,8 +95,17 @@ 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>
 % $m->callback( CallbackName => 'BeforeTitle', %ARGS, title => \$title, titleright => \$titleright );
 <& /Widgets/TitleBoxStart, title => $title, titleright_raw => $titleright &>
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/Helpers/TicketHistory b/share/html/Helpers/TicketHistory
index 075598be1..7ea6ed85d 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'},
+    ReverseTransactionOrder => $ARGS{ReverseTransactionOrder},
     Attachments => $attachments,
     AttachmentContent => $attachment_content,
     %extra_args,
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 2681a3831..b855dbff5 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,10 +120,10 @@ $TicketObj => undef
 $ShowHeaders => 0
 $HideUnsetFields => RT->Config->Get('HideUnsetFieldsOnDisplay', $session{CurrentUser})
 $ForceShowHistory => 0
+$ReverseTransactionOrder => 0
 </%ARGS>
 
 <%INIT>
-
 $m->callback( TicketObj => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'Initial' );
 
 if ( ! $ARGS{'NoRedirect'} && RT::Interface::Web->MobileClient()) {
@@ -128,7 +132,6 @@ if ( ! $ARGS{'NoRedirect'} && RT::Interface::Web->MobileClient()) {
     $m->abort;
 }
 
-
 my (@Actions, $title);
 
 
@@ -235,7 +238,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/ClickToShowHistory b/share/html/Ticket/Elements/ClickToShowHistory
index 20225c30b..1bbc8c185 100644
--- a/share/html/Ticket/Elements/ClickToShowHistory
+++ b/share/html/Ticket/Elements/ClickToShowHistory
@@ -56,7 +56,6 @@ $Ticket
 <%INIT>
 my %params = %ARGS;
 delete $params{Ticket};
-
 my $query   = $m->comp('/Elements/QueryString', %params, id => $Ticket->id );
 my $url     = RT->Config->Get('WebPath')."/Helpers/TicketHistory?$query";
 my $display = RT->Config->Get('WebPath')."/Ticket/Display.html?ForceShowHistory=1;$query";
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