mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-11 19:53:07 +00:00
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:
parent
79c7fc6303
commit
4c7e1629a3
@ -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', ('» ' * 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 ? (' ' * 2 * level + '» ') : '')
|
||||
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 = []
|
||||
|
||||
@ -35,11 +35,7 @@ module ProjectsHelper
|
||||
end
|
||||
|
||||
def parent_project_select_tag(project)
|
||||
options = '<option></option>'
|
||||
project_tree(project.possible_parents) do |p, i|
|
||||
selected = (project.parent == p)
|
||||
options << "<option value='#{p.id}' #{ selected ? 'selected' : nil}>#{ '» ' * i }#{h(p)}</option>"
|
||||
end
|
||||
options = '<option></option>' + project_tree_options_for_select(project.possible_parents, :selected => project.parent)
|
||||
content_tag('select', options, :name => 'project[parent_id]')
|
||||
end
|
||||
|
||||
|
||||
@ -27,14 +27,7 @@ module UsersHelper
|
||||
# Options for the new membership projects combo-box
|
||||
def projects_options_for_select(projects)
|
||||
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
|
||||
projects_by_root = projects.group_by(&:root)
|
||||
projects_by_root.keys.sort.each do |root|
|
||||
options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root)))
|
||||
projects_by_root[root].sort.each do |project|
|
||||
next if project == root
|
||||
options << content_tag('option', '» ' + h(project.name), :value => project.id)
|
||||
end
|
||||
end
|
||||
options << project_tree_options_for_select(projects)
|
||||
options
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user