[rt-commit] [svn] r470 - rt/branches/rt-3.1/html/Elements
jesse at fsck.com
jesse at fsck.com
Thu Mar 4 15:32:52 EST 2004
Author: jesse
Date: Thu Mar 4 15:32:51 2004
New Revision: 470
Modified:
rt/branches/rt-3.1/html/Elements/TicketList
Log:
TicketList now handles relationships and custom fields.
Modified: rt/branches/rt-3.1/html/Elements/TicketList
==============================================================================
--- rt/branches/rt-3.1/html/Elements/TicketList (original)
+++ rt/branches/rt-3.1/html/Elements/TicketList Thu Mar 4 15:32:51 2004
@@ -49,23 +49,64 @@
% }
<%INIT>
-use vars qw($COLUMN_MAP);
+use vars qw($COLUMN_MAP $CUSTOM_FIELD_MAP);
$Format ||= $RT::DefaultSearchResultFormat;
$Rows ||= '25'; # we need a positive value
+
# {{{ item map
sub ColumnMap {
- my $name = shift;
+ my $name = shift;
my $attr = shift;
- if ($COLUMN_MAP->{$name}) {
- return ($COLUMN_MAP->{$name}->{$attr});
+ # First deal with the simple things from the map
+ if ( $COLUMN_MAP->{$name} ) {
+ return ( $COLUMN_MAP->{$name}->{$attr} );
}
-}
+ # now, let's deal with harder things, like Custom Fields
+
+ elsif ( $name =~ /^(?:CF|CustomField).(.*)$/ ) {
+ my $field = $1;
+ my $cf;
+ if ( $CUSTOM_FIELD_MAP->{$field} ) {
+ $cf = $CUSTOM_FIELD_MAP->{$field};
+ }
+ else {
+
+ $cf = RT::CustomField->new( $session{'CurrentUser'} );
+ if ( $field =~ /^(.+?)\.{(.+)}$/ ) {
+ $cf->LoadByNameAndQueue( Queue => $1, Name => $2 );
+ }
+ else {
+ $field = $1 if $field =~ /^{(.+)}$/; # trim { }
+ $cf->LoadByNameAndQueue( Queue => "0", Name => $field );
+ }
+ $CUSTOM_FIELD_MAP->{$field} = $cf if ( $cf->id );
+ }
+
+ unless ( $cf->id ) {
+ return undef;
+ }
+
+ if ( $attr eq 'attribute' ) {
+ return (undef);
+ }
+ elsif ( $attr eq 'title' ) {
+ return ( $cf->Name );
+ }
+ elsif ( $attr eq 'value' ) {
+ my $value = eval "sub {
+ my \$values = \$_[0]->CustomFieldValues('".$cf->id."');
+ return ( join( ', ', map { \$_->Content } \@{ \$values->ItemsArrayRef } ))
+ }" || die $@;
+ return($value);
+ }
+ }
+ }
$COLUMN_MAP = {
QueueName => {
attribute => 'Queue',
@@ -78,13 +119,16 @@
value => sub { return $_[0]->OwnerObj->Name }
},
id => {
+ attribute => 'id',
align => 'right',
value => sub { return $_[0]->id }
},
Status => {
+ attribute => 'Status',
value => sub { return $_[0]->Status }
},
Subject => {
+ attribute => 'Subject',
value => sub { return $_[0]->Subject || "(".loc('No subject').")" }
},
ExtendedStatus => {
@@ -109,27 +153,35 @@
}
}, Priority => {
+ attribute => 'Priority',
value => sub { return $_[0]->Priority }
},
InitialPriority => {
+ attribute => 'InitialPriority',
value => sub { return $_[0]->InitialPriority }
},
FinalPriority => {
+ attribute => 'FinalPriority',
value => sub { return $_[0]->FinalPriority }
},
EffectiveId => {
+ attribute => 'EffectiveId',
value => sub { return $_[0]->EffectiveId }
},
Type => {
+ attribute => 'Type',
value => sub { return $_[0]->Type }
},
TimeWorked => {
+ attribute => 'TimeWorked',
value => sub { return $_[0]->TimeWorked }
},
TimeLeft => {
+ attribute => 'TimeLeft',
value => sub { return $_[0]->TimeLeft }
},
TimeEstimated => {
+ attribute => 'TimeEstimated',
value => sub { return $_[0]->TimeEstimated }
},
Requestors => {
@@ -177,26 +229,123 @@
value => sub { return $_[0]->ResolvedObj->AgeAsString }
},
Starts => {
+ attribute => 'Starts',
value => sub { return $_[0]->StartsObj->AsString }
},
Started => {
+ attribute => 'Started',
value => sub { return $_[0]->StartedObj->AsString }
},
Created => {
+ attribute => 'Created',
value => sub { return $_[0]->CreatedObj->AsString }
},
LastUpdated => {
+ attribute => 'LastUpdated',
value => sub { return $_[0]->LastUpdatedObj->AsString }
},
Told => {
+ attribute => 'Told',
value => sub { return $_[0]->ToldObj->AsString }
},
Due => {
+ attribute => 'Due',
value => sub { return $_[0]->DueObj->AsString }
},
Resolved => {
+ attribute => 'Resolved',
value => sub { return $_[0]->ResolvedObj->AsString }
},
+
+ DependedOnBy => {
+ value => sub {
+ my $links = $_[0]->DependedOnBy;
+ return (
+ join(
+ "<br>",
+ map {
+ '<A HREF="'
+ . $_->BaseURI->Resolver->HREF . '">'
+ . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
+ . '</A>'
+ } @{ $links->ItemsArrayRef } ) );
+ }
+ },
+ Members => {
+ value => sub {
+ my $links = $_[0]->HasMember;
+ return (
+ join(
+ "<br>",
+ map {
+ '<A HREF="'
+ . $_->BaseURI->Resolver->HREF . '">'
+ . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
+ . '</A>'
+ } @{ $links->ItemsArrayRef } ) );
+ }
+ },
+ ReferredToBy => {
+ value => sub {
+ my $links = $_[0]->ReferredToBy;
+ return (
+ join(
+ "<br>",
+ map {
+ '<A HREF="'
+ . $_->BaseURI->Resolver->HREF . '">'
+ . ( $_->BaseIsLocal ? $_->LocalBase : $_->Base )
+ . '</A>'
+ } @{ $links->ItemsArrayRef } ) );
+ }
+ },
+
+ DependsOn => {
+ value => sub {
+ my $links = $_[0]->DependsOn;
+ return (
+ join(
+ "<br>",
+ map {
+ '<A HREF="'
+ . $_->TargetURI->Resolver->HREF . '">'
+ . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
+ . '</A>'
+ } @{ $links->ItemsArrayRef } ) );
+ }
+ },
+ MemberOf => {
+ value => sub {
+ my $links = $_[0]->MemberOf;
+ return (
+ join(
+ "<br>",
+ map {
+ '<A HREF="'
+ . $_->TargetURI->Resolver->HREF . '">'
+ . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
+ . '</A>'
+ } @{ $links->ItemsArrayRef } ) );
+ }
+ },
+ RefersTo => {
+ value => sub {
+ my $links = $_[0]->RefersTo;
+ return (
+ join(
+ "<br>",
+ map {
+ '<A HREF="'
+ . $_->TargetURI->Resolver->HREF . '">'
+ . ( $_->TargetIsLocal ? $_->LocalTarget : $_->Target )
+ . '</A>'
+ } @{ $links->ItemsArrayRef } ) );
+ }
+ },
+
+
+
+
'_CLASS' => {
value => sub { return $_[1] %2 ? 'oddline' : 'evenline' }
},
@@ -263,11 +412,9 @@
my $title = $col->{title};
$title =~ s/^__(.*)__$/$1/o;
$title = ( ColumnMap($title, 'title') || $title );
- if ( $AllowSorting && $col->{'attribute'} ) {
+ if ( $AllowSorting && $col->{'attribute'} && ColumnMap($col->{'attribute'},'attribute')) {
my @query_args = @generic_query_args;
- push @query_args,
- ( "OrderBy="
- . ( ColumnMap($col->{'attribute'}, 'attribute') || $col->{'attribute'} ) );
+ push @query_args, ( "OrderBy=" . ( ColumnMap($col->{'attribute'}, 'attribute') || $col->{'attribute'} ) );
push @query_args,
( "Order=" . ( $ARGS{'Order'} eq 'ASC'
? 'DESC'
@@ -309,6 +456,8 @@
if ( $value && ref($value)) {
$m->out( &{ $value } ( $record, $i ) );
+ } else {
+ $m->out($value . " HI ");
}
}
else {
More information about the Rt-commit
mailing list