copy details for the Linked Title extras pane
authorJason Etheridge <jason@esilibrary.com>
Mon, 11 Apr 2011 14:28:48 +0000 (10:28 -0400)
committerJason Etheridge <jason@esilibrary.com>
Mon, 11 Apr 2011 14:28:48 +0000 (10:28 -0400)
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
Open-ILS/web/opac/skin/default/js/copy_details.js
Open-ILS/web/opac/skin/default/js/rdetail.js

index 1130440..b6a6f6d 100644 (file)
@@ -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' ]
                 }
             }
         ]
index 7c8c847..c94d010 100644 (file)
@@ -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);
        }
 }
index f3af696..a78e9f4 100644 (file)
@@ -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);
     }
 }