[Rt-commit] r4292 - in RT-View-Directory: . html/Search
html/View-Directory html/View-Directory/Elements
html/View-Directory/Ticket
jesse at bestpractical.com
jesse at bestpractical.com
Mon Dec 12 16:12:20 EST 2005
Author: jesse
Date: Mon Dec 12 16:12:20 2005
New Revision: 4292
Removed:
RT-View-Directory/html/Search/
Modified:
RT-View-Directory/ (props changed)
RT-View-Directory/html/View-Directory/Elements/ListAttachments
RT-View-Directory/html/View-Directory/Ticket/File
RT-View-Directory/html/View-Directory/Ticket/dhandler
RT-View-Directory/html/View-Directory/dhandler
Log:
r19961 at truegrounds: jesse | 2005-12-12 16:06:27 -0500
* Functionality works
Modified: RT-View-Directory/html/View-Directory/Elements/ListAttachments
==============================================================================
--- RT-View-Directory/html/View-Directory/Elements/ListAttachments (original)
+++ RT-View-Directory/html/View-Directory/Elements/ListAttachments Mon Dec 12 16:12:20 2005
@@ -1,11 +1,17 @@
<%args>
+$Query => undef
$OrderBy => 'id'
$Order => 'asc'
$Ticket => undef
$Filename => undef
+$OrderAttachmentsBy => undef
+$AttachmentOrder => undef
</%args>
<%init>
+my $default_args = join(';', "Order=$Order", "OrderBy=$OrderBy", "Query=$Query");
+
+
#A default implementation here loops through all transactions and pulls out all their attachments.
# We end up doing an end-run around that to get a bit more performance
@@ -41,26 +47,52 @@
$attachments->Limit( FIELD => 'Filename', VALUE => $Filename) if ($Filename);
-my %documents;
+my @documents;
while ( my $attach = $attachments->Next() ) {
next unless ( $attach->Filename() );
- unshift( @{ $documents{ $attach->Filename } }, $attach );
+
+ unshift( @documents , $attach );
}
+
+my @headers = qw(Created Creator Size);
+if (not $Filename) {
+ unshift @headers, 'Filename';
+}
+
+ if ($OrderAttachmentsBy eq 'Creator') {
+ @documents = sort { $a->CreatorObj->Name cmp $b->CreatorObj->Name } @documents;
+ }
+ elsif ($OrderAttachmentsBy eq 'Created') {
+ @documents = sort { $a->CreatedObj->Unix <=> $b->CreatedObj->Unix } @documents;
+ }
+ elsif ($OrderAttachmentsBy eq 'Size') {
+ @documents = sort { $a->ContentLength <=> $b->ContentLength } @documents;
+ }
+ elsif ($OrderAttachmentsBy eq 'Filename') {
+ @documents = sort { $a->Filename <=> $b->Filename } @documents;
+ }
+
+ if ($AttachmentOrder eq 'DESC') {
+ @documents = reverse @documents;
+ }
+
</%init>
-% foreach my $key (keys %documents) {
-<table width="100%">
+
+
+<table width="100%" cellspacing="0">
<tr>
-% if (not $Filename) {
-<th>Filename</th>
+% my $filename ='';
+% $filename = "/File/$Filename" if ($Filename);
+% foreach my $header (@headers) {
+% my $header_args = $default_args .';'.join(';', "OrderAttachmentsBy=$header", "AttachmentOrder=".($AttachmentOrder eq 'ASC' ? 'DESC' :'ASC'));
+<th><a href="<%$RT::WebPath%>/View-Directory/Ticket/<%$Ticket->id%><%$filename%>?<%$header_args|n%>"><%$header%></a></th>
% }
-<th>Created</th>
-<th>Creator</th>
-<th>Size</th>
</tr>
-% foreach my $rev (@{$documents{$key}}) {
-
+%my $i = 0;
+% foreach my $rev (@documents) {
+% $i++;
<%PERL>
my $size = $rev->ContentLength;
@@ -69,18 +101,17 @@
else { $size = $size ."b"; }
}
</%PERL>
-<tr>
+<tr class="<%$i%2 ? 'oddline' : 'evenline' |n%>">
% if (not $Filename) {
-<td><%$key%><a href="<%$Ticket->id%>/File/<%$key%>">(Show only this file)</a></td>
+ <td><%$rev->Filename%><a href="<%$Ticket->id%>/File/<%$rev->Filename%>?<%$default_args|n%>">(Show only this file)</a></td>
% }
<td>
<%$rev->CreatedAsString%>
-<a href="<%$RT::WebPath%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | u%>">
+<a href="<%$RT::WebPath%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | u%>?<%$default_args|n%>">
(Download this version)</a></td>
<td><%$rev->CreatorObj->Name%></td>
<td><%$size%></td>
</td>
% }
-% }
</table>
Modified: RT-View-Directory/html/View-Directory/Ticket/File
==============================================================================
--- RT-View-Directory/html/View-Directory/Ticket/File (original)
+++ RT-View-Directory/html/View-Directory/Ticket/File Mon Dec 12 16:12:20 2005
@@ -1,16 +1,17 @@
<%args>
$id => undef
$Filename => undef
-$QueryString => undef
</%args>
<%init>
my $Ticket = RT::Ticket->new($session{'CurrentUser'});
$Ticket->Load($id);
+my $title =loc("[_1] for ticket [_2]: [_3]", $Filename, $Ticket->id, $Ticket->Subject);
+
+my $QueryString = join(';', map { "$_=".$ARGS{$_}} keys %ARGS );
+
</%init>
-<& /Elements/Header, Title => loc("Ticket [_1]: [_2]", $Ticket->id, $Ticket->Subject) &>
-<& /Elements/Tabs&>
-<h2><&|/l, $Ticket->id, $Ticket->Subject, $Filename&>Ticket [_1]: [_3]</&></h2>
-<hr/>
+<& /Elements/Header, Title => $title &>
+<& /Elements/Tabs, Title => $title &>
<a href="<%$RT::WebPath%>/View-Directory/Ticket/<%$Ticket->id%>?<%$QueryString%>">Show all attachments</a>
-<& ../Elements/ListAttachments, Ticket => $Ticket, Filename => $Filename &>
+<& ../Elements/ListAttachments, %ARGS, Ticket => $Ticket, Filename => $Filename &>
Modified: RT-View-Directory/html/View-Directory/Ticket/dhandler
==============================================================================
--- RT-View-Directory/html/View-Directory/Ticket/dhandler (original)
+++ RT-View-Directory/html/View-Directory/Ticket/dhandler Mon Dec 12 16:12:20 2005
@@ -1,19 +1,32 @@
+<%args>
+$Query => undef
+$Order => 'ASC'
+$OrderBy => 'id'
+$OrderAttachmentsBy => 'id'
+$AttachmentOrder => 'ASC'
+</%args>
<%init>
my $id = $m->dhandler_arg;
if ($id =~ '^(\d+)/File/(.*?)$') {
- $m->comp('File', id => $1, Filename => $2);
+ $m->comp('File', %ARGS, id => $1, Filename => $2);
return();
}
my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
$Ticket->Load($id);
+
+my $QueryString = join(';', "Query=$Query", "Order=$Order","OrderBy=$OrderBy");
+
+my $title = loc("All attachments for ticket [_1]: [_2]", $Ticket->id, $Ticket->Subject);
</%init>
-<& /Elements/Header, Title => loc("Ticket [_1]: [_2]", $Ticket->id, $Ticket->Subject) &>
-<& /Elements/Tabs &>
-<h2><&|/l, $Ticket->id, $Ticket->Subject&>Ticket [_1]: All attachments</&></h2>
+<& /Elements/Header, Title => $title &>
+<& /Elements/Tabs, Title => $title, &>
<hr />
<a href="<%$RT::WebPath%>/View-Directory/?<%$QueryString%>">Back to search</a>
-<& ../Elements/ListAttachments, Ticket => $Ticket&>
+<& ../Elements/ListAttachments,
+ %ARGS,
+ Ticket => $Ticket,
+&>
Modified: RT-View-Directory/html/View-Directory/dhandler
==============================================================================
--- RT-View-Directory/html/View-Directory/dhandler (original)
+++ RT-View-Directory/html/View-Directory/dhandler Mon Dec 12 16:12:20 2005
@@ -7,13 +7,22 @@
my $tix = RT::Tickets->new($session{'CurrentUser'});
$tix->FromSQL($Query);
$tix->OrderBy( FIELD => $OrderBy, ORDER => $Order);
+my @tickets = @{$tix->ItemsArrayRef};
+my $title = loc("Show attachments");
+my $query_args = join(';',"Query=$Query","OrderBy=$OrderBy", "Order=$Order");
</%init>
-<& /Elements/Header, title => 'Tickets'&>
-<& /Elements/Tabs &>
-<table>
-% while (my $ticket = $tix->Next) {
-<tr>
-<td><a href="Ticket/<%$ticket->id%>"><%$ticket->id%>: <%$ticket->Subject%></a></td>
+<& /Elements/Header, Title => $title&>
+<& /Elements/Tabs, Title => $title &>
+<table width="100%" cellspacing="0">
+% foreach my $col (qw(id Subject Created Due)) {
+<th><%$col%></th>
+% }
+% my $i;
+% foreach my $ticket (@tickets) {
+% $i++;
+<tr class="<%$i % 2 ? 'oddline' : 'evenline' |n%>">
+<td><a href="Ticket/<%$ticket->id%>?<%$query_args|n%>"><%$ticket->id%></a></td>
+<td><a href="Ticket/<%$ticket->id%>?<%$query_args|n%>"><%$ticket->Subject%></a></td>
<td><%$ticket->CreatedObj->AsString%></td>
<td><%$ticket->DueObj->AsString%></td>
</tr>
More information about the Rt-commit
mailing list