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:
1 parent
79c7fc6303
commit
4c7e1629a3
3 files changed
+15
-16
No files matched your search
@@ -156,15 +156,25 @@ module ApplicationHelper
|
|||||||
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
|
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
|
||||||
"<option selected='selected'>#{ l(:label_jump_to_a_project) }</option>" +
|
"<option selected='selected'>#{ l(:label_jump_to_a_project) }</option>" +
|
||||||
'<option disabled="disabled">---</option>'
|
'<option disabled="disabled">---</option>'
|
||||||
ancestors = []
|
s << project_tree_options_for_select(projects) do |p|
|
||||||
project_tree(projects) do |project, level|
|
{ :value => url_for(:controller => 'projects', :action => 'show', :id => p) }
|
||||||
s << content_tag('option', ('» ' * level) + h(project), :value => url_for(:controller => 'projects', :action => 'show', :id => project))
|
|
||||||
end
|
end
|
||||||
s << '</select>'
|
s << '</select>'
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
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
|
# Yields the given block for each project with its level in the tree
|
||||||
def project_tree(projects, &block)
|
def project_tree(projects, &block)
|
||||||
ancestors = []
|
ancestors = []
|
||||||
|
|||||||
@@ -35,11 +35,7 @@ module ProjectsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parent_project_select_tag(project)
|
def parent_project_select_tag(project)
|
||||||
options = '<option></option>'
|
options = '<option></option>' + project_tree_options_for_select(project.possible_parents, :selected => project.parent)
|
||||||
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
|
|
||||||
content_tag('select', options, :name => 'project[parent_id]')
|
content_tag('select', options, :name => 'project[parent_id]')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,7 @@ module UsersHelper
|
|||||||
# Options for the new membership projects combo-box
|
# Options for the new membership projects combo-box
|
||||||
def projects_options_for_select(projects)
|
def projects_options_for_select(projects)
|
||||||
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
|
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
|
||||||
projects_by_root = projects.group_by(&:root)
|
options << project_tree_options_for_select(projects)
|
||||||
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
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user