*/
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;
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;
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);
}
}