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:50:13 +0000 (11:50 -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 3d4125b..3832c97 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;
@@ -118,6 +119,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');
 
     addrTemplateRows = dojo.query('tr[type=addr-template]', tbody);
@@ -919,6 +926,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();