[Rt-devel] Allow TicketList sorting when embedded in other pages

Nicholas Clark nick at ccl4.org
Wed May 30 09:50:56 EDT 2007


I'm not sure if the appended patch is what you want for RT.

The TicketList element is embedded into various pages generated by RT. However,
sorting is (as best I can tell) only enabled for searches and bulk searches
by privileged users. I tried enabling this for a custom page I'd written
for the Self-Service interface and it all went horribly wrong, because
TicketList assumes that the query arguments needed on the sorting link are
those of the RT search. This is accurate for the current uses, but not that
flexible.

With these changes it's possible to enable sorting on TicketList in other
situations, and have it pass through the correct (extra) page parameters to
reload those pages in sorted form.

It would be possible to enable sorting of the open and closed pages on the
default self service interface, but I've not done that here.

Nicholas Clark

Index: rt-external/html/Elements/TicketList
diff -c rt-external/html/Elements/TicketList:1.1.1.1 rt-external/html/Elements/TicketList:1.2
*** rt-external/html/Elements/TicketList:1.1.1.1	Mon May 21 15:38:40 2007
--- rt-external/html/Elements/TicketList	Wed May 30 12:32:26 2007
***************
*** 56,61 ****
--- 56,62 ----
      Page => $Page,
      OrderBy => $OrderBy , 
      BaseURL => $BaseURL,
+     GenericQueryArgs => $GenericQueryArgs,
      maxitems => $maxitems &> 
  % }
  
***************
*** 167,172 ****
--- 168,174 ----
  $Order => undef
  $OrderBy => undef
  $BaseURL => undef
+ $GenericQueryArgs => undef
  $Format => $RT::DefaultSearchResultFormat
  $DisplayFormat => undef
  $ShowNavigation => 1
Index: rt-external/html/Elements/CollectionAsTable/Header
diff -u rt-external/html/Elements/CollectionAsTable/Header:1.1.1.1 rt-external/html/Elements/CollectionAsTable/Header:1.2
--- rt-external/html/Elements/CollectionAsTable/Header:1.1.1.1	Mon May 21 15:38:40 2007
+++ rt-external/html/Elements/CollectionAsTable/Header	Wed May 30 12:32:26 2007
@@ -49,6 +49,7 @@
 $AllowSorting => undef
 $Order=>undef
 $BaseURL => undef
+$GenericQueryArgs => undef
 $Query => undef
 $Rows => undef
 $Page => undef
@@ -57,7 +58,7 @@
 <tr class="collection-as-table">
 <%perl>
 
-my %generic_query_args = ( Query => $Query, Rows => $Rows, Page => $Page, Format => $FormatString );
+my $generic_query_args = $GenericQueryArgs || { Query => $Query, Rows => $Rows, Page => $Page, Format => $FormatString };
 
 my $item = 0;
 foreach my $col (@Format) {
@@ -98,7 +99,7 @@
                 '<a href="' . $BaseURL
                   . $m->comp(
                     '/Elements/QueryString',
-                    %generic_query_args,
+                    %$generic_query_args,
                     OrderBy => (
                         $m->comp(
                             '/Elements/RT__Ticket/ColumnMap',
Index: rt-external/html/SelfService/Elements/MyRequests
diff -u rt-external/html/SelfService/Elements/MyRequests:1.4 rt-external/html/SelfService/Elements/MyRequests:1.5
--- rt-external/html/SelfService/Elements/MyRequests:1.4	Tue May 29 11:25:46 2007
+++ rt-external/html/SelfService/Elements/MyRequests	Wed May 30 12:32:26 2007
@@ -50,6 +50,8 @@
 			 Order   => $Order, 
 			 OrderBy => $OrderBy,
 			 BaseURL => $BaseURL,
+			 GenericQueryArgs => $GenericQueryArgs,
+			 AllowSorting => $AllowSorting,
 			 Page    => $Page &>
 </&>
 
@@ -69,8 +71,6 @@
    $Query .= "' )";
 }
 $Query .= ' ' . $extra_constraint if $extra_constraint;
-my $Order = "ASC";
-my $OrderBy = "Created";
 my @Format = qq{
    '<B><A HREF="$RT::WebPath/SelfService/Display.html?id=__id__">__id__</a></B>/TITLE:Ticket Reference',
    '<B><A HREF="$RT::WebPath/SelfService/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
@@ -119,5 +119,9 @@
 @status => ('open', 'new', 'stalled')
 $extra_constraint => undef
 $BaseURL => undef
+$GenericQueryArgs => undef
+$Order => "ASC"
+$OrderBy => "Created"
+$AllowSorting => undef
 $Page => 1
 </%ARGS>


More information about the Rt-devel mailing list