2 # Org Unit Selector Widget :
3 # INCLUDE 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 # NOTE: DO NOT USE PROCESS
7 # Use of PROCESS results in internal variables, such as value or org_unit, to "leak" out
9 BLOCK build_org_selector;
10 node_stack = [{org => org_unit || ctx.aou_tree}];
13 IF show_loc_groups; name = 'locg'; END;
16 value = ctx.search_ou;
18 value = CGI.param('locg') || ctx.search_ou;
23 <select [% IF id %] id='[% id %]' [% END %] name='[% name %]'>
25 WHILE node_stack.size > 0;
26 node = node_stack.pop();
28 loc_grp = node.loc_grp;
34 NEXT UNLESS ctx.is_staff || org_unit.opac_visible == 't';
36 IF !loc_grp; # processing an org unit
40 # add the location groups that sort below the child org units
41 FOR grp IN ctx.copy_location_groups.$ou_id.reverse;
43 top_loc_groups.push(grp);
45 node_stack.push({org => org_unit, loc_grp => grp});
50 # add the child org units
51 FOR child IN org_unit.children.reverse;
52 node_stack.push({org => child});
55 # add the location groups that sort to the top
56 # above the child org units
57 FOR grp IN top_loc_groups;
58 node_stack.push({org => org_unit, loc_grp => grp});
63 IF loc_grp; node_value = node_value _ ':' _ loc_grp.id; END;
65 css_class = 'class="loc_grp"';
67 css_class = 'class="org_unit"';
70 IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
71 disabled = 'disabled="disabled"';
72 ELSIF node_value == value;
73 selected = 'selected="selected"';
76 <option value='[% node_value %]' [% selected %] [% disabled %] [% css_class %]>
78 # loc_grp's are displayed as children of the current org
79 depth = org_unit.ou_type.depth;
80 IF loc_grp; depth = depth + 1; END;
82 FOR idx IN [0..pad]; ' '; END;
83 loc_grp ? loc_grp.name : org_unit.name | html ;