From f6c3dc8501ff653666e0ed7b451f12d835a78ac0 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 8 Aug 2005 16:03:15 +0000 Subject: [PATCH] moved org_utils into opac_utils git-svn-id: svn://svn.open-ils.org/ILS/trunk@1625 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/javascript/lib/js/opac/opac_utils.js | 46 +++++++++++++- .../src/javascript/lib/js/opac/org_utils.js | 62 ------------------- 2 files changed, 45 insertions(+), 63 deletions(-) delete mode 100644 Open-ILS/src/javascript/lib/js/opac/org_utils.js diff --git a/Open-ILS/src/javascript/lib/js/opac/opac_utils.js b/Open-ILS/src/javascript/lib/js/opac/opac_utils.js index 2e875e0795..2fdbde16a4 100644 --- a/Open-ILS/src/javascript/lib/js/opac/opac_utils.js +++ b/Open-ILS/src/javascript/lib/js/opac/opac_utils.js @@ -311,8 +311,52 @@ function orgSelect(id) { } +/* ------------------------------------------------------------------------------------------------------ */ +/* org tree utilities */ +/* ------------------------------------------------------------------------------------------------------ */ + +/* takes an org unit or id and return the numeric depth */ +function findOrgDepth(org_id_or_node) { + return findOrgType(findOrgUnit(org_id_or_node).ou_type()).depth(); +} + +/* takes the org type id from orgunit.ou_type() field and returns + the org type object */ +function findOrgType(type_id) { + if(typeof type_id == 'object') return type_id; + for(var type in globalOrgTypes) { + var t =globalOrgTypes[type]; + if( t.id() == type_id || t.id() == parseInt(type_id) ) + return t; + } + return null; +} + + +/* returns an org unit by id. if an object is passed in as the id, + then the object is assumed to be an org unit and is returned */ +function findOrgUnit(org_id) { + return (typeof org_id == 'object') ? org_id : orgArraySearcher[org_id]; +} + + +/* builds a trail from the top of the org tree to the node provide. + basically fleshes out 'my orgs' + Returns an array of [org0, org1, ..., myorg] */ +function orgNodeTrail(node) { + var na = new Array(); + while( node ) { + na.push(node); + node = findOrgUnit(node.parent_ou()); + } + return na.reverse(); +} + + +/* returns an array of sibling org units */ +function findSiblingOrgs(node) { return findOrgUnit(node.parent_ou()).children(); } +/* ------------------------------------------------------------------------------------------------------ */ -/* ----------------------------------------------------------------------- */ diff --git a/Open-ILS/src/javascript/lib/js/opac/org_utils.js b/Open-ILS/src/javascript/lib/js/opac/org_utils.js deleted file mode 100644 index fb5e1dcca5..0000000000 --- a/Open-ILS/src/javascript/lib/js/opac/org_utils.js +++ /dev/null @@ -1,62 +0,0 @@ -/* takes an org unit or id and return the numeric depth */ -function findOrgDepth(org_id_or_node) { - - if(org_id_or_node == null || globalOrgTypes == null) - return null; - - var org = findOrgUnit(org_id_or_node); - - var t = findOrgType(org.ou_type()); - if(t != null) return t.depth(); - - return null; -} - -/* takes the org type id from orgunit.ou_type() field and returns - the org type object */ -function findOrgType(type_id) { - - if(type_id == null || globalOrgTypes == null) - return null; - - if(typeof type_id == 'object') - return type_id; - - for(var type in globalOrgTypes) { - var t =globalOrgTypes[type]; - if( t.id() == type_id || t.id() == parseInt(type_id) ) - return t; - } - return null; -} - - -/* returns an org unit by id. if an object is passed in as the id, - then the object is assumed to be an org unit and is returned */ -function findOrgUnit(org_id) { - if(org_id == null) return null; - if(typeof org_id == 'object') return org_id; - return orgArraySearcher[org_id]; -} - - -/* builds a trail from the top of the org tree to the node provide. - basically fleshes out 'my orgs' - Returns an array of [org0, org1, ..., myorg] - */ -function orgNodeTrail(node) { - var nodeArray = new Array(); - while( node ) { - nodeArray.push(node); - node = findOrgUnit(node.parent_ou()); - } - nodeArray = nodeArray.reverse(); - return nodeArray; -} - - -/* returns an array of sibling org units */ -function findSiblingOrgs(node) { - return findOrgUnit(node.parent_ou()).children(); -} - -- 2.43.2