2 # Org Unit Selector Widget :
3 # PROCESS build_org_selector id='selector-id' name='selector-name'
4 # value=org_id show_loc_groups=1/0 can_have_vols_only=1/0
6 BLOCK build_org_selector;
7 node_stack = [{org => org_unit || ctx.aou_tree}];
10 IF show_loc_groups; name = 'locg'; END;
13 value = ctx.search_ou;
15 value = CGI.param('locg') || ctx.search_ou;
20 <select [% IF id %] id='[% id %]' [% END %] name='[% name %]'>
22 WHILE node_stack.size > 0;
23 node = node_stack.pop();
25 loc_grp = node.loc_grp;
30 NEXT UNLESS ctx.is_staff || org_unit.opac_visible == 't';
34 FOR grp IN ctx.copy_location_groups.$ou_id.reverse;
35 node_stack.push({org => org_unit, loc_grp => grp});
38 FOR child IN org_unit.children.reverse;
39 node_stack.push({org => child});
44 IF loc_grp; node_value = node_value _ ':' _ loc_grp.id; END;
46 IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
47 disabled = 'disabled="disabled"';
48 ELSIF node_value == value;
49 selected = 'selected="selected"';
52 <option value='[% node_value %]' [% selected %] [% disabled %]>
54 # loc_grp's are displayed as children of the current org
55 depth = org_unit.ou_type.depth;
56 IF loc_grp; depth = depth + 1; END;
58 FOR idx IN [0..pad]; ' '; END;
59 loc_grp ? loc_grp.name : org_unit.name | html ;