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]);
+ }
}
}
);
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(
/* 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);
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);
}
);
};