1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-30 20:29:37 +00:00

Speed up workflow edit page rendering (#31855).

Patch by Felix Schäfer.


git-svn-id: http://svn.redmine.org/redmine/trunk@18373 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-08-17 02:23:51 +00:00
parent 6a871fdcfc
commit 78d3d6c223
2 changed files with 5 additions and 4 deletions

View File

@ -74,8 +74,8 @@ module WorkflowsHelper
select_tag("permissions[#{status.id}][#{name}]", options_for_select(options, selected), html_options)
end
def transition_tag(workflows, old_status, new_status, name)
w = workflows.select {|w| w.old_status == old_status && w.new_status == new_status}.size
def transition_tag(transition_count, old_status, new_status, name)
w = transition_count
tag_name = "transitions[#{ old_status.try(:id) || 0 }][#{new_status.id}][#{name}]"
if old_status == new_status

View File

@ -21,6 +21,7 @@
<% 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' %>
@ -38,9 +39,9 @@
<% end %>
</td>
<% for new_status in @statuses -%>
<% checked = (old_status == new_status) || workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %>
<% checked = (old_status == new_status) || (transition_counts[[old_status, new_status]] > 0) %>
<td class="<%= checked ? 'enabled' : '' %>" title="<%= old_status_name %> &#187; <%= new_status.name %>">
<%= transition_tag workflows, old_status, new_status, name %>
<%= transition_tag transition_counts[[old_status, new_status]], old_status, new_status, name %>
</td>
<% end -%>
</tr>