[Bps-public-commit] RT-Extension-MandatoryOnTransition branch, master, updated. 0.09_01-1-g3be2b74

? sunnavy sunnavy at bestpractical.com
Wed Feb 18 10:25:42 EST 2015


The branch, master has been updated
       via  3be2b74fbb301b7965d3edfea9a5754929ddea26 (commit)
      from  5367dee44575c0fc6ec16b00f67c541af25ed51e (commit)

Summary of changes:
 lib/RT/Extension/MandatoryOnTransition.pm | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 3be2b74fbb301b7965d3edfea9a5754929ddea26
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Feb 18 23:25:27 2015 +0800

    support grouped custom fields

diff --git a/lib/RT/Extension/MandatoryOnTransition.pm b/lib/RT/Extension/MandatoryOnTransition.pm
index 4fd4f44..b4a9937 100644
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@ -395,10 +395,19 @@ sub CheckMandatoryFields {
         }
 
         # Do we have a submitted value for update?
-        my $arg   = "Object-RT::Ticket-".$TicketId."-CustomField-".$cf->Id."-Value";
-        my $value = ($ARGSRef->{"${arg}s-Magic"} and exists $ARGSRef->{"${arg}s"})
-          ? $ARGSRef->{$arg . "s"}
-            : $ARGSRef->{$arg};
+        my $value;
+        if ( HTML::Mason::Commands->can('_ParseObjectCustomFieldArgs') ) {
+            # steal code from /Elements/ValidateCustomFields
+            my $CFArgs = HTML::Mason::Commands::_ParseObjectCustomFieldArgs( $ARGSRef )->{'RT::Ticket'}{$TicketId || 0} || {};
+            my $submitted = $CFArgs->{$cf->id};
+            # Pick the first grouping
+            $submitted = $submitted ? $submitted->{(keys %$submitted)[0]} : {};
+            $value = $submitted->{Values} // $submitted->{Value};
+        }
+        else {
+            my $arg   = "Object-RT::Ticket-".$TicketId."-CustomField-".$cf->Id."-Value";
+            $value = ($ARGSRef->{"${arg}s-Magic"} and exists $ARGSRef->{"${arg}s"}) ? $ARGSRef->{$arg . "s"} : $ARGSRef->{$arg};
+        }
 
         next if defined $value and length $value;
 

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


More information about the Bps-public-commit mailing list