From 1ec10b00946dd331742d04bba676dc0a640325ea Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 10 Feb 2012 10:37:52 -0500 Subject: [PATCH] Acq upload UI re-use new picklist In the ACQ file upload UI, if the user loads the records into a new selection list, this change allows the user to continue using the new list without having to refresh the page. Without this change, re-using the new list would result in the system trying to create a new list with the same name, which fails. Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- Open-ILS/web/js/ui/default/acq/picklist/upload.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/ui/default/acq/picklist/upload.js b/Open-ILS/web/js/ui/default/acq/picklist/upload.js index 667e272d0d..c6b83d5d8c 100644 --- a/Open-ILS/web/js/ui/default/acq/picklist/upload.js +++ b/Open-ILS/web/js/ui/default/acq/picklist/upload.js @@ -1,4 +1,5 @@ dojo.require('dojo.data.ItemFileReadStore'); +dojo.require('dojo.data.ItemFileWriteStore'); dojo.require('dijit.ProgressBar'); dojo.require('dijit.form.CheckBox'); dojo.require('dijit.form.TextBox'); @@ -10,11 +11,13 @@ dojo.require('openils.User'); dojo.require('openils.widget.AutoFieldWidget'); dojo.require('openils.acq.Picklist'); dojo.require('openils.XUL'); +dojo.require('openils.PermaCrud'); var VANDELAY_URL = '/vandelay-upload'; var providerWidget; var orderAgencyWidget; var vlAgent; +var usingNewPl = false; function init() { dojo.byId('acq-pl-upload-ses').value = openils.User.authtoken; @@ -47,7 +50,7 @@ function init() { oncomplete : function(r) { var list = openils.Util.readResponse(r); acqPlUploadPlSelector.store = - new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(list)}); + new dojo.data.ItemFileWriteStore({data:acqpl.toStoreData(list)}); } } ); @@ -64,11 +67,13 @@ function acqUploadRecords() { onComplete : function(items) { if(items.length == 0) { // create a new picklist for these items + usingNewPl = true; openils.acq.Picklist.create( {name:picklist, org_unit: orderAgencyWidget.attr('value')}, function(plId) { acqSendUploadForm({picklist:plId}) } ); } else { + usingNewPl = false; acqSendUploadForm({picklist:items[0].id[0]}); } } @@ -132,6 +137,14 @@ function acqHandlePostUpload(key, plId) { if(res.picklist_url) { activateLink('acq-pl-upload-complete-pl', res.picklist_url); + + // if the user entered a new picklist, refetch the set to pick + // up the ID and redraw the list with the new one selected + if (usingNewPl) { + var newPl = new openils.PermaCrud().retrieve('acqpl', resp.picklist.id()); + acqPlUploadPlSelector.store.newItem(newPl.toStoreItem()); + acqPlUploadPlSelector.attr('value', newPl.name()); + } } if(res.po_url) { -- 2.11.0