sanger/sequencescape

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

Summary

Maintainability
Test Coverage
<%= page_title "Lab View", Date.today %>
<%= form_for(@asset, as: :labware, url: { controller: 'labware', action: "update", id: @asset.id, lab_view: true }, html: { method: :put }) do |f| %>
  <%= panel do %>
    <table class="table">
      <tr><th>Name</th><td><%= h(@asset.display_name) %></td></tr>
      <tr><th>Type</th><td><%= @asset.sti_type %></td></tr>
      <tr><th>Barcode</th><td><%= @asset.human_barcode %></td></tr>
      <tr><th>Batches</th><td><ul class="list-unstyled mb-0">
      <% requests = Request.where(asset_id: @asset.id).or(Request.where(target_asset_id: @asset.id)) %>
      <% requests.each do |request| %>
        <% request.batches.each do |batch| %>
          <li><%= link_to "#{batch.id} - #{batch.pipeline.name}", batch %></li>
        <% end %>
      <% end %>
      </ul></td></tr>
      <tr><th>Studies</th><td><ul class="list-unstyled mb-0">
      <% @asset.studies.uniq.each do |study| %>
        <li><%= link_to "#{study.id} - #{study.name}", study %></li>
      <% end %>
      </ul></td></tr>
      <% if @asset.respond_to?(:volume) %>
        <tr><th><%= f.label :volume, 'Volume (µL)' %></th><td><%= f.text_field :volume %></td></tr>
      <% end %>
      <% if @asset.respond_to?(:concentration) %>
        <tr><th><%= f.label :concentration, 'Concentration (nM)' %></th><td><%= f.text_field :concentration %></td></tr>
      <% end %>
      <tr><td></td><td><%= submit_tag 'Update' %></td></tr>
    </table>
  <% end %>
  <div class="columnize">
  <% unless @asset.parents.empty? %>
    <%= panel do %>
      <h3><%= pluralize @asset.parents.size, "Source" %></h3>
      <table class='sortable'>
        <thead>
          <tr>
            <th>Asset</th>
          </tr>
        </thead>
        <tbody>
          <% @asset.parents.each do |parent| %>
            <tr>
              <td>
                <% if parent.respond_to?(:human_barcode) %>
                  <%= link_to "#{(parent.label or "").humanize} #{parent.id}", action: :lab_view, barcode: parent.human_barcode %>
                 <% else %>
                  <%= link_to "#{(parent.label or "").humanize} #{parent.id}", labware_path(parent) %>
                <% end %>
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    <% end %>
  <% end %>
  <% unless @asset.children.empty? %>
    <%= panel do %>
      <h3><%= pluralize @asset.children.size, "Target" %></h3>
      <table class='sortable'>
        <thead>
          <tr>
            <th>Asset</th>
          </tr>
        </thead>
        <tbody>
          <% @asset.children.each do |child| %>
            <tr>
              <td>
                <% if child.respond_to?(:human_barcode) %>
                  <%= link_to "#{(child.label or "").humanize} #{child.id}", action: :lab_view, barcode: child.human_barcode %>
                <% else %>
                  <%= link_to "#{(child.label or "").humanize} #{child.id}", labware_path(child) %>
                <% end %>
                </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    <% end %>
  <% end %>
  </div>
<% end %>

<%= render partial: "find_form" %>