From: erickson Date: Mon, 19 May 2008 16:23:35 +0000 (+0000) Subject: adding general PO js X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b631c832752d0a18f38bac553e9d8007c17ad564;p=Evergreen.git adding general PO js git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9640 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/dojo/openils/acq/PO.js b/Open-ILS/web/js/dojo/openils/acq/PO.js new file mode 100644 index 0000000000..f536a6b6d7 --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/acq/PO.js @@ -0,0 +1,54 @@ +/* --------------------------------------------------------------------------- + * Copyright (C) 2008 Georgia Public Library Service + * 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.acq.PO']) { + + dojo._hasResource['openils.acq.PO'] = true; + dojo.provide('openils.acq.PO'); + dojo.require('fieldmapper.Fieldmapper'); + dojo.require('fieldmapper.dojoData'); + + /** Declare the PO class with dojo */ + dojo.declare('openils.acq.PO', null, { + /* add instance methods here if necessary */ + }); + + openils.acq.PO.cache = {}; + + openils.acq.PO.retrieve = function(id, oncomplete) { + + var req = ['open-ils.acq', 'open-ils.acq.purchase_order.retrieve']; + var par = [openils.User.authtoken, id]; + + if(oncomplete) { + fieldmapper.standardRequest( + req, + { params:par, + oncomplete:function(r) { + var po = r.recv().content(); + openils.acq.PO.cache[po.id()] = po; + oncomplete(po); + } + } + ); + } else { + return openils.acq.PO.cache[po.id()] = + fieldmapper.standardRequest(req, par); + } + } +}; + +