Commit 7a630ac1 authored by Kevin Falcone's avatar Kevin Falcone
Browse files

Add a QueryString to the top-level Search Results link.

We don't need it on Search/index.html for the "Build Search" link
because ProcessQuery will look in the search for us.

Because of all the groveling done here, the number of tests basically
trebles in t/walk-web.t.  This warrants more investigation.

Most of this code was borrowed from RT and included in a much larger
commit - 6076487.

Remove the unneeded comment and empty else clause (?).
parent 2d6eeb75
......@@ -54,16 +54,36 @@ my $query_string = sub {
return $u->query || '';
};
my $args = $m->request_args;
my $search_arguments = sub {
my %res = ();
my $caller_args = $m->caller_args(1);
my @query_fields = qw(Query Format RowsPerPage Page OrderBy Order);
if ( $caller_args->{'SearchArgs'} ) {
@res{ @query_fields } = @{ $caller_args->{'SearchArgs'} }{ @query_fields };
} else {
@res{ @query_fields } = @{ $args }{ @query_fields };
}
delete $res{$_} foreach grep !defined $res{$_}, keys %res;
return %res;
};
my $root = Menu->child( rtir => title => loc('RTIR'), path => '/RTIR/' );
my $search = $root->child( search => title => loc('Search'), path => '/RTIR/Search/' );
$search->child( new => title => loc('New Query'), path => '/RTIR/Search/?NewQuery=1' );
# XXX: query string
$search->child( build => title => loc('Build Search'), path => '/RTIR/Search/' );
if ( $session{'CurrentSearchHash'} ) {
$search->child( results => title => loc('Show Results'), path => '/RTIR/Search/Results.html' );
} else {
{
my $current_search = $session{"CurrentSearchHash"} || {};
my $has_query = 1 if ( $args->{'Query'} or $current_search->{'Query'} );
if ( $has_query ) {
$search->child( build => title => loc('Build Search'), path => '/RTIR/Search/' );
$search->child( results => title => loc('Show Results'),
path => '/RTIR/Search/Results.html?' .
$query_string->( $args->{'Query'} ? $search_arguments->() : %$current_search ) );
}
}
$root->child(
......@@ -108,22 +128,8 @@ my $request_path = $HTML::Mason::Commands::r->path_info;
$request_path =~ s!/{2,}!/!g;
return unless $request_path =~ m{^/RTIR/};
my $args = $m->request_args;
my $re_rtir_types = '(?:'. join( '|', map "\Q$_\E", RT::IR->Types ) .')';
my $search_arguments = sub {
my %res = ();
my $caller_args = $m->caller_args(1);
my @query_fields = qw(Query Format RowsPerPage Page OrderBy Order);
if ( $caller_args->{'SearchArgs'} ) {
@res{ @query_fields } = @{ $caller_args->{'SearchArgs'} }{ @query_fields };
} else {
@res{ @query_fields } = @{ $args }{ @query_fields };
}
delete $res{$_} foreach grep !defined $res{$_}, keys %res;
return %res;
};
if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|Advanced)\.html$} ) {
my $id = $args->{'id'};
......
......@@ -5,7 +5,7 @@ use warnings;
use HTML::TreeBuilder;
use RT::IR::Test tests => 486;
use RT::IR::Test tests => undef;
RT::Test->started_ok;
my $m = default_agent();
......@@ -51,3 +51,5 @@ sub test_page {
}
}
undef $m;
done_testing;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment