diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-03-20 09:17:54 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-03-20 09:17:54 +0000 |
commit | 84c8ca6fefa3266527b754944ccb15e9393b1ae7 (patch) | |
tree | 57494dfa5abdf03e9bdc71a6fc11e2102ce3c551 /app | |
parent | 86c6afb5459c20888d6e8d6803b08bc60fdabf86 (diff) | |
download | redmine-84c8ca6fefa3266527b754944ccb15e9393b1ae7.tar.gz redmine-84c8ca6fefa3266527b754944ccb15e9393b1ae7.zip |
Fixed that custom fields with hidden/read-only combination may be displayed on issue form (#19297).
git-svn-id: http://svn.redmine.org/redmine/trunk@14137 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index a45ff53f2..7d2bf5bba 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -548,13 +548,27 @@ class Issue < ActiveRecord::Base workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).to_a if workflow_permissions.any? workflow_rules = workflow_permissions.inject({}) do |h, wp| - h[wp.field_name] ||= [] - h[wp.field_name] << wp.rule + h[wp.field_name] ||= {} + h[wp.field_name][wp.role_id] = wp.rule h end + fields_with_roles = {} + IssueCustomField.where(:visible => false).joins(:roles).pluck(:id, "role_id").each do |field_id, role_id| + fields_with_roles[field_id] ||= [] + fields_with_roles[field_id] << role_id + end + roles.each do |role| + fields_with_roles.each do |field_id, role_ids| + unless role_ids.include?(role.id) + field_name = field_id.to_s + workflow_rules[field_name] ||= {} + workflow_rules[field_name][role.id] = 'readonly' + end + end + end workflow_rules.each do |attr, rules| next if rules.size < roles.size - uniq_rules = rules.uniq + uniq_rules = rules.values.uniq if uniq_rules.size == 1 result[attr] = uniq_rules.first else |