started work on the notes interface in the opac.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Mar 2006 22:46:26 +0000 (22:46 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Mar 2006 22:46:26 +0000 (22:46 +0000)
needs optimization, but the basic interface is there

git-svn-id: svn://svn.open-ils.org/ILS/trunk@3275 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml
Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_notes.xml [new file with mode: 0644]

index e41a533..5ad6a8e 100644 (file)
@@ -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;
 
index 479705c..1baf1e6 100644 (file)
@@ -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;
index 5d2273a..07561f4 100644 (file)
@@ -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';
 /* ---------------------------------------------------------------------------- */
 
 
index c182bdc..8f37795 100644 (file)
@@ -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) {
index 95add5f..37e4ead 100644 (file)
                                                class='classic_link'>Annotation</a>
                                </td>
 
+                               <td id='rdetail_viewnotes_link' class='hide_me rdetail_extras_td'
+                                       style='padding-right: 15px; padding-left: 15px;' >
+                                       <a href='javascript:rdetailShowExtra("notes");' 
+                                               class='classic_link'>Item Notes</a>
+                               </td>
+
                                <td id='rdetail_viewmarc_link' class='rdetail_extras_td'
                                        style='padding-right: 15px; padding-left: 15px;' >
                                        <a href='javascript:rdetailShowExtra("marc");' 
                                                class='classic_link'>MARC Record</a>
                                </td>
 
+
                        </tr>
                </thead>
        </table>
@@ -71,5 +78,7 @@
                        <!--#include virtual="../common/cn_browse.xml"-->
                </div>
 
+               <!--#include virtual="rdetail_notes.xml"-->
+
        </div>
 </div>
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 (file)
index 0000000..e0a48f4
--- /dev/null
@@ -0,0 +1,13 @@
+<div id='rdetail_notes_div' class='rdetail_extras_div hide_me'>
+       <table class='data_grid'>
+               <tbody id='rdetail_notes_tbody'>
+                       <tr id='rdetail_notes_row'>
+                               <td name='rdetail_notes_title'/>
+                               <td name='rdetail_notes_value'/>
+                               <td name='rdetail_notes_cn'/>
+                               <td name='rdetail_notes_barcode'/>
+                               <td name='rdetail_notes_owner'/>
+                       </tr>
+               </tbody>
+       </table>
+</div>