backport workstation registration bugfix so that an incorrect org doesn't show up...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 29 Aug 2007 14:50:50 +0000 (14:50 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 29 Aug 2007 14:50:50 +0000 (14:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@7733 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/main/ws_info.xul

index 61abbd5..037975b 100644 (file)
                                g.aout_hash[ g.aout_list[i].id() ] = g.aout_list[i];
                        }
 
-                       //g.my_libs = g.network.simple_request(
-                       //      'FM_AOU_RETRIEVE_RELATED_VIA_SESSION',
-                       //      [ xulG.auth.session.key ]
-                       //);
-
                        var highest_org_id = g.network.simple_request(
                                'PERM_RETRIEVE_HIGHEST_ORG',
                                [ xulG.auth.session.key, g.user.id(), 'REGISTER_WORKSTATION']
                                g.my_libs_shortname_hash[ g.my_libs[i].id() ] = g.my_libs[i].shortname();
                                g.my_libs_ou_hash[ g.my_libs[i].id() ] = function(o){return o;}(g.my_libs[i]);
                        }
-                       /*
-                       for (var i = 0; i < g.my_libs.length; i++) {
-                               var p = g.my_libs[i].parent_ou();
-                               if (!p) {
-                                       g.my_libs_tree = function(o){return o;}(g.my_libs_ou_hash[g.my_libs[i].id()]);
-                               } else {
-                                       p = g.my_libs_ou_hash[ p ];
-                                       var c = p.children();
-                                       if (!c) c = [];
-                                       c.push( function(o){return o;}(g.my_libs[i]) );
-                                       c = c.sort(
-                                               function( a, b ) {
-                                                       if (a.shortname() < b.shortname()) return -1;
-                                                       if (a.shortname() > b.shortname()) return 1;
-                                                       return 0;
-                                               }
-                                       );
-                                       p.children( c );
-                               }
-                       }
-                       */
 
                        g.tb = document.getElementById('wsname');
 
                        var x = document.getElementById('placeholder');
                        util.widgets.remove_children( x );
 
+                       var default_lib = g.my_lib; 
+                       if ( !get_bool( g.aout_hash[ g.my_libs_ou_hash[ default_lib ].ou_type() ].can_have_users() ) ) {
+                               default_lib = null;
+                       }
+
                        g.ml = util.widgets.make_menulist( 
                                util.functional.map_list( 
                                        util.fm_utils.flatten_ou_branch( g.my_libs_tree ),
-                                       function(obj) { return [ 
-                                               obj.shortname(), 
-                                               obj.id(), 
-                                               ( !get_bool( g.aout_hash[ obj.ou_type() ].can_have_users() ) ),
-                                               ( g.aout_hash[ obj.ou_type() ].depth() ),
-                                       ]; }
+                                       function(obj) { 
+                                               if (!default_lib) {
+                                                       if ( get_bool( g.aout_hash[ obj.ou_type() ].can_have_users() ) ) default_lib = obj.id();
+                                               }
+                                               return [ 
+                                                       obj.shortname(), 
+                                                       obj.id(), 
+                                                       ( !get_bool( g.aout_hash[ obj.ou_type() ].can_have_users() ) ),
+                                                       ( g.aout_hash[ obj.ou_type() ].depth() ),
+                                               ]; 
+                                       }
                                ),
-                               g.my_lib
+                               default_lib
                        );
 
                        x.appendChild( g.ml );