[Rt-commit] r3047 - 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:25 EDT 2005
Author: glasser
Date: Wed Jun 1 18:36:24 2005
New Revision: 3047
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:
r33108 at tin-foil: glasser | 2005-05-26 02:12:48 -0400
rt-ticket: 6568
rt-update: correspond
* Better fix to Query Builder; in addition to refactoring most of the code which got
information out of the tree, prune away childless AND/ORs, fixing the bug from ticket #6568.
Also get rid of the reaction to the "Clear" action, which I don't think exists, and which
I think is incorrect, since the root is supposed to have one child (see where it is
first created).
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:24 2005
@@ -449,9 +449,8 @@
push( @actions, [ loc("error: nothing to toggle"), -1 ] );
}
}
-elsif ( $ARGS{"Clear"} ) {
- $tree = RT::Interface::Web::QueryBuilder::Tree->new;
-}
+
+$tree->PruneChildlessAggregators;
# }}}
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:24 2005
@@ -158,6 +158,33 @@
return (join ' ', map { $_->{TEXT} } @$optionlist), $optionlist;
}
+sub PruneChildlessAggregators {
+ my $self = shift;
+
+
+ $self->TraversePrePost(
+ sub {
+ },
+ sub {
+ my $node = shift;
+
+ return if $node->isRoot or $node->getParent->isRoot;
+
+ # We're only looking for aggregators (AND/OR)
+ return if ref $node->getNodeValue;
+
+ return if $node->getChildCount != 0;
+
+ # OK, this is a childless aggregator. Remove self.
+
+ $node->getParent->removeChild($node);
+
+ # Deal with circular refs
+ $node->DESTROY;
+ }
+ );
+}
+
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