sanger/sequencescape

View on GitHub
app/views/labware/_asset_summary.html.erb

Summary

Maintainability
Test Coverage

<div id="asset-summary" class="asset_summary">
<table class="table">
  <tr>
    <th>Asset name</th>
    <td><%= asset.display_name %></td>
  </tr>
  <tr>
    <th>Asset ID</th>
    <td><%= asset.id.to_s %></td>
  </tr>
  <tr>
    <th>Created at</th>
    <td><%= asset.created_at.to_formatted_s(:day_full_with_time) %></td>
  </tr>
  <tr>
    <th>Type</th>
    <td><%= asset.label %></td>
  </tr>
  <% if asset.respond_to? :purpose %>
  <tr>
    <th>Purpose</th>
    <td><%= asset.purpose.try(:name)||'Unknown' %></td>
  </tr>
  <% end %>
  <% if asset.is_a?(Lane) %>
    <tr>
    <th>Data to be released externally?</th>
    <td><%= asset.external_release_text %></td>
    </tr>
    <tr>
      <th><%= asset.lane_metadata.attribute_details_for(:release_reason).to_field_info.display_name %></th>
      <td><%= asset.lane_metadata.release_reason %></td>
    </tr>
  <% end %>
  <% if asset.respond_to?(:volume) %>
    <tr>
      <th>Volume</th>
      <td><%= asset.volume %> &#181l</td>
    </tr>
  <% end %>
  <% if asset.respond_to?(:concentration) %>
    <tr>
      <th>Concentration</th>
      <td><%= asset.concentration %> nM</td>
    </tr>
  <% end %>
  <% if asset.respond_to?(:human_barcode) %>
    <tr>
      <th>Human barcode</th>
      <td><%= asset.human_barcode %></td>
    </tr>
  <% end %>
  <% if asset.kind_of? TubeRack %>
    <tr>
      <th>Summary page</th>
      <td><%= link_to "Summary for #{asset.human_barcode}",
        tube_rack_summary_path(asset.human_barcode) %></td>
    </tr>
  <% end %>
  <% if  @source_plates.present? %>
    <tr>
      <th>Summary page</th>
      <% @source_plates.each do |source_plate| %>
        <td><%= link_to "Summary for #{source_plate.human_barcode}", plate_summary_path(source_plate.human_barcode) %></td>
      <% end %>
    </tr>
  <% end %>

  <!-- BEGIN if it is a Tube inside a rack -->
  <% if asset.respond_to?(:tube_rack) && asset.tube_rack.present? %>
    <tr>
      <th>TubeRack</th>
      <td>
        <% if asset.tube_rack.present? %>
          <%= link_to asset.tube_rack.human_barcode || 'No barcode', labware_path(asset.tube_rack) %>
        <% else %>
          No tube rack
        <% end %>
      </td>
    </tr>
    <tr>
      <th>Position in rack</th>
      <td>
        <%= asset.racked_tube.coordinate %>
      </td>
    </tr>
  <% end %>
  <!-- END if is a tube inside a rack -->

  <% if asset.respond_to?(:qc_state) && asset.qc_state %>
    <tr>
      <th>QC state</th>
      <td><%= asset.qc_state %></td>
    </tr>
  <% end %>
  <% if asset.respond_to?(:storage_location) && !asset.storage_location.empty? %>
    <tr class="location-service-<%= asset.storage_location_service %>">
      <th>Storage location</th>
      <td><%= asset.storage_location %></td>
    </tr>
  <% end %>
  <tr>
    <th>Retention Instruction</th>
    <!-- First, check if retention instructions are there. -->
    <% if asset.retention_instruction.blank? %>
        <td>Not specified</td>
    <!-- If retention instructions are present, display them. -->
    <%  else  %>
      <td><%= find_retention_instruction_from_key(asset.retention_instruction.to_sym) %></td>
    <%  end %>
    <!-- There shouldn't be a situation where retention instructions are there in both custom_metadata -->
    <!-- and in labware table's retention instruction attribute -->
  </tr>
</table>
</div>