From: senator Date: Fri, 11 Mar 2011 20:46:07 +0000 (+0000) Subject: Backport r19709 from trunk X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4ef3648f3dc0c275271bd2cb7537c8d0ebd7bf80;p=evergreen%2Fjoelewis.git Backport r19709 from trunk 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/branches/rel_2_1@19711 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 f82437e004..576245827e 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); } ); };