From e638ff06634005ce2dd36ac7bb8fb2e6c0c3fd41 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Wed, 11 Jan 2012 15:04:22 -0500 Subject: [PATCH] Display Serial Unit Contents in Catalog 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 --- Open-ILS/examples/fm_IDL.xml | 4 +++ .../lib/OpenILS/Application/Search/Biblio.pm | 9 ++++--- Open-ILS/web/opac/locale/en-US/opac.dtd | 1 + Open-ILS/web/opac/skin/default/js/copy_details.js | 30 +++++++++++++++++++--- .../default/xml/rdetail/rdetail_cn_details.xml | 2 ++ 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 8c481ec5ed..cf1e297e09 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4169,6 +4169,7 @@ SELECT usr, + @@ -5271,8 +5272,10 @@ SELECT usr, + + @@ -5292,6 +5295,7 @@ SELECT usr, + 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 eb166a6318..ad3c6252dd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -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} ] ); diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd index 545085a9ad..0085f1868b 100644 --- a/Open-ILS/web/opac/locale/en-US/opac.dtd +++ b/Open-ILS/web/opac/locale/en-US/opac.dtd @@ -496,6 +496,7 @@ Please see a librarian to renew your account."> + 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 253e671fd2..91d8c4a0f3 100644 --- a/Open-ILS/web/opac/skin/default/js/copy_details.js +++ b/Open-ILS/web/opac/skin/default/js/copy_details.js @@ -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'); diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml index d443b9f9a6..42e3128bd2 100644 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml +++ b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml @@ -14,6 +14,7 @@ &common.status; &rdetail.cn.location; &rdetail.cn.part; + &rdetail.cn.contents; &rdetail.cn.hold.age; &rdetail.cn.genesis; &rdetail.cn.active; @@ -40,6 +41,7 @@ + &rdetail.cn.disabled; -- 2.11.0