From 6c09c367eeb5d04aba4899008136b9b1fd904782 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 11 Apr 2011 10:28:48 -0400 Subject: [PATCH] copy details for the Linked Title extras pane --- .../lib/OpenILS/Application/Search/Biblio.pm | 2 +- Open-ILS/web/opac/skin/default/js/copy_details.js | 77 +++++++++++++++------- Open-ILS/web/opac/skin/default/js/rdetail.js | 8 ++- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 1130440da7..b6a6f6d5b6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -669,7 +669,7 @@ sub find_peer_bibs { flesh => 2, flesh_fields => { bpbcm => [ 'target_copy' ], - acp => [ 'call_number' ] + acp => [ 'call_number', 'location', 'status', 'peer_record_maps' ] } } ] diff --git a/Open-ILS/web/opac/skin/default/js/copy_details.js b/Open-ILS/web/opac/skin/default/js/copy_details.js index 7c8c847e09..c94d010ea2 100644 --- a/Open-ILS/web/opac/skin/default/js/copy_details.js +++ b/Open-ILS/web/opac/skin/default/js/copy_details.js @@ -9,7 +9,7 @@ var showDueDate = false; */ var showDueTime = false; -function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location ) { +function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location, already_fetched_copies ) { var i = cpdCheckExisting(contextRow); if(i) return i; @@ -43,33 +43,50 @@ function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, c var print = $n(templateRow,'print'); print.onclick = function() { cpdBuildPrintPane( contextRow, record, callnumber, orgid, depth) }; + if (typeof callnumber == 'object') { + addCSSClass(print,'hide_me'); + } var mainTbody = $n(templateRow, 'copies_tbody'); var extrasRow = mainTbody.removeChild($n(mainTbody, 'copy_extras_row')); - var req = new Request(FETCH_COPIES_FROM_VOLUME, record.doc_id(), callnumber, orgid); - req.callback(cpdDrawCopies); + var request_args = { + contextTbody : contextTbody, /* tbody that holds the contextrow */ + contextRow : contextRow, /* the row our new row will be inserted after */ + record : record, + callnumber : callnumber, + orgid : orgid, + depth : depth, + templateRow : templateRow, /* contains everything */ + copy_location : copy_location, + mainTbody : mainTbody, /* holds the copy rows */ + extrasRow : extrasRow, /* wrapper row for all extras */ + counter : counter + } - req.request.args = { - contextTbody : contextTbody, /* tbody that holds the contextrow */ - contextRow : contextRow, /* the row our new row will be inserted after */ - record : record, - callnumber : callnumber, - orgid : orgid, - depth : depth, - templateRow : templateRow, /* contains everything */ - copy_location : copy_location, - mainTbody : mainTbody, /* holds the copy rows */ - extrasRow : extrasRow, /* wrapper row for all extras */ - counter : counter - }; + if (! already_fetched_copies) { + var req = new Request(FETCH_COPIES_FROM_VOLUME, record.doc_id(), callnumber, orgid); + req.callback(cpdDrawCopies); + + req.request.args = request_args; + + req.send(); + } else { + setTimeout( + function() { + delete request_args['copy_location']; + cpdDrawCopies({ + 'args' : request_args, + 'getResultObject' : function() { return already_fetched_copies; } + }); + }, 0 + ); + } if( contextRow.nextSibling ) contextTbody.insertBefore( templateRow, contextRow.nextSibling ); else contextTbody.appendChild( templateRow ); - - req.send(); _debug('creating new details row with id ' + templateRow.id); cpdNodes[templateRow.id] = { templateRow : templateRow }; return templateRow.id; @@ -196,11 +213,25 @@ function cpdDrawCopies(r) { for( var i = 0; i < copies.length; i++ ) { var row = copyrow.cloneNode(true); var copyid = copies[i]; - var req = new Request(FETCH_FLESHED_COPY, copies[i]); - req.callback(cpdDrawCopy); - req.request.args = r.args; - req.request.row = row; - req.send(); + if (typeof copyid != 'object') { + var req = new Request(FETCH_FLESHED_COPY, copyid); + req.callback(cpdDrawCopy); + req.request.args = r.args; + req.request.row = row; + req.send(); + } else { + setTimeout( + function(copy,row) { + return function() { + cpdDrawCopy({ + 'getResultObject' : function() { return copy; }, + 'args' : r.args, + 'row' : row + }); + }; + }(copies[i],row), 0 + ); + } copytbody.appendChild(row); } } diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index f3af696026..a78e9f44c6 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -264,11 +264,17 @@ function rdetailForeignItems(r,id) { var details = elem( 'a', { - 'href' : 'javascript:alert("foo")', + 'href' : 'javascript:void(0)', 'class' : 'classic_link' }, 'Copy Details' ); + details.onclick = function(idx){ + return function() { + cpdBuild( tbody, row, robj.records[idx], null, 1, 0, 1, + dojo.filter( robj.items, function(item) { return item.call_number().record() == robj.records[idx].doc_id(); } ) ); + }; + }(i); td3.appendChild(details); } } -- 2.11.0