From 4c193efd038c4e9da8a941cd47d2a2a620eee3a1 Mon Sep 17 00:00:00 2001 From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Fri, 9 Oct 2009 15:28:52 +0000 Subject: [PATCH] when adding copies to a lineitem, you can now choose the total count instead of having to X copies git-svn-id: svn://svn.open-ils.org/ILS/trunk@14328 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 3 +- Open-ILS/web/js/ui/default/acq/common/li_table.js | 32 +++++++++++++++++++++- .../web/templates/default/acq/common/li_table.tt2 | 4 +-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index f31aebb0ca..c688a5b26d 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -1,5 +1,6 @@ { 'CREATE_PO_ASSETS_CONFIRM' : "This will create bibliographic, call number, and copy records for this purchase order in the ILS.\n\nContinue?", 'ROLLBACK_PO_RECEIVE_CONFIRM' : "This will rollback receipt of all copies for this purchase order.\n\nContinue?", - 'XUL_RECORD_DETAIL_PAGE' : 'Record Details' + 'XUL_RECORD_DETAIL_PAGE' : 'Record Details', + 'DELETE_LI_COPIES_CONFIRM' : 'This will delete the last ${0} copies in the table. Proceed?' } 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 cacd808ec2..3fa3643e2e 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 @@ -492,6 +492,7 @@ function AcqLiTable() { acqLitSaveCopies.onClick = function() { self.saveCopyChanges(liId) }; acqLitBatchUpdateCopies.onClick = function() { self.batchCopyUpdate() }; + acqLitCopyCountInput.attr('value', '0'); while(this.copyTbody.childNodes[0]) this.copyTbody.removeChild(this.copyTbody.childNodes[0]); @@ -572,11 +573,29 @@ function AcqLiTable() { }; this._drawCopies = function(li) { + var self = this; + + // this button sets the total number of copies for a given lineitem acqLitAddCopyCount.onClick = function() { var count = acqLitCopyCountInput.attr('value'); - for(var i = 0; i < count; i++) + + // add new rows + while(self.copyCount() < count) self.addCopy(li); + + // delete rows if necessary + var diff = self.copyCount() - count; + if(diff > 0) { + var rows = dojo.query('tr', self.copyTbody).reverse().slice(0, diff); + if(confirm(dojo.string.substitute(localeStrings.DELETE_LI_COPIES_CONFIRM, [diff]))) { + dojo.forEach(rows, function(row) {self.deleteCopy(row); }); + } else { + acqLitCopyCountInput.attr('value', self.copyCount()+''); + } + } } + + if(li.lineitem_details().length > 0) { dojo.forEach(li.lineitem_details(), function(copy) { @@ -588,6 +607,15 @@ function AcqLiTable() { } }; + this.copyCount = function() { + var count = 0; + for(var id in this.copyCache) { + if(!this.copyCache[id].isdeleted()) + count++; + } + return count; + } + this.virtCopyId = -1; this.addCopy = function(li, copy) { var row = this.copyRow.cloneNode(true); @@ -605,6 +633,8 @@ function AcqLiTable() { row.setAttribute('copy_id', copy.id()); self.copyWidgetCache[copy.id()] = {}; + acqLitCopyCountInput.attr('value', self.copyCount()+''); + dojo.forEach(liDetailFields, function(field) { var widget = new openils.widget.AutoFieldWidget({ 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 c1b79c3ef5..f0ac801e2e 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -170,9 +170,9 @@ <td style='text-align:left;'> <div dojoType='dijit.form.Button' id='acq-lit-copies-back-button'>↖ Return</div> <span style='margin-left:10px;padding-left:10px;border-left:2px solid #aaa;'> - Add items: + Item Count: <input dojoType='dijit.form.NumberTextBox' jsId='acqLitCopyCountInput' - constraints="{min:1,max:1000,places:0}" style='width:40px' value='1'></input> + constraints="{min:0,max:1000,places:0}" style='width:40px' value='0'></input> <div dojoType='dijit.form.Button' jsId='acqLitAddCopyCount'>Go</div> </span> </td> -- 2.11.0