$ctx->{search_ou} = $self->_get_search_lib();
$self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
+ $self->load_copy_location_groups;
return Apache2::Const::OK;
}
$self->ctx->{saved_searches_expanded} = $value;
}
+sub load_copy_location_groups {
+ my $self = shift;
+ my $grps = $self->editor->search_asset_copy_location_group({opac_visible => 't'});
+ my %buckets;
+ push(@{$buckets{$_->owner}}, $_) for @$grps;
+ $self->ctx->{copy_location_groups} = \%buckets;
+}
+
# physical_loc (i.e. "original location") passed in as a URL
# param will replace any existing physical_loc stored as a cookie.
sub get_physical_loc {
[%
- BLOCK build_org_selector_options;
- disabled = '';
- selected = '';
- IF can_have_vols_only AND walker.ou_type.can_have_vols != 't';
- disabled = 'disabled="disabled"';
- ELSIF walker.id == value;
- selected = 'selected="selected"';
- END;
- IF ctx.is_staff || walker.opac_visible == 't';
-%]
- <option value='[% walker.id | uri %]' [% selected %] [% disabled %]>
+# Org Unit Selector Widget :
+# PROCESS build_org_selector id='selector-id' name='selector-name'
+# value=org_id show_loc_groups=1/0 can_have_vols_only=1/0
+
+BLOCK build_org_selector;
+ root_node = org_unit || ctx.aou_tree;
+ node_stack = [{org => root_node}] %]
+
+ <select [% IF id %] id='[% id %]' [% END %] name='[% name %]'>
+ [%
+ WHILE node_stack.size > 0;
+ node = node_stack.pop();
+ org_unit = node.org;
+ loc_grp = node.loc_grp;
+ ou_id = org_unit.id;
+ disabled = '';
+ selected = '';
+
+ IF ctx.is_staff || org_unit.opac_visible == 't';
+
+ IF !loc_grp;
+ IF show_loc_groups;
+ FOR grp IN ctx.copy_location_groups.$ou_id.sort('pos').reverse;
+ node_stack.push({org => org_unit, loc_grp => grp});
+ END;
+ END;
+ FOR child IN org_unit.children.reverse;
+ node_stack.push({org => child});
+ END;
+ END;
+
+ IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
+ disabled = 'disabled="disabled"';
+ ELSIF ou_id == value; # TODO: test for copy_loc value
+ selected = 'selected="selected"';
+ END %]
+
+ <option value='[% org_unit.id | uri %]' [% selected %] [% disabled %]>
[%
- pad = walker.ou_type.depth * 2;
+ depth = org_unit.ou_type.depth;
+ IF loc_grp; depth = depth + 1; END;
+ pad = depth * 2;
FOR idx IN [0..pad]; ' '; END;
- walker.name | html;
+ loc_grp ? loc_grp.name : org_unit.name | html ;
%]
- </option>
- [% FOR child IN walker.children;
- PROCESS build_org_selector_options walker=child value=value;
+ </option>
+
+ [%
END;
END;
- END;
-
- # XXX TODO probably put this BLOCK somewhere else so it can be used widely.
- # Org Unit Selector Widget :
- # PROCESS build_org_selector id='selector-id' name='selector-name'
- BLOCK build_org_selector;
-%]
- <select [% IF id %] id='[% id %]' [% END %] name='[% name %]'>
- [% PROCESS build_org_selector_options walker=(org_unit || ctx.aou_tree) value=value %]
+ %]
</select>
-[% END %]
+[% END %]