Project

General

Profile

Defect #5593 » 5593-r17236.patch

Mizuki ISHIKAWA, 2018-03-22 01:17

View differences:

app/helpers/workflows_helper.rb
78 78
    w = workflows.select {|w| w.old_status == old_status && w.new_status == new_status}.size
79 79
    
80 80
    tag_name = "transitions[#{ old_status.try(:id) || 0 }][#{new_status.id}][#{name}]"
81
    if w == 0 || w == @roles.size * @trackers.size
82
      
81
    if old_status == new_status
82
      check_box_tag(tag_name, "1", true,
83
        {:disabled => true, :class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}"})
84
    elsif w == 0 || w == @roles.size * @trackers.size
83 85
      hidden_field_tag(tag_name, "0", :id => nil) +
84 86
      check_box_tag(tag_name, "1", w != 0,
85 87
            :class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}")
app/views/workflows/_form.html.erb
2 2
<thead>
3 3
  <tr>
4 4
    <th>
5
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]')",
5
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled)')",
6 6
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
7 7
                           :class => 'icon-only icon-checked') %>
8 8
      <%=l(:label_current_status)%>
......
13 13
    <td></td>
14 14
    <% for new_status in @statuses %>
15 15
    <td style="width:<%= 75 / @statuses.size %>%;">
16
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox].new-status-#{new_status.id}')",
16
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).new-status-#{new_status.id}')",
17 17
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
18 18
                           :class => 'icon-only icon-checked') %>
19 19
      <%= new_status.name %>
......
26 26
  <% next if old_status.nil? && name != 'always' %>
27 27
  <tr>
28 28
    <td class="name">
29
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox].old-status-#{old_status.try(:id) || 0}')",
29
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).old-status-#{old_status.try(:id) || 0}')",
30 30
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
31 31
                           :class => 'icon-only icon-checked') %>
32 32
      <% if old_status %>
......
38 38
      <% end %>
39 39
    </td>
40 40
    <% for new_status in @statuses -%>
41
    <% checked = workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %>
41
    <% checked = (old_status == new_status) || workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %>
42 42
    <td class="<%= checked ? 'enabled' : '' %>" title="<%= old_status_name %> &#187; <%= new_status.name %>">
43 43
      <%= transition_tag workflows, old_status, new_status, name %>
44 44
    </td>
test/functional/workflows_controller_test.rb
110 110
    assert_equal ["New issue"] + statuses,
111 111
      css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
112 112

  
113
    assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]'
113
    assert_select 'input[type=checkbox][name=?]', 'transitions[0][1][always]'
114
  end
115

  
116
  def test_get_edit_should_show_checked_disabled_transition_checkbox_between_same_statuses
117
    get :edit, :params => {:role_id => 2, :tracker_id => 1}
118
    assert_response :success
119
    assert_select 'table.workflows.transitions-always tbody tr:nth-child(2)' do
120
      assert_select 'td.name', :text => 'New'
121
      # assert that the td is enabled
122
      assert_select "td[title='New » New'][class=?]", 'enabled'
123
      # assert that the checkbox is disabled and checked
124
      assert_select "input[name='transitions[1][1][always]'][checked=?][disabled=?]", 'checked', 'disabled', 1
125
    end
114 126
  end
115 127

  
116 128
  def test_post_edit
(12-12/12)