]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates-bootstrap/opac/parts/check_value_selector.tt2
LP 2061136 follow-up: ng lint --fix
[Evergreen.git] / Open-ILS / src / templates-bootstrap / opac / parts / check_value_selector.tt2
1
2 [%-
3     # If caller passes a list of possible attribute types,
4     # search all until we find some values
5
6     IF !attr.size; attr = [attr]; END;
7     all_values = [];
8     attr_class = '';
9     FOR attr_class IN attr;
10         all_values = ctx.search_ccvm('ctype', attr_class, 'opac_visible', 't');
11         IF all_values.size > 0; LAST; END;
12     END;
13     name = name || "fi:" _ attr_class;
14     id = id || attr_class _ "_selector";
15     values = values || CGI.param(name);
16     IF size AND size < 1; size = all_values.size; END;
17 -%]
18
19 <div class="w-100">
20
21 [% IF none_ok %]
22     <p value=''>[% none_label ? none_label : l('-- Any --') %]</p>
23 [% END;
24 # turn the list of objects into a list of hashes to
25 # leverage TT's array.sort('<hashkey>') behavior
26 simple_sorter = [];
27 sorter = [];
28 FOR o IN all_values;
29     IF o.is_simple == 't';
30         simple_sorter.push({code => o.code, value => (o.search_label ? o.search_label : o.value)});
31     ELSE;
32         sorter.push({code => o.code, value  => (o.search_label ? o.search_label : o.value)});
33     END;
34 END;%]
35
36 [%IF simple_sorter.size %]
37 <ul class="adv_filters">
38 [% FOR o IN simple_sorter.sort('value') %]
39 <li>
40 <div class="form-check">
41     <label class="form-check-label">
42       <input type="checkbox" class="form-check-input"  name='[% name %]' value='[% o.code | html | replace("'","&#39;") %]'[% values.grep('^' _ o.code _ '$').size ? ' checked' : '' %]>
43       [% o.value | html %]
44     </label>
45   </div>
46   </li>
47 [%  END -%]
48 </ul>
49 [% END; %]
50
51 [%IF simple_sorter.size && sorter.size %]
52     <p disabled='true'>-----</p>
53 [%  END; %]
54
55 [%IF sorter.size %]
56 <ul class="adv_filters">
57 [% FOR o IN sorter.sort('value') %]
58 <li>
59 <div class="form-check">
60     <label class="form-check-label">
61       <input type="checkbox" class="form-check-input"  name='[% name %]' value='[% o.code | html | replace("'","&#39;") %]'[% values.grep('^' _ o.code _ '$').size ? ' checked' : '' %]>
62       [% o.value | html %]
63     </label>
64   </div>
65   </li>
66 [%  END -%]
67 </ul>
68 [% END; %]
69
70 </div>