From 3230e7022f65f44b1453ddbf5171d003f680bd0d Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 10 Aug 2006 16:30:31 +0000 Subject: [PATCH] added orig-location and org short-name support to opac git-svn-id: svn://svn.open-ils.org/ILS/trunk@5423 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/config.js | 1 + Open-ILS/web/opac/common/js/init.js | 17 ++++++++++++++-- Open-ILS/web/opac/common/js/opac_utils.js | 34 +++++++++++++++++++++++-------- Open-ILS/web/opac/common/js/org_utils.js | 11 ++++++++++ 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index 4ad57ec1e0..bc86fe9f95 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -331,6 +331,7 @@ var FETCH_CIRC_BY_ID = 'open-ils.circ:open-ils.circ.retrieve'; var FETCH_MR_DESCRIPTORS = 'open-ils.search:open-ils.search.metabib.record_to_descriptors'; var FETCH_HIGHEST_PERM_ORG = 'open-ils.actor:open-ils.actor.user.perm.highest_org.batch'; var FETCH_USER_NOTES = 'open-ils.actor:open-ils.actor.note.retrieve.all'; +var FETCH_ORG_BY_SHORTNAME = 'open-ils.actor:open-ils.actor.org_unit.retrieve_by_shorname'; /* ---------------------------------------------------------------------------- */ diff --git a/Open-ILS/web/opac/common/js/init.js b/Open-ILS/web/opac/common/js/init.js index c1661c9e2c..ea349b6296 100644 --- a/Open-ILS/web/opac/common/js/init.js +++ b/Open-ILS/web/opac/common/js/init.js @@ -4,7 +4,7 @@ window.onunload = windowUnload; attachEvt("common", "init", loadUIObjects); -attachEvt("common", "init", initParams); +//attachEvt("common", "init", initParams); attachEvt("common", "init", initCookies); attachEvt("common", "unload", _tree_killer); @@ -12,8 +12,21 @@ try{ attachEvt("common", "unload", cleanRemoteRequests);} catch(e){} function init() { + initParams(); + + if( getLocation() == null && getOrigLocation() != null ) + LOCATION = getOrigLocation(); + + if( getLocation() == null && getOrigLocation() == null ) + LOCATION = globalOrgTree.id(); + + if( getLocation() != null && getOrigLocation() == null ) + ORIGLOC = getLocation(); + + if(getDepth() == null) DEPTH = findOrgDepth(getLocation()); + + runEvt('common','init'); - if( getOrigLocation() == 0 ) ORIGLOC = LOCATION; var cgi = new CGI(); if( grabUser() ) { diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index 37dfefbeb2..6de3ba38fe 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -90,12 +90,32 @@ function findCurrentPage() { function initParams() { var cgi = new CGI(); + /* handle the location var */ + var org; + var loc = cgi.param(PARAM_LOCATION); + if( loc ) { + org = findOrgUnit(loc); + if(!org) org = findOrgUnitSN(loc); + } + LOCATION = (org) ? org.id() : null; + + org = null; + loc = cgi.param(PARAM_ORIGLOC); + if( loc ) { + org = findOrgUnit(loc); + if(!org) org = findOrgUnitSN(loc); + } + ORIGLOC = (org) ? org.id() : null; + + + DEPTH = parseInt(cgi.param(PARAM_DEPTH)); + if(isNaN(DEPTH)) DEPTH = null; + + TERM = cgi.param(PARAM_TERM); STYPE = cgi.param(PARAM_STYPE); FORM = cgi.param(PARAM_FORM); - LOCATION = parseInt(cgi.param(PARAM_LOCATION)); - ORIGLOC = parseInt(cgi.param(PARAM_ORIGLOC)); - DEPTH = parseInt(cgi.param(PARAM_DEPTH)); + //DEPTH = parseInt(cgi.param(PARAM_DEPTH)); OFFSET = parseInt(cgi.param(PARAM_OFFSET)); COUNT = parseInt(cgi.param(PARAM_COUNT)); HITCOUNT = parseInt(cgi.param(PARAM_HITCOUNT)); @@ -119,15 +139,13 @@ function initParams() { RDEPTH = cgi.param(PARAM_RDEPTH); /* set up some sane defaults */ - if(isNaN(LOCATION)) LOCATION = 1; - if(isNaN(DEPTH)) DEPTH = 0; + //if(isNaN(DEPTH)) DEPTH = 0; if(isNaN(RDEPTH)) RDEPTH = 0; if(isNaN(OFFSET)) OFFSET = 0; if(isNaN(COUNT)) COUNT = 10; if(isNaN(HITCOUNT)) HITCOUNT = 0; if(isNaN(MRID)) MRID = 0; if(isNaN(RID)) RID = 0; - //if(isNaN(ORIGLOC)) ORIGLOC = 1; if(isNaN(ORIGLOC)) ORIGLOC = 0; /* so we know it hasn't been set */ if(isNaN(AUTHTIME)) AUTHTIME = 0; if(ADVTERM==null) ADVTERM = ""; @@ -653,8 +671,8 @@ function doLogout(noredirect) { var args = {}; args[PARAM_TERM] = ""; - args[PARAM_LOCATION] = globalOrgTree.id(); - args[PARAM_DEPTH] = findOrgDepth(globalOrgTree); + args[PARAM_LOCATION] = getOrigLocation(); + args[PARAM_DEPTH] = findOrgDepth(getOrigLocation()); args.page = "home"; diff --git a/Open-ILS/web/opac/common/js/org_utils.js b/Open-ILS/web/opac/common/js/org_utils.js index 5714d503f7..f86afca2f2 100644 --- a/Open-ILS/web/opac/common/js/org_utils.js +++ b/Open-ILS/web/opac/common/js/org_utils.js @@ -38,6 +38,17 @@ function findOrgUnit(org_id) { return (typeof org_id == 'object') ? org_id : orgArraySearcher[org_id]; } +var orgArraySearcherSN = {}; +function findOrgUnitSN(shortname) { + if (typeof shortname == 'object') return shortname; + if( orgArraySearcherSN[shortname] ) return orgArraySearcherSN[shortname]; + _debug("fetching org by shortname "+shortname); + var req = new Request(FETCH_ORG_BY_SHORTNAME, shortname); + req.request.alertEvent = false; + req.send(true); + return req.result(); +} + /* builds a trail from the top of the org tree to the node provide. basically fleshes out 'my orgs' -- 2.11.0