[Rt-commit] rt branch 5.0/modify-query-builder-default-results2 created. rt-5.0.3-182-gaa91f168a5

BPS Git Server git at git.bestpractical.com
Fri Dec 9 18:55:29 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/modify-query-builder-default-results2 has been created
        at  aa91f168a502a68c1a201c27e197c8cb92e9d32e (commit)

- Log -----------------------------------------------------------------
commit aa91f168a502a68c1a201c27e197c8cb92e9d32e
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Dec 9 13:54:04 2022 -0500

    Add information about search preferences
    
    Also align the two boxes with search preferences.

diff --git a/share/html/Prefs/SearchOptions.html b/share/html/Prefs/SearchOptions.html
index 27f14b8fc8..25d2ed507e 100644
--- a/share/html/Prefs/SearchOptions.html
+++ b/share/html/Prefs/SearchOptions.html
@@ -48,9 +48,17 @@
 <& /Elements/Header, Title => loc("Search Preferences") &>
 <& /Elements/Tabs &>
 <& /Elements/ListActions, actions => \@actions &>
-
+<div class="help" id="rt-help-text">
+<&| /Widgets/TitleBox, title => loc('RT Configuration') &>
+<p>This page allows you to set personal configuration for searches. Settings saved here are loaded by default in the Query Builder for new searches.</p>
+% if ($session{'CurrentUser'}->UserObj->Preferences("SearchDisplay")) {
+<p>Personal settings are current saved for this account. Click below to remove these and restore system defaults.</p>
+% }
+</&>
+</div>
 <form method="post" action="SearchOptions.html">
 <input type="hidden" class="hidden" name="Format" value="<%$Format%>" />
+<div id="display-options" class="form-row">
     <& /Search/Elements/DisplayOptions, %ARGS, 
             Format=> $Format, 
             AvailableColumns => $AvailableColumns,  
@@ -58,6 +66,7 @@
             RowsPerPage => $RowsPerPage, 
             OrderBy => $OrderBy, 
             Order => $Order &>
+</div>
   <div class="form-row">
     <div class="col-12">
       <& /Elements/Submit, Name => 'SavePreferences', Label => loc('Save Changes') &>
diff --git a/share/html/Search/Elements/DisplayOptions b/share/html/Search/Elements/DisplayOptions
index 17cbfdda9e..63bc2f997a 100644
--- a/share/html/Search/Elements/DisplayOptions
+++ b/share/html/Search/Elements/DisplayOptions
@@ -46,13 +46,13 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <div class="col-xl-5">
-<&| /Widgets/TitleBox, title => loc("Sorting"), id => 'sorting' &>
+<&| /Widgets/TitleBox, title => loc("Sorting"), id => 'sorting', class => 'h-100' &>
 <& EditSort, %ARGS &>
 </&>
 </div>
 
 <div class="col-xl-7">
-<&| /Widgets/TitleBox, title => loc("Display Columns"), id => 'columns' &>
+<&| /Widgets/TitleBox, title => loc("Display Columns"), id => 'columns', class => 'h-100' &>
 <& EditFormat, %ARGS &>
 </&>
 </div>

commit 3c69433e77b2acd8260e09f9d6eb834d9c1746ce
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Dec 9 10:53:32 2022 -0500

    Use default rows per page for search preferences

diff --git a/share/html/Prefs/SearchOptions.html b/share/html/Prefs/SearchOptions.html
index 74a39e471e..27f14b8fc8 100644
--- a/share/html/Prefs/SearchOptions.html
+++ b/share/html/Prefs/SearchOptions.html
@@ -98,11 +98,13 @@ if ($Reset) {
 
 # Read from user preferences
 my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {};
+my $default_rows_per_page = RT->Config->Get('DefaultSearchResultRowsPerPage') || 50;
 
 $Format      ||= $prefs->{'Format'};
 $Order       ||= ($prefs->{'Order'} || RT->Config->Get('DefaultSearchResultOrder'));
 $OrderBy     ||= ($prefs->{'OrderBy'} || RT->Config->Get('DefaultSearchResultOrderBy'));
-($RowsPerPage =  defined( $prefs->{'RowsPerPage'} ) ? $prefs->{'RowsPerPage'}  : 50) unless defined ($RowsPerPage);
+($RowsPerPage =  defined( $prefs->{'RowsPerPage'} ) ? $prefs->{'RowsPerPage'}  : RT->Config->Get('DefaultSearchResultRowsPerPage'))
+    unless defined ($RowsPerPage);
 
 my ( $AvailableColumns, $CurrentFormat );
 ( $Format, $AvailableColumns, $CurrentFormat ) = $m->comp(

commit f106046192a925224fbf88899c82cf6d406ea0ed
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Fri Dec 2 09:37:17 2022 -0500

    Make search results per page configurable in RT UI

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index b659fbc291..cfa0a9e1c1 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -362,6 +362,27 @@ our %META;
             }
         },
     },
+    DefaultSearchResultRowsPerPage => {
+        Section         => 'General',                       #loc
+        Overridable     => 1,
+        Default         => 50,
+        SortOrder       => 9,
+        Widget          => '/Widgets/Form/Select',
+        WidgetArguments => {
+            Description => 'Default search result rows per page', #loc
+            Callback    => sub {
+                my @values = RT->Config->Get('SearchResultsPerPage');
+                my %labels = (
+                    0 => "Unlimited", # loc
+                    map { $_ => $_ } @values,
+                );
+
+                unshift @values, 0;
+
+                return { Values => \@values, ValuesLabel => \%labels };
+            },
+        },
+    },
     SearchResultsRefreshInterval => {
         Section         => 'General',                       #loc
         Overridable     => 1,

commit 8bda415515685e4812a33cfac74808ac00512e4e
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Mon Sep 26 13:30:44 2022 -0400

    Make # of search results per-page configurable
    
    On larger databases with many tickets and lots of custom roles,
    displaying a page of 50 search results may become slow. Adjusting the
    number of rows of search results per page can result in better
    performance in these cases.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index bd9c001d28..041b09bce2 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2241,7 +2241,7 @@ Set($SearchResultsRefreshInterval, 0);
 =item C<$DefaultSearchResultFormat>
 
 C<$DefaultSearchResultFormat> is the default format for RT search
-results
+results.
 
 =cut
 
@@ -2260,6 +2260,24 @@ Set ($DefaultSearchResultFormat, qq{
    '<small>__LastUpdatedRelative__</small>',
    '<small>__TimeLeft__</small>'});
 
+=item C<$DefaultSearchResultRowsPerPage>
+
+C<$DefaultSearchResultRowsPerPage> is the default rows per page for
+the dropdown on the Query Builder. The system default is 50, but
+setting to a smaller value can make search results render faster.
+
+=cut
+
+Set( $DefaultSearchResultRowsPerPage, 50 );
+
+=item C<@SearchResultsPerPage>
+
+Defines the options in the Rows per page dropdown on the query builder.
+The "Unlimited" option, which is 0, is included automatically.
+
+=cut
+
+Set(@SearchResultsPerPage, qw(10 25 50 100));
 
 =item C<$UserTicketDataResultFormat>
 
diff --git a/share/html/Elements/SelectResultsPerPage b/share/html/Elements/SelectResultsPerPage
index a1757df003..5d152f65e8 100644
--- a/share/html/Elements/SelectResultsPerPage
+++ b/share/html/Elements/SelectResultsPerPage
@@ -56,13 +56,15 @@
 </select>
 
 <%INIT>
-my @values = qw(0 10 25 50 100);
-my @labels = (loc('Unlimited'), qw(10 25 50 100));
-$Default = 50 unless defined $Default && $Default =~ /^\d+$/;
+my @values = RT->Config->Get('SearchResultsPerPage');
+my @labels = (loc('Unlimited'), @values);
+unshift @values, 0;
+unless ( defined $Default && $Default =~ /^\d+$/ ) {
+    RT->Logger->error("RowsPerPage value not a valid number, setting to default");
+    $Default = RT->Config->Get('DefaultSearchResultRowsPerPage') || '50';
+}
 </%INIT>
 <%ARGS>
-
 $Name => undef
-$Default => 50
-
+$Default => RT->Config->Get('DefaultSearchResultRowsPerPage') || '50'
 </%ARGS>
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 2f3be5f914..6a7f7e23d7 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -203,7 +203,7 @@ if ( $NewQuery ) {
         OrderBy => $orderby{$Class},
         Order => $order{$Class},
         ObjectType  => $ObjectType,
-        RowsPerPage => 50
+        RowsPerPage => RT->Config->Get('DefaultSearchResultRowsPerPage') || 50
     };
 
     for( qw(Query Format OrderBy Order RowsPerPage ObjectType) ) {
diff --git a/share/html/Search/Edit.html b/share/html/Search/Edit.html
index a46bfb737e..054fe7416a 100644
--- a/share/html/Search/Edit.html
+++ b/share/html/Search/Edit.html
@@ -109,7 +109,7 @@ $SavedSearchId => 'new'
 $SavedChartSearchId => 'new'
 $Query         => ''
 $Format        => ''
-$Rows          => '50'
+$Rows          => RT->Config->Get('DefaultSearchResultRowsPerPage') || '50'
 $Order         => 'ASC'
 $Class         => 'RT::Tickets'
 $OrderBy       => $Class eq 'RT::Assets' ? 'Name' : 'id'
diff --git a/share/html/Search/Elements/EditSearches b/share/html/Search/Elements/EditSearches
index 6871e702bb..d676a6cbc5 100644
--- a/share/html/Search/Elements/EditSearches
+++ b/share/html/Search/Elements/EditSearches
@@ -431,8 +431,9 @@ return @results;
 
 <%METHOD GetDependedOnByList>
 
+% my $rows_per_page = RT->Config->Get('DefaultSearchResultRowsPerPage') || 50;
 % my $links = $Object->DependedOnBy;
-% $links->RowsPerPage(50);
+% $links->RowsPerPage( $rows_per_page );
 % my $total = $links->CountAll;
   <p>
     <&|/l, $total &>This search is used in the following [quant,_1,dashboard,dashboards]</&>:
@@ -448,7 +449,7 @@ return @results;
     </li>
 % }
 
-% if ( $total > 50 ) {
+% if ( $total > $rows_per_page ) {
     <li class="list-group-item">...</li>
 % }
   </ul>
diff --git a/share/html/Search/Results.html b/share/html/Search/Results.html
index 768b2d5ef6..752b55133e 100644
--- a/share/html/Search/Results.html
+++ b/share/html/Search/Results.html
@@ -156,7 +156,7 @@ if ( !defined($Rows) ) {
     } elsif ( defined $prefs->{'RowsPerPage'} ) {
         $Rows = $prefs->{'RowsPerPage'};
     } else {
-        $Rows = 50;
+        $Rows = RT->Config->Get('DefaultSearchResultRowsPerPage') || 50;
     }
 }
 $Page = 1 unless $Page && $Page > 0;

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list