Merge branch 'master' of https://github.com/jgoodman/Freeside
[freeside.git] / rt / share / html / Elements / CollectionList
index a57006e..44f7624 100644 (file)
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
@@ -51,7 +51,7 @@ if (!$Collection && $Class eq 'RT::Tickets') {
     $Collection->FromSQL($Query);
 }
 
-my $TotalFound = $Collection->CountAll();
+$TotalFound = $Collection->CountAll() unless defined $TotalFound;
 return '' if !$TotalFound && !$ShowEmpty;
 
 if ( $Rows ) {
@@ -71,6 +71,7 @@ if ( @OrderBy && ($AllowSorting || !$Collection->{'order_by'}) ) {
         @OrderBy = split /\|/, $OrderBy[0];
         @Order = split /\|/,$Order[0];
     }
+    @OrderBy = grep length, @OrderBy;
     $Collection->OrderByCols(
         map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } }
         ( 0 .. $#OrderBy )
@@ -105,13 +106,14 @@ foreach my $col (@Format) {
     }
 }
 
-$Class ||= ref $Collection;
-$Class =~ s/s$//;
-$Class =~ s/:/_/g;
+$Class ||= $Collection->ColumnMapClassName;
+if ($Class =~ /::/) { # older passed in value
+    $Class =~ s/s$//;
+    $Class =~ s/:/_/g;
+}
 
-$m->out('<table border="0" cellspacing="0" cellpadding="1"' . 
-       ' width="100%" class="' . 
-       ($Collection->isa('RT::Tickets') ? 'ticket-list' : 'collection') . '">');
+$m->out('<table cellspacing="0" class="' .
+       ($Collection->isa('RT::Tickets') ? 'ticket-list' : 'collection') . ' collection-as-table">');
 
 if ( $ShowHeader ) {
   $m->comp('/Elements/CollectionAsTable/Header',
@@ -133,7 +135,9 @@ if ( $ShowHeader ) {
 my ($i, $column_map) = (0, {});
 while ( my $record = $Collection->Next ) {
     # Every ten rows, flush the buffer and put something on the page.
-    $m->flush_buffer unless ++$i % 10;
+    #broken w/FS, causes rows to be output prematurely
+    #$m->flush_buffer unless ++$i % 10;
+    ++$i;
 
     my $warning = 0;
     my $Classes = '';
@@ -182,6 +186,7 @@ if ( $Rows && $ShowNavigation && $TotalFound > $Rows ) {
 <%ARGS>
 $Class         => ''
 $Collection    => undef
+$TotalFound    => undef
 $Format        => undef
 $DisplayFormat => undef
 @Order         => ()