From 92795ae4dd24957d87f41a942f1447477d9c5e69 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 6 Mar 2006 22:46:26 +0000 Subject: [PATCH] started work on the notes interface in the opac. needs optimization, but the basic interface is there git-svn-id: svn://svn.open-ils.org/ILS/trunk@3275 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/AppUtils.pm | 13 ++++ Open-ILS/src/perlmods/OpenILS/Application/Circ.pm | 74 ++++++++++++++++++++++ Open-ILS/web/opac/common/js/config.js | 1 + Open-ILS/web/opac/skin/default/js/rdetail.js | 56 +++++++++++++++- .../skin/default/xml/rdetail/rdetail_extras.xml | 9 +++ .../skin/default/xml/rdetail/rdetail_notes.xml | 13 ++++ 6 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_notes.xml diff --git a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm index e41a533316..5ad6a8e5f2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm @@ -925,6 +925,19 @@ sub fetch_copy_note { return ($note, $evt); } +sub fetch_call_numbers_by_title { + my( $self, $titleid ) = @_; + $logger->info("Fetching call numbers by title $titleid"); + return $self->storagereq( + 'open-ils.storage.direct.asset.call_number.search.record.atomic', $titleid); +} + +sub fetch_copies_by_call_number { + my( $self, $cnid ) = @_; + $logger->info("Fetching copies by call number $cnid"); + return $self->storagereq( + 'open-ils.storage.direct.asset.copy.search.call_number.atomic', $cnid ); +} 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 479705c948..1baf1e67cc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -426,6 +426,80 @@ sub delete_copy_note { } +__PACKAGE__->register_method( + method => 'note_batch', + api_name => 'open-ils.circ.biblio_notes.public.batch.retrieve', + signature => q/ + Returns a set of notes for a given set of titles, volumes, and copies. + @param titleid The id of the title who's notes are retrieving + @return A list like so: + { + "titles" : [ { id : $id, notes : [ n1, n2 ] },... ] + "volumes" : [ { id : $id, notes : [ n1, n2 ] },... ] + "copies" : [ { id : $id, notes : [ n1, n2 ] },... ] + } + / +); + +sub note_batch { + my( $self, $conn, $titleid ) = @_; + + my @copies; + my $cns = $U->storagereq( + 'open-ils.storage.id_list.asset.call_number.search.record.atomic', $titleid ); + + for my $c (@$cns) { + my $copyids = $U->storagereq( + 'open-ils.storage.id_list.asset.copy.search.call_number.atomic', $c); + push(@copies, @$copyids); + } + + return _note_batch( { titles => [$titleid], volumes => $cns, copies => \@copies} ); +} + + +sub _note_batch { + my $args = shift; + + my %resp; + $resp{titles} = []; + $resp{volumes} = []; + $resp{copies} = []; + + my $titles = (ref($$args{titles})) ? $$args{titles} : []; + my $volumes = (ref($$args{volumes})) ? $$args{volumes} : []; + my $copies = (ref($$args{copies})) ? $$args{copies} : []; + + for my $title (@$titles) { + my $notes = $U->storagereq( + 'open-ils.storage.direct.biblio.record_note.search_where.atomic', + { record => $title, pub => 't' }); + push(@{$resp{titles}}, {id => $title, notes => $notes}) if @$notes; + } + + for my $volume (@$volumes) { + my $notes = $U->storagereq( + 'open-ils.storage.direct.asset.call_number_note.search_where.atomic', + { call_number => $volume, pub => 't' }); + push( @{$resp{volumes}}, {id => $volume, notes => $notes} ) if @$notes; + } + + + for my $copy (@$copies) { + $logger->debug("Fetching copy notes for copy $copy"); + my $notes = $U->storagereq( + 'open-ils.storage.direct.asset.copy_note.search_where.atomic', + { owning_copy => $copy, pub => 't' }); + push( @{$resp{copies}}, { id => $copy, notes => $notes }) if @$notes; + } + + return \%resp; +} + + + + + 1; diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index 5d2273a1c6..07561f4c43 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -278,6 +278,7 @@ var FLESH_CONTAINER = 'open-ils.actor:open-ils.actor.container.flesh'; var FLESH_PUBLIC_CONTAINER = 'open-ils.actor:open-ils.actor.container.public.flesh'; var FETCH_COPY = 'open-ils.search:open-ils.search.asset.copy.retrieve'; var CHECK_HOLD_POSSIBLE = 'open-ils.circ:open-ils.circ.title_hold.is_possible'; +var FETCH_BIBLIO_NOTES = 'open-ils.circ:open-ils.circ.biblio_notes.public.batch.retrieve'; /* ---------------------------------------------------------------------------- */ diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index c182bdc589..8f3779566d 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -15,12 +15,11 @@ var numStatuses = null; var defaultCN; var callnumberCache = {}; var rdetailLocalOnly = true; +var globalCNCache = {}; var nextContainerIndex; function rdetailDraw() { - - copyRowParent = G.ui.rdetail.cp_info_row.parentNode; copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row); statusRow = G.ui.rdetail.cp_status.parentNode; @@ -204,6 +203,7 @@ function rdetailShowExtra(type) { hideMe($('rdetail_marc_div')); hideMe($('cn_browse')); hideMe($('rdetail_cn_browse_div')); + hideMe($('rdetail_notes_div')); var req; switch(type) { @@ -245,6 +245,10 @@ function rdetailShowExtra(type) { unHideMe($('rdetail_cn_browse_div')); rdetailShowCNBrowse(defaultCN, null, true); break; + + case 'notes': + unHideMe($('rdetail_notes_div')); + break; } } @@ -375,8 +379,10 @@ function _rdetailBuildInfoRows(r) { for( var i = 0; i < summary.length; i++ ) { var arr = summary[i]; + globalCNCache[arr[1]] = 1; var thisOrg = findOrgUnit(arr[0]); var rowNode = $("cp_info_" + thisOrg.id()); + if(!rowNode) continue; if(rowNode.getAttribute("used")) { @@ -412,6 +418,52 @@ function _rdetailBuildInfoRows(r) { if(!found) unHideMe(G.ui.rdetail.cp_info_none); + /* now that we know what CN's we have, grab the associated notes */ + rdetailFetchNotes(); +} + +function rdetailFetchNotes() { + var req = new Request(FETCH_BIBLIO_NOTES, record.doc_id()); + req.callback(rdetailDrawNotes); + req.send(); +} + +var rdetailNotesTemplate; +function rdetailDrawNotes(r) { + var notes = r.getResultObject(); + + var tbody = $('rdetail_notes_tbody'); + if(!rdetailNotesTemplate) + rdetailNotesTemplate = tbody.removeChild($('rdetail_notes_row')); + + var found = false; + for( var t in notes.titles ) { + var note = notes.copies[c]; + /* these need to go into a title notes + section different from the copy/cn notes (on the title summary?) */ + } + + for( var v in notes.volumes ) { + var note = notes.copies[c]; + var row = rdetailNotesTemplate.cloneNode(true); + found = true; + } + + for( var c in notes.copies ) { + found = true; + var copynode = notes.copies[c]; + var copy = copynode.id; + var nts = copynode.notes; + for( var n in nts ) { + var note = nts[n]; + var row = rdetailNotesTemplate.cloneNode(true); + $n(row, 'rdetail_notes_title').appendChild(text(note.title())); + $n(row, 'rdetail_notes_value').appendChild(text(note.value())); + tbody.appendChild(row); + } + } + + if(found) unHideMe($('rdetail_viewnotes_link')); } function rdetailBuildBrowseInfo(row, cn, local) { diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml index 95add5f2c2..37e4ead5ea 100644 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml +++ b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml @@ -33,12 +33,19 @@ class='classic_link'>Annotation + + Item Notes + + MARC Record + @@ -71,5 +78,7 @@ + + diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_notes.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_notes.xml new file mode 100644 index 0000000000..e0a48f4ba6 --- /dev/null +++ b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_notes.xml @@ -0,0 +1,13 @@ +
+ + + + + +
+ + + + +
+
-- 2.11.0