summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-16 16:33:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-16 16:33:27 +0000
commit7f1fb7ce81ddd02006ee9050f2a56b249f9dd474 (patch)
treef237586969dabe6746ae27e3121a826dea886862
parent5ac4b6670f40546b63282ef598936065961c2f6b (diff)
downloadredmine-7f1fb7ce81ddd02006ee9050f2a56b249f9dd474.tar.gz
redmine-7f1fb7ce81ddd02006ee9050f2a56b249f9dd474.zip
Don't show "Required" option for standard/custom fields that are always required.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10010 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/workflows_helper.rb11
-rw-r--r--app/views/workflows/permissions.html.erb4
-rw-r--r--test/functional/workflows_controller_test.rb4
3 files changed, 10 insertions, 9 deletions
diff --git a/app/helpers/workflows_helper.rb b/app/helpers/workflows_helper.rb
index 62dca80b3..912b8f153 100644
--- a/app/helpers/workflows_helper.rb
+++ b/app/helpers/workflows_helper.rb
@@ -18,13 +18,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module WorkflowsHelper
+ def field_required?(field)
+ field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id).include?(field)
+ end
+
def field_permission_tag(permissions, status, field)
name = field.is_a?(CustomField) ? field.id.to_s : field
- options = [["", ""], [l(:label_readonly), "readonly"], [l(:label_required), "required"]]
-
- if field.is_a?(CustomField) && field.is_required?
- options = [["(#{l(:label_required)})", ""], [l(:label_readonly), "readonly"]]
- end
+ options = [["", ""], [l(:label_readonly), "readonly"]]
+ options << [l(:label_required), "required"] unless field_required?(field)
select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
end
diff --git a/app/views/workflows/permissions.html.erb b/app/views/workflows/permissions.html.erb
index ecfadec02..c5979b0e3 100644
--- a/app/views/workflows/permissions.html.erb
+++ b/app/views/workflows/permissions.html.erb
@@ -58,7 +58,7 @@
<% @fields.each do |field, name| %>
<tr class="<%= cycle("odd", "even") %>">
<td>
- <%=h name %>
+ <%=h name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
</td>
<% for status in @statuses -%>
<td align="center" class="<%= @permissions[status.id][field] %>">
@@ -77,7 +77,7 @@
<% @custom_fields.each do |field| %>
<tr class="<%= cycle("odd", "even") %>">
<td>
- <%=h field.name %>
+ <%=h field.name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
</td>
<% for status in @statuses -%>
<td align="center" class="<%= @permissions[status.id][field.id.to_s] %>">
diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb
index 32ac03b97..a7d67822d 100644
--- a/test/functional/workflows_controller_test.rb
+++ b/test/functional/workflows_controller_test.rb
@@ -191,7 +191,7 @@ class WorkflowsControllerTest < ActionController::TestCase
end
end
- def test_get_permissions_with_always_required_custom_field
+ def test_get_permissions_with_required_custom_field_should_not_show_required_option
cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [1], :is_required => true)
get :permissions, :role_id => 1, :tracker_id => 1
@@ -201,7 +201,7 @@ class WorkflowsControllerTest < ActionController::TestCase
# Custom field that is always required
# The default option is "(Required)"
assert_select 'select[name=?]', "permissions[#{cf.id}][3]" do
- assert_select 'option[value=]', :text => '(Required)'
+ assert_select 'option[value=]'
assert_select 'option[value=readonly]', :text => 'Read-only'
assert_select 'option[value=required]', 0
end