summaryrefslogtreecommitdiffstats
path: root/app/helpers/workflows_helper.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-13 09:20:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-13 09:20:11 +0000
commit628d05629b734371d3e850a95dadf0be30c5ef20 (patch)
tree58a9da4e8266ee45a0800996f9228e9d2a45108c /app/helpers/workflows_helper.rb
parenta74d55edd99a4bae23e7d9cbd76136ffa7707ccf (diff)
downloadredmine-628d05629b734371d3e850a95dadf0be30c5ef20.tar.gz
redmine-628d05629b734371d3e850a95dadf0be30c5ef20.zip
Role-based issue custom field visibility (#5037).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12012 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/workflows_helper.rb')
-rw-r--r--app/helpers/workflows_helper.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/helpers/workflows_helper.rb b/app/helpers/workflows_helper.rb
index 1cec67a88..7ef6e9942 100644
--- a/app/helpers/workflows_helper.rb
+++ b/app/helpers/workflows_helper.rb
@@ -22,11 +22,20 @@ module WorkflowsHelper
field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id is_private).include?(field)
end
- def field_permission_tag(permissions, status, field)
+ def field_permission_tag(permissions, status, field, role)
name = field.is_a?(CustomField) ? field.id.to_s : field
options = [["", ""], [l(:label_readonly), "readonly"]]
options << [l(:label_required), "required"] unless field_required?(field)
+ html_options = {}
+ selected = permissions[status.id][name]
- select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
+ hidden = field.is_a?(CustomField) && !field.visible? && !role.custom_fields.to_a.include?(field)
+ if hidden
+ options[0][0] = l(:label_hidden)
+ selected = ''
+ html_options[:disabled] = true
+ end
+
+ select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, selected), html_options)
end
end