[open-ils-commits] r11475 - in trunk/Open-ILS/web/js: dojo/openils/acq ui/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Dec 9 12:15:32 EST 2008
Author: erickson
Date: 2008-12-09 12:15:29 -0500 (Tue, 09 Dec 2008)
New Revision: 11475
Modified:
trunk/Open-ILS/web/js/dojo/openils/acq/Picklist.js
trunk/Open-ILS/web/js/ui/default/acq/picklist/view_list.js
Log:
now updating grid dynamically with writestore for initial drawing, additions, and deletiong
Modified: trunk/Open-ILS/web/js/dojo/openils/acq/Picklist.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-12-09 16:10:40 UTC (rev 11474)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/Picklist.js 2008-12-09 17:15:29 UTC (rev 11475)
@@ -146,8 +146,11 @@
/* iterate through the list of IDs deleting asynchronously as we go... */
openils.acq.Picklist._deleteList = function(list, idx, onComplete) {
- if(idx >= list.length)
- return onComplete();
+ if(idx >= list.length) {
+ if(onComplete)
+ onComplete();
+ return;
+ }
fieldmapper.standardRequest(
['open-ils.acq', 'open-ils.acq.picklist.delete'],
{ async: true,
Modified: trunk/Open-ILS/web/js/ui/default/acq/picklist/view_list.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/picklist/view_list.js 2008-12-09 16:10:40 UTC (rev 11474)
+++ trunk/Open-ILS/web/js/ui/default/acq/picklist/view_list.js 2008-12-09 17:15:29 UTC (rev 11475)
@@ -1,4 +1,5 @@
dojo.require('dojox.grid.DataGrid');
+dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dijit.Dialog');
dojo.require('dijit.form.Button');
dojo.require('dijit.form.TextBox');
@@ -6,32 +7,27 @@
dojo.require('openils.acq.Picklist');
dojo.require('openils.Util');
-var plList = [];
var listAll = false;
-function makeGridFromList() {
- var store = new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
- plListGrid.setStore(store);
- plListGrid.render();
-}
-
-
function loadGrid() {
- var method = 'open-ils.acq.picklist.user.retrieve.atomic';
+ var method = 'open-ils.acq.picklist.user.retrieve';
if(listAll)
method = method.replace(/user/, 'user.all');
+ var store = new dojo.data.ItemFileWriteStore({data:acqpl.toStoreData([])});
+ plListGrid.setStore(store);
+ plListGrid.render();
+
fieldmapper.standardRequest(
['open-ils.acq', method],
+
{ async: true,
params: [openils.User.authtoken,
{flesh_lineitem_count:1, flesh_username:1}],
- oncomplete: function(r) {
- var resp = r.recv().content();
- if(e = openils.Event.parse(resp))
- return alert(e);
- plList = resp;
- makeGridFromList();
+
+ onresponse : function(r) {
+ if(pl = openils.Util.readResponse(r))
+ store.newItem(acqpl.toStoreData([pl]).items[0]);
}
}
);
@@ -39,17 +35,20 @@
function createPL(fields) {
if(fields.name == '') return;
+
openils.acq.Picklist.create(fields,
+
function(plId) {
fieldmapper.standardRequest(
+
['open-ils.acq', 'open-ils.acq.picklist.retrieve'],
{ async: true,
params: [openils.User.authtoken, plId,
{flesh_lineitem_count:1, flesh_username:1}],
+
oncomplete: function(r) {
- var pl = r.recv().content();
- plList.push(pl);
- makeGridFromList();
+ if(pl = openils.Util.readResponse(r))
+ plListGrid.store.newItem(acqpl.toStoreData([pl]).items[0]);
}
}
);
@@ -61,17 +60,11 @@
var list = []
var selected = plListGrid.selection.getSelected();
for(var idx = 0; idx < selected.length; idx++) {
- var rowIdx = selected[idx];
- var id = plListGrid.model.getRow(rowIdx).id;
- for(var i = 0; i < plList.length; i++) {
- var pl = plList[i];
- if(pl.id() == id && pl.owner() == new openils.User().user.usrname()) {
- list.push(id);
- plList = (plList.slice(0, i) || []).concat(plList.slice(i+1, plList.length) || []);
- }
- }
+ var item = selected[idx];
+ list.push(item.id);
+ plListGrid.store.deleteItem(item);
}
- openils.acq.Picklist.deleteList(list, function() { makeGridFromList(); });
+ openils.acq.Picklist.deleteList(list);
}
openils.Util.addOnLoad(loadGrid);
More information about the open-ils-commits
mailing list