Mark invalid home ous as such in patron editor
authorThomas Berezansky <tsbere@mvlc.org>
Fri, 10 Jun 2011 13:22:56 +0000 (09:22 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 10 Jun 2011 15:49:39 +0000 (11:49 -0400)
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/actor/user/register.js

index c0afaa6..12ee21e 100644 (file)
@@ -45,6 +45,7 @@ var stageUser;
 var optInSettings;
 var allCardsTemplate;
 var uEditCloneCopyAddr; // if true, copy addrs on clone instead of link
+var homeOuTypes = {};
 
 var dupeUsrname = false;
 var dupeBarcode = false;
@@ -197,6 +198,12 @@ function load() {
         fieldDoc[doc.fm_class()][doc.field()] = doc;
     }
 
+    list = pcrud.search('aout', {can_have_users: 'true'});
+    for(var i in list) {
+        var type = list[i];
+        homeOuTypes[type.id()] = true;
+    }
+
     tbody = dojo.byId('uedit-tbody');
 
     if(orgSettings['ui.patron.edit.default_suggested'])
@@ -1065,6 +1072,15 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
                 return;
 
             case 'home_ou':
+                widget.widget.isValid = function() {
+                    if(this.item) {
+                        if(homeOuTypes[this.store.getValue(this.item, 'ou_type')]) {
+                            return true;
+                        }
+                        return false;
+                    }
+                    return true;
+                };
                 dojo.connect(widget.widget, 'onChange',
                     function(newVal) { 
                         checkClaimsReturnCountPerm();