From: erickson Date: Thu, 26 Mar 2009 18:33:46 +0000 (+0000) Subject: plugged in inital action from dropdown, delete selected linitems. fetch distribution... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3d4e2fc84d92299d91cf6a5a1e19eb77d8d100e5;p=evergreen%2Fbjwebb.git plugged in inital action from dropdown, delete selected linitems. fetch distribution formulas, but don't do anything with them yet git-svn-id: svn://svn.open-ils.org/ILS/trunk@12692 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 3b547e617..1a1db2a1a 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.widget.AutoFieldWidget'); +dojo.require('dojo.data.ItemFileReadStore'); function AcqLiTable() { @@ -20,6 +21,11 @@ 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')) + acqLitLiActionsSelector.attr('value', '_'); + }); dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()}; dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')}; @@ -80,6 +86,7 @@ function AcqLiTable() { self.toggleState = !self.toggleState; }; + /** @param all If true, assume all are selected */ this.getSelected = function(all) { var selected = []; @@ -110,13 +117,22 @@ function AcqLiTable() { // XXX media prefix for added content dojo.query('[name=jacket]', row)[0].setAttribute('src', '/opac/extras/ac/jacket/small/' + isbn); } - dojo.query('[name=infolink]', row)[0].onclick = function() {self.drawInfo(li.id())}; + //dojo.query('[name=infolink]', row)[0].onclick = function() {self.drawInfo(li.id())}; + dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())}; dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())}; dojo.query('[name=count]', row)[0].appendChild(document.createTextNode(li.item_count())); self.tbody.appendChild(row); self.selectors.push(dojo.query('[name=selectbox]', row)[0]); }; + this.removeLineitem = function(liId) { + console.log(liId); + console.log('[li='+liId+']'); + console.log(dojo.query('[li='+liId+']', this.tbody)[0]); + this.tbody.removeChild(dojo.query('[li='+liId+']', this.tbody)[0]); + delete this.liCache[liId]; + } + this.drawInfo = function(liId) { this.show('info'); openils.acq.Lineitem.fetchAttrDefs( @@ -198,6 +214,41 @@ function AcqLiTable() { while(this.copyTbody.childNodes[0]) this.copyTbody.removeChild(this.copyTbody.childNodes[0]); + this._drawBatchCopyWidgets(); + + this._fetchDistribFormulas( + function() { + openils.acq.Lineitem.fetchAttrDefs( + function() { + self._fetchLineitem(liId, function(li){self._drawCopies(li);}); + } + ); + } + ); + }; + + this._fetchDistribFormulas = function(onload) { + if(this.distribForms) { + onload(); + } else { + var self = this; + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.distribution_formula.ranged.retrieve.atomic'], + { async: true, + params: [openils.User.authtoken], + oncomplete: function(r) { + self.distribForms = openils.Util.readResponse(r); + self.distribFormulaStore = + new dojo.data.ItemFileReadStore( + {data:acqdf.toStoreData(self.distribForms)}); + onload(); + } + } + ); + } + } + + this._drawBatchCopyWidgets = function() { var row = this.copyBatchRow; dojo.forEach(['fund', 'owning_lib', 'location'], function(field) { @@ -217,13 +268,6 @@ function AcqLiTable() { } ); this.copyBatchRowDrawn = true; - - - openils.acq.Lineitem.fetchAttrDefs( - function() { - self._fetchLineitem(liId, function(li){self._drawCopies(li);}); - } - ); }; this.batchCopyUpdate = function() { @@ -339,6 +383,30 @@ function AcqLiTable() { } ); } + + this.applySelectedLiAction = function(action) { + switch(action) { + case 'delete_selected': + self._deleteLiList(self.getSelected()); + break; + } + } + + this._deleteLiList = function(list, idx) { + if(idx == null) idx = 0; + if(idx >= list.length) return; + var liId = list[idx].id(); + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.lineitem.delete'], + { async: true, + params: [openils.User.authtoken, liId], + oncomplete: function(r) { + self.removeLineitem(liId); + self._deleteLiList(list, ++idx); + } + } + ); + } } 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 52f112fa2..ad526af7b 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -12,8 +12,9 @@
- + @@ -36,10 +37,12 @@ - - + @@ -118,6 +121,20 @@ + + + + +
+ + Copies()