SpeciesFileGroup/taxonworks

View on GitHub
app/views/shared/data/all/batch_file_load/_preview.html.erb

Summary

Maintainability
Test Coverage
<h2> Batch preview </h2>

<% if @result.valid? -%>
    <p> To complete this batch import, select the file again and click create:</p>

    <%= content_for :batch_form -%>
<% end %>

<%= render partial: 'shared/data/all/batch_file_load/import_file_properties' %>

<h3> Files breakdown </h3>
<% if content_for?(:files_breakdown) -%>
    <%= yield :files_breakdown -%>
<% else %>

  <% @result.processed_files[:names].each_with_index do |filename, file_index| %>
    <h4>File <%= file_index + 1 %>: <%= filename %></h4>
    <table class="top_align_text" border="1">
      <tr>
        <th>Count</th>
        <th>Type</th>
        <th>Valid</th>
        <th>Validation Errors</th>
      </tr>

      <% object_count = 0 %>

      <% @result.processed_files[:objects][file_index].each do |type, objects| %>
        <% objects.each do |object| %>
          <% object_count += 1 %>

          <tr>
            <td><%= object_count %>
            <td><%= object.class.name.demodulize %></td>
            <td><%= begin; object.valid?; rescue ArgumentError; end; %></td>
            <td><%= object.errors.full_messages.join('; ') %></td>
          </tr>
        <% end %>
      <% end %>
    </table>
  <% end %>
<% end %>

<h3> Input files </h3>
<%= render partial: '/shared/data/all/batch_file_load/input_file' -%>