From 04e94bd3dda58665c11c09b6f60497b31b397b80 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 15 Sep 2018 07:09:14 +0000 Subject: Disable workflow checkboxes with no status change (#5593). Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@17487 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/workflows_helper.rb | 6 ++++-- app/views/workflows/_form.html.erb | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/helpers/workflows_helper.rb b/app/helpers/workflows_helper.rb index 142569e05..8ac75aa98 100644 --- a/app/helpers/workflows_helper.rb +++ b/app/helpers/workflows_helper.rb @@ -78,8 +78,10 @@ module WorkflowsHelper w = workflows.select {|w| w.old_status == old_status && w.new_status == new_status}.size tag_name = "transitions[#{ old_status.try(:id) || 0 }][#{new_status.id}][#{name}]" - if w == 0 || w == @roles.size * @trackers.size - + if old_status == new_status + check_box_tag(tag_name, "1", true, + {:disabled => true, :class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}"}) + elsif w == 0 || w == @roles.size * @trackers.size hidden_field_tag(tag_name, "0", :id => nil) + check_box_tag(tag_name, "1", w != 0, :class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}") diff --git a/app/views/workflows/_form.html.erb b/app/views/workflows/_form.html.erb index 958c1e43c..542db4e35 100644 --- a/app/views/workflows/_form.html.erb +++ b/app/views/workflows/_form.html.erb @@ -2,7 +2,7 @@ - <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]')", + <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled)')", :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}", :class => 'icon-only icon-checked') %> <%=l(:label_current_status)%> @@ -13,7 +13,7 @@ <% for new_status in @statuses %> - <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox].new-status-#{new_status.id}')", + <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).new-status-#{new_status.id}')", :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}", :class => 'icon-only icon-checked') %> <%= new_status.name %> @@ -26,7 +26,7 @@ <% next if old_status.nil? && name != 'always' %> - <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox].old-status-#{old_status.try(:id) || 0}')", + <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).old-status-#{old_status.try(:id) || 0}')", :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}", :class => 'icon-only icon-checked') %> <% if old_status %> @@ -38,7 +38,7 @@ <% end %> <% for new_status in @statuses -%> - <% checked = workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %> + <% checked = (old_status == new_status) || workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %> <%= transition_tag workflows, old_status, new_status, name %> -- cgit v1.2.3