From f4b905e21b88a2fe60cf0a29c7f568256ea97b84 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 27 Apr 2009 18:21:18 +0000 Subject: [PATCH] plug in real copy save. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12998 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/acq/common/li_table.js | 50 ++++++++++++++++++---- .../web/templates/default/acq/common/li_table.tt2 | 11 +++-- 2 files changed, 46 insertions(+), 15 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 8aa20acf8c..bd4987ad99 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 @@ -41,7 +41,6 @@ function AcqLiTable() { this.liNotesRow = this.liNotesTbody.removeChild(dojo.byId('acq-lit-notes-row')); this.realCopiesTbody = dojo.byId('acq-lit-real-copies-tbody'); this.realCopiesRow = this.realCopiesTbody.removeChild(dojo.byId('acq-lit-real-copies-row')); - this.volCache = {}; dojo.connect(acqLitLiActionsSelector, 'onChange', function() { @@ -187,12 +186,6 @@ function AcqLiTable() { if(li.state() == 'received') { // if the LI is received, hide the receive link and show the 'update barcodes' link openils.Util.hide(recv_link) - var real_copies_link = dojo.query('[name=real_copies_link]', row)[0]; - openils.Util.show(real_copies_link); - real_copies_link.onclick = function() { - self.showRealCopies(li); - } - } else { recv_link.onclick = function() { self.receiveLi(li); @@ -200,6 +193,14 @@ function AcqLiTable() { } } + if(li.eg_bib_id()) { + var real_copies_link = dojo.query('[name=real_copies_link]', row)[0]; + openils.Util.show(real_copies_link); + real_copies_link.onclick = function() { + self.showRealCopies(li); + } + } + self.tbody.appendChild(row); self.selectors.push(dojo.query('[name=selectbox]', row)[0]); }; @@ -963,11 +964,20 @@ function AcqLiTable() { // grab the li-details for this lineitem, grab the linked copies and volumes, add them to the table this.showRealCopies = function(li) { + while(this.realCopiesTbody.childNodes[0]) + this.realCopiesTbody.removeChild(this.realCopiesTbody.childNodes[0]); this.show('real-copies'); - var pcrud = new openils.PermaCrud({authtoken : this.authtoken}); + var pcrud = new openils.PermaCrud({authtoken : this.authtoken}); + this.realCopyList = []; + this.volCache = {}; var tabIndex = 1000; var self = this; + + acqLitSaveRealCopies.onClick = function() { + self.saveRealCopies(); + } + this._fetchLineitem(li.id(), function(fullLi) { li = self.liCache[li.id()] = fullLi; @@ -997,22 +1007,25 @@ function AcqLiTable() { this.addRealCopy = function(volume, copy, tabIndex) { var row = this.realCopiesRow.cloneNode(true); + this.realCopyList.push(copy); var selectNode; dojo.forEach( ['owning_lib', 'location', 'circ_modifier', 'label', 'barcode'], + function(field) { var isvol = (field == 'owning_lib' || field == 'label'); var widget = new openils.widget.AutoFieldWidget({ fmField : field, fmObject : isvol ? volume : copy, parentNode : nodeByName(field, row), - readOnly : (field != 'barcode') + readOnly : (field != 'barcode'), }); var widgetDrawn = null; if(field == 'barcode') { + widgetDrawn = function(w, ww) { var node = w.domNode; node.setAttribute('tabindex', ''+tabIndex); @@ -1028,6 +1041,15 @@ function AcqLiTable() { } ); + dojo.connect(w, 'onChange', + function(val) { + if(!val || val == copy.barcode()) return; + copy.ischanged(true); + copy.barcode(val); + } + ); + + if(self.realCopiesTbody.getElementsByTagName('TR').length == 0) selectNode = node; } @@ -1040,6 +1062,16 @@ function AcqLiTable() { this.realCopiesTbody.appendChild(row); if(selectNode) selectNode.select(); }; + + this.saveRealCopies = function() { + var pcrud = new openils.PermaCrud({authtoken : this.authtoken}); + progressDialog.show(true); + var list = this.realCopyList.filter(function(copy) { return copy.ischanged(); }); + pcrud.update(list, {oncomplete: function() { + progressDialog.hide(); + self.show('list'); + }}); + } } 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 629b5dc91e..063c49295c 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -48,9 +48,10 @@ Line Items - Price + Items Notes + Price @@ -79,16 +80,14 @@ - - Mark Received - - - + + Mark Received Copies(0) Notes(0) + -- 2.11.0