[Rt-commit] [rtir] 04/08: Add a QueryString to the top-level Search Results link.
Kevin Falcone
falcone at bestpractical.com
Fri Jul 12 22:55:34 EDT 2013
This is an automated email from the git hooks/post-receive script.
falcone pushed a commit to branch 2.9/search-menus
in repository rtir.
commit 7a630ac171aa0d6c3c08f176f583ffa28a36daab
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Fri Jul 12 20:59:17 2013 -0400
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 (?).
---
html/Callbacks/RTIR/Elements/Tabs/Privileged | 44 ++++++++++++++++------------
t/walk-web.t | 4 ++-
2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 3ee4bb2..dbeeaa5 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -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'};
diff --git a/t/walk-web.t b/t/walk-web.t
index b594e15..d14ca3f 100644
--- a/t/walk-web.t
+++ b/t/walk-web.t
@@ -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;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Rt-commit
mailing list