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;
31 NEXT UNLESS ctx.is_staff || org_unit.opac_visible == 't';
33 IF !loc_grp; # processing an org unit
37 # add the location groups that sort below the child org units
38 FOR grp IN ctx.copy_location_groups.$ou_id.reverse;
40 top_loc_groups.push(grp);
42 node_stack.push({org => org_unit, loc_grp => grp});
47 # add the child org units
48 FOR child IN org_unit.children.reverse;
49 node_stack.push({org => child});
52 # add the location groups that sort to the top
53 # above the child org units
54 FOR grp IN top_loc_groups;
55 node_stack.push({org => org_unit, loc_grp => grp});
60 IF loc_grp; node_value = node_value _ ':' _ loc_grp.id; END;
62 css_class = 'class="loc_grp"';
64 css_class = 'class="org_unit"';
67 IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
68 disabled = 'disabled="disabled"';
69 ELSIF node_value == value;
70 selected = 'selected="selected"';
73 <option value='[% node_value %]' [% selected %] [% disabled %] [% css_class %]>
75 # loc_grp's are displayed as children of the current org
76 depth = org_unit.ou_type.depth;
77 IF loc_grp; depth = depth + 1; END;
79 FOR idx IN [0..pad]; ' '; END;
80 loc_grp ? loc_grp.name : org_unit.name | html ;