named anchor support in mkurl() and use thereof
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 5 Mar 2012 20:20:58 +0000 (15:20 -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/templates/opac/parts/header.tt2
Open-ILS/src/templates/opac/parts/record/issues.tt2

index 30dbd6d..c260413 100644 (file)
     #
     # Current page, clear 'some_param' from the existing params:
     # mkurl('', {foo => 'bar', boo => 'baz'}, ['some_param']);
-    MACRO mkurl(page, params, clear_params) BLOCK;
+    #
+    # Current page to a named anchor 'copies'
+    # mkurl('', {}, [], 'copies');
+    MACRO mkurl(page, params, clear_params, named_anchor) BLOCK;
 
         # clone the query string to avoid clobberation
         cgi = CGI.new(CGI.query_string);
             IF val == ''; cgi.delete(p); END;
         END;
 
+        final = named_anchor ? '#' _ named_anchor : '';
+
         IF page;
             IF cgi.query_string;
-                page _ '?' _ cgi.query_string;
+                page _ '?' _ cgi.query_string _ final;
             ELSE;
-                page;
+                page _ final;
             END;
         ELSE;
             # staying on the current page
-            cgi.url("-path" => 1, "-query" => 1);
+            cgi.url("-path" => 1, "-query" => 1) _ final;
         END;
     END;
 
index a26d6b7..36d7567 100644 (file)
@@ -24,7 +24,20 @@ VIEW holding_summary_tree;
         ctx.get_aou(item.org_unit).name;
         '</span>';
         FOREACH summary IN item.holding_summaries;
-            '<li><a href="' _ mkurl('', {sid => summary.id, stype => summary.summary_type}, ['selimit', 'sepath', 'seoffset']) _ '">';
+            IF summary.holdings;
+                link = mkurl(
+                    '', {},
+                    ['sid','stype','selimit','sepath','seoffset'], 'issues'
+                );
+                link_title = l('Collapse');
+            ELSE;
+                link = mkurl(
+                    '', {sid => summary.id, stype => summary.summary_type},
+                    ['selimit','sepath','seoffset'], 'issues'
+                );
+                link_title = l('Expand');
+            END;
+            '<li><a href="' _ link _ '" title="' _ link_title _ '">';
             summary.generated_coverage.join(", ");
             '</a></li>';
             IF summary.holdings;
@@ -48,10 +61,10 @@ END %]
         soffset_next = soffset + slimit;
     %]
     [% IF soffset > 0 %]
-    <a href="[% mkurl('', {soffset => soffset_prev}, ['sid','stype']) %]>[% l('Previous') %]</a>
+    <a href="[% mkurl('', {soffset => soffset_prev}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]>[% l('Previous') %]</a>
     [% END %]
     [% IF ctx.holding_summary_tree.more %]
-    <a href="[% mkurl('', {soffset => soffset_next}, ['sid','stype']) %]">[% l('Next') %]</a>
+    <a href="[% mkurl('', {soffset => soffset_next}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]">[% l('Next') %]</a>
     [% END %]
 </div>
 [% IF ctx.mfhd_summaries.size; %]