From 3e43b4e4acb034ca4551847760dee7e349bb829e Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 12 Oct 2009 16:36:53 +0000 Subject: [PATCH] sort checked out items by due date, oldest first. this brings the items that need the most attention to the top of the list. previously, there was no sorting git-svn-id: svn://svn.open-ils.org/ILS/trunk@14368 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/skin/default/js/myopac.js | 42 ++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js index 48264ca00d..77eaf2373b 100644 --- a/Open-ILS/web/opac/skin/default/js/myopac.js +++ b/Open-ILS/web/opac/skin/default/js/myopac.js @@ -166,19 +166,42 @@ function myOPACDrawCheckedOutSlim(r) { return; } + var totalAsync = checked.overdue.length + checked.out.length; + var fetchedCircs = []; + var collectCircs = function(r) { + var circ = r.getResultObject(); + circ._od = r.od; + fetchedCircs.push(circ); + if(fetchedCircs.length < totalAsync) return; + + // sort by due date, oldest to newest + fetchedCircs = fetchedCircs.sort( + function(a, b) { + if(a.due_date() > b.due_date()) return 1; + return -1; + } + ) + + dojo.forEach(fetchedCircs, + function(circ) { + myOPACDrawCheckedItem(circ, tbody); + } + ); + } + for( var i = 0; i < checked.overdue.length; i++ ) { var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.overdue[i]); - req.request.tbody = tbody; + //req.request.tbody = tbody; req.request.od = true; - req.callback(myOPACDrawCheckedItem); + req.callback(collectCircs); req.send(); } for( var i = 0; i < checked.out.length; i++ ) { var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.out[i]); - req.request.tbody = tbody; - req.callback(myOPACDrawCheckedItem); + //req.request.tbody = tbody; + req.callback(collectCircs); req.send(); } @@ -194,13 +217,14 @@ function myOPACDrawCheckedOutSlim(r) { } -function myOPACDrawCheckedItem(r) { +//function myOPACDrawCheckedItem(r) { +function myOPACDrawCheckedItem(circ, tbody) { - var circ = r.getResultObject(); - var tbody = r.tbody; + //var circ = r.getResultObject(); + //var tbody = r.tbody; var row = checkedRowTemplate.cloneNode(true); row.id = 'myopac_checked_row_ ' + circ.id(); - row.setAttribute('circid', circ.id()); + row.setAttribute('circid', circ.id()); var due = _trimTime(circ.due_date()); @@ -209,7 +233,7 @@ function myOPACDrawCheckedItem(r) { //var rnlink = $n( row, "myopac_checked_renew_link" ); //if( r.od ) due = elem('b', {style:'color:red;font-size:110%'},due); - if( r.od ) { + if( circ._od ) { due = elem('b', null, due); addCSSClass(due, 'overdue'); } else { -- 2.11.0