TPAC: serials display paging bugfix
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 8 Mar 2012 19:14:01 +0000 (14:14 -0500)
committerMike Rylander <mrylander@gmail.com>
Mon, 2 Apr 2012 14:18:53 +0000 (10:18 -0400)
In the previous commit, paging at the deepest level of an expanded tree
was broken.  This fixes that, and improves pager labeling a little bit.

This also makes the default page size for holdings 12 instead of 10,
since monthlies are a pretty common case, and why not show them all on
one page.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/Serial/OPAC.pm
Open-ILS/src/templates/opac/parts/record/issues-db.tt2

index 65f19bb..11bc0a2 100644 (file)
@@ -375,8 +375,8 @@ sub grouped_holdings_for_summary {
     ($summary_type .= "") =~ s/[^\w]//g;
     $summary_id = int($summary_id);
     $expand_path ||= [];
-    $limit ||= 10;
-    $limit = 10 if $limit < 1;
+    $limit ||= 12;
+    $limit = 12 if $limit < 1;
     $offsets ||= [0];
 
     foreach ($expand_path, $offsets) {
@@ -519,13 +519,16 @@ sub grouped_holdings_for_summary {
 
     # Make the tree we have so far.
     my $tree = [
+        { display_grouping => $display_grouping,
+            caption => $pattern_field->subfield($subfield) },
         map(
             _make_grouped_holding_node(
                 $_, $subfield, $deepest_level, $pattern_field,
                 $unit_data, $mfhd_cache
             ),
             @$top
-        ), ($top_more ? undef : ())
+        ),
+        ($top_more ? undef : ())
     ];
 
     # We'll need a parent reference at each level as we descend.
@@ -582,13 +585,16 @@ sub grouped_holdings_for_summary {
 
         # Set parent for the next iteration.
         $parent = $point->{children} = [
+            { display_grouping => $display_grouping,
+                caption => $pattern_field->subfield($subfield) },
             map(
                 _make_grouped_holding_node(
                     $_, $subfield, $deepest_level, $pattern_field,
                     $unit_data, $mfhd_cache
                 ),
                 @$level
-            ), ($level_more ? undef : ())
+            ),
+            ($level_more ? undef : ())
         ];
 
         last if $subfield eq $deepest_level;
@@ -610,7 +616,7 @@ __PACKAGE__->register_method(
             { name => "summary_id", type => "number" },
             { name => "expand_path", type => "array",
                 desc => "In root-to-leaf order, the values of the nodes along the axis you want to expand" },
-            { name => "limit (default 10)", type => "number" },
+            { name => "limit (default 12)", type => "number" },
             { name => "offsets", type => "array", desc =>
                 "This must be exactly one element longer than expand_path" },
             { name => "auto_expand_first", type => "boolean", desc =>
index 6e9179c..2864161 100644 (file)
@@ -15,6 +15,10 @@ ght_depth = 0;
 
 VIEW grouped_holding_tree;
     BLOCK list;
+        level_description = item.shift;
+        level_description.caption =
+            level_description.caption.replace('[\(\)]', '');
+
         '<div class="rdetail-holding-group">';
         prev_seoffset_list = seoffset_list.slice(0, ght_depth);
         next_seoffset_list = seoffset_list.slice(0, ght_depth);
@@ -24,11 +28,18 @@ VIEW grouped_holding_tree;
             prev_seoffset_list.$ght_depth = 0;
         END;
 
+        has_more = 0;
+        at_deepest_level = 0;
+
         next_seoffset_list.$ght_depth = next_seoffset_list.$ght_depth + selimit;
-        IF item.0.units.size;
+        IF item.0.units;
             INCLUDE "opac/parts/record/copy_table.tt2" serial_holdings=item;
             "<hr />";
-            "</div>";
+
+            at_deepest_level = 1;
+            IF NOT item.last.label;
+                has_more = 1;
+            END;
         ELSE;
             FOREACH node IN item;
                 IF NOT node.label;
@@ -80,31 +91,58 @@ VIEW grouped_holding_tree;
                     waste = ght_sepath.pop;
                 ELSE;
                     "<div class='rdetail-holding-group'>"; node.label; "</div>";
-                    # XXX Hold placement link here? Maybe not if no units.
+                    at_deepest_level = 1;
                 END;
             END;
+        END;
 
-            to_clear = 0;
-            new_sepath_end = ght_depth - 1;
-            IF new_sepath_end < 0;
-                to_clear = ['sepath'];
-                new_sepath = [];
-            ELSE;
-                new_sepath = expand_path.slice(0, ght_depth - 1);
-            END;
+        to_clear = 0;
+        new_sepath_end = ght_depth - 1;
+        IF new_sepath_end < 0;
+            to_clear = ['sepath'];
+            new_sepath = [];
+        ELSE;
+            new_sepath = expand_path.slice(0, ght_depth - 1);
+        END;
 
-            IF has_more;
-                '<a class="paging" href="';
-                    mkurl('',{seoffset => next_seoffset_list, sepath => new_sepath},to_clear,'issues');
-                '">&laquo; '; l('Earlier holdings'); '</a>';
-            END;
-            IF seoffset_list.$ght_depth > 0;
-                '<a class="paging" href="';
-                    mkurl('',{seoffset => prev_seoffset_list, sepath => new_sepath},to_clear,'issues');
-                '">'; l('Later holdings'); ' &raquo;</a>&nbsp; ';
+        # So the "holdings" level of the tree is sorted ascending, while all
+        # the higher levels are sorted descending.  This seems weird until you
+        # look at it.  I dunno. I think it feels right.  It could be changed I
+        # guess.  Anyway, this means we have to be careful about which
+        # paging link we label "earlier" and which one we label "later."
+
+        next_link = ''; prev_link = '';
+        IF has_more;
+            next_link = '<a class="paging" href="' _
+                mkurl('',{seoffset => next_seoffset_list, sepath => new_sepath},to_clear,'issues') _ '">LABEL_HERE</a>&nbsp; ';
+        END;
+        IF seoffset_list.$ght_depth > 0;
+            prev_link = '<a class="paging" href="' _
+                mkurl('',{seoffset => prev_seoffset_list, sepath => new_sepath},to_clear,'issues') _ '">LABEL_HERE</a>&nbsp; ';
+        END;
+
+        IF at_deepest_level;
+            prev_link.replace('LABEL_HERE', '&laquo; ' _ l('Earlier issues'));
+            next_link.replace('LABEL_HERE', l('Later issues') _ ' &raquo;');
+        ELSE;
+            # XXX this is really bad for i18n (notice the sloppy pluralization),
+            # but then the middle layer for serials only knows English names
+            # for things like "month". There's a bigger problem to solve
+            # here...
+            caption = level_description.caption;
+            IF level_description.display_grouping == 'chron';
+                caption = caption _ 's';
             END;
-            '</div>';
+            next_link.replace(
+                'LABEL_HERE',
+                '&laquo; ' _ l('Earlier') _ ' ' _ caption
+            );
+            prev_link.replace(
+                'LABEL_HERE',
+                l('Later') _ ' ' _ caption _ ' &raquo;'
+            );
         END;
+        '</div>';
     END;
 END;