[Rt-commit] rt branch, 4.2/dont-recurse-groups-in-role-columnmap, updated. rt-4.1.8-579-g7c845b2

Alex Vandiver alexmv at bestpractical.com
Mon Jul 1 15:40:46 EDT 2013


The branch, 4.2/dont-recurse-groups-in-role-columnmap has been updated
       via  7c845b2f821b4d8842f4c8e0dfd4d019ebcb42e8 (commit)
       via  f9bb83f8d1fbb790c95301482cf7e6b1d82893c8 (commit)
       via  882c587ace2c5d64e36d4bfbc909ce66807866f8 (commit)
      from  9d85251978c738ec9d1e13be4dbd1aa6e46b9911 (commit)

Summary of changes:
 share/html/Elements/ColumnMap            | 50 ++++++++++++++++++--------------
 share/html/Elements/RT__Ticket/ColumnMap | 10 +++----
 2 files changed, 34 insertions(+), 26 deletions(-)

- Log -----------------------------------------------------------------
commit 882c587ace2c5d64e36d4bfbc909ce66807866f8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jul 1 15:19:35 2013 -0400

    Cache roles in columnmap

diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap
index c5f9f26..84237bd 100644
--- a/share/html/Elements/ColumnMap
+++ b/share/html/Elements/ColumnMap
@@ -203,6 +203,8 @@ $COLUMN_MAP = {
 
 $COLUMN_MAP->{'CF'} = $COLUMN_MAP->{'CustomField'};
 
+my $ROLE_MAP = {};
+
 </%ONCE>
 <%INIT>
 $m->callback( COLUMN_MAP => $COLUMN_MAP, CallbackName => 'Once', CallbackOnce => 1 );
@@ -217,18 +219,19 @@ if (RT::Interface::Web->ComponentPathIsSafe($Class) and $m->comp_exists("/Elemen
 # Check for roles, if not handled already
 $Class =~ s/_/:/g;
 if ($Class->DOES("RT::Record::Role::Roles")) {
-    my $ROLE_MAP = {};
-    for my $role ($Class->Roles) {
-        my $attrs = $Class->Role($role);
-        $ROLE_MAP->{$role} = {
-            title => $role,
-            attribute => $attrs->{Column} || "$role.EmailAddress",
-            value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->RoleGroup($role) ) ) },
-        };
-        $ROLE_MAP->{$role . "s"} = $ROLE_MAP->{$role}
-            unless $attrs->{Single};
+    unless ($ROLE_MAP->{$Class}) {
+        for my $role ($Class->Roles) {
+            my $attrs = $Class->Role($role);
+            $ROLE_MAP->{$Class}{$role} = {
+                title => $role,
+                attribute => $attrs->{Column} || "$role.EmailAddress",
+                value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->RoleGroup($role) ) ) },
+            };
+            $ROLE_MAP->{$Class}{$role . "s"} = $ROLE_MAP->{$Class}{$role}
+                unless $attrs->{Single};
+        }
     }
-    my $role_entry = GetColumnMapEntry( Map => $ROLE_MAP, Name => $Name, Attribute => $Attr );
+    my $role_entry = GetColumnMapEntry( Map => $ROLE_MAP->{$Class}, Name => $Name, Attribute => $Attr );
     return $role_entry if defined $role_entry;
 }
 

commit f9bb83f8d1fbb790c95301482cf7e6b1d82893c8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jul 1 15:22:42 2013 -0400

    Insert roles in an intermediate step before calling class-specific component
    
    This makes the role definitions availble to the class-specific columnmap
    in $GenericMap, in case they wish to wrap them.  This is necessary, for
    instance, in the case of KeyRequestors for Tickets.

diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap
index 84237bd..b20fd8a 100644
--- a/share/html/Elements/ColumnMap
+++ b/share/html/Elements/ColumnMap
@@ -208,33 +208,38 @@ my $ROLE_MAP = {};
 </%ONCE>
 <%INIT>
 $m->callback( COLUMN_MAP => $COLUMN_MAP, CallbackName => 'Once', CallbackOnce => 1 );
-$m->callback( COLUMN_MAP => $COLUMN_MAP );
 
-# first deal with class specific things
-if (RT::Interface::Web->ComponentPathIsSafe($Class) and $m->comp_exists("/Elements/$Class/ColumnMap")) {
-    my $class_map = $m->comp("/Elements/$Class/ColumnMap", Attr => $Attr, Name => $Name, GenericMap => $COLUMN_MAP );
-    return $class_map if defined $class_map;
-}
+my $generic_with_roles;
 
-# Check for roles, if not handled already
-$Class =~ s/_/:/g;
-if ($Class->DOES("RT::Record::Role::Roles")) {
-    unless ($ROLE_MAP->{$Class}) {
-        for my $role ($Class->Roles) {
-            my $attrs = $Class->Role($role);
-            $ROLE_MAP->{$Class}{$role} = {
+# Add in roles
+my $RecordClass = $Class;
+$RecordClass =~ s/_/:/g;
+if ($RecordClass->DOES("RT::Record::Role::Roles")) {
+    unless ($ROLE_MAP->{$RecordClass}) {
+        for my $role ($RecordClass->Roles) {
+            my $attrs = $RecordClass->Role($role);
+            $ROLE_MAP->{$RecordClass}{$role} = {
                 title => $role,
                 attribute => $attrs->{Column} || "$role.EmailAddress",
                 value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->RoleGroup($role) ) ) },
             };
-            $ROLE_MAP->{$Class}{$role . "s"} = $ROLE_MAP->{$Class}{$role}
+            $ROLE_MAP->{$RecordClass}{$role . "s"} = $ROLE_MAP->{$RecordClass}{$role}
                 unless $attrs->{Single};
         }
     }
-    my $role_entry = GetColumnMapEntry( Map => $ROLE_MAP->{$Class}, Name => $Name, Attribute => $Attr );
-    return $role_entry if defined $role_entry;
+    $generic_with_roles = { %{$COLUMN_MAP}, %{$ROLE_MAP->{$RecordClass}} };
+} else {
+    $generic_with_roles = { %{$COLUMN_MAP} };
+}
+
+$m->callback( COLUMN_MAP => $generic_with_roles );
+
+# first deal with class specific things
+if (RT::Interface::Web->ComponentPathIsSafe($Class) and $m->comp_exists("/Elements/$Class/ColumnMap")) {
+    my $class_map = $m->comp("/Elements/$Class/ColumnMap", Attr => $Attr, Name => $Name, GenericMap => $generic_with_roles );
+    return $class_map if defined $class_map;
 }
 
-return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
+return GetColumnMapEntry( Map => $generic_with_roles, Name => $Name, Attribute => $Attr );
 
 </%INIT>

commit 7c845b2f821b4d8842f4c8e0dfd4d019ebcb42e8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jul 1 15:38:56 2013 -0400

    Pull Requestors definition from GenericMap when GPG is off
    
    As GenericMap is only available at runtime, and thus not in the <%ONCE>
    block, move it to the <%init> block such that KeyRequestosrs functions
    when GPG is disabled.  KeyOwnerName still examines $COLUMNMAP because
    OwnerName is still a RT::Tickets-specific columnmap, preserved for
    backwards compatibility.

diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 88c77ae..a920bc2 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -308,18 +308,18 @@ $COLUMN_MAP = {
         },
     },
 };
-
+</%ONCE>
+<%init>
 # if no GPG support, then KeyOwnerName and KeyRequestors fall back to the regular
 # versions
 if (RT->Config->Get('GnuPG')->{'Enable'}) {
     require RT::Crypt::GnuPG;
 }
 else {
-    $COLUMN_MAP->{KeyOwnerName} = $COLUMN_MAP->{OwnerName};
-    $COLUMN_MAP->{KeyRequestors} = $COLUMN_MAP->{Requestors};
+    $COLUMN_MAP->{KeyOwnerName}  = $COLUMN_MAP->{OwnerName};
+    $COLUMN_MAP->{KeyRequestors} = $GenericMap->{Requestors};
 }
-</%ONCE>
-<%init>
+
 $m->callback( GenericMap => $GenericMap, COLUMN_MAP => $COLUMN_MAP, CallbackName => 'Once', CallbackOnce => 1 );
 return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
 </%init>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list