[Rt-commit] rt branch, 4.2/customfieldgrouping-extensibility, created. rt-4.2.6-29-gf85567a

Kevin Falcone falcone at bestpractical.com
Fri Jul 25 10:48:01 EDT 2014


The branch, 4.2/customfieldgrouping-extensibility has been created
        at  f85567a43d1f7c5242089155aa161f52b746f94c (commit)

- Log -----------------------------------------------------------------
commit 4937273b200af5d9b3cd4102f8723481f5f3eb28
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Jul 23 13:18:44 2014 -0400

    RT::CustomField provides a wrapper to get the 'type', use it
    
    Hardcoding ref here means that if anything extends
    RT::CustomField->_GroupingClass, it'll fail to find the groupings and
    dump all your CFs into the Custom Fields group.  By calling back in to
    GroupingClass, you get the 'magic' type and can look it up in the
    groupings.
    
    RTIR uses this to provide an RTIR::Ticket grouping type so you can
    separate CF groupings on RTIR tickets from those on core tickets.
    Provided to allow better separation of groupings between RTIR CFs and
    CFs on other Queues, especially since RTIR uses common names such as
    'Customer' and 'IP' which would otherwise complicate using those CFs in
    groups in other Queues. Perhaps points towards wanting per-queue CF
    groupings.

diff --git a/lib/RT/CustomFields.pm b/lib/RT/CustomFields.pm
index eab9a10..a251768 100644
--- a/lib/RT/CustomFields.pm
+++ b/lib/RT/CustomFields.pm
@@ -118,9 +118,11 @@ sub LimitToGrouping {
     my $obj = shift;
     my $grouping = shift;
 
+    my $grouping_class = RT::CustomField->_GroupingClass($obj);
+
     my $config = RT->Config->Get('CustomFieldGroupings');
        $config = {} unless ref($config) eq 'HASH';
-       $config = $config->{ref($obj) || $obj} || [];
+       $config = $config->{$grouping_class} || [];
     my %h = ref $config eq "ARRAY" ? @{$config} : %{$config};
 
     if ( $grouping ) {

commit fa25f47b2b9d485d734554dc7ffa4a81899d2dc4
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Jul 24 11:37:39 2014 -0400

    Pass extra context to _GroupingClass
    
    Because we're calling _GroupingClass as a class method (rather than on a
    loaded CF object) we limit the information available to _GroupingClass
    and anyone overriding it (like RTIR).  In the case of LimitToGrouping
    being called on a Ticket during creation, you get two incomplete objects
    and really can't make any judgements other than the core "ref $object".
    
    For RTIR, which wants to know what Queue you're creating the ticket in,
    passing the ContextObject makes this doable.  If called on a loaded
    CustomField object, code should use ACLEquivalenceObjects instead, but
    this 'rescues' the case of searching for CFs available to a ticket
    during creation by providing more context to users overriding
    _GroupingClass.
    
    It turns out to be surprisingly reasonable to do this override in case
    you want to segment your groups across tickets (or other objects) in the
    system.

diff --git a/lib/RT/CustomFields.pm b/lib/RT/CustomFields.pm
index a251768..ebfb7d1 100644
--- a/lib/RT/CustomFields.pm
+++ b/lib/RT/CustomFields.pm
@@ -118,7 +118,7 @@ sub LimitToGrouping {
     my $obj = shift;
     my $grouping = shift;
 
-    my $grouping_class = RT::CustomField->_GroupingClass($obj);
+    my $grouping_class = RT::CustomField->_GroupingClass($obj,$self->ContextObject);
 
     my $config = RT->Config->Get('CustomFieldGroupings');
        $config = {} unless ref($config) eq 'HASH';

commit f85567a43d1f7c5242089155aa161f52b746f94c
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Jul 24 11:53:49 2014 -0400

    Allow @Groupings to be passed in
    
    The display template (ShowCustomFieldCustomGroupings) takes Groupings as
    an argument, for symmetry, also take it during editing.
    
    This allows code to better control which groups are shown
    on Create or other editing pages (in particular, RTIR and the multitude
    of complex editing/creating pages in that workflow).

diff --git a/share/html/Elements/EditCustomFieldCustomGroupings b/share/html/Elements/EditCustomFieldCustomGroupings
index 6e32436..2edf572 100644
--- a/share/html/Elements/EditCustomFieldCustomGroupings
+++ b/share/html/Elements/EditCustomFieldCustomGroupings
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% foreach my $group ( RT::CustomField->CustomGroupings( $Object ), '' ) {
+% foreach my $group ( @Groupings ) {
 <&| /Widgets/TitleBox,
     title => $group? loc($group) : loc('Custom Fields'),
     class => $css_class .' '. ($group? CSSClass("$css_class-$group") : ''),
@@ -59,6 +59,7 @@
 <%ARGS>
 $Object
 $CustomFieldGenerator => undef,
+ at Groupings => (RT::CustomField->CustomGroupings( $Object ), '')
 </%ARGS>
 <%INIT>
 my $css_class = lc(ref($Object)||$Object);

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


More information about the rt-commit mailing list