[Rt-commit] r7267 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Mon Mar 19 12:37:27 EDT 2007
Author: ruz
Date: Mon Mar 19 12:37:26 2007
New Revision: 7267
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/Elements/RT__Ticket/ColumnMap
Log:
r4756 at cubic-pc: cubic | 2007-03-19 18:35:24 +0300
* generalize format we use for CFs in the column map, so now
it's possible to use __key.{subkey}__ format and if there is no
mapping for whole string then we look for mapping of 'key' and
pass subkey as the last argument to callbacks.
This would allow us to implement named checkboxes in RTIR and
later generic one, so we'll be able to use '__CheckBox.{NameOfCheckboxHTMLElement}__'
in format strings.
Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/RT__Ticket/ColumnMap
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/RT__Ticket/ColumnMap (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/RT__Ticket/ColumnMap Mon Mar 19 12:37:26 2007
@@ -60,35 +60,11 @@
if ( $COLUMN_MAP->{$name} ) {
return ( $COLUMN_MAP->{$name}->{$attr} );
}
+ elsif ( (my ($mainkey, $subkey) = $name =~ /^(.*?)\.{(.+)}$/) && $COLUMN_MAP->{$1} ) {
+ return $COLUMN_MAP->{$mainkey}->{$attr}
+ unless ref $COLUMN_MAP->{$mainkey}->{$attr} eq 'CODE';
- # now, let's deal with harder things, like Custom Fields
-
- elsif ( $name =~ /^(?:CF|CustomField)\.\{(.+)\}$/ ) {
- my $field = $1;
-
- if ( $attr eq 'attribute' ) {
- return (undef);
- }
- elsif ( $attr eq 'title' ) {
- return ( $field );
- }
- elsif ( $attr eq 'value' ) {
- # Display custom field contents, separated by newlines.
- # For Image custom fields we also show a thumbnail here.
- return sub {
- my $values = $_[0]->CustomFieldValues($field);
- my @values = map {
- (
- ($_->CustomFieldObj->Type eq 'Image')
- ? \($m->scomp( '/Elements/ShowCustomFieldImage', Object => $_ ))
- : $_->Content
- ),
- \'<br />',
- } @{ $values->ItemsArrayRef };
- pop @values; # Remove that last <br />
- return @values;
- };
- }
+ return sub { $COLUMN_MAP->{$mainkey}->{$attr}->( @_, $subkey ) };
}
elsif ( $name =~ /^(WebPath|WebBaseURL|WebURL)$/ ) {
if ( $attr eq 'value' ) {
@@ -319,7 +295,30 @@
value => sub { return \('<input type="checkbox" class="checkbox" name="UpdateTicket'.$_[0]->id.'" value="1" checked />') }
},
+ CustomField => {
+ attribute => undef,
+ title => sub { return pop @_ },
+ value => sub {
+ # 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 };
+ pop @values; # Remove that last <br />
+ return @values;
+ },
+ },
};
+
+$COLUMN_MAP->{'CF'} = $COLUMN_MAP->{'CustomField'};
+
</%ONCE>
<%init>
$m->callback( COLUMN_MAP => $COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
More information about the Rt-commit
mailing list