433b2faf44b07d2a2ba11e5001f5b0b23d7367cc
[Evergreen.git] / Open-ILS / src / templates-bootstrap / opac / parts / searchbar.tt2
1 <h3 class="sr-only">[% l('Catalog Search') %]</h3>
2 [% PROCESS "opac/parts/org_selector.tt2";
3
4 # We need to ignore some filters in our count
5
6 fignore = ['location_groups','site','core_limit','limit','badge_orgs','badges','estimation_strategy','depth'];
7 fcount = 0;
8 FOR f IN ctx.query_struct.filters;
9     IF fignore.grep('^' _ f.name _ '$').size;
10         NEXT;
11     END;
12     fcount = fcount + 1;
13 END;
14
15     # don't display a box for the search_format filter,
16     # as that's got its own widget
17     ignore_filters = ['search_format'];
18
19     trimmed_filters = [];
20     FOR filter IN ctx.query_struct.filters;
21         fname = filter.name;
22         IF ignore_filters.grep('^' _ fname _ '$').size;
23             NEXT;
24         END;
25         trimmed_filters.push(filter);
26     END;
27
28     ctx.query_struct.filters = trimmed_filters;
29
30  %]
31
32 <div id="search-wrapper" class="container-fluid">
33     [% UNLESS took_care_of_form -%]
34     <form action="[% ctx.opac_root %]/results" method="get">
35     [%- END %]
36     [% IF ctx.page == 'rresult' && ctx.metarecord && search.metarecord_default %]
37     <input type="hidden" name="modifier" value="metabib"/>
38     [% END %]
39     [% IF (ctx.page == 'place_hold' || ctx.page == 'myopac' || ctx.page == 'home' || ctx.page == 'record') && search.metarecord_default %]
40     <input type="hidden" name="modifier" value="metabib"/>
41     [% END %]
42     <div class="m-5">
43     <div class="row">
44      <!--Keyword-->
45         <div class="col-sm-12 col-md">
46         <span class='search_box_wrapper'>
47             [%- # autosuggest breaks accessibility, as the aria-label
48                 # attribute is removed when the Dijit is created. :(  %]
49             <label id="search_box_label" for="search_box" class="w-100">[% l('Search: ') %]
50             <input class="form-control form-control-sm" type="text" id="search_box" name="query" aria-label="[%
51                     l('Enter search query:');
52                 %]" value="[% is_advanced ? ctx.naive_query_scrub(ctx.user_query) : CGI.param('query') | html %]"
53                 [%- IF use_autosuggest.enabled == "t" %]
54                 dojoType="openils.widget.AutoSuggest" type_selector="'qtype'"
55                 submitter="this.textbox.form.submit();"
56                 [%-     IF use_autosuggest.value.search('opac_visible') %]
57                 store_args='{"org_unit_getter": function() { return [% ctx.search_ou %]; }}'
58                 [%-     END # opac_visible -%]
59                 [%- ELSE -%]
60                     [% IF basic_search != "f" AND is_home_page%] autofocus [% END %]
61                 [%- END # autosuggest enabled %] />
62             </label>
63         </span>
64         </div>
65
66         <!--Type-->
67         <div class="col-sm-12 col-md">
68         <label id="search_qtype_label" for="qtype" class="w-100">
69         [%-
70             l('Type: ');
71             INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
72         -%]
73         </label>
74         </div>
75
76
77         <!-- Force next columns to break to new line below md breakpoint -->
78         <div class="w-100 d-block d-md-none"></div>
79
80          <!--Format-->
81         <div class="col-sm-12 col-md">
82         <label id="search_itype_label" for="search_itype_selector" class="w-100">
83         [%-
84             l('Format: ');
85             IF search.basic_config.type == 'attr';
86                 INCLUDE "opac/parts/coded_value_selector.tt2"
87                     attr=search.basic_config.group none_ok=1
88                     id='search_itype_selector'
89                     none_label=search.basic_config.none_label;
90             ELSIF search.basic_config.type == 'filter';
91                 INCLUDE "opac/parts/filter_group_selector.tt2"
92                     filter_group=search.basic_config.group none_ok=1
93                     id='search_itype_selector'
94                     class='form-control form-control-sm'
95                     none_label=search.basic_config.none_label;
96             END;
97         -%]
98         </label>
99         </div>
100
101          <!--Library-->
102         <div class="col-sm-12 col-md">
103         <label id="search_locg_label" for="search_org_selector" class="w-100">
104         [%-
105             l('Library: ');
106             select_lib_label = l("Select search library");
107             INCLUDE build_org_selector arialabel=select_lib_label
108               id='search_org_selector' show_loc_groups=1
109         -%]
110         </label>
111         </div>
112
113         <!-- Force next columns to break to new line below md breakpoint -->
114         <div class="w-100 d-block d-md-none"></div>
115
116         <div class="col-auto ml-auto ml-md-1">
117         <input id="detail" type="hidden" name="detail_record_view" value="[% show_detail_view %]"/>
118         <button id='search-submit-go' type="submit" class="btn btn-sm btn-opac"
119             onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden";[% IF ctx.depth_sel_button AND NOT took_care_of_form %] $("search-submit-go-depth").className="hidden";[% END %]}, 2000)'><i class="fas fa-search" aria-hidden="true"></i> [% l('Search') %]</button>
120         </div>
121         [%- IF ctx.depth_sel_button AND NOT took_care_of_form %]
122         <div class="col-auto mr-auto mr-md-1">
123         <button id='search-submit-go-depth' type="submit" value="[% ctx.depth_sel_depth %]" name="depth" class="btn btn-sm btn-opac"
124             onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden"; $("search-submit-go-depth").className="hidden";}, 2000)' title="[% ctx.depth_sel_tooltip | html %]"><i class="fas fa-globe" aria-hidden="true"></i> [% ctx.depth_sel_button_label | html %]</button>
125         [%- END %]
126         <img id='search-submit-spinner' src='[% ctx.media_prefix %]/opac/images/progressbar_green.gif[% ctx.cache_key %]' style='height:16px;width:16px;' class='hidden' alt='[% l("Search In Progress") %]'/>
127         </div>
128     </div>
129     </div>
130
131     [% IF ctx.bookbag %]
132     <div id="search-only-bookbag-container" class="text-center">
133         <input type="checkbox" id="search-only-bookbag" name="bookbag"
134             value="[% ctx.bookbag.id | html %]" checked="checked" />
135         <label for="search-only-bookbag">
136             [% l('Search only within the chosen list') %]
137         </label>
138     </div>
139     [% END %]
140     [% IF is_advanced || is_special %]
141     <div>
142         <input type="hidden" name="_adv" value="1" />
143         [% IF ctx.processed_search_query OR (NOT is_advanced AND NOT is_special) %]
144         <input name='page' type='hidden' value="0" />
145         [% END %]
146         [% IF is_advanced;
147             FOR p IN CGI.params.keys;
148                 NEXT UNLESS p.match('^fi:');
149                 NEXT IF p.match('^fi:search_format');
150                 FOR pv IN CGI.params.$p;
151                     %]<input type="hidden" name="[% p | html %]" value="[% pv | html %]" />[%
152                 END;
153             END;
154         END %]
155         [% IF is_special %]
156             <input type="hidden" name="_special" value="1" /> [%
157             number_of_expert_rows = CGI.param('tag').list.size;
158             index = 0;
159             WHILE index < number_of_expert_rows %]
160                 <input type="hidden" name="tag" value="[% CGI.param('tag').list.$index | html %]" />
161                 <input type="hidden" name="subfield" value="[% CGI.param('subfield').list.$index | html %]" />
162                 <input type="hidden" name="term" value="[% CGI.param('term').list.$index | html %]" />
163                 [% index = index + 1; %]
164             [% END %]
165         [% END %]
166     </div>
167     [%- END %]
168     [% UNLESS took_care_of_form %]
169         [% IF ctx.default_sort %]
170             <input type="hidden" name="sort" value="[% ctx.default_sort %]"/>
171         [% END %]
172         </form>
173     [% END %]
174     [% IF fcount > 0 %]
175       <div class="refine_search result_block_visible">
176         <span id="filter_hits">[ <a href="#" onclick="getAdvLimits();return false;">[% l('[quant,_1,filter,filters] applied', fcount) %]</a> ]</span>
177       </div>
178     [% END %]
179     [% IF ctx.query_struct.filters.size > 0 %]
180         [% stuff = INCLUDE 'opac/parts/result/adv_filter.tt2' %]
181         [% IF stuff %]
182         <h3 class="sr-only">[% l('Search Results filters') %]</h3>
183         <div id="adv_filter_results_block" class="adv_filter_results_hide">
184         <span class="adv_filter_results_block_label">[% l('Filtered by:') %]</span>
185             [% stuff %]
186         </div>
187         [% END %]
188     [% END %]
189
190
191     <script>
192     function getAdvLimits() {
193         var AdvLimitsClass = document.getElementById('adv_filter_results_block').classList;
194         if (AdvLimitsClass.contains("adv_filter_results_hide")) {
195            AdvLimitsClass.remove("adv_filter_results_hide");
196         } else {
197            AdvLimitsClass.add("adv_filter_results_hide");
198         }
199         if (AdvLimitsClass.contains("adv_filter_results_show")) {
200            AdvLimitsClass.remove("adv_filter_results_show");
201         } else {
202            AdvLimitsClass.add("adv_filter_results_show");
203         }
204      }
205      </script>
206     <!-- Canonicalized query:
207
208     [% ctx.canonicalized_query | html %]
209
210     -->
211     <!--
212     <div id="breadcrumb">
213         <a href="[% ctx.opac_root %]/home">[% l('Catalog Home') %]</a> &gt;
214     </div>
215     -->
216 </div>