]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/result/adv_filter.tt2
LP#1670425: Moving display of advanced search limiters on search results page
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / result / adv_filter.tt2
1 [%-
2
3 pubdate_filters = ['date1', 'before', 'after', 'between'];
4
5 FOR filter IN ctx.query_struct.filters;
6     fname = filter.name;
7     fvalues = filter.args;
8     crad = ctx.get_crad(fname);
9
10     # will be some special ones, like locations
11     IF crad AND NOT pubdate_filters.grep('^' _ filter.name _ '$').size;
12         remove_filter = 'fi:' _ fname;
13 -%]
14          <div class="adv_filter_results_group">
15             <h4 class="title">[% IF filter.negate; l('Not'); END %] [% (crad.description || crad.label) | html %]</h4>
16             [% temp = [];
17                FOR fval IN fvalues;
18                 thing = ctx.search_ccvm('ctype',fname,'code',fval).0;
19                 display_value = thing.search_label || thing.value;
20                 IF display_value.defined;
21                  temp.push(display_value);
22                 END;
23                END;
24                FOR display_value IN temp.sort;
25             %]
26                  <span class="adv_search_result_filter">
27                     [% display_value | html %]
28                       [% UNLESS loop.last; 
29                          l('OR');
30                       END %]
31                  </span>
32
33             [% END; # FOR %]
34               <a class="button remove_filter"
35               title="[% l('Remove [_1] filter', (crad.description || crad.label)) %]"
36               aria-label=[% l('Remove [_1] filter', (crad.description || crad.label)) %]"
37               href="[% mkurl('', {}, [remove_filter]) %]" rel="nofollow" vocab="">&times; </a>
38            </div>
39     [%- END; # IF crad -%]
40
41 [%-  IF filter.name == 'locations'; locs = ctx.search_acpl('id',filter.args) -%]
42     <div class="adv_filter_results_group">
43             <h4 class="title">[% IF filter.negate; l('Not'); END %] [% l('Locations') %]</h4>
44             [% temp = [];
45                FOR loc IN locs;
46                 temp.push(loc.name);
47                END;
48                FOR display_name IN temp.sort; %]
49                   <span class="adv_search_result_filter">
50                     [% display_name | html%]
51                   </span>
52             [% END; # FOR %]
53             <a class="button remove_filter"
54               title="[% l('Remove location filter') %]"
55               href="[% mkurl('', {}, ['fi:locations']) %]" rel="nofollow" vocab=""> &times;</a>
56
57     </div> 
58 [%- END; # IF locations -%]
59
60 [%- IF pubdate_filters.grep('^' _ filter.name _ '$').size;
61     date1 = CGI.param('date1');
62     date2 = CGI.param('date2');
63 -%]
64     <div class="adv_filter_results_group">
65             <h4 class="title">[% IF filter.negate; l('Not'); END %] [% l('Publication Year') %]</h4>
66               <span class="adv_search_result_filter">
67               [% IF    filter.name == 'date1'      %][% l('[_1]', date1) %]
68               [% ELSIF filter.name == 'before'  %][% l('Before [_1]', date1) %]
69               [% ELSIF filter.name == 'after'   %][% l('After [_1]', date1) %]
70               [% ELSIF filter.name == 'between' %][% l('Between [_1] and [_2]', date1, date2) %]
71               [% END %]
72               </span>
73               <a class="button remove_filter"
74               title="[% l('Remove publication date filter') %]"
75               href="[% mkurl('', {}, ['pubdate', 'date1', 'date2']) %]" rel="nofollow" vocab="">&times; </a>
76     </div>
77
78 [%- END; # IF pubdate_filters -%]
79 [%- END; # FOR -%]