Show Added Content Inline - Instead of showing just one element of the added content user/stompro/added_content_inline_larl
authorJosh Stompro <stomproj@larl.org>
Mon, 15 May 2017 14:19:23 +0000 (09:19 -0500)
committerJosh Stompro <stomproj@larl.org>
Mon, 15 May 2017 14:19:23 +0000 (09:19 -0500)
  data at a time, show all available added content inline in the record description.
  Limited to author notes and reviews in our case.  Added ability to order the content
  display, to always show reviews first, then author notes.

Signed-off-by: Josh Stompro <stomproj@larl.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/templates/opac/parts/record/addedcontentinline.tt2 [new file with mode: 0644]
Open-ILS/src/templates/opac/parts/record/contents.tt2
Open-ILS/src/templates/opac/parts/record/extras.tt2

index 98aef3c..488bb95 100644 (file)
@@ -9,7 +9,7 @@ use Net::HTTP::NB;
 use IO::Select;
 my $U = 'OpenILS::Application::AppUtils';
 
-our $ac_types = ['toc',  'anotes', 'excerpt', 'summary', 'reviews'];
+our $ac_types = ['anotes', 'reviews'];
 
 # context additions: 
 #   record : bre object
@@ -566,7 +566,7 @@ sub added_content_stage1 {
 
         $req->host($self->apache->hostname);
 
-        my $http_type = ($type eq $sel_type) ? 'GET' : 'HEAD';
+        my $http_type = 'GET';
         $req->write_request($http_type => "/opac/extras/ac/$type/html/r/" . $rec_id);
         $ctx->{added_content}->{$type}->{request} = $req;
     }
@@ -591,14 +591,14 @@ sub added_content_stage2 {
 
             # if we are requesting a specific type of content, give the 
             # backend code a little extra time to retrieve the content.
-            my $wait = $type eq $sel_type ? 3 : 0; # TODO: config?
+            my $wait = 3; # TODO: config?
 
             if ($sel->can_read($wait)) {
                 my ($code) = $req->read_response_headers;
                 $content->{status} = $code eq '200' ? 1 : 2;
                 $logger->debug("tpac: added content request for $type returned $code");
 
-                if ($code eq '200' and $type eq $sel_type) {
+                if ($code eq '200') {
                     while (1) {
                         my $buf;
                         my $n = $req->read_entity_body($buf, 1024);
diff --git a/Open-ILS/src/templates/opac/parts/record/addedcontentinline.tt2 b/Open-ILS/src/templates/opac/parts/record/addedcontentinline.tt2
new file mode 100644 (file)
index 0000000..089ced6
--- /dev/null
@@ -0,0 +1,25 @@
+[%
+    ac_types = {
+        reviews => l('Reviews'),
+        anotes  => l('Author Notes'),
+        toc     => l('Table of Contents'),
+        excerpt => l('Excerpt'),
+        summary => l('Summary')
+    };
+    ac_types_ordered = [ 'reviews', 'anotes' ];
+
+%]
+  <div id='ac_inline'>
+
+  [%
+
+  # FOR type IN ac_types.keys;
+  FOREACH type IN ac_types_ordered;
+    IF ctx.added_content.$type.content; %]
+     <strong>[% ac_types.$type %]</strong>
+     <p>[% ctx.added_content.$type.content %]</p>
+  [%
+    END;
+  END;
+  %]
+  </div>
index 29fc33b..4dca611 100644 (file)
@@ -202,4 +202,5 @@ END
 [%- content_html %]
     </tbody>
 </table>
+[%- INCLUDE "opac/parts/record/addedcontentinline.tt2"; %]
 [%- END %]
index b35cf54..c4b9f36 100644 (file)
         END;
 
         extras = [
-            {name => 'summaryplus',  label => l('Summaries & More'), hide => hide_summary},
+            {name => 'summaryplus',  label => l('Summaries & More'), hide => 1},
             {name => 'annotation', label => l('Annotation'), hide => 1}, 
-            {name => 'awards',  label => l('Awards, Reviews, & Suggested Reads')}, 
+            {name => 'awards',  label => l('Awards, Reviews, & Suggested Reads'), hide => 1}, 
             {name => 'excerpt',  label => l('Excerpt'), hide => 1},
             {name => 'issues',   label => l('Issues Held'), hide => !(ctx.have_holdings_to_show || ctx.have_mfhd_to_show)},
             {name => 'preview',  label => l('Preview'), hide => 1}, 
-            {name => 'addedcontent',  label => l('Additional Content'), hide => hide_ac},  # hide if all content is known to not exist
+            {name => 'addedcontent',  label => l('Additional Content'), hide => 1},  # hide if all content is known to not exist
             {name => 'cnbrowse', label => l('Shelf Browser')},
             {name => 'marchtml', label => l('MARC Record')}
         ];