summaryrefslogtreecommitdiffstats
path: root/lib/redmine/field_format.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-18 05:59:20 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-06-18 05:59:20 +0000
commitadb9980728c0500046ce623dc023a295b4af21d5 (patch)
treef4d38f288be0394e728377449de52b39c0e846b6 /lib/redmine/field_format.rb
parent3be2185683479f65e95cba89a419e30375a34df6 (diff)
downloadredmine-adb9980728c0500046ce623dc023a295b4af21d5.tar.gz
redmine-adb9980728c0500046ce623dc023a295b4af21d5.zip
Allow global versions to be shown outside of a project for version custom fields (#23083).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@15536 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/field_format.rb')
-rw-r--r--lib/redmine/field_format.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb
index 77014579b..874220933 100644
--- a/lib/redmine/field_format.rb
+++ b/lib/redmine/field_format.rb
@@ -802,17 +802,24 @@ module Redmine
projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
elsif object.respond_to?(:project) && object.project
scope = object.project.shared_versions
- if !all_statuses && custom_field.version_status.is_a?(Array)
- statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
- if statuses.any?
- scope = scope.where(:status => statuses.map(&:to_s))
- end
- end
- scope.sort.collect {|u| [u.to_s, u.id.to_s]}
+ filtered_versions_options(custom_field, scope, all_statuses)
+ elsif object.nil?
+ scope = Version.visible.where(:sharing => 'system')
+ filtered_versions_options(custom_field, scope, all_statuses)
else
[]
end
end
+
+ def filtered_versions_options(custom_field, scope, all_statuses=false)
+ if !all_statuses && custom_field.version_status.is_a?(Array)
+ statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
+ if statuses.any?
+ scope = scope.where(:status => statuses.map(&:to_s))
+ end
+ end
+ scope.sort.collect{|u| [u.to_s, u.id.to_s] }
+ end
end
end
end