LP#1487527 - Provide shortcut for changing search scope. user/dpearl/scope_switch_1487527
authorDan Pearl <dpearl@cwmars.org>
Thu, 1 Oct 2015 16:12:29 +0000 (12:12 -0400)
committerDan Pearl <dpearl@cwmars.org>
Mon, 26 Oct 2015 15:48:12 +0000 (11:48 -0400)
A common usage of the TPAC is to do a search in a restricted scope,
and when the results are lacking, to repeat the search in a
consortium-wide search.  This provides a distinctively-colored
alternate search button to re-do the current search in the widest
scope.

Signed-off-by: Dan Pearl <dpearl@cwmars.org>
Open-ILS/src/templates/opac/css/style.css.tt2
Open-ILS/src/templates/opac/parts/css/colors.tt2
Open-ILS/src/templates/opac/parts/org_selector.tt2
Open-ILS/src/templates/opac/parts/result/paginate.tt2
Open-ILS/src/templates/opac/parts/searchbar.tt2
Open-ILS/src/templates/opac/results.tt2
docs/RELEASE_NOTES_NEXT/OPAC/search_scope_express_change [new file with mode: 0644]

index ff8c6ad..87316fb 100644 (file)
@@ -1296,6 +1296,13 @@ a.opac-button-header:hover, #dash_wrapper a.opac-button:hover {
     display: inline-block;
 }
 
+.opac-distinctive {
+   background-color: [% css_colors.distinct_medium %];
+}
+.opac-distinctive:hover {
+    background: [% css_colors.distinct_dark %];
+}
+
 #myopac_checked_div {
     padding: 0px;
 }
index 85e00bd..700b84d 100644 (file)
@@ -16,6 +16,8 @@
         primary_fade = "#007a54", # medium green
         primary_offset = "#417860", # light_green
         control = "#69A088", # lighter green
+        distinct_medium = "#1a7f99", # blue
+        distinct_dark = "#0f485a",   # blue (dark)
         accent_light = "#ccc", #  grey (light)
         accent_lighter = "#ddd", #  grey (lighter)
         accent_lighter2 = "#d8d8d8", #  grey (lighter again)
index ab4d7c9..a1a6598 100644 (file)
@@ -14,6 +14,10 @@ BLOCK build_org_selector;
     node_stack = [{org => org_unit || ctx.aouct_tree || ctx.aou_tree}];
     inherited_vis = ctx.get_cgf('opac.org_unit.non_inherited_visibility').enabled == 'f';
 
+    # Save the topmost org unit in the list (for the All Libraries global search)
+    first_selectable_ou_index = -1;  
+    option_index = -1;
+
     IF !name; 
         name = loc_name;
     END;
@@ -123,12 +127,34 @@ BLOCK build_org_selector;
             END;
 
             pad_depth = pad_depth * 2;
-            display_name = loc_grp ? loc_grp.name : org_unit.name %]
+            display_name = loc_grp ? loc_grp.name : org_unit.name;
+
+            option_index = option_index + 1;
+
+            # This restores the library selector selected value to what it was before the "all library"
+            # express search overrode the previous value;
+            IF CGI.param('scope_restore') != -1;
+                IF option_index == CGI.param('scope_restore'); 
+                    selected = 'selected="selected"';
+                    ctx.selected_label = l('All Libraries');
+                ELSE;
+                    selected = '';
+                END;
+            ELSE; 
+               IF selected == 'selected="selected"';
+                    ctx.selected_label = display_name;
+                END;
+            END;
+
+            IF first_selectable_ou_index == -1 AND disabled == '';
+                first_selectable_ou_index = option_index;
+            END -%]
 
             <option value='[% node_value %]' [% selected %] [% disabled %] [% css_class %]> 
                 [% '&nbsp;' FOR [0..pad_depth]; display_name | html %]
             </option> 
-
+            
         [%- END %]
     </select>
+
 [%- END %]
index cccf18b..92e3992 100644 (file)
@@ -1,6 +1,11 @@
 [% BLOCK results_count_header %]
 <div class="results_header_nav1">
-    <span class="h1">[% ctx.bookbag ? l('List Contents') : l('Search Results') %]</span>
+
+    <span class="h1">[% ctx.bookbag ? l('List Contents') : l('Search Results') %]</span> 
+    [% IF  ctx.selected_label; 
+       ' ' _ l('in') _ ' ' _ ctx.selected_label _ ' ';
+    END %]
+    
     <span class="result_number">
                 [%~ |l('<span class="result_count_number">' _ ctx.result_start _'</span>',
                 '<span class="result_count_number">' _ ctx.result_stop _ '</span>',
index c2d2710..4947b00 100644 (file)
@@ -2,7 +2,7 @@
 [% PROCESS "opac/parts/org_selector.tt2" %]
 <div id="search-wrapper">
     [% UNLESS took_care_of_form -%]
-    <form action="[% ctx.opac_root %]/results" method="get">
+    <form action="[% ctx.opac_root %]/results" method="get" name="searchbox_form">
     [%- END %]
     <div id="search-box">
         <span class="search_catalog_lbl mobile_hide">[% l('Search the Catalog') %]</span>
@@ -15,6 +15,7 @@
             [%- # autosuggest breaks accessibility, as the aria-label
                 # attribute is removed when the Dijit is created. :(  %]
             <label id="search_box_label" for="search_box">[% l('Search: ') %]
+            <input type="hidden" id="scope_restore" name="scope_restore" value="-1"/>
             <input type="text" id="search_box" name="query" aria-label="[%
                     l('Enter search query:');
                 %]" value="[% is_advanced ? ctx.naive_query_scrub(ctx.processed_search_query) : CGI.param('query') | html %]"
     [%- IF (show_more_details.default == 'true' OR show_more_details.default == 'hide') AND !CGI.param('detail_record_view') %]
         <input id="detail" type="hidden" name="detail_record_view" value="1"/>
     [%- END %]
+        <span id='search-submits'>
         <input id='search-submit-go' type="submit" value="[% l('Search') %]" class="opac-button"
-            onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden"}, 2000)'/>
+            onclick='
+               setTimeout(function(){$("search-submit-spinner").className=""; 
+                                $("search-submits").className="hidden"}, 2000)'/>
+        <input id='search-submit-global-go' type="submit" value="[% l('All Libraries') %]" class="opac-button opac-distinctive" 
+            onclick='
+               document.searchbox_form.scope_restore.value = document.searchbox_form.locg.selectedIndex; 
+               document.searchbox_form.locg.selectedIndex = "[% first_selectable_ou_index %]";
+               setTimeout(function(){$("search-submit-spinner").className=""; 
+                                $("search-submits").className="hidden"}, 2000)'/>
+        </span>
         <img id='search-submit-spinner' src='/opac/images/progressbar_green.gif' style='height:16px;width:16px;' class='hidden' alt='[% l("Search In Progress") %]'/>
     </span>
     </div>
index f1bb957..091ad70 100644 (file)
@@ -20,7 +20,7 @@
     PROCESS get_library;
 -%]
     <h2 class="sr-only">[% l('Search Results') %]</h2>
-    <form action="[% ctx.opac_root %]/results" method="get">
+    <form action="[% ctx.opac_root %]/results" method="get" name="searchbox_form">
     [% INCLUDE "opac/parts/searchbar.tt2" took_care_of_form=1 %]
     <h3 class="sr-only">[% l('Additional search filters and navigation') %]</h3>
     <div class="almost-content-wrapper">
diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/search_scope_express_change b/docs/RELEASE_NOTES_NEXT/OPAC/search_scope_express_change
new file mode 100644 (file)
index 0000000..d8b4a93
--- /dev/null
@@ -0,0 +1,10 @@
+Search Scope Express Selection
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+A common usage of the catalog is to do a search in a restricted scope,
+like a local library. When the results are lacking, the search is repeated in a
+consortium-wide scope.  This feature provides a distinctively-colored
+alternate search button to re-do the current search in the widest
+scope.
+
+After the wide-scope is done, the scope indicated in the drop-down control will
+be restored to what it was before.