From 7df4e36364f32a650ffeb47a9ace173e8223f612 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Mon, 5 Mar 2012 18:36:15 -0500 Subject: [PATCH] expand/collapse generally working well Signed-off-by: Lebbeous Fogle-Weekley --- .../src/perlmods/lib/OpenILS/Application/Serial.pm | 4 +- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 7 +- Open-ILS/src/templates/opac/parts/header.tt2 | 7 +- .../src/templates/opac/parts/record/issues.tt2 | 77 ++++++++++++++++++++-- 4 files changed, 84 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm index a6ebba6d5b..0516805147 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm @@ -1120,9 +1120,9 @@ sub grouped_holdings_for_summary { my $parent = $tree; # Will we try magic auto-expansion of the first top-level grouping? - if ($auto_expand_first and (not @$expand_path) and @$tree) { + if ($auto_expand_first and @$tree and not @$expand_path) { $expand_path = [$tree->[0]->{value}]; - unshift @$offsets, 0; + $offsets = [0]; } foreach my $value (@$expand_path) { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 4b92fbed08..1110a0d24f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -294,10 +294,9 @@ sub load_serial_holding_summaries { if ($holdings and ref $holdings eq "ARRAY") { $self->place_holdings_with_summary( $tree, $holdings, $summary_id, $summary_type + ) or $self->apache->log->warn( + "could not place holdings within summary tree" ); -# or $self->apache->log->warn( -# "could not place holdings within summary tree" -# ); } else { $self->apache_log_if_event( $holdings, "getting holdings grouped by summary $summary_id" @@ -329,7 +328,7 @@ sub place_holdings_with_summary { } foreach my $child (@{$tree->{children}}) { - return if $self->place_holdings_with_summary( + return 1 if $self->place_holdings_with_summary( $child, $holdings, $sid, $stype ); } diff --git a/Open-ILS/src/templates/opac/parts/header.tt2 b/Open-ILS/src/templates/opac/parts/header.tt2 index c26041306a..01c75bf782 100644 --- a/Open-ILS/src/templates/opac/parts/header.tt2 +++ b/Open-ILS/src/templates/opac/parts/header.tt2 @@ -49,7 +49,12 @@ FOR k IN params.keys; encoded = []; max = params.$k.max; - list = (params.$k.0 OR max == -1) ? params.$k : [params.$k]; + + # The following commented-out line can be fooled. Its replacement + # below is what you really mean. + # list = (params.$k.0 OR max == -1) ? params.$k : [params.$k]; + list = params.$k.list; + IF list.size == 0; NEXT; END; # CGI croaks on already-decoded strings. force-encode to be safe. FOR p IN list; encoded.push(ctx.encode_utf8(p)); END; diff --git a/Open-ILS/src/templates/opac/parts/record/issues.tt2 b/Open-ILS/src/templates/opac/parts/record/issues.tt2 index 36d756756a..491c9c0211 100644 --- a/Open-ILS/src/templates/opac/parts/record/issues.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/issues.tt2 @@ -1,18 +1,87 @@
[% +expand_path = CGI.param('sepath') || []; +seoffset_list = CGI.param('seoffset') || []; +IF expand_path.size == 0 AND seoffset_list.size == 0; + seoffset_list = [0,0]; # compensate for $auto_expand_first; see ML +END; + +selimit = CGI.param('selimit') || 10; +ght_sepath = []; +ght_depth = 0; + VIEW grouped_holding_tree; BLOCK list; '
    '; - has_more = 0; + prev_seoffset_list = seoffset_list.slice(0, ght_depth + 1); + next_seoffset_list = seoffset_list.slice(0, ght_depth + 1); + + prev_seoffset_list.$ght_depth = prev_seoffset_list.$ght_depth - selimit; + IF prev_seoffset_list.$ght_depth < 0; + prev_seoffset_list.$ght_depth = 0; + END; + + next_seoffset_list.$ght_depth = next_seoffset_list.$ght_depth + selimit; FOREACH node IN item; IF NOT node.label; has_more = 1; LAST; END; - "
  • "; node.label; "
  • "; - IF node.children; - view.print(node.children); + + IF node.value; + ght_sepath.push(node.value); + all_balls = []; + FOREACH i IN [-1 .. ght_depth]; # aka [0 .. ght_depth+1] + all_balls.push(0); + END; + + expand_link = mkurl( + '', {'sepath' => ght_sepath, 'seoffset' => all_balls}, + 0, 'issues' + ); + + collapse_sepath = ght_sepath.slice(0, -2); + IF collapse_sepath.size == 0; + collapse_clear_params = ['sepath']; + ELSE; + collapse_clear_params = 0; + END; + + collapse_link = mkurl( + '', { + 'sepath' => collapse_sepath, + 'seoffset' => all_balls.slice(0, -2) + }, collapse_clear_params, 'issues' + ); + + "
  • "; node.label; "
  • "; + + IF node.children.size; + ght_depth = ght_depth + 1; + view.print(node.children); + ght_depth = ght_depth - 1; + END; + + waste = ght_sepath.pop; + ELSE; + "
  • "; node.label; "
  • "; # XXX hold placement link here END; END; + IF seoffset_list.$ght_depth > 0; + ''; l('Previous'); ''; + END; + IF has_more; + ''; l('Next'); ''; + END; '
'; END; END; -- 2.11.0