Display Serial Unit Contents in Catalog collab/dbwells/sunit_contents_display
authorDan Wells <dbw2@calvin.edu>
Wed, 11 Jan 2012 20:04:22 +0000 (15:04 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 11 Jan 2012 20:04:22 +0000 (15:04 -0500)
This commit is the first few pieces needed to expose the
content information of serial units to the public.  It does
the following:

1) Adds some linking information to the IDL to allow better
correlation between copies and units
2) Changes a few middle layer methods to pull in the contents info
and also to sort by the unit sort_key when available
3) Displays the contents information in the JSOPAC copy info table

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
Open-ILS/web/opac/locale/en-US/opac.dtd
Open-ILS/web/opac/skin/default/js/copy_details.js
Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml

index 8c481ec..cf1e297 100644 (file)
@@ -4169,6 +4169,7 @@ SELECT  usr,
                        <field reporter:label="Statistical Category Entries" name="stat_cat_entries" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
+                       <link field="id" reltype="has_a" key="id" map="" class="acp"/>
                        <link field="age_protect" reltype="has_a" key="id" map="" class="crahp"/>
                        <link field="call_number" reltype="has_a" key="id" map="" class="acn"/>
                        <link field="location" reltype="has_a" key="id" map="" class="acpl"/>
@@ -5271,8 +5272,10 @@ SELECT  usr,
                        <field reporter:label="Peer Record Maps" name="peer_record_maps" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Peer Records" name="peer_records" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Last Captured Hold" name="last_captured_hold" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Detailed Contents (Serial Unit)" name="sunit_detailed_contents" oils_persist:virtual="true" reporter:datatype="text"/>
                </fields>
                <links>
+                       <link field="id" reltype="might_have" key="id" map="" class="sunit"/>
                        <link field="age_protect" reltype="has_a" key="id" map="" class="crahp"/>
                        <link field="call_number" reltype="has_a" key="id" map="" class="acn"/>
                        <link field="location" reltype="has_a" key="id" map="" class="acpl"/>
@@ -5292,6 +5295,7 @@ SELECT  usr,
                        <link field="peer_record_maps" reltype="has_many" key="target_copy" map="" class="bpbcm"/>
                        <link field="peer_records" reltype="has_many" key="target_copy" map="peer_record" class="bpbcm"/>
                        <link field="last_captured_hold" reltype="has_a" key="current_copy" map="" class="alhr"/>
+                       <link field="sunit_detailed_contents" reltype="might_have" key="id" map="detailed_contents" class="sunit"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
index eb166a6..ad3c625 100644 (file)
@@ -494,7 +494,7 @@ sub fleshed_copy_retrieve2 {
                 flesh        => 2,
                 flesh_fields => {
                     acp => [
-                        qw/ location status stat_cat_entry_copy_maps notes age_protect parts peer_record_maps /
+                        qw/ location status stat_cat_entry_copy_maps notes age_protect parts peer_record_maps sunit_detailed_contents /
                     ],
                     ascecm => [qw/ stat_cat stat_cat_entry /],
                 }
@@ -2691,15 +2691,18 @@ sub copies_by_cn_label {
        my $cns = $e->search_asset_call_number({record => $record, prefix => $cnp_id, label => $cn_parts->[1], suffix => $cns_id, deleted => 'f'}, {idlist=>1});
        return [] unless @$cns;
 
+       my $join = {'sunit' => {'type' => 'left'}};
+       my $order_by = {'sunit' => 'sort_key ASC'};
+
        # show all non-deleted copies in the staff client ...
        if ($self->api_name =~ /staff$/o) {
-               return $e->search_asset_copy({call_number => $cns, circ_lib => $circ_lib, deleted => 'f'}, {idlist=>1});
+               return $e->search_asset_copy({call_number => $cns, circ_lib => $circ_lib, deleted => 'f'}, {'join' => $join, order_by => $order_by, idlist => 1});
        }
 
        # ... otherwise, grab the copies ...
        my $copies = $e->search_asset_copy(
                [ {call_number => $cns, circ_lib => $circ_lib, deleted => 'f', opac_visible => 't'},
-                 {flesh => 1, flesh_fields => { acp => [ qw/location status/] } }
+                 {flesh => 1, flesh_fields => { acp => [ qw/location status/] }, 'join' => $join, order_by => $order_by}
                ]
        );
 
index 545085a..0085f18 100644 (file)
@@ -496,6 +496,7 @@ Please see a librarian to renew your account.">
 <!ENTITY rdetail.print "print these details">
 <!ENTITY rdetail.cn.part "Part">
 <!ENTITY rdetail.cn.barcode "Barcode">
+<!ENTITY rdetail.cn.contents "Contents">
 <!ENTITY rdetail.cn.location "Location">
 <!ENTITY rdetail.cn.hold.age "Age Hold Protection">
 <!ENTITY rdetail.cn.genesis "Create Date">
index 253e671..91d8c4a 100644 (file)
@@ -216,29 +216,32 @@ function cpdDrawCopies(r) {
 
        for( var i = 0; i < copies.length; i++ ) {
                var row = copyrow.cloneNode(true);
+               copytbody.appendChild(row);
                var copyid = copies[i];
         var pt; if (args.peer_types) pt = args.peer_types[i];
+        var cols_showing = {};
         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.request.cols_showing = cols_showing;
             req.send();
         } else {
             setTimeout(
-                function(copy,row,pt) {
+                function(copy,row,pt,cols_showing) {
                     return function() {
                         cpdDrawCopy({
                             'getResultObject' : function() { return copy; },
                             'args' : r.args,
                             'peer_type' : pt,
+                            'cols_showing' : cols_showing,
                             'row' : row
                         });
                     };
-                }(copies[i],row,pt), 0
+                }(copies[i],row,pt,cols_showing), 0
             );
         }
-               copytbody.appendChild(row);
        }
 }
 
@@ -247,6 +250,7 @@ function cpdDrawCopy(r) {
        var row  = r.row;
        var pt   = r.peer_type;
     var trow = r.args.templateRow;
+    var cols_showing = r.cols_showing;
 
     if (r.args.copy_location && copy.location().name() != r.args.copy_location) {
         hideMe(row);
@@ -287,6 +291,26 @@ function cpdDrawCopy(r) {
         }
     }
 
+    // show unit contents if any copies have them available
+    if (copy.sunit_detailed_contents()) {
+        if (!cols_showing.sunit_contents) {
+            // this is the first copy with contents,
+            // unhide the column in the header and
+            // in any existing rows
+            unHideMe($n(trow, 'sunit_contents_label'));
+            var allRows = row.parentNode.children;
+            for (var i = 0; i < allRows.length; i++) {
+                unHideMe($n(allRows[i], 'sunit_contents'));
+            }
+            cols_showing.sunit_contents = true;
+        }
+        var node = $n(row, 'sunit_contents');
+        node.appendChild(text(copy.sunit_detailed_contents()));
+    } else if (cols_showing.sunit_contents) {
+        // the column is already showing, so show it in this row no matter what
+        unHideMe($n(row, 'sunit_contents'));
+    }
+
     /* show the other bibs link */
     if (copy.peer_record_maps().length > 0) {
         var l = $n(row, 'copy_multi_home');
index d443b9f..42e3128 100644 (file)
@@ -14,6 +14,7 @@
                                                                <td>&common.status;</td>
                                                                <td>&rdetail.cn.location;</td>
                                                                <td name='copy_part_label' class='hide_me'>&rdetail.cn.part;</td>
+                                                               <td name='sunit_contents_label' class='hide_me'>&rdetail.cn.contents;</td>
                                                                <td name='age_protect_label' class='hide_me'>&rdetail.cn.hold.age;</td>
                                                                <td name='create_date_label' class='hide_me'>&rdetail.cn.genesis;</td>
                                 <td name='active_date_label' class='hide_me'>&rdetail.cn.active;</td>
@@ -40,6 +41,7 @@
                                                                <td name='status'> </td>
                                                                <td name='location'> </td>
                                                                <td name='copy_part' class='hide_me'> </td>
+                                                               <td name='sunit_contents' class='hide_me'> </td>
                                                                <td name='age_protect_value' class='hide_me'>&rdetail.cn.disabled;</td>
                                                                <td name='create_date_value' class='hide_me'> </td>
                                 <td name='active_date_value' class='hide_me'> </td>