sanger/sequencescape

View on GitHub
app/views/shared/_show_plate.html.erb

Summary

Maintainability
Test Coverage

<table id="plate" width="100%">
  <tr>
    <th></th>
    <% plate.plate_columns.each do |header| %>
      <th><%= header %></th>
    <% end %>
  </tr>
  <% indexed_wells = plate.wells.includes(:map, :samples, :requests, upstream_wells: :map).indexed_by_location %>
  <% plate.plate_rows.each_with_index do |row, row_index| %>
    <tr>
    <td id='border' width='2%'><%= row %></td>
      <% plate.plate_columns.each_with_index do |column, column_index| -%>
        <td>
          <div id="boxNormal">
            <% well = indexed_wells["#{row}#{column}"] %>
            <% if well %>
              <% well.samples.each do |sample| %>
                <%= link_to sample.name, sample_path(sample) %><br/>
              <% end %>
              <%= link_to "#{row}#{column}", receptacle_path(well) %><br/>
              Parent: <%= well.upstream_wells.map(&:map_description).join(',').presence || 'None' %>
              <%= pluralize well.requests.size, 'request' %>
            <% else %>
              [ Empty ]
            <% end %>
           </div>
         </td>
      <% end -%>
    </tr>
  <% end -%>
</table>