From e024e6bfc48dacffaeca4e9fd9c8395de156f356 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 30 Mar 2009 22:51:15 +0000 Subject: [PATCH] move the select list creation actoin in with the rest of the linietem actions (dropdown) git-svn-id: svn://svn.open-ils.org/ILS/trunk@12724 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/acq/common/li_table.js | 82 +++++++++++++++++++++- .../web/js/ui/default/acq/picklist/bib_search.js | 65 ----------------- .../web/templates/default/acq/common/li_table.tt2 | 34 +++++++++ .../templates/default/acq/picklist/bib_search.tt2 | 35 --------- 4 files changed, 113 insertions(+), 103 deletions(-) diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 21c236f43e..9df4a44713 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -6,6 +6,7 @@ dojo.require('openils.User'); dojo.require('openils.Util'); dojo.require('openils.acq.Lineitem'); dojo.require('openils.acq.PO'); +dojo.require('openils.acq.Picklist'); dojo.require('openils.widget.AutoFieldWidget'); dojo.require('dojo.data.ItemFileReadStore'); @@ -22,6 +23,7 @@ function AcqLiTable() { this.copyRow = this.copyTbody.removeChild(dojo.byId('acq-lit-li-details-row')); this.copyBatchRow = dojo.byId('acq-lit-li-details-batch-row'); this.copyBatchWidgets = {}; + dojo.connect(acqLitLiActionsSelector, 'onChange', function() { self.applySelectedLiAction(this.attr('value')) @@ -33,6 +35,11 @@ function AcqLiTable() { self._createPO(acqLitPoCreateDialog.getValues()); } + acqLitSavePlButton.onClick = function() { + acqLitSavePlDialog.hide(); + self._savePl(acqLitSavePlDialog.getValues()); + } + dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()}; dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')}; dojo.byId('acq-lit-copies-back-button').onclick = function(){self.show('list')}; @@ -340,11 +347,14 @@ function AcqLiTable() { orgLimitPerms : ['CREATE_PICKLIST'], readOnly : self.isPO }); - widget.build(); + widget.build( + // make sure we capture the value from any async widgets + function(w, ww) { copy[field](ww.getFormattedValue()) } + ); dojo.connect(widget.widget, 'onChange', function(val) { - if(val != copy[field]()) { - // prevent setting ischanged() automatically on widget load + if(copy.isnew() || val != copy[field]()) { + // prevent setting ischanged() automatically on widget load for existing copies copy[field](widget.getFormattedValue()) copy.ischanged(true); } @@ -406,9 +416,11 @@ function AcqLiTable() { this.applySelectedLiAction = function(action) { var self = this; switch(action) { + case 'delete_selected': this._deleteLiList(self.getSelected()); break; + case 'create_order': if(!this.createPoProviderSelector) { @@ -425,6 +437,11 @@ function AcqLiTable() { acqLitPoCreateDialog.show(); break; + + case 'save_picklist': + this._loadPLSelect(); + acqLitSavePlDialog.show(); + break; } } @@ -509,6 +526,65 @@ function AcqLiTable() { } }; } + + + this._savePl = function(values) { + var self = this; + var selected = this.getSelected( (values.which == 'all') ); + openils.Util.show('acq-lit-generic-progress'); + + if(values.new_name) { + openils.acq.Picklist.create( + {name: values.new_name}, + function(id) { + self._updateLiList(id, selected, 0, + function(){ + location.href = oilsBasePath + '/eg/acq/picklist/view/' + id; + }); + } + ); + } else if(values.existing_pl) { + // update lineitems to use an existing picklist + self._updateLiList(values.existing_pl, selected, 0, + function(){ + location.href = oilsBasePath + '/eg/acq/picklist/view/' + values.existing_pl; + }); + } + } + + this._updateLiList = function(pl, list, idx, oncomplete) { + if(idx >= list.length) return oncomplete(); + var li = list[idx]; + li.picklist(pl); + litGenericProgress.update({maximum: list.length, progress: idx}); + new openils.acq.Lineitem({lineitem:li}).update( + function(r) { + self._updateLiList(pl, list, ++idx, oncomplete); + } + ); + } + + this._loadPLSelect = function() { + if(this._plSelectLoaded) return; + var plList = []; + function handleResponse(r) { + plList.push(r.recv().content()); + } + var method = 'open-ils.acq.picklist.user.retrieve'; + fieldmapper.standardRequest( + ['open-ils.acq', method], + { async: true, + params: [this.authtoken], + onresponse: handleResponse, + oncomplete: function() { + self._plSelectLoaded = true; + acqLitAddExistingSelect.store = + new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)}); + acqLitAddExistingSelect.setValue(); + } + } + ); + } } diff --git a/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js b/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js index de1c986778..de53033d84 100644 --- a/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js +++ b/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js @@ -148,71 +148,6 @@ function showDiv(div) { dojo.style(div, 'display', 'block'); } -function loadPLSelect() { - var plList = []; - function handleResponse(r) { - plList.push(r.recv().content()); - } - var method = 'open-ils.acq.picklist.user.retrieve'; - fieldmapper.standardRequest( - ['open-ils.acq', method], - { async: true, - params: [openils.User.authtoken], - onresponse: handleResponse, - oncomplete: function() { - plAddExistingSelect.store = - new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)}); - plAddExistingSelect.setValue(); - } - } - ); -} - - -function saveResults(values) { - openils.Util.show('oils-acq-update-li-progress'); - selectedLIs = liTable.getSelected( (values.which == 'all') ); - - if(values.new_name && values.new_name != '') { - // save selected lineitems to a new picklist - if(values.which = 'selected') { - openils.acq.Picklist.create( - {name: values.new_name}, - function(id) { - updateLiList(id, selectedLIs, 0, - function(){location.href = 'view/' + id}); - } - ); - } else { - // save all == change the name of the results picklist - resultPicklist.name(values.new_name); - openils.acq.Picklist.update(resultPicklist, - function(stat) { - location.href = 'view/' + resultPicklist.id(); - } - ); - } - } else if(values.existing_pl) { - // update lineitems to use an existing picklist - updateLiList(values.existing_pl, selectedLIs, 0, - function(){location.href = 'view/' + values.existing_pl}); - } -} - -function updateLiList(pl, list, idx, oncomplete) { - if(idx >= list.length) { - openils.Util.hide('oils-acq-update-li-progress'); - return oncomplete(); - } - var li = selectedLIs[idx]; - li.picklist(pl); - liUpdateProgress.update({maximum: list.length, progress: idx}); - new openils.acq.Lineitem({lineitem:li}).update( - function(r) { - updateLiList(pl, list, ++idx, oncomplete); - } - ); -} openils.Util.addOnLoad(drawForm); diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index 25fcb6da5f..e3fe968523 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -14,12 +14,16 @@ +
@@ -218,5 +222,35 @@
+
+ + + + + + + + + + + + + + + + +
+ + + + +

+ +
+ +
+
+ diff --git a/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2 b/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2 index f8b7eeba71..7cd985625f 100644 --- a/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2 +++ b/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2 @@ -58,41 +58,6 @@
New Search
-
- Save Results -
- - - - - - - - - - - - - - - - - -
- - - - -

- -
- -
-
-
-- 2.11.0