From 265cff2b53bfb10d1fd98226dffa46936043c60a Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 26 Jun 2008 22:09:57 +0000 Subject: [PATCH] adding some copy loc handling code git-svn-id: svn://svn.open-ils.org/ILS/trunk@9943 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/CopyLocation.js | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Open-ILS/web/js/dojo/openils/CopyLocation.js diff --git a/Open-ILS/web/js/dojo/openils/CopyLocation.js b/Open-ILS/web/js/dojo/openils/CopyLocation.js new file mode 100644 index 0000000000..28c6619f4b --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/CopyLocation.js @@ -0,0 +1,54 @@ +/* --------------------------------------------------------------------------- + * Copyright (C) 2008 Georgia Public Library Service + * Author: Bill Erickson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * --------------------------------------------------------------------------- + */ + +if(!dojo._hasResource["openils.CopyLocation"]) { + + dojo._hasResource["openils.CopyLocation"] = true; + dojo.provide("openils.CopyLocation"); + dojo.declare('openils.CopyLocation', null, { + }); + + openils.CopyLocation.cache = {}; + openils.CopyLocation.storeCache = {}; + + openils.CopyLocation.createStore = function(focusOrg, onload, nocache) { + if(!nocache && openils.CopyLocation.storeCache[focusOrg]) + return onload(openils.CopyLocation.storeCache[focusOrg]); + function mkStore(r) { + var locs = r.recv().content(); + for(var i = 0; i < locs.length; i++) + openils.CopyLocation.cache[locs[i].id()] = locs[i]; + openils.CopyLocation.storeCache[focusOrg] = acpl.toStoreData(locs); + onload(openils.CopyLocation.storeCache[focusOrg]); + } + fieldmapper.standardRequest( + ['open-ils.circ', 'open-ils.circ.copy_location.retrieve.all'], + { async: true, + params: [focusOrg], + oncomplete: mkStore + } + ); + } + + openils.CopyLocation.retrieve = function(id) { + if(openils.CopyLocation.cache[id]) + return openils.CopyLocation.cache[id]; + return openils.CopyLocation.cache[id] = + fieldmapper.standardRequest( + ['open-ils.circ', 'open-ils.circ.copy_location.retrieve'], [id]); + } +} + -- 2.43.2