Tpac: staff saved searches expand/collapse, use right ou context for setting
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 27 Oct 2011 22:20:00 +0000 (18:20 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 31 Oct 2011 16:17:47 +0000 (12:17 -0400)
1) Display staff saved searches collapsed by default. This makes the facet
display right underneath it more accessible in the case of long search
histories.

2) When checking the org unit setting for the limiting number of
searches to save, use the user's ws_ou as the context, since this is a
staff-client feature.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/templates/opac/parts/staff_saved_searches.tt2
Open-ILS/web/css/skin/default/opac/style.css

index 4a50820..e934a39 100644 (file)
@@ -26,6 +26,7 @@ my $U = 'OpenILS::Application::AppUtils';
 
 use constant COOKIE_SES => 'ses';
 use constant COOKIE_PHYSICAL_LOC => 'eg_physical_loc';
+use constant COOKIE_SSS_EXPAND => 'eg_sss_expand';
 
 use constant COOKIE_ANON_CACHE => 'anoncache';
 use constant ANON_CACHE_MYLIST => 'mylist';
@@ -249,9 +250,35 @@ sub load_common {
         }
     }
 
+    $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
+
     return Apache2::Const::OK;
 }
 
+sub staff_saved_searches_set_expansion_state {
+    my $self = shift;
+
+    my $param = $self->cgi->param('sss_expand');
+    my $value;
+    
+    if (defined $param) {
+        $value = ($param ? 1 : 0);
+        $self->apache->headers_out->add(
+            "Set-Cookie" => $self->cgi->cookie(
+                -name => COOKIE_SSS_EXPAND,
+                -path => $self->ctx->{base_path},
+                -secure => 1,   # not strictly necessary, but this feature is staff-only, so may as well
+                -value => $value,
+                -expires => undef
+            )
+        );
+    } else {
+        $value = $self->cgi->cookie(COOKIE_SSS_EXPAND);
+    }
+
+    $self->ctx->{saved_searches_expanded} = $value;
+}
+
 # physical_loc (i.e. "original location") passed in as a URL 
 # param will replace any existing physical_loc stored as a cookie.
 sub get_physical_loc {
index fb8ce21..0250651 100644 (file)
@@ -1,8 +1,26 @@
 [% IF ctx.saved_searches.size %]
-    <div class="saved-searches-header big-strong">[% l("Your recent searches:") %]</div>
-    [% FOR s IN ctx.saved_searches %]
-    <ul>
-        <li><a href="[% ctx.opac_root %]/results?query=[% s | uri %]&amp;_adv=1">[% s | html %]</a></li>
-    </ul>
+
+    <div class="saved-searches-header">
+        <div class="text">
+            [% l("Recent searches") %]
+        </div>
+        <div class="button">
+            [% IF ctx.saved_searches_expanded %]
+            <a href="[% mkurl('', {'sss_expand' => 0}) %]" title="[% l('Collapse') %]"><img src="[% ctx.media_prefix %]/images/adv_search_minus_btn.png" alt="[% l('Collapse') %]" /></a>
+            [% ELSE %]
+            <a href="[% mkurl('', {'sss_expand' => 1}) %]" title="[% l('Expand') %]"><img src="[% ctx.media_prefix %]/images/adv_search_plus_btn.png" alt="[% l('Expand') %]" /></a>
+            [% END %]
+        </div>
+        <div class="clear">&nbsp;</div>
+    </div>
+    <div class="clear">&nbsp;</div>
+    <div class="saved-searches">
+    [% IF ctx.saved_searches_expanded %]
+        [% FOR s IN ctx.saved_searches %]
+        <ul>
+            <li><a href="[% ctx.opac_root %]/results?query=[% s | uri %]&amp;_adv=1">[% s | html %]</a></li>
+        </ul>
+        [% END %]
     [% END %]
+    </div>
 [% END %]
index e3a425d..91b789c 100644 (file)
@@ -1166,3 +1166,11 @@ table.bookbag-specific {
     margin-bottom: 2ex;
 }
 .save-notes { padding-bottom: 1.5ex; }
+.saved-searches-header { width: 100%; font-weight: bold; font-size: 120%; }
+.saved-searches-header .button { float: right; width: 28px; }
+.saved-searches-header .text { float: left; padding-right: 1em; margin: 0.5ex 0;}
+.saved-searches-header {font-weight: bold; font-size: 120%; }
+.saved-searches { border-bottom: 1px solid #666; }
+#staff-saved-search { /* wraps .saved-searches-header and .saved-searches on the record page */
+    border-right: 1px solid #333;
+}