sort the attr defs by label. better handle events on the startup calls
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Sep 2008 02:22:39 +0000 (02:22 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Sep 2008 02:22:39 +0000 (02:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10516 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/vandelay/vandelay.js

index 652bb3d..ccf72c6 100644 (file)
@@ -61,12 +61,19 @@ function vlInit() {
             params: [authtoken, {id:{'!=':null}}],
             onresponse: function(r) {
                 var def = r.recv().content(); 
-                if(openils.Event.parse(def)) 
-                    return alert(def);
+                if(e = openils.Event.parse(def[0])) 
+                    return alert(e);
                 bibAttrDefs.push(def);
             },
             oncomplete: function() {
                 bibAttrsFetched = true;
+                bibAttrDefs = bibAttrDefs.sort(
+                    function(a, b) {
+                        if(a.description() > b.description()) return 1;
+                        if(a.description() < b.description()) return -1;
+                        return 0;
+                    }
+                );
                 if(authAttrsFetched) 
                     runStartupCommands();
             }
@@ -79,12 +86,19 @@ function vlInit() {
             params: [authtoken, {id:{'!=':null}}],
             onresponse: function(r) {
                 var def = r.recv().content(); 
-                if(openils.Event.parse(def)) 
-                    return alert(def);
+                if(e = openils.Event.parse(def[0])) 
+                    return alert(e);
                 authAttrDefs.push(def);
             },
             oncomplete: function() {
                 authAttrsFetched = true;
+                authAttrDefs = authAttrDefs.sort(
+                    function(a, b) {
+                        if(a.description() > b.description()) return 1;
+                        if(a.description() < b.description()) return -1;
+                        return 0;
+                    }
+                );
                 if(bibAttrsFetched) 
                     runStartupCommands();
             }