Adds a optgroup for groups in users/groups select tags.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6307 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2011-07-23 19:05:22 +00:00
parent 578fdc62f2
commit ed01ae121d
7 changed files with 42 additions and 5 deletions

View File

@@ -291,6 +291,20 @@ module ApplicationHelper
end
s
end
# Returns a string for users/groups option tags
def principals_options_for_select(collection, selected=nil)
s = ''
groups = ''
collection.sort.each do |element|
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected)
(element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
end
unless groups.empty?
s << %(<optgroup label="#{h(l(:label_group_plural))}">#{groups}</optgroup>)
end
s
end
# Truncates and returns the string as a single line
def truncate_single_line(string, *args)