From 9dc2d018b2eb365590f486fb5da45e3170cf861f Mon Sep 17 00:00:00 2001 From: djfiander Date: Mon, 28 Apr 2008 01:32:44 +0000 Subject: [PATCH] Functioning Picklist grid. TODO: use vendor names, not indices, and hook up line item detail display git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9463 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/acq/Picklist.js | 97 +++++++++++++--------- .../templates/oils/default/acq/picklist/view.html | 71 ++++++++++++---- 2 files changed, 111 insertions(+), 57 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/acq/Picklist.js b/Open-ILS/web/js/dojo/openils/acq/Picklist.js index ad318944c1..de6710aa61 100644 --- a/Open-ILS/web/js/dojo/openils/acq/Picklist.js +++ b/Open-ILS/web/js/dojo/openils/acq/Picklist.js @@ -1,52 +1,71 @@ +/* --------------------------------------------------------------------------- + * Copyright (C) 2008 Georgia Public Library Service + * David J. Fiander + * + * 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.Picklist']) { dojo._hasResource['openils.acq.Picklist'] = true; dojo.provide('openils.acq.Picklist'); -dojo.require('util.Dojo'); + +dojo.require('fieldmapper.Fieldmapper'); /** Declare the Picklist class with dojo */ dojo.declare('openils.acq.Picklist', null, { /* add instance methods here if necessary */ }); - openils.acq.Picklist.find_attr = function(li, at_name, at_type) { - for (var i in li.attributes()) { - var attr = li.attributes()[i]; - if (attr.attr_type() == at_type && attr.attr_name() == at_name) { - return attr.attr_value(); - } +openils.acq.Picklist.cache = {}; + +openils.acq.Picklist.createStore = function(pl_id, onComplete) { + // Fetches the list of titles in a picklist and builds a grid + + function mkStore(r) { + var msg; + var items = []; + while (msg = r.recv()) { + var data = msg.content(); + openils.acq.Picklist.cache[data.id()] = data; + + items.push(data); + } + onComplete(jub.toStoreData(items)); + } + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.lineitem.picklist.retrieve'], + { async: true, + params: [openils.User.authtoken, pl_id, {flesh_attrs:1}], + oncomplete: mkStore + }); +}; + +openils.acq.Picklist.find_attr = function(id, at_name, at_type) { + var li = openils.acq.Picklist.cache[id]; + for (var i in li.attributes()) { + var attr = li.attributes()[i]; + if (attr.attr_type() == at_type && attr.attr_name() == at_name) { + return attr.attr_value(); } - return ''; - }; - - - openils.acq.Picklist.loadGrid = function(domId, columns, pl_id) { - /** Fetches the list of picklists and builds a grid from them */ - - var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true); - var ses = new OpenSRF.ClientSession('open-ils.acq'); - var req = ses.request('open-ils.acq.lineitem.picklist.retrieve', - openils.User.authtoken, pl_id, {flesh_attrs:1}); - - req.oncomplete = function(r) { - var msg - gridRefs.grid.setModel(gridRefs.model); - gridRefs.model.query = {id:'*'}; - while(msg = r.recv()) { - var jub = msg.content(); - //alert(js2JSON(jub)); - gridRefs.store.newItem({ - id:jub.id(), - title:openils.acq.Picklist.find_attr(jub, "title", "lineitem_marc_attr_definition"), - price:openils.acq.Picklist.find_attr(jub, "price", "lineitem_marc_attr_definition"), - provider:jub.provider(), - copies:jub.item_count() - }); - } - gridRefs.grid.update(); - }; - - req.send(); - return gridRefs.grid; + } + return ''; +}; + +openils.acq.Picklist.onRowClick = function(evt) { + var gridRefs = openils.acq.Picklist._gridRefs; + var row = gridRefs.grid.model.getRow(evt.rowIndex); + + openils.acq.Lineitems.loadGrid('oils-acq-picklist-details-grid', row.id); }; } diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html index 688b93f913..b3cd46c510 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html @@ -11,6 +11,19 @@ + <%def name="page_title()">${_('Picklist')} @@ -22,29 +35,51 @@
-
-
- - + activeSizing="1" layoutAlign="client"> +
+
-

Hi!

-
+ +
+

Copy order details go here...

+
-- 2.11.0