[open-ils-commits] r17818 - branches/rel_2_0/Open-ILS/web/js/ui/default/circ/selfcheck (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Sep 19 15:17:19 EDT 2010


Author: erickson
Date: 2010-09-19 15:17:14 -0400 (Sun, 19 Sep 2010)
New Revision: 17818

Modified:
   branches/rel_2_0/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
Log:
back-port: 17817 => for large sets of holds, usually around 10 or more, the holds display takes a little too long.  instead of collecting them all and sorting them by queue position, slot them into the display table (by queue position) as they arrive

Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2010-09-19 19:15:48 UTC (rev 17817)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2010-09-19 19:17:14 UTC (rev 17818)
@@ -678,12 +678,12 @@
                 }
 
                 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));
                         }
                     }
                 );
@@ -692,54 +692,45 @@
     );
 }
 
-/**
- * Fetch and add a single hold to the list of holds
- */
-SelfCheckManager.prototype.drawHolds = function(holds) {
+SelfCheckManager.prototype.insertHold = function(data) {
+    var row = this.holdTemplate.cloneNode(true);
 
-    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;
-        }
-    );
+    if(data.mvr.isbn()) {
+        this.byName(row, 'jacket').setAttribute('src', '/opac/extras/ac/jacket/small/' + data.mvr.isbn());
+    }
 
-    this.holds = holds;
+    this.byName(row, 'title').innerHTML = data.mvr.title();
+    this.byName(row, 'author').innerHTML = data.mvr.author();
 
-    progressDialog.hide();
+    if(data.status == 4) {
 
-    for(var i in holds) {
+        // hold is ready for pickup
+        this.byName(row, 'status').innerHTML = localeStrings.HOLD_STATUS_READY;
 
-        var data = holds[i];
-        var row = this.holdTemplate.cloneNode(true);
+    } else {
 
-        if(data.mvr.isbn()) {
-            this.byName(row, 'jacket').setAttribute('src', '/opac/extras/ac/jacket/small/' + data.mvr.isbn());
-        }
+        // hold is still pending
+        this.byName(row, 'status').innerHTML = 
+            dojo.string.substitute(
+                localeStrings.HOLD_STATUS_WAITING,
+                [data.queue_position, data.potential_copies]
+            );
+    }
 
-        this.byName(row, 'title').innerHTML = data.mvr.title();
-        this.byName(row, 'author').innerHTML = data.mvr.author();
+    // find the correct place the table to slot in the hold based on queue position
 
-        if(data.status == 4) {
+    var position = (data.status == 4) ? 0 : data.queue_position;
+    row.setAttribute('position', position);
 
-            // hold is ready for pickup
-            this.byName(row, 'status').innerHTML = localeStrings.HOLD_STATUS_READY;
-
-        } else {
-
-            // 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);
 }
 
 



More information about the open-ils-commits mailing list