}
fieldmapper.standardRequest( // fetch the hold objects with fleshed details
- ['open-ils.circ', 'open-ils.circ.hold.details.batch.retrieve.atomic'],
+ ['open-ils.circ', 'open-ils.circ.hold.details.batch.retrieve'],
{ async : true,
params : [self.authtoken, ids],
-
- oncomplete : function(rr) {
- self.drawHolds(openils.Util.readResponse(rr));
+ onresponse : function(rr) {
+ progressDialog.hide();
+ self.insertHold(openils.Util.readResponse(rr));
}
}
);
);
}
-/**
- * Fetch and add a single hold to the list of holds
- */
-SelfCheckManager.prototype.drawHolds = function(holds) {
-
- holds = holds.sort(
- // sort available holds to the top of the list
- // followed by queue position order
- function(a, b) {
- if(a.status == 4) return -1;
- if(a.queue_position < b.queue_position) return -1;
- return 1;
- }
- );
-
- this.holds = holds;
+SelfCheckManager.prototype.insertHold = function(data) {
+ var row = this.holdTemplate.cloneNode(true);
- progressDialog.hide();
+ if(data.mvr.isbn()) {
+ this.byName(row, 'jacket').setAttribute('src', '/opac/extras/ac/jacket/small/' + data.mvr.isbn());
+ }
- for(var i in holds) {
+ this.byName(row, 'title').innerHTML = data.mvr.title();
+ this.byName(row, 'author').innerHTML = data.mvr.author();
- var data = holds[i];
- var row = this.holdTemplate.cloneNode(true);
+ if(data.status == 4) {
- if(data.mvr.isbn()) {
- this.byName(row, 'jacket').setAttribute('src', '/opac/extras/ac/jacket/small/' + data.mvr.isbn());
- }
+ // hold is ready for pickup
+ this.byName(row, 'status').innerHTML = localeStrings.HOLD_STATUS_READY;
- this.byName(row, 'title').innerHTML = data.mvr.title();
- this.byName(row, 'author').innerHTML = data.mvr.author();
+ } else {
- if(data.status == 4) {
+ // hold is still pending
+ this.byName(row, 'status').innerHTML =
+ dojo.string.substitute(
+ localeStrings.HOLD_STATUS_WAITING,
+ [data.queue_position, data.potential_copies]
+ );
+ }
- // hold is ready for pickup
- this.byName(row, 'status').innerHTML = localeStrings.HOLD_STATUS_READY;
+ // find the correct place the table to slot in the hold based on queue position
- } else {
+ var position = (data.status == 4) ? 0 : data.queue_position;
+ row.setAttribute('position', position);
- // hold is still pending
- this.byName(row, 'status').innerHTML =
- dojo.string.substitute(
- localeStrings.HOLD_STATUS_WAITING,
- [data.queue_position, data.potential_copies]
- );
+ for(var i = 0; i < this.holdTbody.childNodes.length; i++) {
+ var node = this.holdTbody.childNodes[i];
+ if(Number(node.getAttribute('position')) >= position) {
+ this.holdTbody.insertBefore(row, node);
+ return;
}
-
- this.holdTbody.appendChild(row);
}
+
+ this.holdTbody.appendChild(row);
}