LP1274999: Next Link Appears at "End" of Copy List
authorJason Boyer <jboyer@library.in.gov>
Tue, 21 Feb 2017 21:31:31 +0000 (16:31 -0500)
committerJason Boyer <jboyer@library.in.gov>
Wed, 22 Feb 2017 13:25:22 +0000 (08:25 -0500)
The total number of copies wasn't checked against the
copy_limit and copy_offset, so anytime that the
number of copies per page mod copy_limit == 0 the
Next link would appear, even if there were only
copy_limit copies total. Now the offset and limit are
compared to the total number of copies available at
the current depth to determine if the Next link
should appear.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Open-ILS/src/templates/opac/parts/record/copy_table.tt2

index c6ab1aa..92c3db9 100644 (file)
@@ -25,7 +25,13 @@ FOREACH copy_info IN copies;
     END;
 END;
 -%]
-[%- IF has_copies; %]
+[%-
+IF has_copies; 
+  # The "deepest" depth that a summary is available for determines how many total copies can be displayed here.
+  $depth = ctx.copy_summary.size - 1;
+  $total_copies = ctx.copy_summary.$depth.count;
+
+%]
 <table class="table_no_border_space table_no_cell_pad table_no_border" width="100%" id="rdetails_status">
     <thead>
         <tr>
@@ -256,7 +262,7 @@ END; # FOREACH bib
                     l('Previous [_1]', ctx.copy_offset - new_offset) %]</a>
             </td>
         [%- END %]
-        [%- IF copies.size >= ctx.copy_limit AND NOT serial_holdings %]
+        [%- IF copies.size >= ctx.copy_limit AND NOT serial_holdings AND (ctx.copy_offset + ctx.copy_limit > $total_copies) %]
             <td>
                 <a href="[% mkurl('', {copy_offset => ctx.copy_offset + ctx.copy_limit, copy_limit => ctx.copy_limit}) %]">[%
                     l('Next [_1]', ctx.copy_limit) %] &raquo;</a>
@@ -267,7 +273,7 @@ END; # FOREACH bib
         <tr>
             <td>
                 [%- more_copies_limit = 50 %] [%# TODO: config %]
-                [%- IF  ctx.copy_limit != more_copies_limit AND copies.size >= ctx.copy_limit %]
+                [%- IF  ctx.copy_limit != more_copies_limit AND copies.size >= ctx.copy_limit AND $total_copies > ctx.copy_limit %]
                     <div class="rdetail_show_copies">
                         <img src="[% ctx.media_prefix %]/images/plus_sign.png" alt="[% l('Show more copies icon') %]"/>
                         <a href="[% mkurl('', {copy_limit => more_copies_limit, copy_offset => 0}) %]">[% l('Show more copies') %]</a>