[Rt-commit] r7076 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Mon Feb 26 09:44:33 EST 2007


Author: ruz
Date: Mon Feb 26 09:44:33 2007
New Revision: 7076

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm

Log:
 r4608 at cubic-pc (orig r7049):  ruz | 2007-02-22 18:09:51 +0300
 * fix autocompletion with multiple values on Create


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	Mon Feb 26 09:44:33 2007
@@ -390,26 +390,38 @@
             $create_args{$arg} = $ARGS{$arg};
         }
         # Object-RT::Ticket--CustomField-3-Values
-        elsif ($arg =~ /^Object-RT::Ticket--CustomField-(\d+)(.*?)$/) {
+        elsif ( $arg =~ /^Object-RT::Ticket--CustomField-(\d+)(.*?)$/ ) {
             my $cfid = $1;
-            my $cf = RT::CustomField->new( $session{'CurrentUser'});
-            $cf->Load($cfid);
 
-            if ( $cf->Type eq 'Freeform' && ! $cf->SingleValue) {
-                $ARGS{$arg} =~ s/\r\n/\n/g;
-                $ARGS{$arg} = [split('\n', $ARGS{$arg})];
+            my $cf = RT::CustomField->new( $session{'CurrentUser'} );
+            $cf->Load( $cfid );
+            unless ( $cf->id ) {
+                $RT::Logger->error( "Couldn't load custom field #". $cfid );
+                next;
             }
 
-            if ( $cf->Type =~ /text/i) { # Catch both Text and Wikitext
-                $ARGS{$arg} =~ s/\r//g;
+            if ( $arg =~ /-Upload$/ ) {
+                $create_args{"CustomField-$cfid"} = _UploadedFile( $arg );
+                next;
             }
 
-            if ( $arg =~ /-Upload$/ ) {
-                $create_args{"CustomField-".$cfid} = _UploadedFile($arg);
+            my $type = $cf->Type;
+
+            my @values = ();
+            if ( ref $ARGS{ $arg } eq 'ARRAY' ) {
+                @values = @{ $ARGS{ $arg } };
+            } elsif ( $type =~ /text/i ) {
+                @values = ($ARGS{ $arg });
+            } else {
+                @values = split /\n/, $ARGS{ $arg } || '';
             }
-            else {
-                $create_args{"CustomField-".$cfid} = $ARGS{"$arg"};
+        
+            if ( $type =~ /text/i || $type eq 'Freeform' ) {
+                s/\r//g foreach grep defined, @values;
             }
+            @values = grep defined && $_ ne '', @values;
+
+            $create_args{"CustomField-$cfid"} = \@values;
         }
     }
 
@@ -1234,7 +1246,7 @@
             @values = split /\n/, $args{'ARGS'}->{ $arg } || '';
         }
         
-        if ( ( $cf_type eq 'Freeform' && !$cf->SingleValue ) || $cf_type =~ /text/i ) {
+        if ( $cf_type eq 'Freeform' || $cf_type =~ /text/i ) {
             s/\r//g foreach grep defined, @values;
         }
         @values = grep defined && $_ ne '', @values;
@@ -1359,8 +1371,7 @@
     foreach my $key ( keys %$ARGSRef ) {
 
         # Delete deletable watchers
-        if ( ( $key =~ /^Ticket-DeleteWatcher-Type-(.*)-Principal-(\d+)$/ ) )
-        {
+        if ( $key =~ /^Ticket-DeleteWatcher-Type-(.*)-Principal-(\d+)$/ ) {
             my ( $code, $msg ) = $Ticket->DeleteWatcher(
                 PrincipalId => $2,
                 Type        => $1
@@ -1378,8 +1389,8 @@
         }
 
         # Add new wathchers by email address
-        elsif ( ( $ARGSRef->{$key} =~ /^(AdminCc|Cc|Requestor)$/ )
-            and ( $key =~ /^WatcherTypeEmail(\d*)$/ ) )
+        elsif ( ( $ARGSRef->{$key} || '' ) =~ /^(?:AdminCc|Cc|Requestor)$/
+            and $key =~ /^WatcherTypeEmail(\d*)$/ )
         {
 
             #They're in this order because otherwise $1 gets clobbered :/


More information about the Rt-commit mailing list