[Rt-commit] r2208 - in RT-View-Tree: . html/Search

jesse at bestpractical.com jesse at bestpractical.com
Thu Feb 10 13:56:10 EST 2005


Author: jesse
Date: Thu Feb 10 13:56:09 2005
New Revision: 2208

Modified:
   RT-View-Tree/   (props changed)
   RT-View-Tree/html/Search/Tree.html
Log:
 r2298 at hualien (orig r296):  jesse | 2004-09-08T21:56:59.300977Z
  ----------------------------------------------------------------------
  r10217 at tinbook:  jesse | 2004-09-08T21:46:33.136489Z
  part way through..
  ----------------------------------------------------------------------
 


Modified: RT-View-Tree/html/Search/Tree.html
==============================================================================
--- RT-View-Tree/html/Search/Tree.html	(original)
+++ RT-View-Tree/html/Search/Tree.html	Thu Feb 10 13:56:09 2005
@@ -23,14 +23,8 @@
 
 
 
-foreach my $ticket (values %$top_tickets ) {
-    $m->comp( '.entry', Ticket => $ticket, Depth => 0, Format => \@Format,
-    MaxDepth => $MaxDepth,
-    HideChildren => $HideChildren,
-    HideDependencies => $HideDependencies,
-    OrderBy => $OrderBy,
-    Order   => $Order
-    );
+foreach my ($ticket, $kids)  (@tree) {
+    $m->comp( '.entry', Ticket => $ticket, Depth => 0, Format => \@Format, Children => $kids);
 
 }
 
@@ -124,27 +118,75 @@
     $top_tickets->{ $ticket->id } = $ticket;
 }
 
-# for each ticket found by our search, check to see if it depends on any
-# others. if so, discard it
+
+my @tree;
+
 foreach my $ticket (@tickets) {
     next unless exists $top_tickets->{ $ticket->id };
+    my $kids = build_subtree(
+        Ticket           => $ticket,
+        TopTickets       => $top_tickets,
+        Depth            => 0,
+        MaxDepth         => $MaxDepth,
+        HideChildren     => $HideChildren,
+        HideDependencies => $HideDependencies
+    );
+
+    push @tree, [ $ticket, $kids ];
+
+}
+
+# Ok. Let's build up our tree of tickets, recursing down.
+sub build_subtree {
+    my %args = (  Ticket => undef,
+                  TopTickets => undef,
+                  HideChildren => undef,
+                  HideDependencies => undef,
+                  Depth => undef,
+                  MaxDepth => undef,
+                  @_);
+
+
+    my $ticket = $args{'Ticket'};
+    my $top_tickets = $args{'TopTickets'};
+
+
     my $deps = RT::Tickets->new( $session{'CurrentUser'} );
     my @query;
-    unless ($HideDependencies) {
+
+    my @tickets;
+
+    unless ($args{'HideDependencies'}) {
         push @query, 'DependentOn = '.$ticket->id;
     }
-    unless ($HideChildren) {
+    unless ($args{'HideChildren'}) {
         push @query, 'MemberOf = '.$ticket->id;
 
     }
     $deps->FromSQL( join(' OR ', @query));
+    $kids->OrderBy( FIELD => $args{'OrderBy'} , ORDER => $args{'Order'});
     while ( my $dep = $deps->Next ) {
-
         # Discard
         delete $top_tickets->{ $dep->id };
+        my $kids = undef;
+      $kids = build_subtree(
+        Ticket           => $dep,
+        TopTickets       => $top_tickets,
+        Depth            => $Depth+1,
+        MaxDepth         => $MaxDepth,
+        HideChildren     => $HideChildren,
+        HideDependencies => $HideDependencies
+    );
+        unless ($args{'Depth'} >$args{'MaxDepth'});
+        push @tickets, [$dep,$kids];
+
     }
+
+    return (\@tickets);
 }
 
+# for each ticket found by our search, check to see if it depends on any
+# others. if so, discard it
 
 </%init>
 <%DEF .entry>


More information about the Rt-commit mailing list