Changes project selection boxes.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2277 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2009-01-17 13:07:40 +00:00
parent 79c7fc6303
commit 4c7e1629a3
3 changed files with 15 additions and 16 deletions
@@ -156,15 +156,25 @@ module ApplicationHelper
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
"<option selected='selected'>#{ l(:label_jump_to_a_project) }</option>" +
'<option disabled="disabled">---</option>'
ancestors = []
project_tree(projects) do |project, level|
s << content_tag('option', ('&#187; ' * level) + h(project), :value => url_for(:controller => 'projects', :action => 'show', :id => project))
s << project_tree_options_for_select(projects) do |p|
{ :value => url_for(:controller => 'projects', :action => 'show', :id => p) }
end
s << '</select>'
s
end
end
def project_tree_options_for_select(projects, options = {})
s = ''
project_tree(projects) do |project, level|
name_prefix = (level > 0 ? ('&nbsp;' * 2 * level + '&#187; ') : '')
tag_options = {:value => project.id, :selected => ((project == options[:selected]) ? 'selected' : nil)}
tag_options.merge!(yield(project)) if block_given?
s << content_tag('option', name_prefix + h(project), tag_options)
end
s
end
# Yields the given block for each project with its level in the tree
def project_tree(projects, &block)
ancestors = []