[Rt-commit] r3048 - in rt/branches/3.4-RELEASE: . html/Search
lib/RT/Interface/Web/QueryBuilder
glasser at bestpractical.com
glasser at bestpractical.com
Wed Jun 1 18:36:41 EDT 2005
Author: glasser
Date: Wed Jun 1 18:36:40 2005
New Revision: 3048
Modified:
rt/branches/3.4-RELEASE/ (props changed)
rt/branches/3.4-RELEASE/html/Search/Build.html
rt/branches/3.4-RELEASE/lib/RT/Interface/Web/QueryBuilder/Tree.pm
Log:
r33109 at tin-foil: glasser | 2005-05-26 12:02:13 -0400
More docs and refactoring on QueryBuilder::Tree
Modified: rt/branches/3.4-RELEASE/html/Search/Build.html
==============================================================================
--- rt/branches/3.4-RELEASE/html/Search/Build.html (original)
+++ rt/branches/3.4-RELEASE/html/Search/Build.html Wed Jun 1 18:36:40 2005
@@ -247,7 +247,7 @@
$Query = "";
-my @options = get_displayed_nodes($tree);
+my @options = $tree->GetDisplayedNodes;
my @current_values = grep { defined } @options[@clauses];
@@ -466,21 +466,6 @@
-# This function returns an array ref of the nodes of the tree in depth-first
-# order which correspond to options in the "clauses" multi-select box.
-# In fact, it's all of them but the top-level ones.
-sub get_displayed_nodes {
- my $tree = shift;
- my @keys;
-
- $tree->traverse(sub {
- my $node = shift;
-
- push @keys, $node unless $node->getParent->isRoot;
- });
-
- return @keys;
-}
use Regexp::Common qw /delimited/;
Modified: rt/branches/3.4-RELEASE/lib/RT/Interface/Web/QueryBuilder/Tree.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Interface/Web/QueryBuilder/Tree.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Interface/Web/QueryBuilder/Tree.pm Wed Jun 1 18:36:40 2005
@@ -50,6 +50,17 @@
use base qw/Tree::Simple/;
+=head1 NAME
+
+ RT::Interface::Web::QueryBuilder::Tree - subclass of Tree::Simple used in Query Builder
+
+=head1 DESCRIPTION
+
+This class provides support functionality for the Query Builder (Search/Build.html).
+It is a subclass of L<Tree::Simple>.
+
+=head1 METHODS
+
=head2 TraversePrePost PREFUNC POSTFUNC
Traverses the tree depth-first. Before processing the node's children,
@@ -102,6 +113,19 @@
return $queues;
}
+=head2 GetQueryAndOptionList 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
+representing the "clauses" select option list. Each has contains the keys
+TEXT, INDEX, SELECTED, and DEPTH. TEXT is the displayed text of the option
+(including parentheses, not including indentation); INDEX is the 0-based
+index of the option in the list (also used as its CGI parameter); SELECTED
+is either 'SELECTED' or '', depending on whether the node corresponding
+to the select option was in the SELECTED_NODES list; and DEPTH is the
+level of indentation for the option.
+
+=cut
sub GetQueryAndOptionList {
my $self = shift;
@@ -158,10 +182,16 @@
return (join ' ', map { $_->{TEXT} } @$optionlist), $optionlist;
}
+=head2 PruneChildLessAggregators
+
+If tree manipulation has left it in a state where there are ANDs, ORs,
+or parenthesizations with no children, get rid of them.
+
+=cut
+
sub PruneChildlessAggregators {
my $self = shift;
-
$self->TraversePrePost(
sub {
},
@@ -185,6 +215,27 @@
);
}
+=head2 GetDisplayedNodes
+
+This function returns a list of the nodes of the tree in depth-first
+order which correspond to options in the "clauses" multi-select box.
+In fact, it's all of them but the root and its child.
+
+=cut
+
+sub GetDisplayedNodes {
+ my $self = shift;
+ my @lines;
+
+ $self->traverse(sub {
+ my $node = shift;
+
+ push @lines, $node unless $node->isRoot or $node->getParent->isRoot;
+ });
+
+ return @lines;
+}
+
eval "require RT::Interface::Web::QueryBuilder::Tree_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Interface/Web/QueryBuilder/Tree_Vendor.pm});
More information about the Rt-commit
mailing list