Skip to content

Commit

Permalink
Don't add Unlimited automatically in Rows per page
Browse files Browse the repository at this point in the history
Adding Unlimited automatically prevented admins from
removing that option if desired. Update the option
to use the configuration as provided, updating the
label for 0 to Unlimited if present.
  • Loading branch information
cbrandtbuffalo committed Apr 19, 2024
1 parent 15fc2d1 commit 5ac852e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
12 changes: 12 additions & 0 deletions docs/UPGRADING-5.0
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,18 @@ compatible version of DBD::mysql.
If you install a newer version of DBD::mysql by mistake, you can uninstall it or
manually force install a version older than 5.001.

=item Unlimited Option in SearchResultsPerPage Configuration

RT 5.0.4 added C<@SearchResultsPerPage> as a configuration option to allow admins to
control the options presented in the "Rows per page" dropdown in the Query Builder.
When it was added, the "Unlimited" option was automatically added to the list of options
configured. This prevented admins from removing the "Unlimited" option from the
list, so this has been updated in RT 5.0.6 to use the configured options only with
no other options added automatically.

If you previously set a custom C<@SearchResultsPerPage> and you want to keep the
"Unlimited" option, update your configuration and add "0" to your list.

=back

=cut
4 changes: 2 additions & 2 deletions etc/RT_Config.pm.in
Original file line number Diff line number Diff line change
Expand Up @@ -2427,11 +2427,11 @@ 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.
Include "0" to provide the "Unlimited" option.

=cut

Set(@SearchResultsPerPage, qw(10 25 50 100));
Set(@SearchResultsPerPage, qw(0 10 25 50 100));

=item C<$UserTicketDataResultFormat>

Expand Down
5 changes: 3 additions & 2 deletions lib/RT/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2119,11 +2119,12 @@ our %META;
Callback => sub {
my @values = RT->Config->Get('SearchResultsPerPage');
my %labels = (
0 => "Unlimited", # loc
map { $_ => $_ } @values,
);

unshift @values, 0;
if ( exists $labels{'0'} ) {
$labels{'0'} = 'Unlimited';
}

return { Values => \@values, ValuesLabel => \%labels };
},
Expand Down
10 changes: 8 additions & 2 deletions share/html/Elements/SelectResultsPerPage
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@

<%INIT>
my @values = RT->Config->Get('SearchResultsPerPage');
my @labels = (loc('Unlimited'), @values);
unshift @values, 0;
my @labels = @values;

# Convert the label for 0 to 'Unlimited', if provided
for ( my $rows = 0; $rows < scalar(@values); $rows++ ) {
if ( $values[$rows] == 0 ) {
$labels[$rows] = loc('Unlimited');
}
}

$Default //= RT->Config->Get('DefaultSearchResultRowsPerPage') // 50;
unless ( $Default =~ /^\d+$/ ) {
Expand Down

0 comments on commit 5ac852e

Please sign in to comment.