sanger/sequencescape

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

Summary

Maintainability
Test Coverage

<% add :about, "This page displays details the event history for an item." -%>
<% add :menu, "Back to labware" => labware_path(@asset.id) -%>

<%= page_title 'Event History', @asset.name %>

<p class="lead">
  Complete event history for labware <%= @asset.id %>, in chronological order.
</p>

<div class="ss-card">
  <%- unless @asset.events.empty? %>
    <div class="card-body"><h3><%= pluralize @asset.events.size, "event" %></h3></div>
    <table class="sortable table table-striped" id="events">
      <thead>
        <tr>
          <th>Message</th>
          <th>Content</th>
          <th>Created at</th>
          <th>Created by</th>
        </tr>
      </thead>
      <tbody>
        <%= render partial: "requests/event", collection: @asset.events.sort_by(&:id) %>
      </tbody>
    </table>
  <%- else %>
    <div class="card-body"><%= display_user_guide("No events registered") %></div>
  <%- end %>
</div>

<div class="ss-card">
  <%- if @asset.try(:asset_audits).present? %>
    <div class="card-body"><h3 class="card-title">Activity Logging</h3></div>
    <table class="sortable table table-striped" id="asset_audits">
      <thead><tr>
        <th>Message</th>
        <th>Key</th>
        <th>Created at</th>
        <th>Created by</th>
        <th>Details</th>
      </tr></thead>
      <tbody>
        <% @asset.asset_audits.each do |asset_audit| %>
          <tr>
            <td><%= asset_audit.message %></td>
            <td><%= asset_audit.key %></td>
            <td><%= asset_audit.created_at.to_formatted_s(:long) %></td>
            <td><%= asset_audit.created_by %></td>
            <td class="asset-audit-details"><%= render_parsed_json(asset_audit.metadata) %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  <%- else %>
    <div class="card-body"><%= display_user_guide("No asset audit activity") %></div>
  <%- end %>
</div>