Vandelay: repair item attr context org selector
authorBill Erickson <berick@esilibrary.com>
Fri, 19 Aug 2011 19:50:22 +0000 (15:50 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 19 Aug 2011 19:50:22 +0000 (15:50 -0400)
1. Prevents resetting the context selector to the workstation org unit
each time it's changed.

2. Prevent the unintentional pileup of dojo.connect() events, which
can lead to exponential growth in the number of server calls to fetch
import-item-attribute-definitions with each change of the context org
selector.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/vandelay/vandelay.js

index fbca54e..3d6f019 100644 (file)
@@ -1690,23 +1690,30 @@ function buildProfileGrid() {
 /* --- Import Item Attr Grid --------------- */
 
 var itemAttrContextOrg;
+var itemAttrGridFirstTime = true;
 function vlShowImportItemAttrEditor() {
     displayGlobalDiv('vl-item-attr-editor-div');
-    buildImportItemAttrGrid();
 
-    var connect = function() {
-        dojo.connect(itemAttrContextOrgSelector, 'onChange',
-            function() {
-                itemAttrContextOrg = this.attr('value');
-                itemAttrGrid.resetStore();
-                vlShowImportItemAttrEditor();
-            }
-        );
-    };
+    if (itemAttrGridFirstTime) {
 
-    new openils.User().buildPermOrgSelector(
-        'ADMIN_IMPORT_ITEM_ATTR_DEF', 
-            itemAttrContextOrgSelector, null, connect);
+        buildImportItemAttrGrid();
+
+        var connect = function() {
+            dojo.connect(itemAttrContextOrgSelector, 'onChange',
+                function() {
+                    itemAttrContextOrg = this.attr('value');
+                    itemAttrGrid.resetStore();
+                    buildImportItemAttrGrid();
+                }
+            );
+        };
+
+        new openils.User().buildPermOrgSelector(
+            'ADMIN_IMPORT_ITEM_ATTR_DEF', 
+                itemAttrContextOrgSelector, null, connect);
+
+        itemAttrGridFirstTime = false;
+    }
 }
 
 function buildImportItemAttrGrid() {