more added content methods created and some added content added to the
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Nov 2005 18:52:35 +0000 (18:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Nov 2005 18:52:35 +0000 (18:52 +0000)
record detail page

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

13 files changed:
Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/web/opac/skin/default/css/layout.css
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/myopac_checked.xml
Open-ILS/web/opac/skin/default/xml/myopac_fines.xml
Open-ILS/web/opac/skin/default/xml/myopac_holds.xml
Open-ILS/web/opac/skin/default/xml/myopac_summary.xml
Open-ILS/web/opac/skin/default/xml/rdetail.xml
Open-ILS/web/opac/skin/default/xml/rdetail_copyinfo.xml
Open-ILS/web/opac/skin/default/xml/sidebar.xml
Open-ILS/web/opac/theme/default/css/colors.css

index d5a361e..5327c68 100644 (file)
@@ -17,6 +17,7 @@ my $types = {
        toc                     => "TOC.asmx",
        review          => "Review.asmx",
        annotation      => "Annotation.asmx",
+       member          => "Member.asmx",
        };
 
 sub initialize {
@@ -31,62 +32,145 @@ sub initialize {
 
 
 
-__PACKAGE__->register_method(
-       method  => "added_content",
-       api_name        => "open-ils.search.added_content.retrieve",
-       notes           => <<"  NOTE");
-               Returns a list values based on the added content type. 
-               types include: toc, review, annotation
-               PARAMS( ISBN ),
-       NOTE
+# Fetches the added content and returns the data as a string.
+# If not data is retrieved (or timeout occurs), undef is returned
+sub retrieve_added_content {
+       my( $type, $isbn, $summary ) = @_;
 
-sub added_content {
-       my( $self, $client, $isbn, $type ) = @_;
+       my $func = "fnDetailByItemKey";
+       if($summary) { $func = "fnContentByItemKey"; }
 
        my $url = "$host/$urlbase/" . $types->{$type} . 
-               "/fnDetailByItemKey?UserId=$username&Password=$password&ItemKey=$isbn";
+               "/$func?UserId=$username&Password=$password&ItemKey=$isbn";
+
 
        warn "Added Content URL: $url\n";
 
-       my $data;
+       my $data = undef;
        try {
                alarm(15);
                $data = LWP::UserAgent->new->get($url)->content;
                alarm(0);
        } catch Error with {
                alarm(0);
-               $data = [];
        };
        alarm(0);
 
        warn "received content data:\n$data\n";
+       return $data;
+}
 
-       return $data if(ref($data));
+__PACKAGE__->register_method(
+       method  => "summary",
+       api_name        => "open-ils.search.added_content.summary.retrieve",
+       notes           => <<"  NOTE");
+               Returns an object like so:
+                       {
+                               Review : true/false,
+                               Inventory : true/false,
+                               Annotation : true/false,
+                               Jacket : true/false
+                               TOC : true/false
+                               Product : true/false
+                       }
+               This object indicates the existance of each type of added content for the given ISBN
+               PARAMS( ISBN ),
+       NOTE
+
+sub summary {
+       my( $self, $client, $isbn ) = @_;
+       my $data = retrieve_added_content( "member", $isbn, 1 );
+       my $doc = XML::LibXML->new->parse_string($data);
+       my $summary = {};
+       return $summary unless $doc;
 
-       return _parse_content($type, $data);
+       for my $node ( $doc->getDocumentElement->childNodes ) {
+               if( $node->localName ) {
+                       $summary->{$node->localName} = $node->textContent;      
+               }
+       }
+       return $summary;
 }
 
-sub _parse_content {
-       my( $type, $data ) = @_;
 
+
+
+
+__PACKAGE__->register_method(
+       method  => "reviews",
+       api_name        => "open-ils.search.added_content.review.retrieve.random",
+       notes           => <<"  NOTE");
+               Returns a singe random review article object
+               PARAMS( ISBN ),
+       NOTE
+
+__PACKAGE__->register_method(
+       method  => "reviews",
+       api_name        => "open-ils.search.added_content.review.retrieve.all",
+       notes           => <<"  NOTE");
+               Returns an array review article objects
+               PARAMS( ISBN ),
+       NOTE
+
+sub reviews {
+       my( $self, $client, $isbn ) = @_;
+
+       my $data = retrieve_added_content( "review", $isbn );
        my $doc = XML::LibXML->new->parse_string($data);
        my $ret = [];
-       return $ret unless $doc;
 
-       if( $type eq "review" ) {
+       if(!$doc) {
+               if( $self->api_name =~ /random/ ) { return undef; }
+               return $ret;
+       }
+
+       my $reviews = $doc->findnodes("//*[local-name()='Review']");
+
+       for my $rev ( $reviews->get_nodelist() ) {
+               my $revobj = {};
+               for my $node ($rev->childNodes) {
 
-               warn '-'x50 . "\n";
-               warn $doc->toString(1) . "\n";
-               warn '-'x50 . "\n";
+                       if( $node->localName ) {
+                               if( $node->localName eq "ReviewText" ) {
+                                       $revobj ->{'text'} = $node->textContent;
+                               }
+                               if( $node->localName eq "ReviewLiteral" ) {
+                                       $revobj->{'info'} = $node->textContent;
+                               }
 
-               my $nodelist = $doc->findnodes("//*[local-name()='ReviewText']");
-               for my $rev ( $nodelist->get_nodelist() ) {
-                       push( @$ret, $rev->textContent );
+                       }
                }
+
+               if( $self->api_name =~ /random/ ) { return $revobj; }
+               push( @$ret, $revobj );
        }
 
        return $ret;
 }
 
 
+__PACKAGE__->register_method(
+       method  => "toc",
+       api_name        => "open-ils.search.added_content.toc.retrieve",
+       notes           => <<"  NOTE");
+               Returns the table of contents for the given ISBN
+               PARAMS( ISBN ),
+       NOTE
+
+sub toc {
+       my( $self, $client, $isbn ) = @_;
+
+       my $data = retrieve_added_content( "toc", $isbn );
+       my $doc = XML::LibXML->new->parse_string($data);
+       my $ret = {};
+
+       my $reviews = $doc->findnodes("//*[local-name()='Review']");
+
+       # XXX
+       $ret->{text} = $reviews->toString();
+
+       return $ret;
+}
+
+
 1;
index feda65d..a932290 100644 (file)
@@ -201,6 +201,9 @@ var UPDATE_PASSWORD                         = "open-ils.actor:open-ils.actor.user.password.update";
 var UPDATE_EMAIL                                       = "open-ils.actor:open-ils.actor.user.email.update";
 var RENEW_CIRC                                         = "open-ils.circ:open-ils.circ.renew";
 var CHECK_SPELL                                        = "open-ils.search:open-ils.search.spell_check";
+var FETCH_REVIEWS                                      = "open-ils.search:open-ils.search.added_content.review.retrieve.all";
+var FETCH_TOC                                          = "open-ils.search:open-ils.search.added_content.toc.retrieve";
+var FETCH_ACONT_SUMMARY                        = "open-ils.search:open-ils.search.added_content.summary.retrieve";
 /* ---------------------------------------------------------------------------- */
 
 
index 2659dc1..1ba2040 100644 (file)
@@ -42,6 +42,7 @@
 <!ENTITY sidebar.relevantSubjects.headerLabel "Relevant Subjects">
 <!ENTITY sidebar.relevantAuthors.headerLabel "Relevant Authors">
 <!ENTITY sidebar.relevantSeries.headerLabel "Relevant Series">
+<!ENTITY sidebar.relevantReviews.headerLabel "Reviews">
 
 
 <!-- Record Details -->
index 1afab75..6287ad9 100644 (file)
@@ -10,8 +10,9 @@ table { border-collapse: collapse; }
 
 /* generic CSS for a table with data */
 .data_grid { font-weight: 500; }
-.data_grid thead tr { background: #CCFFFF; color: #000000; border: 1px solid #808080; }
-.data_grid thead td { border-bottom: 1px solid #808080; }
+/*.data_grid thead tr { background: #CCFFFF; color: #000000; border: 1px solid #808080; }*/
+.data_grid thead tr { background: #E0F0E0; color: #000000; border: 1px solid #808080; }
+.data_grid thead td { border-bottom: 1px solid #808080; padding-right: 5px; padding-left: 5px;}
 .data_grid tbody td { border: 1px solid #E0E0E0; padding: 5px; }
 
 .classic_link { text-decoration: underline; color: blue;}
@@ -140,26 +141,7 @@ border-left: 1px solid #E0E0E0; border-top: 1px solid #E0E0E0; border-bottom: 1p
        border-bottom: 1px solid #808080; 
        border-top: 1px solid #808080; }
 
-/*
-.myopac_link { 
-       width: 18%; margin: 3px; padding: 3px; 
-       text-align: center; vertical-align: middle; 
-       border-top: 1px solid #808080; }
-       */
-
-/*
-.myopac_link_active { background: #CCFFFF; border-bottom: 6px solid green;} 
-*/
-
-.myopac_link_active { background: #CCFFFF; font-weight: 700;}
-
-
-/*
-.color_1 { background: #A7EA9D; color: #000000; }
-.color_2 { background: #64EA4F; color: #000000; }
-.color_3 { background: #CCFFFF; color: #000000; }
-*/
-
+.myopac_link_active { background: #E0F0E0; font-weight: 700;}
 .myopac_table thead tr td { padding: 2px; font-weight: 500; border: 1px solid #808080;}
 .myopac_table td { padding: 3px; }
 .myopac_form_pic { width: 20px; height: 20px; }
@@ -173,4 +155,15 @@ border-left: 1px solid #E0E0E0; border-top: 1px solid #E0E0E0; border-bottom: 1p
 #result_low_hits { border-top: 2px solid #A7EA9D }
 
 .lowhits_div { width: 100%; border-top: 1px solid #E0E0E0; text-align: center; 
-       padding-top: 8px; padding-bottom: 8px; }/*margin-top:15px; vertical-align: middle; }*/
+       padding-top: 8px; padding-bottom: 8px; }
+
+.rdetail_extras_div {
+       border-top: 2px solid #E0E0E0;
+}
+
+.copy_info_region_row {
+       padding: 6px;
+       border: 2px solid #E0E0E0;
+       font-weight: 600;
+       background: #E0F0E0;
+}
index 207a52d..a2c6394 100644 (file)
@@ -99,6 +99,68 @@ function _rdetailDraw(r) {
        G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
        runEvt("rdetail", "recordDrawn");
        recordsCache.push(record);
+
+       var req = new Request(FETCH_ACONT_SUMMARY, cleanISBN(record.isbn()));
+       req.callback(rdetailHandleAddedContent);
+       req.send();
+
+}
+
+function rdetailShowExtra(type) {
+
+       hideMe($('rdetail_copy_info_div'));
+       hideMe($('rdetail_reviews_div'));
+       hideMe($('rdetail_toc_div'));
+
+       switch(type) {
+               case "copyinfo": unHideMe($('rdetail_copy_info_div')); break;
+               case "reviews": unHideMe($('rdetail_reviews_div')); break;
+               case "tocs": unHideMe($('rdetail_tocs_div')); break;
+       }
+}
+
+function rdetailHandleAddedContent(r) {
+       var resp = r.getResultObject();
+
+       if( resp.Review == 'true' ) { 
+               var req = new Request(FETCH_REVIEWS, cleanISBN(record.isbn()));
+               req.callback(rdetailShowReviews);
+               req.send();
+       }
+
+       if( resp.TOC == 'true' ) { 
+               var req = new Request(FETCH_TOC, cleanISBN(record.isbn()));
+               req.callback(rdetailShowTOC);
+               req.send();
+       }
+
+}
+
+
+function rdetailShowReviews(r) {
+       var res = r.getResultObject();
+       var par = $('rdetail_reviews_div');
+       var template = par.removeChild($('rdetail_review_template'));
+       if( res && res.length > 0 ) {
+               unHideMe($('rdetail_reviews_link'));
+               for( var i = 0; i != res.length; i++ ) {
+                       var rev = res[i];       
+                       if( rev.text && rev.info ) {
+                               var node = template.cloneNode(true);
+                               $n(node, 'review_header').appendChild(text(rev.info));
+                               $n(node, 'review_text').appendChild(text(rev.text));
+                               par.appendChild(node);
+                       }
+               }
+       }
+}
+
+function rdetailShowTOC(r) {
+       var resp = r.getResultObject();
+       if(resp) {
+               unHideMe($('rdetail_toc_link'));
+               $('rdetail_toc_div').appendChild(text(resp));
+       }
 }
 
 
@@ -130,7 +192,8 @@ function _rdetailRows(node) {
 
                        libtd.setAttribute("colspan", numStatuses + 2 );
                        libtd.colSpan = numStatuses + 2;
-                       addCSSClass(row, config.css.color_3);
+                       //addCSSClass(row, config.css.color_3);
+                       addCSSClass(row, 'copy_info_region_row');
                } 
        
                copyRowParent.appendChild(row);
index 3a9a724..b081509 100644 (file)
@@ -6,7 +6,7 @@
        </script>
 
 
-       <table width='100%' class='light_border myopac_table'>
+       <table width='100%' class='light_border data_grid'>
 
                <thead class='color_3'>
                        <tr>
index d09ddad..808e156 100644 (file)
@@ -3,7 +3,7 @@
 <div id='myopac_fines_div' xmlns:xi="http://www.w3.org/2001/XInclude" >
 
        <br/>
-       <table width='100%' class='light_border myopac_table'>
+       <table width='100%' class='light_border data_grid'>
 
                <thead class='color_3'>
                        <tr><td colspan='3' align='center' style='background: none'><b>Summary</b></td></tr>
index d028e35..d221937 100644 (file)
@@ -4,7 +4,7 @@
 
        <script language='javascript' src='../js/holds.js'> </script>
 
-       <table width='100%' class='light_border myopac_table'>
+       <table width='100%' class='light_border data_grid'>
 
                <thead class='color_3'>
                        <tr>
index f77e149..6eb4956 100644 (file)
@@ -4,35 +4,35 @@
 
        <br/>
 
-       <table width='100%' class='light_border myopac_table'>
+       <table width='100%' class='light_border data_grid'>
 
                <tbody id='myopac_summary_tbody'>
                        <tr>
-                               <td class='color_3 light_border' width='20%'>First Name</td>
+                               <td class='color_4 light_border' width='20%'>First Name</td>
                                <td class='light_border' id='myopac_summary_first'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Middle Name</td>
+                               <td class='color_4 light_border'>Middle Name</td>
                                <td class='light_border' id='myopac_summary_middle'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Last Name</td>
+                               <td class='color_4 light_border'>Last Name</td>
                                <td class='light_border' id='myopac_summary_last'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Day Phone</td>
+                               <td class='color_4 light_border'>Day Phone</td>
                                <td class='light_border' id='myopac_summary_dayphone'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Evening Phone</td>
+                               <td class='color_4 light_border'>Evening Phone</td>
                                <td class='light_border' id='myopac_summary_eveningphone'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Other Phone</td>
+                               <td class='color_4 light_border'>Other Phone</td>
                                <td class='light_border' id='myopac_summary_otherphone'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Username</td>
+                               <td class='color_4 light_border'>Username</td>
                                <td class='light_border' id='myopac_summary_username'> </td>
                                <td class='light_border'><a href='javascript:void(0);' 
                                        onclick='unHideMe($("myopac_update_username_row"));$("myopac_new_username").focus();'
@@ -55,7 +55,7 @@
 
 
                        <tr>
-                               <td class='color_3 light_border'>Password</td>
+                               <td class='color_4 light_border'>Password</td>
                                <td class='light_border' id='myopac_summary_password'>(not shown)</td>
                                <td class='light_border'><a href='javascript:void(0);' 
                                        onclick='unHideMe($("myopac_update_password_row"));$("myopac_current_password").focus();'
@@ -93,7 +93,7 @@
                        </tr>
 
                        <tr>
-                               <td class='color_3 light_border'>Email Address</td>
+                               <td class='color_4 light_border'>Email Address</td>
                                <td class='light_border' id='myopac_summary_email'> </td>
                                <td class='light_border'><a href='javascript:void(0);' 
                                        onclick='unHideMe($("myopac_update_email_row"));$("myopac_new_email").focus();'
                        </tr>
 
                        <tr>
-                               <td class='color_3 light_border'>Primary Identification</td>
+                               <td class='color_4 light_border'>Primary Identification</td>
                                <td class='light_border' id='myopac_summary_ident1'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Secondary Identification</td>
+                               <td class='color_4 light_border'>Secondary Identification</td>
                                <td class='light_border' id='myopac_summary_ident2'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Active Barcode</td>
+                               <td class='color_4 light_border'>Active Barcode</td>
                                <td class='light_border' id='myopac_summary_barcode'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Home Library</td>
+                               <td class='color_4 light_border'>Home Library</td>
                                <td class='light_border' id='myopac_summary_homelib'> </td>
                        </tr>
                        <tr>
-                               <td class='color_3 light_border'>Account Creation Date</td>
+                               <td class='color_4 light_border'>Account Creation Date</td>
                                <td class='light_border' id='myopac_summary_create_date'> </td>
                        </tr>
 
 
 
        <br/><br/><br/>
-       <table width='100%' class='light_border myopac_table'>
-               <thead class='color_3'>
+       <table width='100%' class='light_border data_grid'>
+               <thead class='color_4'>
                        <tr><td style='background: none; border-bottom: none' align='center' colspan='7'><b>Addresses</b></td></tr>
                        <tr>
                                <td width='16%'>Address Type</td>
index f86bbee..c0f4600 100644 (file)
                                                                </table>
                                                                <xi:include href="rdetail_summary.xml"/>
                                                                <br/><br/>
+                                                               <!--
                                                                <xi:include href="rdetail_copyinfo.xml"/>
+                                                               -->
+                                                               <xi:include href='rdetail_extras.xml'/>
                                                        </div>
                                                </div>
                                        </td>
index 860d64d..f1ec94f 100644 (file)
@@ -1,21 +1,23 @@
 <?xml version='1.0'?>
 
 <!-- This holds information for copies attached to this record -->
-<div>
+<div id='rdetail_copy_info_div'>
 
        <!-- header bar for the copy info table.  this allows you to select local
                        or global copy information -->
-       <table class='color_1 rdetail_header' width='100%' >
+       <table class='rdetail_extras_div' width='100%' >
                <tbody>
                        <tr>
+                               <!--
                                <td align='left'>&rdetail.copyInfo.headerLabel;</td>
-                               <td align='right'>
+                               -->
+                               <td align='center' width=''>
                                        <a href='javascript:void(0);' id='copy_info_local_link' 
-                                               class='rdetail_copy_nav_link hide_me'>&rdetail.copyInfo.local;</a>
+                                               class='rdetail_copy_nav_link hide_me classic_link'>&rdetail.copyInfo.local;</a>
                                </td>
-                               <td align='right'>
+                               <td align='center' width=''>
                                        <a href='javascript:void(0);' id='copy_info_all_link' 
-                                               class='rdetail_copy_nav_link'>&rdetail.copyInfo.all;</a>
+                                               class='rdetail_copy_nav_link classic_link'>&rdetail.copyInfo.all;</a>
                                </td>
                        </tr>
                </tbody>
index 2ab5947..9a5e0e6 100644 (file)
        </div>
 
 
-
-
-
        <!-- ============================================================================= -->
        <!-- Our javascript -->
        <script language='javascript' src='../js/sidebar.js'> </script>
index 3923270..53181ff 100644 (file)
@@ -5,6 +5,7 @@ body a:hover    { color: red; text-decoration: underline;}
 .color_1 { background: #A7EA9D; color: #000000; }
 .color_2 { background: #64EA4F; color: #000000; }
 .color_3 { background: #CCFFFF; color: #000000; }
+.color_4 { background: #E0F0E0; color: #000000; }
 
 /*
 .color_1 { background: #4D8444; color: #000000; }