return @results;
}
+sub default_FormatDate { $_[0]->AsString }
+
+sub ProcessColumnMapValue {
+ my $value = shift;
+ my %args = ( Arguments => [],
+ Escape => 1,
+ FormatDate => \&default_FormatDate,
+ @_ );
+
+ if ( ref $value ) {
+ if ( ref $value eq 'RT::Date' ) {
+ return $args{FormatDate}->($value);
+ } elsif ( UNIVERSAL::isa( $value, 'CODE' ) ) {
+ my @tmp = $value->( @{ $args{'Arguments'} } );
+ return ProcessColumnMapValue( ( @tmp > 1 ? \@tmp : $tmp[0] ), %args );
+ } elsif ( UNIVERSAL::isa( $value, 'ARRAY' ) ) {
+ return join '', map ProcessColumnMapValue( $_, %args ), @$value;
+ } elsif ( UNIVERSAL::isa( $value, 'SCALAR' ) ) {
+ return $$value;
+ }
+ }
+
+ return $m->interp->apply_escapes( $value, 'h' ) if $args{'Escape'};
+ return $value;
+}
+
+
1;
Created => {
attribute => 'Created',
title => 'Created', # loc
- date => sub { return $_[0]->CreatedObj },
- value => sub { return $_[0]->CreatedObj->AsString }
+ value => sub { return $_[0]->CreatedObj },
},
CreatedRelative => {
attribute => 'Created',
LastUpdated => {
attribute => 'LastUpdated',
title => 'Last Updated', # loc
- date => sub { return $_[0]->LastUpdatedObj },
- value => sub { return $_[0]->LastUpdatedObj->AsString }
+ value => sub { return $_[0]->LastUpdatedObj },
},
LastUpdatedRelative => {
attribute => 'LastUpdated',
# Display custom field contents, separated by newlines.
# For Image custom fields we also show a thumbnail here.
- my $values = $_[0]->CustomFieldValues( $_[-1] );
- my @values = map {
- (
- ($_->CustomFieldObj->Type eq 'Image')
- ? \($m->scomp( '/Elements/ShowCustomFieldImage', Object => $_ ))
- : $_->Content
- ),
- \'<br />',
- } @{ $values->ItemsArrayRef };
+ my $object = shift;
+ my $cfname = pop;
+ my $values = $object->CustomFieldValues( $cfname );
+ return if $values->Count == 0;
+ my @values;
+ # it is guaranteed to be the same type for all fields, right?
+ my $v = $values->First;
+ my $cftype = $v->CustomFieldObj->Type;
+
+ do {
+ if ($cftype eq 'Image') {
+ push @values,
+ \($m->scomp( '/Elements/ShowCustomFieldImage',
+ Object => $v ));
+ } elsif ( $cftype eq 'Date' or $cftype eq 'DateTime' ) {
+ # then actually return the date object;
+ # ProcessColumnMapValue will stringify it
+ my $DateObj = RT::Date->new( $session{'CurrentUser'} );
+ $DateObj->Set(Format => 'unknown', Value => $v->Content);
+ push @values, $DateObj;
+ } else {
+ push @values, $v->Content;
+ }
+ push @values, \'<br />'; # this is deeply silly
+ } while ($v = $values->Next);
pop @values; # Remove that last <br />
return @values;
},
Starts => {
title => 'Starts', # loc
attribute => 'Starts',
- date => sub { return $_[0]->StartsObj },
- value => sub { return $_[0]->StartsObj->AsString }
+ value => sub { return $_[0]->StartsObj }
},
Started => {
title => 'Started', # loc
attribute => 'Started',
- date => sub { return $_[0]->StartedObj },
- value => sub { return $_[0]->StartedObj->AsString }
+ value => sub { return $_[0]->StartedObj },
},
Told => {
title => 'Told', # loc
attribute => 'Told',
- date => sub { return $_[0]->ToldObj },
- value => sub { return $_[0]->ToldObj->AsString }
+ value => sub { return $_[0]->ToldObj },
},
Due => {
title => 'Due', # loc
attribute => 'Due',
- date => sub { return $_[0]->DueObj },
- value => sub { return $_[0]->DueObj->AsString }
+ value => sub { return $_[0]->DueObj },
},
Resolved => {
title => 'Resolved', # loc
attribute => 'Resolved',
- date => sub { return $_[0]->ResolvedObj },
- value => sub { return $_[0]->ResolvedObj->AsString }
+ value => sub { return $_[0]->ResolvedObj }
},
UpdateStatus => {
title => 'New messages', # loc
if ( !exists $ColumnMap->{$col}{'value'} ) {
my $map = {};
- foreach ('attribute', 'value', 'date') {
+ foreach ('attribute', 'value') {
$map->{$_} = $m->comp(
'/Elements/ColumnMap',
Class => 'RT__Ticket',
Attr => $_,
);
}
- # Canonicalize dates
- if ( defined $map->{'date'} ) {
- $map->{value} = sub {
- my $DateObj = $map->{'date'}->(@_) or return undef;
- $FormatDate->($DateObj);
- };
- }
$ColumnMap->{$col} = $map;
}
push @out, ProcessColumnMapValue(
$ColumnMap->{$col}{'value'},
Arguments => [ $Ticket, $row ],
+ FormatDate => $FormatDate,
);
} #foreach $subcol
$value = join('', '<span>', @out, '</span>');