[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 74c9281d11d7f92e6da3dc00b795e50493c11258
Mark Wells
mark at 420.am
Wed May 29 13:31:11 PDT 2013
The branch, FREESIDE_2_3_BRANCH has been updated
via 74c9281d11d7f92e6da3dc00b795e50493c11258 (commit)
from 88df244c8078f6db7701ff6deb928e4b7edecf58 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 74c9281d11d7f92e6da3dc00b795e50493c11258
Author: Mark Wells <mark at freeside.biz>
Date: Wed May 29 13:15:34 2013 -0700
display date custom fields as real dates, #23121
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm
index ee8c34b..6218641 100644
--- a/rt/lib/RT/Interface/Web_Vendor.pm
+++ b/rt/lib/RT/Interface/Web_Vendor.pm
@@ -533,5 +533,32 @@ sub ProcessUpdateMessage {
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;
diff --git a/rt/share/html/Elements/ColumnMap b/rt/share/html/Elements/ColumnMap
index 2d226da..c81dbb8 100644
--- a/rt/share/html/Elements/ColumnMap
+++ b/rt/share/html/Elements/ColumnMap
@@ -64,8 +64,7 @@ my $COLUMN_MAP = {
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',
@@ -80,8 +79,7 @@ my $COLUMN_MAP = {
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',
@@ -101,15 +99,31 @@ my $COLUMN_MAP = {
# 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;
},
diff --git a/rt/share/html/Elements/RT__Ticket/ColumnMap b/rt/share/html/Elements/RT__Ticket/ColumnMap
index 9e6466c..9cceaf6 100644
--- a/rt/share/html/Elements/RT__Ticket/ColumnMap
+++ b/rt/share/html/Elements/RT__Ticket/ColumnMap
@@ -220,32 +220,27 @@ $COLUMN_MAP = {
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
diff --git a/rt/share/html/Search/Elements/ResultsStructuredView b/rt/share/html/Search/Elements/ResultsStructuredView
index 495f0d0..0e9457c 100644
--- a/rt/share/html/Search/Elements/ResultsStructuredView
+++ b/rt/share/html/Search/Elements/ResultsStructuredView
@@ -132,7 +132,7 @@ while ( my $Ticket = $Tickets->Next()) {
if ( !exists $ColumnMap->{$col}{'value'} ) {
my $map = {};
- foreach ('attribute', 'value', 'date') {
+ foreach ('attribute', 'value') {
$map->{$_} = $m->comp(
'/Elements/ColumnMap',
Class => 'RT__Ticket',
@@ -140,19 +140,13 @@ while ( my $Ticket = $Tickets->Next()) {
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>');
-----------------------------------------------------------------------
Summary of changes:
rt/lib/RT/Interface/Web_Vendor.pm | 27 +++++++++++++
rt/share/html/Elements/ColumnMap | 40 +++++++++++++------
rt/share/html/Elements/RT__Ticket/ColumnMap | 15 ++-----
.../html/Search/Elements/ResultsStructuredView | 10 +----
4 files changed, 61 insertions(+), 31 deletions(-)
More information about the freeside-commits
mailing list