[Rt-commit] r8172 - in rt/branches/3.7-EXPERIMENTAL-TUNIS:
html/Elements html/Elements/RT__Queue
html/Elements/RT__Template html/Elements/RT__Ticket lib/RT/Interface
ruz at bestpractical.com
ruz at bestpractical.com
Mon Jul 16 14:21:58 EDT 2007
Author: ruz
Date: Mon Jul 16 14:21:58 2007
New Revision: 8172
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/ColumnMap
rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Queue/ColumnMap
rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Template/ColumnMap
rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Ticket/ColumnMap
rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__User/ColumnMap
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Web.pm
Log:
* move handling lookups in column maps into ::Interface::Web::GetColumnMapEntry()
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/ColumnMap
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/ColumnMap (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/ColumnMap Mon Jul 16 14:21:58 2007
@@ -92,19 +92,7 @@
# first deal with class specific things
my $class_map = $m->comp("/Elements/$Class/ColumnMap", Attr => $Attr, Name => $Name );
-return $class_map if $class_map;
-
-# deal with the simple things from the generic map
-if ( $COLUMN_MAP->{$Name} ) {
- return ( $COLUMN_MAP->{$Name}->{$Attr} );
-}
-# complex things
-elsif ( (my ($mainkey, $subkey) = $Name =~ /^(.*?)\.{(.+)}$/) && $COLUMN_MAP->{$1} ) {
- return $COLUMN_MAP->{$mainkey}->{$Attr}
- unless ref $COLUMN_MAP->{$mainkey}->{$Attr} eq 'CODE';
-
- return sub { $COLUMN_MAP->{$mainkey}->{$Attr}->( @_, $subkey ) };
-}
-return undef;
+return $class_map if defined $class_map;
+return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%INIT>
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Queue/ColumnMap
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Queue/ColumnMap (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Queue/ColumnMap Mon Jul 16 14:21:58 2007
@@ -92,6 +92,6 @@
</%ONCE>
<%INIT>
$m->callback( COLUMN_MAP => $QUEUE_COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
-return $ColumnMap->($Name, $Attr);
+return GetColumnMapEntry( Map => $QUEUE_COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%INIT>
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Template/ColumnMap
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Template/ColumnMap (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Template/ColumnMap Mon Jul 16 14:21:58 2007
@@ -66,6 +66,5 @@
</%ONCE>
<%INIT>
$m->callback( COLUMN_MAP => $TEMPLATE_COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
-return undef unless $TEMPLATE_COLUMN_MAP->{ $Name };
-return $TEMPLATE_COLUMN_MAP->{ $Name }->{ $Attr };
+return GetColumnMapEntry( Map => $TEMPLATE_COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%INIT>
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Ticket/ColumnMap
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Ticket/ColumnMap (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__Ticket/ColumnMap Mon Jul 16 14:21:58 2007
@@ -54,23 +54,6 @@
<%ONCE>
our ( $TICKET_COLUMN_MAP );
-my $ColumnMap = sub {
- my $name = shift;
- my $attr = shift;
-
- # First deal with the simple things from the map
- if ( $TICKET_COLUMN_MAP->{$name} ) {
- return ( $TICKET_COLUMN_MAP->{$name}->{$attr} );
- }
- elsif ( (my ($mainkey, $subkey) = $name =~ /^(.*?)\.{(.+)}$/) && $TICKET_COLUMN_MAP->{$1} ) {
- return $TICKET_COLUMN_MAP->{$mainkey}->{$attr}
- unless ref $TICKET_COLUMN_MAP->{$mainkey}->{$attr} eq 'CODE';
-
- return sub { $TICKET_COLUMN_MAP->{$mainkey}->{$attr}->( @_, $subkey ) };
- }
-
-};
-
my $LinkCallback = sub {
my $method = shift;
@@ -292,5 +275,5 @@
<%init>
$m->callback( COLUMN_MAP => $TICKET_COLUMN_MAP, CallbackName => 'Once', CallbackOnce => 1 );
$m->callback( COLUMN_MAP => $TICKET_COLUMN_MAP, CallbackName => 'ColumnMap' );
-return $ColumnMap->( $Name, $Attr );
+return GetColumnMapEntry( Map => $TICKET_COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%init>
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__User/ColumnMap
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__User/ColumnMap (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/RT__User/ColumnMap Mon Jul 16 14:21:58 2007
@@ -68,6 +68,5 @@
</%ONCE>
<%INIT>
$m->callback( COLUMN_MAP => $USER_COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
-return undef unless $USER_COLUMN_MAP->{ $Name };
-return $USER_COLUMN_MAP->{ $Name }->{ $Attr };
+return GetColumnMapEntry( Map => $USER_COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%INIT>
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Web.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Web.pm Mon Jul 16 14:21:58 2007
@@ -1641,6 +1641,23 @@
};
}
+sub GetColumnMapEntry {
+ my %args = ( Map => {}, Name => '', Attribute => undef, @_ );
+ # deal with the simplest thing first
+ if ( $args{'Map'}{ $args{'Name'} } ) {
+ return $args{'Map'}{ $args{'Name'} }{ $args{'Attribute'} };
+ }
+ # complex things
+ elsif ( my ($mainkey, $subkey) = $args{'Name'} =~ /^(.*?)\.{(.+)}$/ ) {
+ return undef unless $args{'Map'}->{ $mainkey };
+ return $args{'Map'}{ $mainkey }{ $args{'Attribute'} }
+ unless ref $args{'Map'}{ $mainkey }{ $args{'Attribute'} } eq 'CODE';
+
+ return sub { $args{'Map'}{ $mainkey }{ $args{'Attribute'} }->( @_, $subkey ) };
+ }
+ return undef;
+}
+
=head2 _load_container_object ( $type, $id );
Instantiate container object for saving searches.
More information about the Rt-commit
mailing list