From 8d1b74bfad07098855d438a447815c2bdf542f82 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 15 Jan 2016 17:09:34 -0500 Subject: [PATCH] JBAS-1038 Refresh notes on print/receive/cancel Refresh lineitem notes after a PO print, lineitem receive, or lineitem cancel action occur to pick up the latest lineitem action notes. Signed-off-by: Bill Erickson --- Open-ILS/web/js/ui/default/acq/common/li_table.js | 46 +++++++++++++++++++++++ Open-ILS/web/js/ui/default/acq/po/view_po.js | 1 + 2 files changed, 47 insertions(+) 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 2f935b433f..8b12f9ce8c 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 @@ -219,6 +219,9 @@ function AcqLiTable() { if (!dojo.isArray(disabled_fields)) disabled_fields = []; + // Widgets already created. No need to rebuild. + if (this.batchUpdateWidgets) return; + /* Note that this will directly contain dijits, not the AutoWidget * wrapper object. */ if (!this.batchUpdateWidgets) { @@ -1337,6 +1340,30 @@ function AcqLiTable() { */ }; + /* Re-fetches lineitem notes and updates + * note count for selected lineitems */ + this.refreshLiNotes = function(li_ids) { + var self = this; + if (!li_ids) li_ids = Object.keys(this.liCache); + dojo.forEach(li_ids, function(li_id) { + fieldmapper.standardRequest( + ['open-ils.acq', + 'open-ils.acq.lineitem.retrieve.authoritative'], + { async: true, + params: [self.authtoken, li_id, + {clear_marc : true, flesh_notes : true}], + oncomplete: function(r) { + var li = openils.Util.readResponse(r); + // update the notes array on cached + // lineitem for consistency. + self.liCache[li_id].lineitem_notes(li.lineitem_notes()); + self.updateLiNotesCount(li); + } + } + ); + }); + } + this.updateLiNotesCount = function(li, row) { if (!row) row = this._findLiRow(li); @@ -1517,6 +1544,12 @@ function AcqLiTable() { */ this.drawLiNotes = function(li) { var self = this; + + // get the LI from the cache, since it may have been + // modified since this closure was first created. + // See refreshLiNotes(); + li = self.liCache[li.id()]; + this.focusLineitem = li.id(); if (!acqLitAlertAlertText._store_ready) @@ -3325,6 +3358,9 @@ function AcqLiTable() { } } } + }, + "oncomplete" : function() { + self.refreshLiNotes(id_list); } } ); @@ -3394,6 +3430,7 @@ function AcqLiTable() { this.printPO = function() { if(!this.isPO) return; + var self = this; progressDialog.show(true); fieldmapper.standardRequest( ['open-ils.acq', 'open-ils.acq.purchase_order.format'], @@ -3405,6 +3442,7 @@ function AcqLiTable() { if(evt && evt.template_output()) { openils.Util.printHtmlString(evt.template_output().data()); } + self.refreshLiNotes(); } } ); @@ -3471,6 +3509,10 @@ function AcqLiTable() { var resp = openils.Util.readResponse(r); self._updateProgressNumbers(resp, true); }, + oncomplete : function() { + self.refreshLiNotes( + li_list.map(function(li) { return li.id(); })) + } } ); }; @@ -3495,6 +3537,10 @@ function AcqLiTable() { ); progressDialog.hide(); } + }, + oncomplete : function() { + if (part == 'lineitem' && !rollback) + self.refreshLiNotes([obj.id()]); } } ); diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 19febae347..e1f786a3f9 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -189,6 +189,7 @@ function cancellationUpdater(r) { } } } + liTable.refreshLiNotes(); } } -- 2.11.0