From d43eb99ba936155f01fe95f0bf66ff03aefc8fdb Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Thu, 8 Mar 2012 14:14:01 -0500 Subject: [PATCH] TPAC: serials display paging bugfix 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 Signed-off-by: Dan Wells Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Serial/OPAC.pm | 16 +++- .../src/templates/opac/parts/record/issues-db.tt2 | 80 ++++++++++++++----- 2 files changed, 70 insertions(+), 26 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial/OPAC.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial/OPAC.pm index 65f19bb..11bc0a2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial/OPAC.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial/OPAC.pm @@ -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 => diff --git a/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 b/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 index 6e9179c..2864161 100644 --- a/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 @@ -15,6 +15,10 @@ ght_depth = 0; VIEW grouped_holding_tree; BLOCK list; + level_description = item.shift; + level_description.caption = + level_description.caption.replace('[\(\)]', ''); + '
'; 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; "
"; - "
"; + + 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; "
"; node.label; "
"; - # 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; - '« '; l('Earlier holdings'); ''; - END; - IF seoffset_list.$ght_depth > 0; - ''; l('Later holdings'); ' »  '; + # 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 = 'LABEL_HERE  '; + END; + IF seoffset_list.$ght_depth > 0; + prev_link = 'LABEL_HERE  '; + END; + + IF at_deepest_level; + prev_link.replace('LABEL_HERE', '« ' _ l('Earlier issues')); + next_link.replace('LABEL_HERE', l('Later issues') _ ' »'); + 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; - ''; + next_link.replace( + 'LABEL_HERE', + '« ' _ l('Earlier') _ ' ' _ caption + ); + prev_link.replace( + 'LABEL_HERE', + l('Later') _ ' ' _ caption _ ' »' + ); END; + ''; END; END; -- 1.7.2.5