[Rt-commit] rt branch, 4.2/configurable-search-order, created. rt-4.2.3-169-gdbd76e3

Kevin Falcone falcone at bestpractical.com
Tue Apr 29 17:20:23 EDT 2014


The branch, 4.2/configurable-search-order has been created
        at  dbd76e394a37f9bc9b5ac2eada2b24338a0008b7 (commit)

- Log -----------------------------------------------------------------
commit dbd76e394a37f9bc9b5ac2eada2b24338a0008b7
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Apr 29 16:48:40 2014 -0400

    Allow global default search result sorts
    
    Users could define these from Logged in -> Settings -> Search options
    basically forever, but you couldn't set a global default.
    
    We keep the old hard-coded-default of id, ASC despite it being one of
    those "almost never what you want" since it means you always see your 5
    year old bugs first. Let admins give their users a saner sort
    (especially helpful on links in Quick Search).
    
    When setting your user search prefs or creating a new search from
    scratch, use the defaults rather than id/ASC.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index d01d1c7..f9b24be 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1310,6 +1310,23 @@ Set ($DefaultSearchResultFormat, qq{
    '<small>__LastUpdatedRelative__</small>',
    '<small>__TimeLeft__</small>'});
 
+=item C<$DefaultSearchResultOrderBy>
+
+What Tickets column should we order by for RT Ticket search results.
+
+=cut
+
+Set($DefaultSearchResultOrderBy, 'id');
+
+=item C<$DefaultSearchResultOrder>
+
+When ordering RT Ticket search results by C<$DefaultSearchResultOrderBy>,
+should the sort be ascending (ASC) or descending (DESC).
+
+=cut
+
+Set($DefaultSearchResultOrder, 'ASC');
+
 =item C<$DefaultSelfServiceSearchResultFormat>
 
 C<$DefaultSelfServiceSearchResultFormat> is the default format of
diff --git a/share/html/Prefs/SearchOptions.html b/share/html/Prefs/SearchOptions.html
index 422fc67..d0b5f37 100644
--- a/share/html/Prefs/SearchOptions.html
+++ b/share/html/Prefs/SearchOptions.html
@@ -86,8 +86,8 @@ if ($ARGS{'SavePreferences'}) {
 my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
 
 $Format      ||= $prefs->{'Format'};
-$Order       ||= ($prefs->{'Order'} || 'ASC');
-$OrderBy     ||= ($prefs->{'OrderBy'} || 'id');
+$Order       ||= ($prefs->{'Order'} || RT->Config->Get('DefaultSearchResultOrder'));
+$OrderBy     ||= ($prefs->{'OrderBy'} || RT->Config->Get('DefaultSearchResultOrderBy'));
 ($RowsPerPage =  defined( $prefs->{'RowsPerPage'} ) ? $prefs->{'RowsPerPage'}  : 50) unless defined ($RowsPerPage);
 
 my ( $AvailableColumns, $CurrentFormat );
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index c1b151b..da56f0c 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -140,7 +140,11 @@ if ( $NewQuery ) {
 
     my $current = $session{'CurrentSearchHash'};
     my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
-    my $default = { Query => '', Format => '', OrderBy => 'id', Order => 'ASC', RowsPerPage => 50 };
+    my $default = { Query => '',
+                    Format => '',
+                    OrderBy => RT->Config->Get('DefaultSearchResultOrderBy'),
+                    Order => RT->Config->Get('DefaultSearchResultOrder'),
+                    RowsPerPage => 50 };
 
     for( qw(Query Format OrderBy Order RowsPerPage) ) {
         $query{$_} = $current->{$_} unless defined $query{$_};
diff --git a/share/html/Search/Results.html b/share/html/Search/Results.html
index cd92649..a1876c5 100644
--- a/share/html/Search/Results.html
+++ b/share/html/Search/Results.html
@@ -98,8 +98,8 @@ my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {}
 # These variables are what define a search_hash; this is also
 # where we give sane defaults.
 $Format      ||= $prefs->{'Format'} || RT->Config->Get('DefaultSearchResultFormat');
-$Order       ||= $prefs->{'Order'} || 'ASC';
-$OrderBy     ||= $prefs->{'OrderBy'} || 'id';
+$Order       ||= $prefs->{'Order'} || RT->Config->Get('DefaultSearchResultOrder');
+$OrderBy     ||= $prefs->{'OrderBy'} || RT->Config->Get('DefaultSearchResultOrderBy');
 
 # Some forms pass in "RowsPerPage" rather than "Rows"
 # We call it RowsPerPage everywhere else.

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


More information about the rt-commit mailing list