sort the children of each aou in the tree by shortname
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Jun 2007 14:56:49 +0000 (14:56 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Jun 2007 14:56:49 +0000 (14:56 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@7399 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js

index 3685ce0..a9ebff4 100644 (file)
@@ -92,6 +92,19 @@ OpenILS.data.prototype = {
 
                                        // Convert soft path to object reference.  Error if any but the last node is undefined
                                        for (var i in path_list) stash = stash[ path_list[i] ];
+
+                                       /*
+
+                                       // experiment with storing only json in cache to avoid the [ ] -> { '0' : .., '1' : .. } bug
+
+                                       if (stash[observed_prop] && getKeys( obj.observers.cache[ full_path ] ).length == 0) {
+                                               stash['_' + observed_prop] = js2JSON(stash[observed_prop]);
+                                       }
+
+                                       stash.__defineSetter__(observed_prop, function(x) { this['_'+observed_prop] = js2JSON(x); });
+                                       stash.__defineGetter__(observed_prop, function() { return JSON2js(this['_'+observed_prop]); });
+                                       */
+
                                        stash.watch(
                                                observed_prop,
                                                function(p,old_value,new_value) {
@@ -596,6 +609,19 @@ OpenILS.data.prototype = {
                        function () {
                                obj.tree.aou = obj.list.aou;
                                obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
+                               for (var i = 0; i < obj.list.aou.length; i++) {
+                                       var c = obj.list.aou[i].children();
+                                       if (!c) c = [];
+                                       c = c.sort(
+                                               function( a, b ) {
+                                                       if (a.shortname() < b.shortname()) return -1;
+                                                       if (a.shortname() > b.shortname()) return 1;
+                                                       return 0;
+                                               }
+                                       );
+                                       obj.list.aou[i].children( c );
+                               }
+                               obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
                                obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
                        }
                );