From: erickson Date: Wed, 9 Aug 2006 13:11:52 +0000 (+0000) Subject: added default search location and depth preference X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=33dc5d7d2b630ecd295baebf5887b540bfdfffb9;p=Evergreen.git added default search location and depth preference git-svn-id: svn://svn.open-ils.org/ILS/trunk@5401 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index d656bbd810..4ad57ec1e0 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -130,6 +130,8 @@ var LOGOUT_WARNING_TIME = 30; /* "head up" for session timeout */ var PREF_HITS_PER = 'opac.hits_per_page'; var PREF_DEF_FONT = 'opac.default_font'; var PREF_HOLD_NOTIFY = 'opac.hold_notify'; +var PREF_DEF_LOCATION = 'opac.default_search_location'; +var PREF_DEF_DEPTH = 'opac.default_search_depth'; /* container for global variables shared accross pages */ diff --git a/Open-ILS/web/opac/common/js/init.js b/Open-ILS/web/opac/common/js/init.js index 28a2242be0..2fd2edaea3 100644 --- a/Open-ILS/web/opac/common/js/init.js +++ b/Open-ILS/web/opac/common/js/init.js @@ -12,15 +12,20 @@ try{ attachEvt("common", "unload", cleanRemoteRequests);} catch(e){} function init() { - runEvt('common','init'); if( getOrigLocation() == 0 ) ORIGLOC = LOCATION; var cgi = new CGI(); if( grabUser() ) { if( cgi.param(PARAM_LOCATION) == null ) { - LOCATION = G.user.ws_ou(); - DEPTH = findOrgDepth(G.user.ws_ou()); + var org = G.user.prefs[PREF_DEF_LOCATION]; + var depth = G.user.prefs[PREF_DEF_DEPTH]; + + if(!org) org = G.use.ws_ou(); + if(!depth) depth = findOrgDepth(org); + + LOCATION = org; + DEPTH = DEPTH; } } diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js index a1bec6fb4f..0c71e80992 100644 --- a/Open-ILS/web/opac/skin/default/js/myopac.js +++ b/Open-ILS/web/opac/skin/default/js/myopac.js @@ -578,6 +578,9 @@ function myOPACSavePrefs() { G.user.prefs[PREF_HITS_PER] = getSelectorVal($('prefs_hits_per')); G.user.prefs[PREF_DEF_FONT] = getSelectorVal($('prefs_def_font')); G.user.prefs[PREF_HOLD_NOTIFY] = getSelectorVal($('prefs_hold_notify')); + G.user.prefs[PREF_DEF_LOCATION] = getSelectorVal($('prefs_def_location')); + G.user.prefs[PREF_DEF_DEPTH] = getSelectorVal($('prefs_def_range')); + if(commitUserPrefs()) alert($('prefs_update_success').innerHTML); else alert($('prefs_update_failure').innerHTML); @@ -614,9 +617,45 @@ function myOPACShowPrefs() { myOPACShowHitsPer(); myOPACShowDefFont(); myOPACShowHoldNotify(); + myOPACShowDefLocation(); hideMe($('myopac_prefs_loading')); } +var defSearchLocationDrawn = false; +var defDepthIndex = 0; +function myOPACShowDefLocation() { + + var selector = $('prefs_def_location'); + var rsel = $('prefs_def_range'); + + var org = G.user.prefs[PREF_DEF_LOCATION]; + if(!org) org = G.user.home_ou(); + + if(!defSearchLocationDrawn) { + defSearchLocationDrawn = true; + buildOrgSel(selector, globalOrgTree, 0); + + globalOrgTypes = globalOrgTypes.sort( + function(a, b) { + if( a.depth() < b.depth() ) return -1; + return 1; + } + ); + + iterate(globalOrgTypes, + function(t) { + if( t.depth() <= findOrgDepth(org) ) { + setSelectorVal(rsel, defDepthIndex++, t.opac_label(), t.depth()); + if( t.depth() == findOrgDepth(org) ) + setSelector(rsel, t.depth()); + } + } + ); + } + + setSelector(selector, org); +} + function myOPACShowHitsPer() { var hits = 10; if(G.user.prefs[PREF_HITS_PER]) diff --git a/Open-ILS/web/opac/skin/default/js/sidebar.js b/Open-ILS/web/opac/skin/default/js/sidebar.js index d70d0260ce..fb7e2c5b59 100644 --- a/Open-ILS/web/opac/skin/default/js/sidebar.js +++ b/Open-ILS/web/opac/skin/default/js/sidebar.js @@ -80,7 +80,15 @@ function loggedInOK() { unHideMe(G.ui.sidebar.logged_in_as); hideMe(G.ui.sidebar.loginbox); runEvt( 'common', 'loggedIn'); - runEvt( "common", "locationChanged", G.user.home_ou(), findOrgDepth(G.user.home_ou()) ); + + var org = G.user.prefs[PREF_DEF_LOCATION]; + if(!org) org = G.user.home_ou(); + + var depth = G.user.prefs[PREF_DEF_DEPTH]; + if(! ( depth && depth <= findOrgDepth(org)) ) + depth = findOrgDepth(org); + + runEvt( "common", "locationChanged", org, depth); } diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml index 055927643f..431cd1175b 100644 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml +++ b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml @@ -56,6 +56,24 @@ + + Default Search Location + + + + + + + Default Search Range + + + + + + +