GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit e8293803 authored by jplang's avatar jplang

Disable workflow checkboxes with no status change (#5593).

Patch by Mizuki ISHIKAWA.

git-svn-id: https://svn.redmine.org/redmine/trunk@17487 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 05314729
...@@ -78,8 +78,10 @@ module WorkflowsHelper ...@@ -78,8 +78,10 @@ module WorkflowsHelper
w = workflows.select {|w| w.old_status == old_status && w.new_status == new_status}.size 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}]" 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) + hidden_field_tag(tag_name, "0", :id => nil) +
check_box_tag(tag_name, "1", w != 0, check_box_tag(tag_name, "1", w != 0,
:class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}") :class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}")
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<thead> <thead>
<tr> <tr>
<th> <th>
<%= 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)}", :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
:class => 'icon-only icon-checked') %> :class => 'icon-only icon-checked') %>
<%=l(:label_current_status)%> <%=l(:label_current_status)%>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<td></td> <td></td>
<% for new_status in @statuses %> <% for new_status in @statuses %>
<td style="width:<%= 75 / @statuses.size %>%;"> <td style="width:<%= 75 / @statuses.size %>%;">
<%= 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)}", :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
:class => 'icon-only icon-checked') %> :class => 'icon-only icon-checked') %>
<%= new_status.name %> <%= new_status.name %>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<% next if old_status.nil? && name != 'always' %> <% next if old_status.nil? && name != 'always' %>
<tr> <tr>
<td class="name"> <td class="name">
<%= 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)}", :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
:class => 'icon-only icon-checked') %> :class => 'icon-only icon-checked') %>
<% if old_status %> <% if old_status %>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<% end %> <% end %>
</td> </td>
<% for new_status in @statuses -%> <% 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} %>
<td class="<%= checked ? 'enabled' : '' %>" title="<%= old_status_name %> &#187; <%= new_status.name %>"> <td class="<%= checked ? 'enabled' : '' %>" title="<%= old_status_name %> &#187; <%= new_status.name %>">
<%= transition_tag workflows, old_status, new_status, name %> <%= transition_tag workflows, old_status, new_status, name %>
</td> </td>
......
...@@ -110,7 +110,19 @@ class WorkflowsControllerTest < Redmine::ControllerTest ...@@ -110,7 +110,19 @@ class WorkflowsControllerTest < Redmine::ControllerTest
assert_equal ["New issue"] + statuses, assert_equal ["New issue"] + statuses,
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip) css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]' assert_select 'input[type=checkbox][name=?]', 'transitions[0][1][always]'
end
def test_get_edit_should_show_checked_disabled_transition_checkbox_between_same_statuses
get :edit, :params => {:role_id => 2, :tracker_id => 1}
assert_response :success
assert_select 'table.workflows.transitions-always tbody tr:nth-child(2)' do
assert_select 'td.name', :text => 'New'
# assert that the td is enabled
assert_select "td[title='New » New'][class=?]", 'enabled'
# assert that the checkbox is disabled and checked
assert_select "input[name='transitions[1][1][always]'][checked=?][disabled=?]", 'checked', 'disabled', 1
end
end end
def test_post_edit def test_post_edit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment