]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/coded_value_selector.tt2
LP2042879 Shelving Location Groups Admin accessibility
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / coded_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 <select id='[% id %]' name='[% name %]'[%
20     multiple ? ' multiple="multiple"' : '';
21     size ? (' size="' _ size _ '"') : '';
22 %] title="[% filter_label || l('Select item type:') %]">
23 [% IF none_ok %]
24     <option value=''>[% none_label ? none_label : l('-- Any --') %]</option>
25 [% END;
26 # turn the list of objects into a list of hashes to 
27 # leverage TT's array.sort('<hashkey>') behavior
28 simple_sorter = [];
29 sorter = [];
30 FOR o IN all_values;
31     IF o.is_simple == 't';
32         simple_sorter.push({code => o.code, value => (o.search_label ? o.search_label : o.value)});
33     ELSE;
34         sorter.push({code => o.code, value  => (o.search_label ? o.search_label : o.value)}); 
35     END;
36 END;
37 FOR o IN simple_sorter.sort('value') %]
38     <option value='[% o.code | html | replace("'","&#39;") %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
39 [%  END;
40 IF simple_sorter.size && sorter.size %]
41     <option disabled='true'>-----</option>
42 [%  END;
43 FOR o IN sorter.sort('value') %]
44     <option value='[% o.code | html | replace("'","&#39;") %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
45 [%  END -%]
46 </select>
47