adding some copy loc handling code
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 26 Jun 2008 22:09:57 +0000 (22:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 26 Jun 2008 22:09:57 +0000 (22:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9943 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/CopyLocation.js [new file with mode: 0644]

diff --git a/Open-ILS/web/js/dojo/openils/CopyLocation.js b/Open-ILS/web/js/dojo/openils/CopyLocation.js
new file mode 100644 (file)
index 0000000..28c6619
--- /dev/null
@@ -0,0 +1,54 @@
+/* ---------------------------------------------------------------------------
+ * Copyright (C) 2008  Georgia Public Library Service
+ * Author: Bill Erickson <erickson@esilibrary.com>
+ *
+ * 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]);
+    }
+}
+