LP#1564685 Prevent linked address edit on reload
authorBill Erickson <berickxx@gmail.com>
Sat, 2 Apr 2016 22:11:12 +0000 (18:11 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 4 Apr 2016 20:36:35 +0000 (16:36 -0400)
Prevent editing of linked addresses when a user is loaded after the
clone operation.

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 437c401..69577d3 100644 (file)
@@ -67,6 +67,23 @@ angular.module('egCoreMod')
         });
     }
 
+    // When editing a user with addresses linked to other users, fetch
+    // the linked user(s) so we can display their names and edit links.
+    service.get_linked_addr_users = function(addrs) {
+        angular.forEach(addrs, function(addr) {
+            if (addr.usr == service.existing_patron.id()) return;
+            egCore.pcrud.retrieve('au', addr.usr)
+            .then(function(usr) {
+                addr._linked_owner_id = usr.id();
+                addr._linked_owner = service.format_name(
+                    usr.family_name(),
+                    usr.first_given_name(),
+                    usr.second_given_name()
+                );
+            })
+        });
+    }
+
     service.apply_secondary_groups = function(user_id, group_ids) {
         return egCore.net.request(
             'open-ils.actor',
@@ -611,6 +628,8 @@ angular.module('egCoreMod')
         angular.forEach(patron.addresses, 
             function(addr) { service.ingest_address(patron, addr) });
 
+        service.get_linked_addr_users(patron.addresses);
+
         // Remove stat cat entries that link to out-of-scope stat
         // cats.  With this, we avoid unnecessarily updating (or worse,
         // modifying) stat cat values that are not ours to modify.