Add some reasonable default sorting to this expired holds list
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 7 Oct 2010 17:18:58 +0000 (17:18 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 7 Oct 2010 17:18:58 +0000 (17:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18222 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/extras/circ/alt_holds_print.html

index 370aa98..30fdd65 100644 (file)
                 );
             }
 
+            function place_by_sortkey(node, container) {
+                /*Don't use a forEach() or anything like that here. too slow.*/
+                var sortkey = dojo.attr(node, "sortkey");
+                for (var i = 0; i < container.childNodes.length; i++) {
+                    var rover = container.childNodes[i];
+                    if (rover.nodeType != 1) continue;
+                    if (dojo.attr(rover, "sortkey") > sortkey) {
+                        dojo.place(node, rover, "before");
+                        return;
+                    }
+                }
+                dojo.place(node, container, "last");
+            }
+
             function do_shelf_expired_holds(user, cgi) {
                 progress_dialog.show(true);
 
                 var any = false;
+                var target = dojo.byId("target");
                 fieldmapper.standardRequest(
                     ["open-ils.circ",
                         "open-ils.circ.captured_holds.expired.print.stream"], {
                                         "delay": false
                                     });
             
-                                    dojo.place(tr, "target");
+                                    dojo.attr(
+                                        tr, "sortkey", hold.usr.display_name
+                                    );
+                                    place_by_sortkey(tr, target);
                                 }
                             );
                         },