From 47ded788a4aed141141950c3163beb9651acf1ce Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 16 Aug 2007 19:49:04 +0000 Subject: [PATCH] Don't let the menu default to an org that can't have users, regardless of the home_ou (soon work_ou) for the staff registering the workstation git-svn-id: svn://svn.open-ils.org/ILS/trunk@7690 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/main/ws_info.xul | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/main/ws_info.xul b/Open-ILS/xul/staff_client/server/main/ws_info.xul index 61abbd5fc3..037975b2d1 100644 --- a/Open-ILS/xul/staff_client/server/main/ws_info.xul +++ b/Open-ILS/xul/staff_client/server/main/ws_info.xul @@ -74,11 +74,6 @@ 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'] @@ -105,27 +100,6 @@ 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'); @@ -142,17 +116,27 @@ 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 ); -- 2.43.2