expand/collapse generally working well
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 5 Mar 2012 23:36:15 +0000 (18:36 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 7 Mar 2012 21:57:11 +0000 (16:57 -0500)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/templates/opac/parts/header.tt2
Open-ILS/src/templates/opac/parts/record/issues.tt2

index a6ebba6..0516805 100644 (file)
@@ -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) {
index 4b92fbe..1110a0d 100644 (file)
@@ -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 if $self->place_holdings_with_summary(
             $child, $holdings, $sid, $stype
         );
     }
index c260413..01c75bf 100644 (file)
         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;
index 36d7567..491c9c0 100644 (file)
@@ -1,18 +1,87 @@
 <div class='rdetail_extras_div'>[%
+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;
         '<ul class="rdetail-holding-group">';
-        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;
-            "<li>"; node.label; "</li>";
-            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'
+                );
+
+                "<li><a href='";
+                IF node.children.size;
+                    collapse_link;
+                ELSE;
+                    expand_link;
+                END;
+                "'>"; node.label; "</a></li>";
+
+                IF node.children.size;
+                    ght_depth = ght_depth + 1;
+                    view.print(node.children);
+                    ght_depth = ght_depth - 1;
+                END;
+
+                waste = ght_sepath.pop;
+            ELSE;
+                "<li>"; node.label; "</li>"; # XXX hold placement link here
             END;
         END;
+        IF seoffset_list.$ght_depth > 0;
+            '<a href="';
+            mkurl('', {seoffset => prev_seoffset_list}, 0, 'issues');
+            '">'; l('Previous'); '</a>';
+        END;
+        IF has_more;
+            '<a href="';
+            mkurl('', {seoffset => next_seoffset_list}, 0, 'issues');
+            '">'; l('Next'); '</a>';
+        END;
         '</ul>';
     END;
 END;