[Rt-commit] [svn] r922 - rt/branches/rt-3.1/html/Search

leira at pallas.eruditorum.org leira at pallas.eruditorum.org
Tue May 18 23:31:21 EDT 2004


Author: leira
Date: Tue May 18 23:31:21 2004
New Revision: 922

Modified:
   rt/branches/rt-3.1/html/Search/Build.html
Log:
Improvements to moving items in the query.

Make things into separate forms.


Modified: rt/branches/rt-3.1/html/Search/Build.html
==============================================================================
--- rt/branches/rt-3.1/html/Search/Build.html	(original)
+++ rt/branches/rt-3.1/html/Search/Build.html	Tue May 18 23:31:21 2004
@@ -29,16 +29,23 @@
     Query => $Query,
     Rows => $ARGS{'Rows'} &>
 
-<FORM METHOD="POST" ACTION="Build.html" NAME="BuildQuery">
-<input type=hidden name=Query value="<%$Query%>">
-<input type=hidden name=Format value="<%$Format%>">
 <table width=100%>
 <tr>
 <td valign=top>
+<FORM METHOD="POST" ACTION="Build.html" NAME="BuildQuery">
+<input type=hidden name=SearchId value="<%$ARGS{'SearchId'}%>">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
 <& Elements/PickCriteria, query => $Query, cfqueues => \%queues, %ARGS &>
 <& /Elements/Submit, Caption => "Add additional criteria", Label => loc('Add'), Name => 'AddClause'&>
+</form>
+
 </td>
 <td valign=top>
+<FORM METHOD="POST" ACTION="Build.html" NAME="NavigateQuery">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
+<input type=hidden name=SearchId value="<%$ARGS{'SearchId'}%>">
 <& /Elements/TitleBoxStart, title => loc("Query") . ": " .$search_hash->{'Description'} &>
 <& Elements/NewListActions, actions => \@actions &>
 <select size=10 name=clauses style="width : 100%">
@@ -53,18 +60,28 @@
 <br>
 <input type=submit name="Clear" value="Clear">
 <input type=submit name="Toggle" value="And/Or">
-%#<input type=submit name="EditQuery" value="Advanced">
+<input type=submit name="EditQuery" value="Advanced">
 </center>
 <& /Elements/TitleBoxEnd &>
+</form>
 <br>
+<FORM METHOD="POST" ACTION="Build.html" NAME="SavedSearch">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
 <& Elements/EditSearches, CurrentSearch => $search_hash &>
+</form>
 </td>
 </tr>
 <tr>
 <td colspan=2>
 
+<FORM METHOD="POST" ACTION="Build.html" NAME="EditFormat">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
+<input type=hidden name=SearchId value="<%$ARGS{'SearchId'}%>">
 <& Elements/DisplayOptions, Format=> ($Format||$search_hash->{'Format'}),
 AvailableColumns => $AvailableColumns,  CurrentFormat => $CurrentFormat, %ARGS &>
+</form>
 </td>
 </tr>
 </table>
@@ -471,6 +488,7 @@
     my $depth = 1;
     my $query = {};
     my %depths;
+    my %items;
 
     setvalue($query, "{0.0}", {});
     setvalue($query, "{0.0}{Subkey}", {});
@@ -498,6 +516,7 @@
     # as a keyword or value.
 
     my $num = 0;
+    $depths{1} = 0;
     while ( $string =~ /(
                       $re_aggreg
                       |$re_op
@@ -532,14 +551,9 @@
         # Parens are highest priority
         if ( $current & PAREN ) {
             if ( $val eq "(" ) {
-                if ( !( defined $depths{$depth} ) ) {
-                    $depths{$depth} = 0;
-                }
-                else {
-                    $depths{$depth}++;
-                }
-                $depth++;
                 $num = 0;
+                $depth++;
+		$depths{$depth} = 0;
 
                 my $hashkey;
                 my @keys;
@@ -568,10 +582,12 @@
                 $depth--;
                 $num = $depths{$depth} + 1;
             }
+
             $want = KEYWORD | PAREN | AGGREG;
         }
         elsif ( $current & AGGREG ) {
             $ea = $val;
+	    $depths{$depth}++ if ($last & PAREN);
 
             $want = KEYWORD | PAREN;
         }
@@ -619,15 +635,9 @@
         }
 
         if ( $current & VALUE ) {
-            if ( !( defined $depths{$depth} ) ) {
-                $depths{$depth} = 0;
-            }
-            else {
-                $depths{$depth}++;
-            }
+	    $depths{$depth}++;
 
             my $keystring = "";
-	    my $pd = $parentdepth;
             $keystring = "{Subkey}{" . $parentdepth . ".$num" . "}";
             $parentdepth--;
 
@@ -706,16 +716,18 @@
     my $hash = shift;
     my $key  = shift;
 
-    my $nextkey;
-    if ( subkeyexists( $hash, nextkey($key) ) ) {
-        $nextkey = appendkey( $hash, subkey( nextkey($key) ) );
+    my $newkey;
+
+    # if the next key exists, get the last key
+    my $nextkey = nextkey($key);
+    if ( subkeyexists( $hash, $nextkey ) ) {
+        $newkey = appendkey( $hash, subkey( $nextkey ) );
     }
     else {
-        my ( $prefix, $depth, $num ) = parsekey($key);
-        $nextkey = subkey($key);
+        $newkey = subkey($key);
     }
 
-    return $nextkey;
+    return $newkey;
 }
 
 sub prevkey {
@@ -889,8 +901,8 @@
     setvalue($hash, $newkey, \%temp);
 
     $$currentkey = $orignewkey;
-    reworkkeys( $hash, $origkey, $currentkey );
     reworkkeys( $hash, $orignewkey, $currentkey );
+    reworkkeys( $hash, $origkey, $currentkey );
 
     return 1;
 }
@@ -944,10 +956,13 @@
     my $newhash;
     if ($prefix) {
 	my $parentkey = parentkey($key);
-	my $parent = gethash($hash, $parentkey);
+
+	my $parent;
 	if (!gethash($hash, $parentkey)) {
 	    setvalue($hash, $parentkey, {});
 	    $parent = gethash($hash, $parentkey);
+	} else {
+	    $parent = gethash($hash, $parentkey);
 	}
 
 	if (!exists $parent->{Subkey}) {
@@ -959,6 +974,13 @@
     }
 
     $newhash->{$depth + ($num / 10)} = $value;
+
+    # if there isn't an aggregator, set it to AND
+    my $ea = getaggregator( $hash, $key);
+    if (!$ea) {
+	setaggregator( $hash, $key, 'AND' );
+    }
+
 }
 
 sub deletevalue {
@@ -1110,6 +1132,7 @@
 
 $session{'CurrentSearchHash'} = $search_hash;
 
+$ARGS{'SearchId'} =$search_hash->{'SearchId'};
 </%INIT>
 
 <%ARGS>


More information about the Rt-commit mailing list