scinote-web/app/views/protocols/index/_results_modal_body.html.erb
2018-07-27 15:27:08 +02:00

55 lines
2 KiB
Text

<% nr_successful = results.count { |r| r[:success] } %>
<% failed = results.select { |r| !r[:success] } %>
<% unchanged = results.select { |r| r[:success] && r[:name] == r[:new_name] } %>
<% renamed = results.select { |r| r[:success] && r[:name] != r[:new_name] } %>
<% if failed.count > 0 %>
<div class="alert alert-danger" style="margin-bottom: 15px;" role="alert">
<span class="fas fa-exclamation-circle"></span>
<%= t("protocols.index.#{en_action}.message_failed", nr: failed.count) %>
</div>
<% end %>
<% if nr_successful > 0 %>
<div>
<%= t("protocols.index.#{en_action}.message_ok", nr: nr_successful) %>
</div>
<% end %>
<div class="well well-sm well-protocols-results">
<ul>
<% if unchanged.count > 0 %>
<% unchanged.each do |r| %>
<li>
<span class="label label-success"><%= t("protocols.index.#{en_action}.row_success") %></span>
<% if en_action == "restore_results" %>
<%= t("protocols.index.restore_results.row_#{r[:type]}", protocol: h(r[:name])).html_safe %>
<% else %>
<%= r[:name] %>
<% end %>
</li>
<% end %>
<% end %>
<% if renamed.count > 0 %>
<% renamed.each do |r| %>
<li>
<span class="label label-warning"><%= t("protocols.index.#{en_action}.row_renamed") %></span>
<% protocol_str = t("protocols.index.row_renamed_html", old_name: h(r[:name]), new_name: h(r[:new_name])) %>
<% if en_action == "restore_results" %>
<%= t("protocols.index.restore_results.row_#{r[:type]}", protocol: protocol_str).html_safe %>
<% else %>
<%= protocol_str.html_safe %>
<% end %>
</li>
<% end %>
<% end %>
<% if failed.count > 0 %>
<% failed.each do |r| %>
<li>
<span class="label label-danger"><%= t("protocols.index.#{en_action}.row_failed") %></span>
<%= r[:name] %>
</li>
<% end %>
<% end %>
</ul>
</div>