showing org info for noncats and sorting
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Sep 2006 16:01:50 +0000 (16:01 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Sep 2006 16:01:50 +0000 (16:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5834 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/fm_utils.js
Open-ILS/xul/staff_client/server/circ/checkout.js

index d988772..95c838a 100644 (file)
@@ -3,7 +3,7 @@ dump('entering util/fm_utils.js\n');
 if (typeof util == 'undefined') var util = {};
 util.fm_utils = {};
 
-util.fm_utils.EXPORT_OK        = [ 'flatten_ou_branch', 'find_ou', 'compare_aou_a_is_b_or_ancestor' ];
+util.fm_utils.EXPORT_OK        = [ 'flatten_ou_branch', 'find_ou', 'compare_aou_a_is_b_or_ancestor', 'sort_func_aou_by_depth_and_then_string' ];
 util.fm_utils.EXPORT_TAGS      = { ':all' : util.fm_utils.EXPORT_OK };
 
 util.fm_utils.flatten_ou_branch = function(branch) {
@@ -45,3 +45,23 @@ util.fm_utils.compare_aou_a_is_b_or_ancestor = function(a,b) {
        }
        return false;
 }
+
+util.fm_utils.sort_func_aou_by_depth_and_then_string = function(a,b) {
+       try {
+               JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+               var a_aou = a[0]; var b_aou = b[0];
+               var a_string = a[1]; var b_string = b[1];
+               if (typeof a_aou != 'object') a_aou = data.hash.aou[ a_aou ];
+               if (typeof b_aou != 'object') b_aou = data.hash.aou[ b_aou ];
+               var A = data.hash.aout[ a_aou.ou_type() ].depth();
+               var B = data.hash.aout[ b_aou.ou_type() ].depth();
+               if (A < B) return 1;
+               if (A > B) return -1;
+               if (a_string < b_string ) return -1;
+               if (a_string > b_string ) return 1;
+               return 0;
+       } catch(E) {
+               alert('error in util.fm_utils.sort_func_aou_by_depth_and_string: ' + E);
+               return 0;
+       }
+}
index 21f958a..dfe7632 100644 (file)
@@ -59,9 +59,23 @@ circ.checkout.prototype = {
                                                                                        function(o) {
                                                                                                return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
                                                                                        }
+                                                                               ).sort(
+
+                                                                                       function(a,b) {
+                                                                                               try { 
+                                                                                                       return util.fm_utils.sort_func_aou_by_depth_and_then_string(
+                                                                                                               [ a.owning_lib(), a.name() ],
+                                                                                                               [ b.owning_lib(), b.name() ]
+                                                                                                       );
+                                                                                               } catch(E) {
+                                                                                                       alert('error in noncat sorting: ' + E);
+                                                                                                       return 0;
+                                                                                               }
+                                                                                       }
+
                                                                                ),
                                                                                function(o) {
-                                                                                       return [ o.name(), o.id() ];
+                                                                                       return [ obj.data.hash.aou[ o.owning_lib() ].shortname() + ' : ' + o.name(), o.id() ];
                                                                                }
                                                                        )
                                                                );