From 43a06151e47d2c59b833cbd8c26d97865ee850b6 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 7 Jun 2012 00:56:06 -0700 Subject: starting to work... --- rt/share/html/Search/Build.html | 86 ++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 39 deletions(-) (limited to 'rt/share/html/Search/Build.html') diff --git a/rt/share/html/Search/Build.html b/rt/share/html/Search/Build.html index 506384c4b..ae4c7ba78 100644 --- a/rt/share/html/Search/Build.html +++ b/rt/share/html/Search/Build.html @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -53,7 +53,7 @@ %# Build/Edit.html (Advanced).) %# %# After doing some stuff with default arguments and saved searches, the ParseQuery -%# function (which is similar to, but not the same as, _parser in RT/Tickets_Overlay_SQL) +%# function (which is similar to, but not the same as, _parser in lib/RT/Tickets_SQL.pm) %# converts the Query into a RT::Interface::Web::QueryBuilder::Tree. This mason file %# then adds stuff to or modifies the tree based on the actions that had been requested %# by clicking buttons. It then calls GetQueryAndOptionList on the tree to generate @@ -66,15 +66,9 @@ %# action does quote it (this breaks SQLite). %# <& /Elements/Header, Title => $title &> -<& /Ticket/Elements/Tabs, - current_tab => "Search/Build.html?".$QueryString, - Title => $title, - %query, - SavedSearchId => $saved_search{'Id'}, - SavedChartSearchId => $ARGS{SavedChartSearchId}, -&> +<& /Elements/Tabs, %TabArgs &> -
+ @@ -85,8 +79,8 @@
<& Elements/PickCriteria, query => $query{'Query'}, cfqueues => $queues &> -<& /Elements/Submit, Label => loc('Add these terms'), Name => 'AddClause'&> -<& /Elements/Submit, Label => loc('Add these terms and Search'), Name => 'DoSearch'&> +<& /Elements/Submit, Label => loc('Add these terms'), SubmitId => 'AddClause', Name => 'AddClause'&> +<& /Elements/Submit, Label => loc('Add these terms and Search'), SubmitId => 'DoSearch', Name => 'DoSearch'&>
@@ -108,8 +102,8 @@ AvailableColumns => $AvailableColumns, CurrentFormat => $CurrentFormat, &> -<& /Elements/Submit, Label => loc('Update format and Search'), Name => 'DoSearch', id=>"formatbuttons"&> +<& /Elements/Submit, Label => loc('Update format and Search'), Name => 'DoSearch', id=>"formatbuttons"&>
<%INIT> @@ -179,14 +173,22 @@ my $tree = $ParseQuery->( $query{'Query'}, \@parse_results ); # if parsing went poorly, send them to the edit page to fix it if ( @parse_results ) { - return $m->comp( "Edit.html", Query => $query{'Query'}, actions => \@actions ); + push @actions, @parse_results; + return $m->comp( + "Edit.html", + Query => $query{'Query'}, + Format => $query{'Format'}, + SavedSearchId => $saved_search{'Id'}, + SavedChartSearchId => $ARGS{'SavedChartSearchId'}, + actions => \@actions, + ); } my @options = $tree->GetDisplayedNodes; my @current_values = grep defined, @options[@clauses]; my @new_values = (); -# {{{ Try to find if we're adding a clause +# Try to find if we're adding a clause foreach my $arg ( keys %ARGS ) { next unless $arg =~ m/^ValueOf([\w\.]+|'CF.{.*?}')$/ && ( ref $ARGS{$arg} eq "ARRAY" @@ -226,14 +228,16 @@ foreach my $arg ( keys %ARGS ) { elsif ( $op eq '!=' ) { $op = "IS NOT"; } - - # This isn't "right", but... - # It has to be this way until #5182 is fixed - $value = "'NULL'"; } - else { - $value =~ s/'/\\'/g; - $value = "'$value'" unless $value =~ /^\d+$/; + elsif ($value =~ /\D/) { + $value =~ s/(['\\])/\\$1/g; + $value = "'$value'"; + } + + if ($keyword =~ /^'CF\.{(.*)}'/) { + my $cf = $1; + $cf =~ s/(['\\])/\\$1/g; + $keyword = "'CF.{$cf}'"; } my $clause = { @@ -246,7 +250,6 @@ foreach my $arg ( keys %ARGS ) { } } -# }}} push @actions, $m->comp('Elements/EditQuery:Process', %ARGS, @@ -255,7 +258,7 @@ push @actions, $m->comp('Elements/EditQuery:Process', New => \@new_values, ); -# {{{ Rebuild $Query based on the additions / movements +# Rebuild $Query based on the additions / movements my $optionlist_arrayref; ($query{'Query'}, $optionlist_arrayref) = $tree->GetQueryAndOptionList(\@current_values); @@ -264,11 +267,10 @@ my $optionlist = join "\n", map { qq() } @$optionlist_arrayref; -# }}} my $queues = $tree->GetReferencedQueues; -# {{{ Deal with format changes +# Deal with format changes my ( $AvailableColumns, $CurrentFormat ); ( $query{'Format'}, $AvailableColumns, $CurrentFormat ) = $m->comp( 'Elements/BuildFormatString', @@ -277,12 +279,17 @@ my ( $AvailableColumns, $CurrentFormat ); Format => $query{'Format'}, ); -# }}} # if we're asked to save the current search, save it push @actions, $m->comp( 'Elements/EditSearches:Save', %ARGS, Query => \%query, SavedSearch => \%saved_search); -# {{{ Push the updates into the session so we don't loose 'em +# Populate the "query" context with saved search data + +if ($ARGS{SavedSearchSave}) { + $query{'SavedSearchId'} = $saved_search{'Id'}; +} + +# Push the updates into the session so we don't lose 'em $session{'CurrentSearchHash'} = { %query, @@ -291,30 +298,31 @@ $session{'CurrentSearchHash'} = { Description => $saved_search{'Description'}, }; -# }}} -# {{{ Show the results, if we were asked. +# Show the results, if we were asked. if ( $ARGS{'DoSearch'} ) { - $m->comp( 'Results.html', %query, SavedChartSearchId => $ARGS{'SavedChartSearchId'}, ); - $m->comp( '/Elements/Footer' ); + my $redir_query_string = $m->comp( + '/Elements/QueryString', + %query, + SavedChartSearchId => $ARGS{'SavedChartSearchId'}, + SavedSearchId => $saved_search{'Id'}, + ); + RT::Interface::Web::Redirect(RT->Config->Get('WebPath') . '/Search/Results.html?' . $redir_query_string); $m->abort; } -# }}} -# {{{ Build a querystring for the tabs +# Build a querystring for the tabs -my $QueryString = ''; +my %TabArgs = (); if ($NewQuery) { - $QueryString = 'NewQuery=1'; + $TabArgs{QueryString} = 'NewQuery=1'; } elsif ( $query{'Query'} ) { - $QueryString = $m->comp('/Elements/QueryString', %query ); + $TabArgs{QueryArgs} = \%query; } -# }}} - <%ARGS> -- cgit v1.2.1 From c24d6e2242ae0e026684b8f95decf156aba6e75e Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 7 Jun 2012 16:55:45 -0700 Subject: rt 4.0.6 --- rt/share/html/Search/Build.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rt/share/html/Search/Build.html') diff --git a/rt/share/html/Search/Build.html b/rt/share/html/Search/Build.html index ae4c7ba78..b200f9050 100644 --- a/rt/share/html/Search/Build.html +++ b/rt/share/html/Search/Build.html @@ -78,7 +78,7 @@
- <& Elements/PickCriteria, query => $query{'Query'}, cfqueues => $queues &> + <& Elements/PickCriteria, query => $query{'Query'}, queues => $queues &> <& /Elements/Submit, Label => loc('Add these terms'), SubmitId => 'AddClause', Name => 'AddClause'&> <& /Elements/Submit, Label => loc('Add these terms and Search'), SubmitId => 'DoSearch', Name => 'DoSearch'&>
@@ -275,7 +275,7 @@ my ( $AvailableColumns, $CurrentFormat ); ( $query{'Format'}, $AvailableColumns, $CurrentFormat ) = $m->comp( 'Elements/BuildFormatString', %ARGS, - cfqueues => $queues, + queues => $queues, Format => $query{'Format'}, ); @@ -308,7 +308,7 @@ if ( $ARGS{'DoSearch'} ) { SavedChartSearchId => $ARGS{'SavedChartSearchId'}, SavedSearchId => $saved_search{'Id'}, ); - RT::Interface::Web::Redirect(RT->Config->Get('WebPath') . '/Search/Results.html?' . $redir_query_string); + RT::Interface::Web::Redirect(RT->Config->Get('WebURL') . 'Search/Results.html?' . $redir_query_string); $m->abort; } -- cgit v1.2.1