[Rt-commit] r13066 - in rt/branches/3.8-TESTING: share/html/Elements
kyoki at bestpractical.com
kyoki at bestpractical.com
Mon Jun 9 15:22:14 EDT 2008
Author: kyoki
Date: Mon Jun 9 15:22:14 2008
New Revision: 13066
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/share/html/Elements/CollectionList
rt/branches/3.8-TESTING/share/html/Elements/TicketList
Log:
r22612 at nyx: kyoki | 2008-06-09 14:06:52 -0400
Final refactoring - TicketList now completely depends on CollectionList, which can replace it.
Modified: rt/branches/3.8-TESTING/share/html/Elements/CollectionList
==============================================================================
--- rt/branches/3.8-TESTING/share/html/Elements/CollectionList (original)
+++ rt/branches/3.8-TESTING/share/html/Elements/CollectionList Mon Jun 9 15:22:14 2008
@@ -46,6 +46,11 @@
%#
%# END BPS TAGGED BLOCK }}}
<%INIT>
+if (!$Collection && $Class eq 'RT::Tickets') {
+ $Collection = RT::Tickets->new( $session{'CurrentUser'} );
+ $Collection->FromSQL($Query);
+}
+
my $TotalFound = $Collection->CountAll();
return '' if !$TotalFound && !$ShowEmpty;
@@ -89,11 +94,13 @@
}
}
-my $Class = ref $Collection;
+$Class ||= ref $Collection;
$Class =~ s/s$//;
$Class =~ s/:/_/g;
-$m->out('<table border="0" cellspacing="0" cellpadding="1" width="100%" class="collection">') unless ($IsTicket);
+$m->out('<table border="0" cellspacing="0" cellpadding="1"' .
+ ' width="100%" class="' .
+ ($Collection->isa('RT::Tickets') ? 'ticket-list' : 'collection') . '>');
if ( $ShowHeader ) {
$m->comp('/Elements/CollectionAsTable/Header',
@@ -126,7 +133,6 @@
}
$m->out('</table>');
-
if ( $Rows && $ShowNavigation && $TotalFound > $Rows ) {
$m->out('<hr />');
my $oddRows = ($TotalFound && $TotalFound % $Rows == 0 )? 0 : 1;
@@ -149,6 +155,7 @@
</%INIT>
<%ARGS>
+$Class => ''
$Collection => undef
$Query => undef
$Format => undef
Modified: rt/branches/3.8-TESTING/share/html/Elements/TicketList
==============================================================================
--- rt/branches/3.8-TESTING/share/html/Elements/TicketList (original)
+++ rt/branches/3.8-TESTING/share/html/Elements/TicketList Mon Jun 9 15:22:14 2008
@@ -46,152 +46,11 @@
%#
%# END BPS TAGGED BLOCK }}}
<%INIT>
-# unless ($Collection) {
-# $Collection = RT::Tickets->new( $session{'CurrentUser'} );
-# $Collection->FromSQL($Query);
-# }
-
-# my $TotalFound = $Collection->CountAll();
-# return '' if !$TotalFound && !$ShowEmpty;
-
-# $Collection->RowsPerPage($Rows) if $Rows;
-# $Page = 1
-# unless $Page && $Page > 0; # workaround problems with Page = '' or undef
-# $Collection->GotoPage( $Page - 1 ); # SB uses page 0 as the first page
-
-%if ($Rows && $ShowNavigation) {
-<hr />
-<%PERL>
-my $oddRows = ($TotalFound && $TotalFound % $Rows == 0 )? 0 : 1;
-my $pages = int($TotalFound/$Rows)+$oddRows;
-$pages = 1 if $pages < 1;
-my @url_params = (Query => $Query,
- Format => $Format,
- Rows => $Rows,
- OrderBy => $OrderBy,
- Order => $Order);
-$m->comp( '/Elements/CollectionListPaging',
- BaseURL => $BaseURL,
- Rows => $Rows,
- TotalFound => $TotalFound,
- CurrentPage => $Page,
- Pages => $pages,
- URLParams => \@url_params);
-}
-</%PERL>
-<%INIT>
-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;
-$Page = 1
- unless $Page && $Page > 0; # workaround problems with Page = '' or undef
-$Collection->GotoPage( $Page - 1 ); # SB uses page 0 as the first page
-
-# DisplayFormat lets us use a "temporary" format for display, while
-# still using our original format for next/prev page links.
-# bulk update uses this feature to add checkboxes
-
-# $m->out('</table>');
-
-# 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 );
-
-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 ( $maxitems, $item ) = ( 0, 0 );
-foreach my $col (@Format) {
- $item++;
- if ( $col->{title} && ( $col->{title} eq 'NEWLINE' ) ) {
- $item = 0;
- }
- else {
- $maxitems = $item if $item > $maxitems;
- }
-}
-
-$m->out(
-'<table border="0" cellspacing="0" cellpadding="1" width="100%" class="ticket-list">'
-);
-
-if ($ShowHeader) {
- $m->comp(
- '/Elements/CollectionAsTable/Header',
- Format => \@Format,
- FormatString => $Format,
- AllowSorting => $AllowSorting,
- Order => $Order,
- Query => $Query,
- Rows => $Rows,
- Page => $Page,
- OrderBy => $OrderBy,
- BaseURL => $BaseURL,
- maxitems => $maxitems
- );
-}
-
-my ( $i, $column_map ) = ( 0, {} );
-while ( my $record = $Collection->Next ) {
- $i++;
-
- # Every ten rows, flush the buffer and put something on the page.
- $m->flush_buffer unless $i % 10;
- $m->comp(
- '/Elements/CollectionAsTable/Row',
- i => $i,
- Format => \@Format,
- record => $record,
- maxitems => $maxitems,
- ColumnMap => $column_map,
- );
-}
-
-$m->out('</table>');
-
-if ( $Rows && $ShowNavigation ) {
- $m->out('<hr />');
- my $oddRows = ( $TotalFound && $TotalFound % $Rows == 0 ) ? 0 : 1;
- my $pages = int( $TotalFound / $Rows ) + $oddRows;
- $pages = 1 if $pages < 1;
- my @url_params = (
- Query => $Query,
- Format => $Format,
- Rows => $Rows,
- OrderBy => $OrderBy,
- Order => $Order
- );
- $m->comp(
- '/Elements/CollectionListPaging',
- BaseURL => $BaseURL,
- Rows => $Rows,
- TotalFound => $TotalFound,
- CurrentPage => $Page,
- Pages => $pages,
- URLParams => \@url_params
- );
-}
-
+$m->comp(
+ '/Elements/CollectionList',
+ %ARGS,
+ Class => 'RT::Tickets'
+ );
</%INIT>
<%ARGS>
$Collection => undef
More information about the Rt-commit
mailing list