added orig-location and org short-name support to opac
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 10 Aug 2006 16:30:31 +0000 (16:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 10 Aug 2006 16:30:31 +0000 (16:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5423 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/init.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/common/js/org_utils.js

index 4ad57ec..bc86fe9 100644 (file)
@@ -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';
 
 /* ---------------------------------------------------------------------------- */
 
index c1661c9..ea349b6 100644 (file)
@@ -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() ) {
index 37dfefb..6de3ba3 100644 (file)
@@ -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";
 
        
index 5714d50..f86afca 100644 (file)
@@ -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'