summaryrefslogtreecommitdiffstats
path: root/app/views/workflows/_form.html.erb
blob: d565a02a2e17b8784996f4a9f9ca01f968c9edb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<table class="list workflows transitions transitions-<%= name %>">
<thead>
  <tr>
    <th>
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled)')",
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
                           :class => 'no-tooltip icon-only icon-checked') %>
      <%=l(:label_current_status)%>
    </th>
    <th colspan="<%= @statuses.length %>"><%=l(:label_new_statuses_allowed)%></th>
  </tr>
  <tr>
    <td></td>
    <% for new_status in @statuses %>
    <td style="width:<%= 75 / @statuses.size %>%;">
      <%= 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 => 'no-tooltip icon-only icon-checked') %>
      <%= new_status.name %>
    </td>
    <% end %>
  </tr>
</thead>
<% transition_counts = workflows.each_with_object(Hash.new(0)) {|w,memo| memo[[w.old_status, w.new_status]] += 1} %>
<tbody>
  <% for old_status in [nil] + @statuses %>
  <% next if old_status.nil? && name != 'always' %>
  <tr>
    <td class="name">
      <%= 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 => 'no-tooltip icon-only icon-checked') %>
      <% if old_status %>
        <% old_status_name = old_status.name %>
        <%= old_status_name %>
      <% else %>
        <% old_status_name = l(:label_issue_new) %>
        <%= content_tag('em', old_status_name) %>
      <% end %>
    </td>
    <% for new_status in @statuses -%>
    <% checked = (old_status == new_status) || (transition_counts[[old_status, new_status]] > 0) %>
    <td class="no-tooltip <%= checked ? 'enabled' : '' %>" title="<%= old_status_name %> &#187; <%= new_status.name %>">
      <%= transition_tag transition_counts[[old_status, new_status]], old_status, new_status, name %>
    </td>
    <% end -%>
  </tr>
  <% end %>
</tbody>
</table>