[Rt-commit] rt branch, librarize-search-logic, updated. 6bdc6dbf90c25015ab5c60ec728de02f15eb97d4
jesse
jesse at bestpractical.com
Mon Nov 9 19:24:36 EST 2009
The branch, librarize-search-logic has been updated
via 6bdc6dbf90c25015ab5c60ec728de02f15eb97d4 (commit)
via f969806ad7e520ff5a019497911c79ed45a0da30 (commit)
via 88ffef1fc4b04eb5061cc05903a14d4526cf5681 (commit)
via 0f31ca72e6017a39f7a76ad1d1448c2ac3d43a36 (commit)
from b1befea01c969a08b6cc8dee572d0ebe6d27e21f (commit)
Summary of changes:
lib/RT/Interface/Web/QueryBuilder.pm | 4 +-
lib/RT/Interface/Web/QueryBuilder/Tree.pm | 4 +-
share/html/Search/Build.html | 78 +++++++++++------------------
share/html/SelfService/Display.html | 2 +-
share/html/Ticket/Update.html | 2 +-
5 files changed, 35 insertions(+), 55 deletions(-)
- Log -----------------------------------------------------------------
commit 88ffef1fc4b04eb5061cc05903a14d4526cf5681
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Nov 9 15:32:14 2009 -0500
15 more loc down.
diff --git a/lib/RT/Interface/Web/QueryBuilder.pm b/lib/RT/Interface/Web/QueryBuilder.pm
index 0618596..fed1532 100644
--- a/lib/RT/Interface/Web/QueryBuilder.pm
+++ b/lib/RT/Interface/Web/QueryBuilder.pm
@@ -52,8 +52,8 @@ sub process_query {
my $self = shift;
my $tree = shift;
my $selected = shift;
- my $new = shift || [];
+ my $new = $self->process_query_additions || [];
my @NewSelection = ();
my $ARGS = Jifty->web->request->arguments;
@@ -256,7 +256,7 @@ sub process_query_additions {
);
}
}
- return @new_values;
+ return \@new_values;
}
sub load_saved_search {
diff --git a/lib/RT/Interface/Web/QueryBuilder/Tree.pm b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
index 08330e3..2723340 100755
--- a/lib/RT/Interface/Web/QueryBuilder/Tree.pm
+++ b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
@@ -120,7 +120,7 @@ sub get_referenced_queues {
return $queues;
}
-=head2 get_query_and_option_list SELECTED_NODES
+=head2 get_query_option_list SELECTED_NODES
Given an array reference of tree nodes that have been selected by the user,
traverses the tree and returns the equivalent SQL query and a list of hashes
@@ -134,7 +134,7 @@ level of indentation for the option.
=cut
-sub get_query_and_option_list {
+sub get_query_option_list {
my $self = shift;
my $selected_nodes = shift;
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 9c39baf..d03dbe4 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -67,18 +67,18 @@
%#
<&| /_elements/wrapper, title => _("Query Builder") &>
<& /Ticket/Elements/Tabs,
- current_tab => "Search/Build.html?".$query_string,
+ current_tab => "Search/Build.html?".$querystring,
title => _("Query Builder"),
- %$query,
+ %$current_search,
saved_search_id => $saved_search->{'id'},
&>
<form method="post" action="Build.html" name="build_query">
<input type="hidden" class="hidden" name="saved_search_id" value="<% $saved_search->{'id'} || '' %>" />
-<input type="hidden" class="hidden" name="query" value="<% $query->{'query'} || '' %>" />
-<input type="hidden" class="hidden" name="format" value="<% $query->{'format'} || '' %>" />
+<input type="hidden" class="hidden" name="query" value="<% $current_search->{'query'} || '' %>" />
+<input type="hidden" class="hidden" name="format" value="<% $current_search->{'format'} || '' %>" />
<div id="pick-criteria">
- <& Elements/PickCriteria, query => $query->{'query'}, queues => $queues &>
+ <& Elements/PickCriteria, query => $current_search->{'query'}, queues => $queues &>
</div>
<& /Elements/Submit, label => _('Add these terms'), name => 'add_clause'&>
<& /Elements/Submit, label => _('Add these terms and Search'), name => 'do_search'&>
@@ -91,11 +91,11 @@
&>
</div>
<div id="editsearches">
- <& Elements/EditSearches, %$saved_search, current_search => $query &>
+ <& Elements/EditSearches, %$saved_search, current_search => $current_search &>
</div>
<span id="display-options">
<& Elements/DisplayOptions,
- %ARGS, %$query,
+ %ARGS, %$current_search,
available_columns => $available_columns,
current_format => $current_format,
&>
@@ -105,65 +105,50 @@
</&>
<%INIT>
-my ( $saved_search, $query, $results ) = RT::Interface::Web::QueryBuilder->setup_query();
+my $querystring = '';
+my @clauses = ();
-my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
+my ( $saved_search, $current_search, $results ) = RT::Interface::Web::QueryBuilder->setup_query();
-push @$results, $tree->parse_sql( query => $query->{query} );
-my @options = $tree->get_displayed_nodes;
-my @current_values = grep defined, @options[@clauses];
+my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
+push @$results, $tree->parse_sql( query => $current_search->{query} );
-my @new_values = RT::Interface::Web::QueryBuilder->process_query_additions();
+my $current_values = [ ( $tree->get_displayed_nodes() )[@clauses] ];
-push @$results, RT::Interface::Web::QueryBuilder->process_query( $tree, \@current_values, \@new_values, );
+push @$results, RT::Interface::Web::QueryBuilder->process_query( $tree, $current_values );
-# Rebuild $Query based on the additions / movements
-my ( $new_serialized_query, $parsed_query ) = $tree->get_query_and_option_list( \@current_values );
-$query->{'query'} = $new_serialized_query;
+my $queues = $tree->get_referenced_queues;
+my $parsed_query = $tree->get_query_option_list($current_values);
-my $queues = $tree->get_referenced_queues;
+$current_search->{'query'} = join ' ', map $_->{'TEXT'}, @$parsed_query;
# Deal with format changes
-my ( $new_format, $available_columns, $current_format ) = RT::Interface::Web::QueryBuilder->build_format_string(
+my ( $available_columns, $current_format );
+ ( $current_search->{'format'}, $available_columns, $current_format )
+ = RT::Interface::Web::QueryBuilder->build_format_string(
%{ Jifty->web->request->arguments },
queues => $queues,
- format => $query->{'format'}
-);
-
-$query->{'format'} = $new_format;
+ format => $current_search->{'format'}
+ );
# if we're asked to save the current search, save it
-if ( Jifty->web->request->argument('saved_search_save') || Jifty->web->request->argument('saved_search_copy') ) {
- push @$results, RT::Interface::Web::QueryBuilder->save_search( $query, $saved_search );
-}
+push @$results, RT::Interface::Web::QueryBuilder->save_search( $current_search, $saved_search )
+ if ( Jifty->web->request->argument('saved_search_save') || Jifty->web->request->argument('saved_search_copy') );
# Push the updates into the session so we don't lose 'em
-
-Jifty->web->session->set(
- 'CurrentSearchHash',
- { %$query,
- search_id => $saved_search->{'id'},
- object => $saved_search->{'object'},
- description => $saved_search->{'description'},
- }
-);
-
-# Show the results, if we were asked.
-my $query_string = '';
+Jifty->web->session->set( 'CurrentSearchHash', { %$saved_search, %$current_search, } );
# Build a query_string for the tabs
if ( Jifty->web->request->argument('new_query') ) {
- $query_string = 'new_query=1';
-} elsif ( $query->{'query'} ) {
- $query_string = RT::Interface::Web->format_query_params(%$query);
+ $querystring = 'new_query=1';
+} elsif ( $current_search->{'query'} ) {
+ $querystring = RT::Interface::Web->format_query_params(%$current_search);
}
-if ( Jifty->web->request->argument('do_search') ) {
- Jifty->web->redirect( Jifty->web->url . "Search/Results.html?" . $query_string );
-}
+Jifty->web->redirect( Jifty->web->url . "Search/Results.html?" . $querystring )
+ if ( Jifty->web->request->argument('do_search') );
</%INIT>
<%ARGS>
- at clauses => ()
</%ARGS>
commit f969806ad7e520ff5a019497911c79ed45a0da30
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Nov 9 19:09:10 2009 -0500
make it not explode
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index d03dbe4..f7f2bca 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -104,10 +104,7 @@
</form>
</&>
<%INIT>
-
my $querystring = '';
-my @clauses = ();
-
my ( $saved_search, $current_search, $results ) = RT::Interface::Web::QueryBuilder->setup_query();
my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
@@ -151,4 +148,5 @@ Jifty->web->redirect( Jifty->web->url . "Search/Results.html?" . $querystring )
</%INIT>
<%ARGS>
+ at clauses => ()
</%ARGS>
commit 6bdc6dbf90c25015ab5c60ec728de02f15eb97d4
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Nov 9 19:24:15 2009 -0500
unraveling the mysteries of "selected_clauses"
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index f7f2bca..127d795 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -105,12 +105,13 @@
</&>
<%INIT>
my $querystring = '';
+my $selected_clauses = Jifty->web->request->argument('clauses');
my ( $saved_search, $current_search, $results ) = RT::Interface::Web::QueryBuilder->setup_query();
my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
push @$results, $tree->parse_sql( query => $current_search->{query} );
-my $current_values = [ ( $tree->get_displayed_nodes() )[@clauses] ];
+my $current_values = [ ( $tree->get_displayed_nodes() )[ref $selected_clauses ? @$selected_clauses : $selected_clauses] ];
push @$results, RT::Interface::Web::QueryBuilder->process_query( $tree, $current_values );
@@ -146,7 +147,3 @@ Jifty->web->redirect( Jifty->web->url . "Search/Results.html?" . $querystring )
if ( Jifty->web->request->argument('do_search') );
</%INIT>
-
-<%ARGS>
- at clauses => ()
-</%ARGS>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list