From 1850029a0f1fe052042577d8f869022182eb501d Mon Sep 17 00:00:00 2001 From: senator Date: Fri, 11 Mar 2011 20:44:33 +0000 Subject: [PATCH] Acq: The "Claim-Ready Items" interface did not render correctly for > 1 item The problem was racy async rendering logic. Now we look at our whole result set and build our table accordingly at the end. This interface should probably learn about paging one day in order to handle large result sets. git-svn-id: svn://svn.open-ils.org/ILS/trunk@19709 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../js/ui/default/acq/financial/claim_eligible.js | 37 +++++++++++--------- 1 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js b/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js index f82437e..5762458 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js +++ b/Open-ILS/web/js/ui/default/acq/financial/claim_eligible.js @@ -81,21 +81,24 @@ function EligibleLiTable(filter) { var count = 0; this.reset(); fieldmapper.standardRequest( - ["open-ils.acq", "open-ils.acq.claim.eligible.lineitem_detail"], { + ["open-ils.acq", "open-ils.acq.claim.eligible.lineitem_detail.atomic"], { "params": [openils.User.authtoken, this.filter], "async": true, - "onresponse": function(r) { - if (r = openils.Util.readResponse(r)) { - if (!count++) - openils.Util.show("acq-eligible-claim-controls"); - self.addIfMissing(r.lineitem()); - } else { - progressDialog.hide(); - } - }, - "oncomplete": function() { - if (count < 1) self.showEmpty(); + "oncomplete": function(r) { progressDialog.hide(); + var rset = openils.Util.readResponse(r); + if (rset.length < 1) self.showEmpty(); + else { + var byLi = {}; + rset.forEach( + function(r) { + byLi[r.lineitem()] = + (byLi[r.lineitem()] || 0) + 1; + } + ); + for (var key in byLi) + self.addIfMissing(key, byLi[key]); + } } } ); @@ -113,7 +116,7 @@ function EligibleLiTable(filter) { nodeByName("lid_link", "eligible-li-" + liId).onclick = function() { location.href = oilsBasePath + "/acq/po/view/" + - self.liCache[liId].purchase_order().id() + "," + + self.liCache[liId].purchase_order().id() + "/" + liId; }; openils.Util.show( @@ -124,10 +127,7 @@ function EligibleLiTable(filter) { /* Despite being called with an argument that's a lineitem ID, this method * is actually called once per lineitem _detail_. */ - this.addIfMissing = function(liId) { - this._updateLidLink(liId); - if (this.liCache[liId]) return; - + this.addIfMissing = function(liId, number_of_appearances) { var row = dojo.clone(this.rowTemplate); var checkbox = nodeByName("selector", row); @@ -141,6 +141,9 @@ function EligibleLiTable(filter) { dojo.attr(row, "id", "eligible-li-" + liId); dojo.attr(checkbox, "value", liId); dojo.place(row, self.tBody, "last"); + + for (var i = 0; i < number_of_appearances; i++) + self._updateLidLink(liId); } ); }; -- 1.7.2.5