[Rt-commit] rt branch, 4.0/saved-search-context, updated. rt-4.0.1-209-g4bc4e38
Jason May
jasonmay at bestpractical.com
Mon Aug 8 18:08:22 EDT 2011
The branch, 4.0/saved-search-context has been updated
via 4bc4e389cebabbb06a41bf32bcdcf737c425694c (commit)
via ce8b404ccdc11f98f8f6ec9311f4a7cfdcd6c1ec (commit)
from 956de34b890c725798111ff3b75ff331e8717fe1 (commit)
Summary of changes:
share/html/Elements/Tabs | 85 ++++++++++++++++++-------------
share/html/Search/Chart.html | 7 ++-
share/html/Search/Elements/EditSearches | 2 +-
t/web/saved_search_chart.t | 6 ++-
4 files changed, 60 insertions(+), 40 deletions(-)
- Log -----------------------------------------------------------------
commit ce8b404ccdc11f98f8f6ec9311f4a7cfdcd6c1ec
Author: Jason May <jasonmay at bestpractical.com>
Date: Mon Aug 8 17:59:42 2011 -0400
Name the "Load Saved Search" button for more granular tests
diff --git a/share/html/Search/Elements/EditSearches b/share/html/Search/Elements/EditSearches
index 89d652d..ebea7bf 100644
--- a/share/html/Search/Elements/EditSearches
+++ b/share/html/Search/Elements/EditSearches
@@ -77,7 +77,7 @@
<hr />
<span class="label"><&|/l&>Load saved search</&>:</span>
<& SelectSearchesForObjects, Name => 'SavedSearchLoad', Objects => \@Objects, SearchType => $Type &>
-<input type="submit" value="<% loc('Load') %>" class="button" />
+<input type="submit" value="<% loc('Load') %>" id="SavedSearchLoadSubmit" name="SavedSearchLoadSubmit" class="button" />
</&>
</div>
diff --git a/t/web/saved_search_chart.t b/t/web/saved_search_chart.t
index a92b67f..f843071 100644
--- a/t/web/saved_search_chart.t
+++ b/t/web/saved_search_chart.t
@@ -131,16 +131,18 @@ sub page_chart_link_has {
# load the first chart
$m->field('SavedSearchLoad' => $saved_search_ids[0]);
-$m->submit;
+$m->click('SavedSearchLoadSubmit');
page_chart_link_has($m, $saved_search_ids[0]);
$m->form_name('SaveSearch');
is($m->form_number(3)->value('SavedChartSearchId'), $saved_search_ids[0]);
+$m->form_name('SaveSearch');
+
# now load the second chart
$m->field('SavedSearchLoad' => $saved_search_ids[1]);
-$m->submit;
+$m->click('SavedSearchLoadSubmit');
page_chart_link_has($m, $saved_search_ids[1]);
commit 4bc4e389cebabbb06a41bf32bcdcf737c425694c
Author: Jason May <jasonmay at bestpractical.com>
Date: Mon Aug 8 18:00:46 2011 -0400
Rework the saved search tab logic to allow gramular arg overrides
/Elements/Tabs provides a default of arguments for the query string
that gets tacked onto each tab link. Instead of throwing those defaults
away when passing a QueryString. This change lets you pass in QueryArgs
instead of QueryString if necessary. QueryArgs basically 'merges' into
the default query hash, gets, serialized, and appended to the links.
Some code outside of this logic (such as RSS links) was affected by this
change in an effort to refactor the query building.
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 0f30903..f41c60c 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -572,36 +572,48 @@ my $build_admin_menu = sub {
my $search_id = $m->request_args->{'SavedSearchLoad'} || $m->request_args->{'SavedSearchId'} || $current_search->{'SearchId'} || '';
my $chart_id = $m->request_args->{'SavedChartSearchId'} || $current_search->{SavedChartSearchId};
- if ($request_path =~ m{^/Search/Chart\.html}) {
- if ($m->request_args->{'SavedSearchLoadButton'}) {
- chart_id = $m->request_args->{'SavedSearchLoad'};
- }
- }
-
$has_query = 1 if ( $m->request_args->{'Query'} or $current_search->{'Query'} );
- my %query_args = (
- SavedSearchId => ( $search_id eq 'new' ) ? undef : $search_id,
- SavedChartSearchId => $chart_id,
- Query => $m->request_args->{'Query'} || $current_search->{'Query'},
- Format => $m->request_args->{'Format'} || $current_search->{'Format'},
- OrderBy => $m->request_args->{'OrderBy'} || $current_search->{'OrderBy'} ||'',
- Order => $m->request_args->{'Order'} || $current_search->{'Order'} ||'',
- Page => $m->request_args->{'Page'} || $current_search->{'Page'},
- RowsPerPage => ( defined $m->request_args->{'RowsPerPage'}
- ? $m->request_args->{'RowsPerPage'}
- : $current_search->{'RowsPerPage'})
- );
- for my $field (qw(Order OrderBy)) {
- if ( ref( $query_args{$field} ) eq 'ARRAY' ) {
- $query_args{$field} = join( "|", @{ $query_args{$field} } );
- } elsif (not defined $query_args{$field}) {
- delete $query_args{$field};
- }
+ my %query_args;
+ my %fallback_query_args = (
+ SavedSearchId => sub { ( $search_id eq 'new' ) ? undef : $search_id },
+ SavedChartSearchId => sub { $chart_id },
+ (
+ map {
+ $_ => sub { $m->request_args->{$_} || $current_search->{$_} }
+ } qw(Query Format OrderBy Order Page)
+ ),
+ RowsPerPage => sub {
+ defined $m->request_args->{'RowsPerPage'}
+ ? $m->request_args->{'RowsPerPage'}
+ : $current_search->{'RowsPerPage'}
+ },
+ );
+
+ if ($QueryString) {
+ $args = '?' . $QueryString;
}
+ else {
+ my %final_query_args = ();
+ # key => callback to avoid unnecessary work
- $args = "?" . ($QueryString || $query_string->(%query_args));
+ for my $param (keys %fallback_query_args) {
+ $final_query_args{$param} = $QueryArgs->{$param} || $fallback_query_args{$param}->();
+ }
+
+ for my $field (qw(Order OrderBy)) {
+ if ( ref( $final_query_args{$field} ) eq 'ARRAY' ) {
+ $final_query_args{$field} = join( "|", @{ $final_query_args{$field} } );
+ } elsif (not defined $final_query_args{$field}) {
+ delete $final_query_args{$field};
+ }
+ else {
+ $final_query_args{$field} ||= '';
+ }
+ }
+ $args = '?' . $query_string->(%final_query_args);
+ }
my $current_search_menu;
if ( $request_path =~ m{^/Ticket} ) {
@@ -629,23 +641,25 @@ my $build_admin_menu = sub {
spreadsheet => title => loc('Spreadsheet'),
path => "/Search/Results.tsv$args" );
+ my %rss_data = map { $_ => $QueryArgs->{$_} || $query_args{$_} || '' }
+ qw(Query Order OrderBy Rows);
my $RSSQueryString = "?"
- . $query_string->( Query => $query_args{Query},
- Order => $query_args{Order},
- OrderBy => $query_args{OrderBy}
+ . $query_string->( Query => $rss_data{Query},
+ Order => $rss_data{Order},
+ OrderBy => $rss_data{OrderBy}
);
my $RSSPath = join '/', map $m->interp->apply_escapes( $_, 'u' ),
$session{'CurrentUser'}->UserObj->Name,
$session{'CurrentUser'}
- ->UserObj->GenerateAuthString( $query_args{Query}
- . $query_args{Order}
- . $query_args{OrderBy} );
+ ->UserObj->GenerateAuthString( $rss_data{Query}
+ . $rss_data{Order}
+ . $rss_data{OrderBy} );
$more->child( rss => title => loc('RSS') => path => "/NoAuth/rss/$RSSPath/$RSSQueryString");
my $ical_path = join '/', map $m->interp->apply_escapes($_, 'u'),
$session{'CurrentUser'}->UserObj->Name,
- $session{'CurrentUser'}->UserObj->GenerateAuthString( $query_args{Query} ),
- $query_args{Query};
+ $session{'CurrentUser'}->UserObj->GenerateAuthString( $rss_data{Query} ),
+ $rss_data{Query};
$more->child( ical => title => loc('iCal') => path => '/NoAuth/iCal/'.$ical_path);
if ($request_path =~ m{^/Search/Results.html}
@@ -654,8 +668,8 @@ my $build_admin_menu = sub {
my $shred_args = $query_string->(
search => 1,
plugin => 'Tickets',
- 'Tickets:query' => $query_args{'Query'},
- 'Tickets:limit' => $query_args{'Rows'},
+ 'Tickets:query' => $rss_data{'Query'},
+ 'Tickets:limit' => $rss_data{'Rows'},
);
$more->child( 'shredder' => title => loc('Shredder'),
@@ -774,4 +788,5 @@ if ( $request_path !~ m{^/SelfService/} ) {
<%ARGS>
$show_menu => 1
$QueryString => ''
+$QueryArgs => {}
</%ARGS>
diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index b9413be..05de333 100644
--- a/share/html/Search/Chart.html
+++ b/share/html/Search/Chart.html
@@ -101,12 +101,15 @@ my %query;
$query{$_} = $m->request_args->{$_} unless defined $query{$_};
}
+ if ($m->request_args->{'SavedSearchLoadSubmit'}) {
+ $query{'SavedChartSearchId'} = $m->request_args->{'SavedSearchLoad'};
+ }
+
}
-my $QueryString = $m->comp('/Elements/QueryString', %query );
</%init>
<& /Elements/Header, Title => $title &>
-<& /Elements/Tabs, QueryString => $QueryString &>
+<& /Elements/Tabs, QueryArgs => \%query &>
<& /Elements/ListActions, actions => \@actions &>
<& /Search/Elements/Chart, %ARGS &>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list