]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/parts/advanced/global_row.tt2
TPac: propagate searches to advanced search page
[Evergreen.git] / Open-ILS / src / templates / opac / parts / advanced / global_row.tt2
1 [%
2     contains_options = [
3         {value => 'contains', label => l('Contains')},
4         {value => 'nocontains', label => l('Does not contain')},
5         {value => 'phrase', label => l('Contains phrase')},
6         {value => 'exact', label => l('Matches exactly')}
7     ];
8     contains = CGI.param('contains');
9     queries = CGI.param('query');
10     bools = CGI.param('bool') || ['and' x 3];
11     qtypes = CGI.param('qtype') || ['keyword' x 3];
12
13     IF !qtypes.0; # not an array
14         qtypes = [qtypes];
15         bools = [bools];
16         queries = [queries];
17     END;
18
19     WHILE qtypes.size < 3;
20         qtypes.push('keyword');
21         bools.push('and');
22         queries.push('');
23     END;
24
25     FOR qtype IN qtypes;
26         c = contains.shift;
27         b = bools.shift;
28         q = queries.shift; %]
29
30 <!-- tag the second row so the bool column won't be hidden -->
31 <tr[% IF loop.index == 1 %] id="adv_global_row"[% END %]>
32     <td align='left' width='100%' nowrap='nowrap'>
33
34         <!-- bool selector.  hide for first row.  safe to ignore first bool value in form submission -->
35         <select name='bool' style='width: auto' [% IF loop.first %] class='invisible' [% END %]>
36             <option value='and' [% b == 'and' ? 'selected="selected"' : '' %]>[% l('And') %]</option>
37             <option value='or' [% b == 'or' ? 'selected="selected"' : '' %]>[% l('Or') %]</option>
38         </select>
39
40         <!-- keyword, subject, etc. selector -->
41         <span class="qtype_selector_margin">
42             [% INCLUDE "opac/parts/qtype_selector.tt2"
43                 query_type=qtype %]
44         </span>
45
46         <select name='contains' style='margin-right: 7px;'>
47             [% FOR o IN contains_options; -%]
48             <option value="[% o.value %]" [% c == o.value ? ' selected="selected"' : '' %]>[% o.label %]</option>
49             [% END %]
50         </select>
51         <input type='text' size='18' name='query' value="[% q | html %]" x-webkit-speech />
52         <a href="javascript:;" class="row-remover"
53             title="[% l('Remove row') %]" alt="[% l('Remove row') %]"
54             onclick='return killRowIfAtLeast(2, this);'><img src="[% ctx.media_prefix %]/images/adv_row_close_btn.png" /></a>
55     </td>
56 </tr>
57 [% END %]