ReverseHistoryOrder: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
(No difference)

Latest revision as of 15:36, 6 April 2016

Can I reverse order of transactions on history page?

A: Yes. RT-3.4.6 and 3.6.1 have global config option OldestTransactionsFirst. Note that while the name of this variable is OldestTransactionsFirst, you must set it to '0' to be true, and '1' to be false.

RT-3.7 allows user to change this option in preferences. The patch below has more features then in the core. Feel free to update patch to 3.6 or 3.7 code and submit to devel list.

A: Yes. There are times when multiple correspondences can lead up to a rather large ticket. In this instance, it is often desirable to reverse the order of the the order of transactions displayed under the history tab. This howto will change the "History" title into a link that will reverse which ever is the current order. Read also next discussion.

Copy the text below (between the --PATCH-- lines) and paste in into a new text file. Name it something like ReverseHistoryOrder-RT-v3.2.x.patch. Next copy this file to /path/to/rt3/share. From this directory (/path/to/rt3/share) run the following command:

patch -l -p0 < ReverseHistoryOrder-3.2.patch

Then CleanMasonCache and restart the RT http server.

--PATCH-3.4.5-default-reverse--

--- html/Ticket/Display.html-orig       2005-06-28 18:47:38.000000000 -0400
+++ html/Ticket/Display.html    2006-02-21 21:46:23.000000000 -0500
@@ -62,10 +62,11 @@
 <& /Elements/Callback, _CallbackName => 'BeforeShowHistory', Ticket => $TicketObj, %ARGS &>

 <& /Ticket/Elements/ShowHistory ,
-      Ticket => $TicketObj,
       Tickets => $Tickets,
-      Collapsed => $ARGS{'Collapsed'},
-      ShowHeaders => $ARGS{'ShowHeaders'},
+      Ticket => $TicketObj,
+      HistorySort => $HistorySort,
+      Collapsed => $Collapsed,
+      ShowHeaders => $ShowHeaders,
       Attachments => $attachments,
       AttachmentContent => $attachment_content

@@ -78,6 +79,7 @@
 $ShowHeaders => 0
 $Collapsed => undef
 $TicketObj => undef
+$HistorySort => 'DESC'
 </%ARGS>

 <%INIT>
--- html/Ticket/Elements/ShowHistory-orig       2005-07-06 11:07:45.000000000 -0400
+++ html/Ticket/Elements/ShowHistory    2006-02-21 21:58:24.000000000 -0500
@@ -48,7 +48,16 @@
 my $title;
 my $titleright;
 if ($ShowTitle) {
-    $title = loc('History');
+    my $sort_order = $HistorySort;
+
+    if($sort_order eq 'DESC'){
+       $sort_order = 'ASC';
+    }else{
+       $sort_order = 'DESC';
+    }
+
+    $title = '<A  HREF="/Ticket/Display.html?id='.$Ticket->id."&HistorySort=$sort_order\">".loc('History')."</a>";
+
 }
 else {
     $title = ' ';
@@ -136,6 +145,10 @@
 } else {
     $Transactions = $Ticket->Transactions;
 }
+$Transactions->OrderByCols (
+                { FIELD => 'Created',   ORDER => $HistorySort },
+                { FIELD => 'id',     ORDER => $HistorySort } );
+
 my $i;

 $Attachments ||=  $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket, Tickets =>  $Tickets || undef);
@@ -153,6 +166,7 @@
 $ShowTitle => 1
 $ShowDisplayModes => 1
 $ShowTitleBarCommands => 1
+$HistorySort => $RT::TicketHistoryOrder || 'ASC'
 $AttachPath => $RT::WebPath."/Ticket/Attachment"
 $UpdatePath => $RT::WebPath."/Ticket/Update.html"
 </%ARGS>

--END-PATCH-3.4.5-default-reverse--

--PATCH-3.2.3-- (will also apply against 3.4.1 and 3.4.2)

--- html/Ticket/Display.html    2004-08-17 09:03:08.000000000 -0700
+++ html/Ticket/Display.html    2005-02-25 13:03:35.000000000 -0800
@@ -59,10 +59,11 @@

 <BR>
 <& /Ticket/Elements/ShowHistory ,
-      Ticket => $TicketObj,
       Tickets => $Tickets,
-      Collapsed => $ARGS{'Collapsed'},
-      ShowHeaders => $ARGS{'ShowHeaders'},
+      Ticket => $TicketObj,
+      HistorySort => $HistorySort,
+      Collapsed => $Collapsed,
+      ShowHeaders => $ShowHeaders,
       Attachments => $attachments,
       AttachmentContent => $attachment_content

@@ -75,6 +76,7 @@
 $ShowHeaders => 0
 $Collapsed => undef
 $TicketObj => undef
+$HistorySort => 'DESC'
 </%ARGS>

 <%INIT>
--- html/Ticket/Elements/ShowHistory    2004-08-18 14:53:17.000000000 -0700
+++ html/Ticket/Elements/ShowHistory    2005-02-25 13:04:41.000000000 -0800
@@ -48,7 +48,16 @@
 my $title;
 my $titleright;
 if ($ShowTitle) {
-    $title = loc('History');
+    my $sort_order = $HistorySort;
+
+    if($sort_order eq 'DESC'){
+       $sort_order = 'ASC';
+    }else{
+       $sort_order = 'DESC';
+    }
+
+    $title = '<A HREF="/Ticket/Display.html?id='.$Ticket->id."&HistorySort=$sort_order\">".loc('History')."</a>";
+
 }
 else {
     $title = ' ';
@@ -134,6 +143,10 @@
 } else {
     $Transactions = $Ticket->Transactions;
 }
+$Transactions->OrderByCols (
+                { FIELD => 'Created',   ORDER => $HistorySort },
+                { FIELD => 'id',     ORDER => $HistorySort } );
+
 my $i;

 $Attachments ||=  $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket, Tickets => $Tickets || undef);
@@ -151,6 +164,7 @@
 $ShowTitle => 1
 $ShowDisplayModes => 1
 $ShowTitleBarCommands => 1
+$HistorySort => $RT::TicketHistoryOrder || 'DESC'
 $AttachPath => $RT::WebPath."/Ticket/Attachment"
 $UpdatePath => $RT::WebPath."/Ticket/Update.html"

--END-PATCH-3.2.3--

--PATCH-orig--

--- html/Ticket/Display.html    2004-06-27 16:05:17.000000000 -0700
+++ html/Ticket/Display.html    2004-09-13 14:06:27.000000000 -0700
@@ -37,10 +37,11 @@

 <BR>
 <& /Ticket/Elements/ShowHistory ,
-      Ticket => $TicketObj,
       Tickets => $Tickets,
-      Collapsed => $ARGS{'Collapsed'},
-      ShowHeaders => $ARGS{'ShowHeaders'},
+      Ticket => $TicketObj,
+      HistorySort => $HistorySort,
+      Collapsed => $Collapsed,
+      ShowHeaders => $ShowHeaders,
       Attachments => $attachments,
       AttachmentContent => $attachment_content

@@ -53,6 +54,7 @@
 $ShowHeaders => 0
 $Collapsed => undef
 $TicketObj => undef
+$HistorySort => 'DESC'
 </%ARGS>

 <%INIT>
--- html/Ticket/Elements/ShowHistory    2004-06-16 17:52:13.000000000 -0700
+++ html/Ticket/Elements/ShowHistory    2004-09-13 14:13:04.000000000 -0700
@@ -26,7 +26,16 @@
 my $title;
 my $titleright;
 if ($ShowTitle) {
-    $title = loc('History');
+    my $sort_order = $HistorySort;
+
+    if($sort_order eq 'DESC'){
+       $sort_order = 'ASC';
+    }else{
+       $sort_order = 'DESC';
+    }
+
+    $title = '<A HREF="Display.html?id='.$Ticket->id."&HistorySort=$sort_order\">".loc('History')."</a>";
+
 }
 else {
     $title = ' ';
@@ -113,6 +122,10 @@
 } else {
     $Transactions = $Ticket->Transactions;
 }
+$Transactions->OrderByCols (
+                { FIELD => 'Created',   ORDER => $HistorySort },
+                { FIELD => 'id',     ORDER => $HistorySort } );
+
 my $i;

 $Attachments ||=  $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket, Tickets => $Tickets || undef);
@@ -130,6 +143,7 @@
 $ShowTitle => 1
 $ShowDisplayModes => 1
 $ShowTitleBarCommands => 1
+$HistorySort => $RT::TicketHistoryOrder || 'DESC'
 $AttachPath => $RT::WebPath."/Ticket/Attachment"
 $UpdatePath => $RT::WebPath."/Ticket/Update.html"

--END-PATCH-orig--

Enjoy.