[Rt-commit] r4264 - in rt/branches/3.7-EXPERIMENTAL: . html/Elements

ruz at bestpractical.com ruz at bestpractical.com
Wed Dec 7 08:08:52 EST 2005


Author: ruz
Date: Wed Dec  7 08:08:51 2005
New Revision: 4264

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Elements/TicketList
Log:
 r1426 at cubic-pc:  cubic | 2005-12-07 16:06:30 +0300
 * ShowEmpty argument, if false and result set is empty then
   component returns without output.


Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/TicketList
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/TicketList	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/TicketList	Wed Dec  7 08:08:51 2005
@@ -102,7 +102,28 @@
 % }
 % }
 <%INIT>
-my $maxitems = 0;
+unless ($Collection) {
+        $Collection = RT::Tickets->new($session{'CurrentUser'});
+        $Collection->FromSQL($Query);
+}
+
+my $TotalFound =  $Collection->CountAll();
+return '' if !$TotalFound && !$ShowEmpty;
+
+if ($OrderBy =~ /\|/) {
+    # Multiple Sorts
+    my @OrderBy = split /\|/,$OrderBy;
+    my @Order = split /\|/,$Order;
+    $Collection->OrderByCols(
+        map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } }
+        ( 0 .. $#OrderBy )
+    );
+} else {
+    $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order); 
+}
+
+$Collection->RowsPerPage($Rows) if ($Rows);
+$Collection->GotoPage($Page-1); # SB uses page 0 as the first page
 
 $Format ||= $RT::DefaultSearchResultFormat;
 
@@ -110,23 +131,16 @@
 # still using our original format for next/prev page links.
 # bulk update uses this feature to add checkboxes
 
-
 $DisplayFormat ||= $Format;
 
 # Scrub the html of the format string to remove any potential nasties.
 $Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
 $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $DisplayFormat);
 
-
-unless ($Collection) {
-        $Collection = RT::Tickets->new($session{'CurrentUser'});
-        $Collection->FromSQL($Query);
-}
-
 my (@Format) = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
 
 # Find the maximum number of items in any row, so we can pad the table.
-my $item = 0;
+my ($maxitems, $item) = (0, 0);
 foreach my $col (@Format) {
     $item++;
     if ( $col->{title} eq 'NEWLINE' ) {
@@ -137,21 +151,6 @@
     }
 }
 
-if ($OrderBy =~ /\|/) {
-    # Multiple Sorts
-    my @OrderBy = split /\|/,$OrderBy;
-    my @Order = split /\|/,$Order;
-    $Collection->OrderByCols(
-        map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0
-        .. $#OrderBy ) );; 
-} else {
-    $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order); 
-}
-
-$Collection->RowsPerPage($Rows) if ($Rows);
-$Collection->GotoPage($Page-1); # SB uses page 0 as the first page
-my $TotalFound =  $Collection->CountAll();
-
 </%INIT>
 <%ARGS>
 $Query => undef
@@ -167,4 +166,5 @@
 $DisplayFormat => undef
 $ShowNavigation => 1
 $ShowHeader => 1
+$ShowEmpty => 0
 </%ARGS>


More information about the Rt-commit mailing list