JBAS-1379 Avoid dupe stat cats for stage users (WHD #5007215)
authorBill Erickson <berickxx@gmail.com>
Tue, 17 May 2016 17:31:04 +0000 (13:31 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Ensure at most one copy of each stat cat is represented when saving a
staged user.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/actor/user/register.js

index cc26a19..c245310 100644 (file)
@@ -2172,7 +2172,9 @@ function _uEditSave(doClone) {
                     val = w.attr('displayedValue');
                 }
 
+                var map_exists = false;
                 if(map) {
+                    map_exists = true;
                     if(map.stat_cat_entry() == val) 
                         break;
                     if(val == null) {
@@ -2191,10 +2193,16 @@ function _uEditSave(doClone) {
                 map.stat_cat(w._statcat);
                 map.stat_cat_entry(val);
                 map.target_usr(patron.id());
-                var t = patron.stat_cat_entries();
+
+                if (!map_exists) {
+                    // only add the stat cat to the list if it's not
+                    // already in the list.
+                    var t = patron.stat_cat_entries();
                     if (!t) { t = []; }
                     t.push(map);
                     patron.stat_cat_entries(t);
+                }
+
                 break;
         }
     }