[Rt-commit] rt branch, 4.4/unique-custom-fields, updated. rt-4.4.0-230-g226865f

Shawn Moore shawn at bestpractical.com
Tue May 31 18:03:03 EDT 2016


The branch, 4.4/unique-custom-fields has been updated
       via  226865f301163a216b5a1a973d6a9595ff3e8b19 (commit)
      from  080f81f5850b67f850d9a8062b97adbed0715e3e (commit)

Summary of changes:
 share/html/Elements/ValidateCustomFields | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit 226865f301163a216b5a1a973d6a9595ff3e8b19
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue May 31 22:00:41 2016 +0000

    Check for uniqueness in ValidateCustomFields
    
        This improves the user experience by displaying the duplicate value
        error right alongside the CF input field

diff --git a/share/html/Elements/ValidateCustomFields b/share/html/Elements/ValidateCustomFields
index ac7e271..4c32c5c 100644
--- a/share/html/Elements/ValidateCustomFields
+++ b/share/html/Elements/ValidateCustomFields
@@ -98,12 +98,27 @@ while ( my $CF = $CustomFields->Next ) {
             }
         }
 
-        next if $CF->MatchPattern($value);
+        if (!$CF->MatchPattern($value)) {
+            my $msg = loc("Input must match [_1]", $CF->FriendlyPattern);
+            $m->notes( ('InvalidField-' . $CF->Id) => $msg );
+            push @res, $CF->Name .': '. $msg;
+            $valid = 0;
+        }
 
-        my $msg = loc("Input must match [_1]", $CF->FriendlyPattern);
-        $m->notes( ('InvalidField-' . $CF->Id) => $msg );
-        push @res, $CF->Name .': '. $msg;
-        $valid = 0;
+        if ($CF->UniqueValues) {
+            my $existing = RT::ObjectCustomFieldValue->new(RT->SystemUser);
+            $existing->LoadByCols(
+                CustomField  => $CF->Id,
+                Content      => $value,
+                Disabled     => 0,
+            );
+            if ($existing->Id) {
+                my $msg = loc("That is not a unique value");
+                $m->notes( ('InvalidField-' . $CF->Id) => $msg );
+                push @res, $CF->Name .': '. $msg;
+                $valid = 0;
+            }
+        }
     }
 }
 $m->notes('ValidFields', $valid);

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


More information about the rt-commit mailing list