summaryrefslogtreecommitdiffstats
path: root/app/helpers
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
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')
-rw-r--r--app/helpers/issues_helper.rb9
-rw-r--r--app/helpers/workflows_helper.rb13
2 files changed, 16 insertions, 6 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index f88a61e21..2e45d2e97 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -160,12 +160,13 @@ module IssuesHelper
end
def render_custom_fields_rows(issue)
- return if issue.custom_field_values.empty?
+ values = issue.visible_custom_field_values
+ return if values.empty?
ordered_values = []
- half = (issue.custom_field_values.size / 2.0).ceil
+ half = (values.size / 2.0).ceil
half.times do |i|
- ordered_values << issue.custom_field_values[i]
- ordered_values << issue.custom_field_values[i + half]
+ ordered_values << values[i]
+ ordered_values << values[i + half]
end
s = "<tr>\n"
n = 0
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