From: erickson Date: Mon, 27 Apr 2009 16:41:46 +0000 (+0000) Subject: started a per-lineitem, batch-barcode updater ui. just need to plug in the save X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d992308a91236275a5d2bce407c6c0f94b18d6e5;p=Evergreen.git started a per-lineitem, batch-barcode updater ui. just need to plug in the save git-svn-id: svn://svn.open-ils.org/ILS/trunk@12997 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 8bd2e83fb2..8aa20acf8c 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 @@ -20,6 +20,10 @@ dojo.requireLocalization('openils.acq', 'acq'); var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq'); const XUL_OPAC_WRAPPER = 'chrome://open_ils_staff_client/content/cat/opac.xul'; +function nodeByName(name, context) { + return dojo.query('[name='+name+']', context)[0]; +} + function AcqLiTable() { var self = this; @@ -35,6 +39,9 @@ function AcqLiTable() { this.copyBatchWidgets = {}; this.liNotesTbody = dojo.byId('acq-lit-notes-tbody'); 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() { @@ -52,12 +59,14 @@ function AcqLiTable() { self._savePl(acqLitSavePlDialog.getValues()); } + //dojo.byId('acq-lit-notes-new-button').onclick = function(){acqLitCreateLiNoteDialog.show();} 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')}; dojo.byId('acq-lit-notes-back-button').onclick = function(){self.show('list')}; + dojo.byId('acq-lit-real-copies-back-button').onclick = function(){self.show('list')}; this.reset = function() { while(self.tbody.childNodes[0]) @@ -90,6 +99,7 @@ function AcqLiTable() { openils.Util.hide('acq-lit-info-div'); openils.Util.hide('acq-lit-li-details'); openils.Util.hide('acq-lit-notes-div'); + openils.Util.hide('acq-lit-real-copies-div'); switch(div) { case 'list': openils.Util.show('acq-lit-table-div'); @@ -100,6 +110,9 @@ function AcqLiTable() { case 'copies': openils.Util.show('acq-lit-li-details'); break; + case 'real-copies': + openils.Util.show('acq-lit-real-copies-div'); + break; case 'notes': openils.Util.show('acq-lit-notes-div'); break; @@ -170,8 +183,16 @@ function AcqLiTable() { priceInput.onchange = function() { self.updateLiPrice(priceInput, li) }; var recv_link = dojo.query('[name=receive_link]', row)[0]; + 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); @@ -939,6 +960,86 @@ function AcqLiTable() { } ); } + + // grab the li-details for this lineitem, grab the linked copies and volumes, add them to the table + this.showRealCopies = function(li) { + this.show('real-copies'); + var pcrud = new openils.PermaCrud({authtoken : this.authtoken}); + + var tabIndex = 1000; + var self = this; + this._fetchLineitem(li.id(), + function(fullLi) { + li = self.liCache[li.id()] = fullLi; + + pcrud.search( + 'acp', { + id : li.lineitem_details().map( + function(item) { return item.eg_copy_id() } + ) + }, { + async : true, + streaming : true, + onresponse : function(r) { + var copy = openils.Util.readResponse(r); + var volId = copy.call_number(); + var volume = self.volCache[volId]; + if(!volume) { + volume = self.volCache[volId] = pcrud.retrieve('acn', volId); + } + self.addRealCopy(volume, copy, tabIndex++); + } + } + ); + } + ); + } + + this.addRealCopy = function(volume, copy, tabIndex) { + var row = this.realCopiesRow.cloneNode(true); + + 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') + }); + + var widgetDrawn = null; + + if(field == 'barcode') { + widgetDrawn = function(w, ww) { + var node = w.domNode; + node.setAttribute('tabindex', ''+tabIndex); + + // on enter, select the next barcode input + dojo.connect(w, 'onKeyDown', + function(e) { + if(e.keyCode == dojo.keys.ENTER) { + var ti = node.getAttribute('tabindex'); + var nextNode = dojo.query('[tabindex=' + String(Number(ti) + 1) + ']', self.realCopiesTbody)[0]; + if(nextNode) nextNode.select(); + } + } + ); + + if(self.realCopiesTbody.getElementsByTagName('TR').length == 0) + selectNode = node; + } + } + + widget.build(widgetDrawn); + } + ); + + this.realCopiesTbody.appendChild(row); + if(selectNode) selectNode.select(); + }; } 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 c4268dfc6a..629b5dc91e 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -79,7 +79,10 @@ - Mark Received + + Mark Received + + Copies(0) @@ -239,6 +242,49 @@ + + + +