ruby1.8 compatibility.
git-svn-id: http://svn.redmine.org/redmine/trunk@12404 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a59dc1658b
commit
3e5f1e326a
|
@ -39,8 +39,7 @@ module Redmine
|
||||||
|
|
||||||
# Return an array of custom field formats which can be used in select_tag
|
# Return an array of custom field formats which can be used in select_tag
|
||||||
def self.as_select(class_name=nil)
|
def self.as_select(class_name=nil)
|
||||||
formats = all.values
|
formats = all.values.select do |format|
|
||||||
formats.select! do |format|
|
|
||||||
format.class.customized_class_names.nil? || format.class.customized_class_names.include?(class_name)
|
format.class.customized_class_names.nil? || format.class.customized_class_names.include?(class_name)
|
||||||
end
|
end
|
||||||
formats.map {|format| [::I18n.t(format.label), format.name] }.sort_by(&:first)
|
formats.map {|format| [::I18n.t(format.label), format.name] }.sort_by(&:first)
|
||||||
|
@ -547,7 +546,8 @@ module Redmine
|
||||||
missing = [custom_value.value_was].flatten.reject(&:blank?) - options.map(&:last)
|
missing = [custom_value.value_was].flatten.reject(&:blank?) - options.map(&:last)
|
||||||
if missing.any?
|
if missing.any?
|
||||||
options += target_class.find_all_by_id(missing.map(&:to_i)).map {|o| [o.to_s, o.id.to_s]}
|
options += target_class.find_all_by_id(missing.map(&:to_i)).map {|o| [o.to_s, o.id.to_s]}
|
||||||
options.sort_by!(&:first)
|
#TODO: use #sort_by! when ruby1.8 support is dropped
|
||||||
|
options = options.sort_by(&:first)
|
||||||
end
|
end
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue