X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FColumnMap;h=9c65825078d19939ba6fb654b4e4478f6cb06968;hb=e131b1f71f08b69abb832c1687d1f29682d171f8;hp=3ae10ea3ee0798913484fbd1cfb2c52c12ee6ad6;hpb=d05d7346bb2387fd9d0354923d577275c5c7f019;p=freeside.git diff --git a/rt/share/html/Elements/ColumnMap b/rt/share/html/Elements/ColumnMap index 3ae10ea3e..9c6582507 100644 --- a/rt/share/html/Elements/ColumnMap +++ b/rt/share/html/Elements/ColumnMap @@ -52,11 +52,14 @@ $Attr => undef %ARGS> <%ONCE> +use Scalar::Util; + # This is scary and should totally be refactored -- jesse -my $COLUMN_MAP = { +my ($COLUMN_MAP, $WCOLUMN_MAP); +$WCOLUMN_MAP = $COLUMN_MAP = { id => { attribute => 'id', - title => 'id', # loc + title => '#', # loc align => 'right', value => sub { return $_[0]->id } }, @@ -96,6 +99,12 @@ my $COLUMN_MAP = { attribute => sub { return shift @_ }, title => sub { return pop @_ }, value => sub { + my $self = $WCOLUMN_MAP->{CustomField}; + my $cf = $self->{load}->(@_); + return unless $cf->Id; + return $self->{render}->( $cf, $cf->ValuesForObject($_[0])->ItemsArrayRef ); + }, + load => sub { # Cache the CF object on a per-request basis, to avoid # having to load it for every row my $key = join("-","CF", @@ -106,36 +115,31 @@ my $COLUMN_MAP = { my $cf = $m->notes($key); unless ($cf) { $cf = $_[0]->LoadCustomFieldByIdentifier($_[-1]); + RT->Logger->notice("Unable to load $_[-1] for ".$_[0]->CustomFieldLookupType." ".$_[0]->CustomFieldLookupId) + unless $cf->Id; $m->notes($key, $cf); } - # Display custom field contents, separated by newlines. - # For Image custom fields we also show a thumbnail here. - my $values = $cf->ValuesForObject( $_[0] ); - 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; + return $cf; + }, + render => sub { + my ($cf, $ocfvs) = @_; + my $comp = $m->comp_exists("/Elements/ShowCustomField".$cf->Type) + ? "/Elements/ShowCustomField".$cf->Type + : undef; + + my @values = map { + $comp + ? \($m->scomp( $comp, Object => $_ )) + : $_->Content + } @$ocfvs; + + if (@values > 1) { + for my $value (splice @values) { + push @values, \"