[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.6-212-g71e732f

Kevin Falcone falcone at bestpractical.com
Sat Nov 27 10:18:34 EST 2010


The branch, 3.9-trunk has been updated
       via  71e732fcacb7730a77a13a07fa61435b36617137 (commit)
       via  c670fd0a0f4dfa60678f2d545e0679843791ab68 (commit)
      from  8bc85591998fccbe2ec575ac679967c5cf8019de (commit)

Summary of changes:
 lib/RT/CustomField_Overlay.pm              |   15 +++++++++++++++
 lib/RT/Dashboards.pm                       |    3 +++
 lib/RT/SearchBuilder.pm                    |   16 ++++++++++++++++
 share/html/Admin/CustomFields/Objects.html |    2 +-
 share/html/Elements/CollectionList         |    8 +++++---
 5 files changed, 40 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit c670fd0a0f4dfa60678f2d545e0679843791ab68
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Nov 26 21:31:23 2010 -0500

    aafceca9b93263a2d79eff4c9b38a8a88004af90 blocked RTFM from being able to
    apply a custom field to a single class
    
    Instead of just saying that anything with RT::Queue can be assigned,
    list the things that must be assigned globally.  Also, move the check to
    a library so you can override it with less pain.  This fixes

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 51e602b..a2d56c3 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -1125,6 +1125,21 @@ sub CollectionClassFromLookupType {
     return $collection_class;
 }
 
+=head1 ApplyGlobally
+
+Certain custom fields (users, groups) should only be applied globally
+but rather than regexing in code for LookupType =~ RT::Queue, we'll codify
+the rules here.
+
+=cut
+
+sub ApplyGlobally {
+    my $self = shift;
+
+    return ($self->LookupType =~ /^RT::(?:Group|User)/io);
+
+}
+
 =head1 AppliedTo
 
 Returns collection with objects this custom field is applied to.
diff --git a/share/html/Admin/CustomFields/Objects.html b/share/html/Admin/CustomFields/Objects.html
index c0af6d8..3afb5b5 100644
--- a/share/html/Admin/CustomFields/Objects.html
+++ b/share/html/Admin/CustomFields/Objects.html
@@ -63,7 +63,7 @@
 <input type="checkbox" name="AddCustomField-<% $CF->id %>" value="0" />
 <&|/l&>check this box to apply this Custom Field to all objects.</&>
 
-% if ( $CF->LookupType =~ /^RT::Queue-/io ) {
+% unless ( $CF->ApplyGlobally ) {
 <h2><&|/l&>Selected objects</&></h2>
 <& /Elements/CollectionList,
     OrderBy => 'id',

commit 71e732fcacb7730a77a13a07fa61435b36617137
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Nov 26 21:39:35 2010 -0500

    CollectionList has a really naive algorithm for naming
    
    Move this somewhere a collection can override it.  This avoids needing
    to add a Class argument to CollectionList calls (except for the old
    behavior that passing Class => 'RT::Tickets' from ShowSearch
    causes a special cased query to be run.  This can probably be
    refactored).

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index 0360467..2e697aa 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -103,6 +103,9 @@ sub LimitToPrivacy {
     }
 }
 
+sub ColumnMapClassName {
+    return 'RT__Dashboard';
+}
 
 RT::Base->_ImportOverlays();
 
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 07cbeda..cd8e3f7 100755
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -282,6 +282,22 @@ sub _DoCount {
     return $self->SUPER::_DoCount(@_);
 }
 
+=head2 ColumnMapClassName
+
+ColumnMap needs a Collection name to load the correct list display.
+Depluralization is hard, so provide an easy way to correct the naive
+algorithm that this code uses.
+
+=cut
+
+sub ColumnMapClassName {
+    my $self = shift;
+    my $Class = ref $self;
+    $Class =~ s/s$//;
+    $Class =~ s/:/_/g;
+    return $Class;
+}
+
 RT::Base->_ImportOverlays();
 
 1;
diff --git a/share/html/Elements/CollectionList b/share/html/Elements/CollectionList
index 8e57d4d..452b1e5 100644
--- a/share/html/Elements/CollectionList
+++ b/share/html/Elements/CollectionList
@@ -105,9 +105,11 @@ foreach my $col (@Format) {
     }
 }
 
-$Class ||= ref $Collection;
-$Class =~ s/s$//;
-$Class =~ s/:/_/g;
+$Class ||= $Collection->ColumnMapClassName;
+if ($Class =~ /::/) { # older passed in value
+    $Class =~ s/s$//;
+    $Class =~ s/:/_/g;
+}
 
 $m->out('<table class="' .
 	($Collection->isa('RT::Tickets') ? 'ticket-list' : 'collection') . ' collection-as-table">');

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


More information about the Rt-commit mailing list