LP#1564685 Avoid dupe usrname warning on matching patron
authorBill Erickson <berickxx@gmail.com>
Thu, 24 Mar 2016 01:21:12 +0000 (21:21 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 4 Apr 2016 20:31:26 +0000 (16:31 -0400)
Do not treat usernames as duplicates when they belong to the patron
being edited.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index ae7838e..c68a20d 100644 (file)
@@ -125,6 +125,16 @@ angular.module('egCoreMod')
     }
 
     service.check_dupe_username = function(usrname) {
+
+        // empty usernames can't be dupes
+        if (!usrname) return $q.when(false);
+
+        // avoid dupe check if username matches the originally loaded usrname
+        if (service.existing_patron) {
+            if (usrname == service.existing_patron.usrname())
+                return $q.when(false);
+        }
+
         return egCore.net.request(
             'open-ils.actor',
             'open-ils.actor.username.exists',
@@ -573,6 +583,8 @@ angular.module('egCoreMod')
      */
     service.init_existing_patron = function(current) {
 
+        service.existing_patron = current;
+
         var patron = egCore.idl.toHash(current);
 
         patron.home_ou = egCore.org.get(patron.home_ou.id);