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';
32 IF !loc_grp; # processing an org unit
36 # add the location groups that sort below the child org units
37 FOR grp IN ctx.copy_location_groups.$ou_id.reverse;
39 top_loc_groups.push(grp);
41 node_stack.push({org => org_unit, loc_grp => grp});
46 # add the child org units
47 FOR child IN org_unit.children.reverse;
48 node_stack.push({org => child});
51 # add the location groups that sort to the top
52 # above the child org units
53 FOR grp IN top_loc_groups;
54 node_stack.push({org => org_unit, loc_grp => grp});
59 IF loc_grp; node_value = node_value _ ':' _ loc_grp.id; END;
61 IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
62 disabled = 'disabled="disabled"';
63 ELSIF node_value == value;
64 selected = 'selected="selected"';
67 <option value='[% node_value %]' [% selected %] [% disabled %]>
69 # loc_grp's are displayed as children of the current org
70 depth = org_unit.ou_type.depth;
71 IF loc_grp; depth = depth + 1; END;
73 FOR idx IN [0..pad]; ' '; END;
74 loc_grp ? loc_grp.name : org_unit.name | html ;