]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/result/adv_filter.tt2
LP#1005040: teach filter boxes about human-readable crad descriptions
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / result / adv_filter.tt2
1 <div class="facet_box_wrapper filter_box_wrapper">
2 [%
3
4 # don't display a box for the search_format filter,
5 # as that's got its own widget
6 ignore_filters = ['search_format'];
7
8 FOR filter IN ctx.query_struct.filters;
9     fname = filter.name;
10     IF ignore_filters.grep('^' _ fname _ '$').size;
11       NEXT;
12     END;
13
14     fvalues = filter.args;
15     crad = ctx.get_crad(fname);
16
17     IF crad; # will be some special ones, like locations
18         remove_filter = 'fi:' _ fname;
19 %]
20     <div class="facet_box_temp filter_box_temp">
21         <div class="header">
22             <a class="button"
23               title="[% l('Remove [_1] filter', (crad.description || crad.label)) %]"
24               href="[% mkurl('', {}, [remove_filter]) %]" rel="nofollow" vocab="">
25               [% l("Remove") %]
26             </a>
27             <h4 class="title">[% IF filter.negate; l('Not'); END %] [% (crad.description || crad.label) | html %]</h4>
28         </div>
29         <div class="box_wrapper">
30             <div class="box">
31             [% temp = [];
32                FOR fval IN fvalues;
33                 thing = ctx.search_ccvm('ctype',fname,'code',fval).0;
34                 display_value = thing.search_label || thing.value;
35                 IF display_value.defined;
36                  temp.push(display_value);
37                 END;
38                END;
39                FOR display_value IN temp.sort;
40             %]
41                     <div class="facet_template filter_template">
42                         <div class="facet filter">
43                               [% display_value | html%]
44                         </div>
45                     </div>
46             [% END; # FOR %]
47             </div>
48         </div> <!-- box_wrapper -->
49     </div> <!-- facet_box_temp -->
50     [% END; # IF crad %]
51
52 [%  IF filter.name == 'locations'; locs = ctx.search_acpl('id',filter.args) %]
53     <div class="facet_box_temp filter_box_temp">
54         <div class="header">
55             <a class="button"
56               title="[% l('Remove location filter') %]"
57               href="[% mkurl('', {}, ['fi:locations']) %]" rel="nofollow" vocab="">
58               [% l("Remove") %]
59             </a>
60             <h4 class="title">[% IF filter.negate; l('Not'); END %] [% l('Locations') %]</h4>
61         </div>
62         <div class="box_wrapper">
63             <div class="box">
64             [% temp = [];
65                FOR loc IN locs;
66                 temp.push(loc.name);
67                END;
68                FOR display_name IN temp.sort; %]
69                 <div class="facet_template filter_template">
70                   <div class="facet filter">
71                     [% display_name | html%]
72                   </div>
73                 </div>
74             [% END; # FOR %]
75             </div>
76         </div> <!-- box_wrapper -->
77     </div> <!-- facet_box_temp -->
78     [% END; # IF locations %]
79 [% END; # FOR %]
80 </div> <!-- facet_box_wrapper -->
81