[Rt-commit] rt branch, 4.4/allow-dashboard-sorting, created. rt-4.4.0-66-g076d8c5

Jim Brandt jbrandt at bestpractical.com
Wed Mar 16 06:52:30 EDT 2016


The branch, 4.4/allow-dashboard-sorting has been created
        at  076d8c5b451142bf4a9a0d96d498beb3ba9e2578 (commit)

- Log -----------------------------------------------------------------
commit 076d8c5b451142bf4a9a0d96d498beb3ba9e2578
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Mar 16 11:45:53 2016 +0100

    Allow sorting in dashboards for objects with a default order by
    
    The logic in /Elements/CollectionList checks for a default
    sort order in the object passed in unless you explicitly set
    AllowSorting. By default, dashboards rendering a saved search
    do not pass this. This is not be a problem for tickets
    as they don't have default search orders. However,
    other objects (like assets) default to sorting by Name,
    so the sort order from the saved search is ignored.
    
    Provide a way to give preference to a passed on OrderBy over
    the default object order by.

diff --git a/share/html/Elements/CollectionList b/share/html/Elements/CollectionList
index 5325b2e..fd8c6e6 100644
--- a/share/html/Elements/CollectionList
+++ b/share/html/Elements/CollectionList
@@ -70,7 +70,7 @@ if ( $Rows ) {
 
 # XXX: ->{'order_by'} is hacky, but there is no way to check if
 # collection is ordered or not
-if ( @OrderBy && ($AllowSorting || !$Collection->{'order_by'}) ) {
+if ( @OrderBy && ($AllowSorting || $PreferOrderBy || !$Collection->{'order_by'}) ) {
     if ( $OrderBy[0] =~ /\|/ ) {
         @OrderBy = split /\|/, $OrderBy[0];
         @Order = split /\|/,$Order[0];
@@ -203,7 +203,8 @@ $Title         => loc('Ticket Search')
 $BaseURL       => RT->Config->Get('WebPath') . $m->request_comp->path .'?'
 @PassArguments => qw( Query Format Rows Page Order OrderBy)
 
-$AllowSorting   => 0
+$AllowSorting   => 0  # Make headers in table links that will resort results
+$PreferOrderBy  => 0  # Prefer the passed-in @OrderBy to the collection default
 $ShowNavigation => 1
 $ShowHeader     => 1
 $ShowEmpty      => 0
diff --git a/share/html/Elements/ShowSearch b/share/html/Elements/ShowSearch
index c154bca..1483b4a 100644
--- a/share/html/Elements/ShowSearch
+++ b/share/html/Elements/ShowSearch
@@ -51,7 +51,7 @@
     titleright => $customize ? loc('Edit') : '',
     titleright_href => $customize,
     hideable => $hideable &>
-<& $query_display_component, hideable => $hideable, %$ProcessedSearchArg, ShowNavigation => 0, Class => 'RT::Tickets', HasResults => $HasResults &>
+<& $query_display_component, hideable => $hideable, %$ProcessedSearchArg, ShowNavigation => 0, Class => 'RT::Tickets', HasResults => $HasResults, PreferOrderBy => 1 &>
 </&>
 <%init>
 my $search;

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


More information about the rt-commit mailing list