Pass peer types around to be surfaced next to foreign copies
authorMike Rylander <mrylander@gmail.com>
Tue, 12 Apr 2011 01:34:07 +0000 (21:34 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 12 Apr 2011 01:34:07 +0000 (21:34 -0400)
Open-ILS/web/opac/skin/default/js/copy_details.js
Open-ILS/web/opac/skin/default/js/rdetail.js

index c94d010..50361b6 100644 (file)
@@ -9,7 +9,7 @@ var showDueDate = false;
 */
 var showDueTime = false;
 
-function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location, already_fetched_copies ) {
+function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location, already_fetched_copies, peer_types ) {
        var i = cpdCheckExisting(contextRow);
        if(i) return i;
 
@@ -51,6 +51,7 @@ function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, c
        var extrasRow = mainTbody.removeChild($n(mainTbody, 'copy_extras_row'));
 
     var request_args = {
+        peer_types      : peer_types, /* indexed the same as already_fetched_copies */
         contextTbody   : contextTbody, /* tbody that holds the contextrow */
         contextRow             : contextRow, /* the row our new row will be inserted after */
         record                 : record,
@@ -213,6 +214,7 @@ function cpdDrawCopies(r) {
        for( var i = 0; i < copies.length; i++ ) {
                var row = copyrow.cloneNode(true);
                var copyid = copies[i];
+        var pt; if (args.peer_types) pt = args.peer_types[i];
         if (typeof copyid != 'object') {
             var req = new Request(FETCH_FLESHED_COPY, copyid);
             req.callback(cpdDrawCopy);
@@ -221,15 +223,16 @@ function cpdDrawCopies(r) {
             req.send();
         } else {
             setTimeout(
-                function(copy,row) {
+                function(copy,row,pt) {
                     return function() {
                         cpdDrawCopy({
                             'getResultObject' : function() { return copy; },
                             'args' : r.args,
+                            'peer_type' : pt,
                             'row' : row
                         });
                     };
-                }(copies[i],row), 0
+                }(copies[i],row,pt), 0
             );
         }
                copytbody.appendChild(row);
@@ -239,6 +242,7 @@ function cpdDrawCopies(r) {
 function cpdDrawCopy(r) {
        var copy = r.getResultObject();
        var row  = r.row;
+       var pt   = r.peer_type;
     var trow = r.args.templateRow;
 
     if (r.args.copy_location && copy.location().name() != r.args.copy_location) {
@@ -247,6 +251,12 @@ function cpdDrawCopy(r) {
     }
 
        var b = $n(row, 'barcode').appendChild(text(copy.barcode()));
+
+    /* show the peer type*/
+    if (pt) {
+        $n(row, 'barcode').appendChild(text(' :: ' + pt));
+    }
+
        $n(row, 'location').appendChild(text(copy.location().name()));
        $n(row, 'status').appendChild(text(copy.status().name()));
 
@@ -275,6 +285,7 @@ function cpdDrawCopy(r) {
         }
         l.setAttribute('href',buildOPACLink(link_args));
     }
+
        if(isXUL()) {
                /* show the hold link */
                var l = $n(row, 'copy_hold_link');
index 1f960fd..8197318 100644 (file)
@@ -282,6 +282,10 @@ function rdetailForeignItems(r,id) {
                     dojo.map(
                         robj[idx].foreign_copy_maps(),
                         function(x){ return x.target_copy(); }
+                    ),
+                    dojo.map(
+                        robj[idx].foreign_copy_maps(),
+                        function(x){ return x.peer_type().name(); }
                     )
                 );
             };