[Rt-commit] rt branch, 5.0/customize-search, created. rt-5.0.0alpha1-83-ge3ee2c67b5
? sunnavy
sunnavy at bestpractical.com
Tue Apr 7 18:51:20 EDT 2020
The branch, 5.0/customize-search has been created
at e3ee2c67b5c3c1693439e02a5dfd617107a5992b (commit)
- Log -----------------------------------------------------------------
commit 8f55beddff4d73029b4760cee0389004322be4ab
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Apr 3 16:36:49 2020 +0800
Add ShowSearchAdvanced/ShowSearchBulkUpdate rights
Sometimes we want to hide the 2 advanced and powerful search pages from
users, and it's quite straightforward to achieve that using rights.
We still show the 2 pages by default, for initial usability and also
back compatibility.
diff --git a/etc/initialdata b/etc/initialdata
index 74951a5b85..d428d5c472 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -840,6 +840,14 @@ Hour: { $SubscriptionObj->SubValue('Hour') }
GroupType => 'privileged',
Right => 'ShowApprovalsTab', },
+ { GroupDomain => 'SystemInternal',
+ GroupType => 'Privileged',
+ Right => 'ShowSearchAdvanced',
+ },
+ { GroupDomain => 'SystemInternal',
+ GroupType => 'Privileged',
+ Right => 'ShowSearchBulkUpdate',
+ },
);
# Predefined searches
diff --git a/etc/upgrade/4.5.5/content b/etc/upgrade/4.5.5/content
new file mode 100644
index 0000000000..92d0386f96
--- /dev/null
+++ b/etc/upgrade/4.5.5/content
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+our @ACL = (
+ { GroupDomain => 'SystemInternal',
+ GroupType => 'Privileged',
+ Right => 'ShowSearchAdvanced',
+ },
+ { GroupDomain => 'SystemInternal',
+ GroupType => 'Privileged',
+ Right => 'ShowSearchBulkUpdate',
+ },
+);
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index d9f7f6944b..630292056f 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -555,8 +555,9 @@ sub BuildMainNav {
$current_search_menu->child( edit_search =>
title => loc('Edit Search'), path => "/Search/Build.html" . ( ($has_query) ? $args : '' ) );
- $current_search_menu->child( advanced =>
- title => loc('Advanced'), path => "/Search/Edit.html$args" );
+ if ( $current_user->HasRight( Right => 'ShowSearchAdvanced', Object => RT->System ) ) {
+ $current_search_menu->child( advanced => title => loc('Advanced'), path => "/Search/Edit.html$args" );
+ }
$current_search_menu->child( custom_date_ranges =>
title => loc('Custom Date Ranges'), path => "/Search/CustomDateRanges.html" ) if $class eq 'RT::Tickets';
if ($has_query) {
@@ -565,7 +566,9 @@ sub BuildMainNav {
if ( $has_query ) {
if ( $class eq 'RT::Tickets' ) {
- $current_search_menu->child( bulk => title => loc('Bulk Update'), path => "/Search/Bulk.html$args" );
+ if ( $current_user->HasRight( Right => 'ShowSearchBulkUpdate', Object => RT->System ) ) {
+ $current_search_menu->child( bulk => title => loc('Bulk Update'), path => "/Search/Bulk.html$args" );
+ }
$current_search_menu->child( chart => title => loc('Chart'), path => "/Search/Chart.html$args" );
}
diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index e7b761eda1..e32cb4688d 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -94,6 +94,8 @@ __PACKAGE__->AddRight( General => LoadSavedSearch => 'Allow loading of saved
__PACKAGE__->AddRight( General => CreateSavedSearch => 'Allow creation of saved searches'); # loc
__PACKAGE__->AddRight( Admin => ExecuteCode => 'Allow writing Perl code in templates, scrips, etc'); # loc
__PACKAGE__->AddRight( General => SeeSelfServiceGroupTicket => 'See tickets for other group members in SelfService' ); # loc
+__PACKAGE__->AddRight( Staff => ShowSearchAdvanced => 'Show search "Advanced" menu' ); # loc
+__PACKAGE__->AddRight( Staff => ShowSearchBulkUpdate => 'Show search "Bulk Update" menu' ); # loc
=head2 AvailableRights
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index 884d8a328e..e7cfedf9f3 100644
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -379,6 +379,8 @@ $cfs->SetContextObject( values %$seen_queues ) if keys %$seen_queues == 1;
</div>
<%INIT>
+Abort( loc("Permission Denied") ) unless $session{CurrentUser}->HasRight( Right => 'ShowSearchBulkUpdate', Object => RT->System );
+
my (@results);
$m->callback(CallbackName => 'Initial', ARGSRef => \%ARGS, results_ref => \@results, QueryRef => \$Query, UpdateTicketRef => \@UpdateTicket);
diff --git a/share/html/Search/Edit.html b/share/html/Search/Edit.html
index 308af2295b..fb1724a6ac 100644
--- a/share/html/Search/Edit.html
+++ b/share/html/Search/Edit.html
@@ -70,6 +70,8 @@
</form>
<%INIT>
+Abort( loc("Permission Denied") ) unless $session{CurrentUser}->HasRight( Right => 'ShowSearchAdvanced', Object => RT->System );
+
my $title;
if ( $Class eq 'RT::Transactions' ) {
$title = loc('Edit Transaction Query');
commit acf73a7473e8673d3edb3805a76f6110d73618da
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Apr 5 16:57:57 2020 +0800
Show ticket shredder link on all ticket search pages
Previously we only showed it on search results page, which was a bit
inconvenient, especially considering that people can preview ticket list
on shredder page before shredding.
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 630292056f..79574eecd3 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -597,11 +597,8 @@ sub BuildMainNav {
$rss_data{Query};
$more->child( ical => title => loc('iCal'), path => '/NoAuth/iCal/' . $ical_path );
- if ($request_path =~ m{^/Search/Results.html}
- && #XXX TODO better abstraction
- $current_user->HasRight( Right => 'SuperUser', Object => RT->System )
- )
- {
+ #XXX TODO better abstraction of SuperUser right check
+ if ( $current_user->HasRight( Right => 'SuperUser', Object => RT->System ) ) {
my $shred_args = QueryString(
Search => 1,
Plugin => 'Tickets',
commit db09e0b2fadbc5b85ca7527dc8c0ebdb89e5d51b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Apr 8 03:50:49 2020 +0800
Support to filter lifecycle in ticket search builder
diff --git a/share/html/Elements/SelectLifecycle b/share/html/Elements/SelectLifecycle
new file mode 100644
index 0000000000..b9f3329496
--- /dev/null
+++ b/share/html/Elements/SelectLifecycle
@@ -0,0 +1,64 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<select name="<% $Name %>" class="selectpicker form-control">
+% if ( $DefaultValue ) {
+ <option value="" <% $Default ? '' : qq[selected="selected"] |n %>><% $DefaultLabel %></option>
+% }
+% for my $lifecycle ( sort { loc $a cmp loc $b } @Lifecycles ) {
+% my $selected = defined $Default && $lifecycle eq $Default ? 'selected="selected"' : '';
+ <option value="<% $lifecycle %>" <% $selected |n %>><% $lifecycle %></option>
+% }
+</select>
+
+<%ARGS>
+$Name => ''
+$Default => ''
+$DefaultValue => 1
+$DefaultLabel => '-'
+ at Lifecycles => RT::Lifecycle->List
+</%ARGS>
diff --git a/share/html/Search/Elements/PickBasics b/share/html/Search/Elements/PickBasics
index e9d43aca52..e75b71f65e 100644
--- a/share/html/Search/Elements/PickBasics
+++ b/share/html/Search/Elements/PickBasics
@@ -255,6 +255,19 @@ else {
Arguments => { NamedValues => 1, },
},
},
+ {
+ Name => 'Lifecycle',
+ Field => loc('Lifecycle'),
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectBoolean',
+ Arguments => { TrueVal=> '=', FalseVal => '!=' },
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectLifecycle',
+ },
+ },
{
Name => 'Status',
Field => loc('Status'),
commit 9323c566483ddf78ccec608b15778edd742490b1
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Apr 3 04:49:45 2020 +0800
Add BeforeDisplay callback to search builder page
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 1240dd8faa..9b8d767e28 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -352,6 +352,7 @@ elsif ( $query{'Query'} ) {
$TabArgs{QueryArgs} = \%query;
}
+$m->callback( ARGSRef => \%ARGS, Query => \%query, CallbackName => 'BeforeDisplay' );
</%INIT>
<%ARGS>
commit fdc8e48d12dfe3e2ef8c7fb0e369fb800e9cb54e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jun 5 04:15:56 2018 +0800
Add ExtraQueryParams parameter to search pages
With this, users can add extra parameters to search pages easily. e.g.
to render customized search builder for RTIR searches, we can pass:
ExtraQueryParams => 'RTIR', RTIR => 1
Then both parameters will be kept during page navigation and also form
submission.
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 79574eecd3..5c372f2b52 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -497,6 +497,7 @@ sub BuildMainNav {
$has_query = 1 if ( $HTML::Mason::Commands::DECODED_ARGS->{'Query'} or $current_search->{'Query'} );
my %query_args;
+ my $extra_query_params = $HTML::Mason::Commands::DECODED_ARGS->{ExtraQueryParams};
my %fallback_query_args = (
SavedSearchId => ( $search_id eq 'new' ) ? undef : $search_id,
SavedChartSearchId => $chart_id,
@@ -504,7 +505,7 @@ sub BuildMainNav {
map {
my $p = $_;
$p => $HTML::Mason::Commands::DECODED_ARGS->{$p} || $current_search->{$p}
- } qw(Query Format OrderBy Order Page Class ObjectType)
+ } qw(Query Format OrderBy Order Page Class ObjectType ExtraQueryParams), ( $extra_query_params ? ( ref $extra_query_params eq 'ARRAY' ? @$extra_query_params : $extra_query_params ) : () )
),
RowsPerPage => (
defined $HTML::Mason::Commands::DECODED_ARGS->{'RowsPerPage'}
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 9b8d767e28..b63da9eb79 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -75,8 +75,14 @@
<input type="hidden" class="hidden" name="Format" value="<% $query{'Format'} %>" />
<input type="hidden" class="hidden" name="ObjectType" value="<% $query{'ObjectType'} %>" />
<input type="hidden" class="hidden" name="Class" value="<% $Class %>" />
-
-
+% if ( $query{ExtraQueryParams} ) {
+% for my $input ( ref $query{ExtraQueryParams} eq 'ARRAY' ? @{$query{ExtraQueryParams}} : $query{ExtraQueryParams} ) {
+<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
+% if ( defined $query{$input} ) {
+<input type="hidden" class="hidden" name="<% $input %>" value="<% $query{$input} %>" />
+% }
+% }
+% }
<div class="row">
<div class="col-xl-7">
@@ -134,7 +140,7 @@ else {
}
my %query;
-for( qw(Query Format OrderBy Order RowsPerPage Class ObjectType) ) {
+for( qw(Query Format OrderBy Order RowsPerPage Class ObjectType ExtraQueryParams), @ExtraQueryParams ) {
$query{$_} = $ARGS{$_} if defined $ARGS{$_};
}
@@ -155,7 +161,7 @@ if ( $NewQuery ) {
# Wipe all data-carrying variables clear if we want a new
# search, or we're deleting an old one..
- %query = ();
+ %query = map { $_ => $ARGS{$_} } grep { defined $ARGS{$_} } 'ExtraQueryParams', @ExtraQueryParams;
%saved_search = ( Id => 'new' );
# ..then wipe the session out..
@@ -360,4 +366,5 @@ $NewQuery => 0
@clauses => ()
$Class => 'RT::Tickets'
$ObjectType => 'RT::Ticket'
+ at ExtraQueryParams => ()
</%ARGS>
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index e7cfedf9f3..3f2c8912c4 100644
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -53,6 +53,14 @@
% foreach my $var (qw(Query Format OrderBy Order Rows Page SavedSearchId SavedChartSearchId Token)) {
<input type="hidden" class="hidden" name="<%$var%>" value="<%$ARGS{$var} || ''%>" />
%}
+
+% for my $input ( @ExtraQueryParams ) {
+<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
+% if ( defined $ARGS{$input} ) {
+<input type="hidden" class="hidden" name="<% $input %>" value="<% $ARGS{$input} %>" />
+% }
+% }
+
<& /Elements/CollectionList,
Query => $Query,
DisplayFormat => $DisplayFormat,
@@ -518,4 +526,5 @@ $Order => 'ASC'
$OrderBy => 'id'
$Query => undef
@UpdateTicket => ()
+ at ExtraQueryParams => ()
</%args>
diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index 5ee8ceb275..fd7e63d872 100644
--- a/share/html/Search/Chart.html
+++ b/share/html/Search/Chart.html
@@ -57,7 +57,7 @@ $m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
my $title = loc( "Grouped search results");
-my @search_fields = qw(Query GroupBy ChartStyle ChartFunction Width Height);
+my @search_fields = ( qw(Query GroupBy ChartStyle ChartFunction Width Height ExtraQueryParams), @ExtraQueryParams );
my $saved_search = $m->comp( '/Widgets/SavedSearch:new',
SearchType => 'Chart',
SearchFields => [@search_fields],
@@ -76,6 +76,14 @@ my %query;
foreach my $search_field (@{ $saved_search->{'SearchFields'} }) {
$query{$search_field} = $saved_search->{'CurrentSearch'}->{'Object'}->Content->{$search_field};
}
+
+ my $content = $saved_search->{'CurrentSearch'}->{'Object'}->Content;
+ if ( my $extra_params = $content->{ExtraQueryParams} ) {
+ $query{ExtraQueryParams} = $extra_params;
+ for my $param ( ref $extra_params eq 'ARRAY' ? @$extra_params : $extra_params ) {
+ $query{$param} = $content->{$param};
+ }
+ }
}
my $current = $session{'CurrentSearchHash'};
@@ -140,6 +148,15 @@ $m->callback( ARGSRef => \%ARGS, QueryArgsRef => \%query );
<input type="hidden" class="hidden" name="Query" value="<% $query{Query} %>" />
<input type="hidden" class="hidden" name="SavedChartSearchId" value="<% $saved_search->{SearchId} || 'new' %>" />
+% if ( $query{ExtraQueryParams} ) {
+% for my $input ( ref $query{ExtraQueryParams} eq 'ARRAY' ? @{$query{ExtraQueryParams}} : $query{ExtraQueryParams} ) {
+<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
+% if ( defined $query{$input} ) {
+<input type="hidden" class="hidden" name="<% $input %>" value="<% $query{$input} %>" />
+% }
+% }
+% }
+
<&| /Widgets/TitleBox, title => loc('Group by'), class => "chart-group-by" &>
<fieldset><legend><% loc('Group tickets by') %></legend>
<& Elements/SelectGroupBy,
@@ -261,3 +278,7 @@ jQuery(".chart-picture [name=ChartStyleIncludeSQL]").change( updateChartStyle );
</div>
</div>
+
+<%ARGS>
+ at ExtraQueryParams => ()
+</%ARGS>
diff --git a/share/html/Search/Edit.html b/share/html/Search/Edit.html
index fb1724a6ac..afaa6d8b89 100644
--- a/share/html/Search/Edit.html
+++ b/share/html/Search/Edit.html
@@ -55,6 +55,12 @@
<input type="hidden" class="hidden" name="SavedChartSearchId" value="<% $SavedChartSearchId %>" />
<input type="hidden" class="hidden" name="Class" value="<% $Class %>" />
<input type="hidden" class="hidden" name="ObjectType" value="<% $ObjectType %>" />
+% for my $input ( @ExtraQueryParams ) {
+<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
+% if ( defined $ARGS{$input} ) {
+<input type="hidden" class="hidden" name="<% $input %>" value="<% $ARGS{$input} %>" />
+% }
+% }
<&|/Widgets/TitleBox, title => loc('Query'), &>
<textarea class="form-control" name="Query" rows="8" cols="72"><% $Query %></textarea>
@@ -104,4 +110,5 @@ $Class => 'RT::Tickets'
$ObjectType => 'RT::Ticket'
@actions => ()
+ at ExtraQueryParams => ()
</%ARGS>
diff --git a/share/html/Search/Elements/EditSearches b/share/html/Search/Elements/EditSearches
index 3750212e16..24dbc4247f 100644
--- a/share/html/Search/Elements/EditSearches
+++ b/share/html/Search/Elements/EditSearches
@@ -116,7 +116,7 @@ my $is_dirty = sub {
my %arg = (
Query => {},
SavedSearch => {},
- SearchFields => [qw(Query Format OrderBy Order RowsPerPage ObjectType)],
+ SearchFields => [qw(Query Format OrderBy Order RowsPerPage ObjectType ExtraQueryParams), @ExtraQueryParams],
@_
);
@@ -149,12 +149,14 @@ $CurrentSearch => {}
@SearchFields => ()
$AllowCopy => 1
$Title => loc('Saved searches')
+ at ExtraQueryParams => ()
</%ARGS>
<%METHOD Init>
<%ARGS>
$Query => {}
$SavedSearch => {}
+ at ExtraQueryParams => ()
@SearchFields => qw(Query Format OrderBy Order RowsPerPage ObjectType)
$Class => 'RT::Tickets'
$Type => $Class eq 'RT::Transactions' ? 'Transaction' : 'Ticket'
@@ -183,6 +185,13 @@ if ( $ARGS{'SavedSearchLoad'} ) {
$SavedSearch->{'Description'} = $search->Description;
$Query->{$_} = $search->SubValue($_) foreach @SearchFields;
+ if ( my $extra_params = $search->SubValue('ExtraQueryParams') ) {
+ $Query->{ExtraQueryParams} = $extra_params;
+ for my $param ( ref $extra_params eq 'ARRAY' ? @$extra_params : $extra_params ) {
+ $Query->{$param} = $search->SubValue($param);
+ }
+ }
+
if ( $ARGS{'SavedSearchRevert'} ) {
push @results, loc('Loaded original "[_1]" saved search', $SavedSearch->{'Description'} );
} else {
@@ -242,7 +251,8 @@ return @results;
<%ARGS>
$Query => {}
$SavedSearch => {}
- at SearchFields => qw(Query Format OrderBy Order RowsPerPage ObjectType)
+ at ExtraQueryParams => ()
+ at SearchFields => ( qw(Query Format OrderBy Order RowsPerPage ObjectType ExtraQueryParams), @ExtraQueryParams )
</%ARGS>
<%INIT>
@@ -254,7 +264,7 @@ my $id = $SavedSearch->{'Id'};
my $desc = $SavedSearch->{'Description'};
my $privacy = $SavedSearch->{'Privacy'};
-my %params = map { $_ => $Query->{$_} } @SearchFields;
+my %params = map { $_ => $Query->{$_} } grep { defined $Query->{$_} } @SearchFields;
my ($new_obj_type, $new_obj_id) = split(/\-/, ($privacy || ''));
if ( $obj && $obj->id ) {
diff --git a/share/html/Search/Results.html b/share/html/Search/Results.html
index 863c761eb5..a620591ba4 100644
--- a/share/html/Search/Results.html
+++ b/share/html/Search/Results.html
@@ -75,7 +75,8 @@
SavedSearchId => $ARGS{'SavedSearchId'},
SavedChartSearchId => $ARGS{'SavedChartSearchId'},
ObjectType => $ObjectType,
- PassArguments => [qw(Query Format Rows Page Order OrderBy SavedSearchId SavedChartSearchId Class ObjectType)],
+ @ExtraQueryParams ? ( map { $_ => $ARGS{$_} } grep { defined $ARGS{$_} } 'ExtraQueryParams', @ExtraQueryParams ) : (),
+ PassArguments => [qw(Query Format Rows Page Order OrderBy SavedSearchId SavedChartSearchId Class ObjectType ExtraQueryParams), @ExtraQueryParams],
&>
% }
% $m->callback( ARGSRef => \%ARGS, CallbackName => 'AfterResults' );
@@ -86,6 +87,14 @@
% foreach my $key (keys(%hiddens)) {
<input type="hidden" class="hidden" name="<%$key%>" value="<% defined($hiddens{$key})?$hiddens{$key}:'' %>" />
% }
+
+% for my $input ( @ExtraQueryParams ) {
+<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
+% if ( defined $ARGS{$input} ) {
+<input type="hidden" class="hidden" name="<% $input %>" value="<% $ARGS{$input} %>" />
+% }
+% }
+
<div class="form-row">
<div class="col-auto">
<& /Elements/Refresh, Name => 'TicketsRefreshInterval', Default => $session{$interval_name}||RT->Config->Get('SearchResultsRefreshInterval', $session{'CurrentUser'}) &>
@@ -277,4 +286,5 @@ $SavedSearchId => undef
$SavedChartSearchId => undef
$Class => 'RT::Tickets'
$ObjectType => 'RT::Ticket'
+ at ExtraQueryParams => ()
</%ARGS>
commit e3ee2c67b5c3c1693439e02a5dfd617107a5992b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Apr 7 03:05:38 2020 +0800
Add ResultPage parameter to redirect to customized search result page
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 5c372f2b52..17e5c56a52 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -505,7 +505,7 @@ sub BuildMainNav {
map {
my $p = $_;
$p => $HTML::Mason::Commands::DECODED_ARGS->{$p} || $current_search->{$p}
- } qw(Query Format OrderBy Order Page Class ObjectType ExtraQueryParams), ( $extra_query_params ? ( ref $extra_query_params eq 'ARRAY' ? @$extra_query_params : $extra_query_params ) : () )
+ } qw(Query Format OrderBy Order Page Class ObjectType ResultPage ExtraQueryParams), ( $extra_query_params ? ( ref $extra_query_params eq 'ARRAY' ? @$extra_query_params : $extra_query_params ) : () )
),
RowsPerPage => (
defined $HTML::Mason::Commands::DECODED_ARGS->{'RowsPerPage'}
@@ -562,7 +562,13 @@ sub BuildMainNav {
$current_search_menu->child( custom_date_ranges =>
title => loc('Custom Date Ranges'), path => "/Search/CustomDateRanges.html" ) if $class eq 'RT::Tickets';
if ($has_query) {
- $current_search_menu->child( results => title => loc('Show Results'), path => "/Search/Results.html$args" );
+ my $result_page = $HTML::Mason::Commands::DECODED_ARGS->{ResultPage};
+ if ( my $web_path = RT->Config->Get('WebPath') ) {
+ $result_page =~ s!^$web_path!!;
+ }
+
+ $result_page ||= '/Search/Results.html';
+ $current_search_menu->child( results => title => loc('Show Results'), path => "$result_page$args" );
}
if ( $has_query ) {
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index b63da9eb79..c7ad3f0ef6 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -75,6 +75,9 @@
<input type="hidden" class="hidden" name="Format" value="<% $query{'Format'} %>" />
<input type="hidden" class="hidden" name="ObjectType" value="<% $query{'ObjectType'} %>" />
<input type="hidden" class="hidden" name="Class" value="<% $Class %>" />
+% if ( $ResultPage ) {
+<input type="hidden" class="hidden" name="ResultPage" value="<% $ResultPage %>" />
+% }
% if ( $query{ExtraQueryParams} ) {
% for my $input ( ref $query{ExtraQueryParams} eq 'ARRAY' ? @{$query{ExtraQueryParams}} : $query{ExtraQueryParams} ) {
<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
@@ -339,7 +342,7 @@ if ( $ARGS{'DoSearch'} ) {
SavedChartSearchId => $ARGS{'SavedChartSearchId'},
SavedSearchId => $saved_search{'Id'},
);
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL') . 'Search/Results.html?' . $redir_query_string);
+ RT::Interface::Web::Redirect("$ResultPage?$redir_query_string");
$m->abort;
}
@@ -367,4 +370,5 @@ $NewQuery => 0
$Class => 'RT::Tickets'
$ObjectType => 'RT::Ticket'
@ExtraQueryParams => ()
+$ResultPage => RT->Config->Get('WebPath') . '/Search/Results.html'
</%ARGS>
diff --git a/share/html/Search/Edit.html b/share/html/Search/Edit.html
index afaa6d8b89..d3ca398616 100644
--- a/share/html/Search/Edit.html
+++ b/share/html/Search/Edit.html
@@ -55,6 +55,9 @@
<input type="hidden" class="hidden" name="SavedChartSearchId" value="<% $SavedChartSearchId %>" />
<input type="hidden" class="hidden" name="Class" value="<% $Class %>" />
<input type="hidden" class="hidden" name="ObjectType" value="<% $ObjectType %>" />
+% if ( $ResultPage ) {
+<input type="hidden" class="hidden" name="ResultPage" value="<% $ResultPage %>" />
+% }
% for my $input ( @ExtraQueryParams ) {
<input type="hidden" class="hidden" name="ExtraQueryParams" value="<% $input %>" />
% if ( defined $ARGS{$input} ) {
@@ -111,4 +114,5 @@ $ObjectType => 'RT::Ticket'
@actions => ()
@ExtraQueryParams => ()
+$ResultPage => RT->Config->Get('WebPath') . '/Search/Results.html'
</%ARGS>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list