sanger/sequencescape

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

Summary

Maintainability
Test Coverage

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

<%= page_title 'Event History' %>

<div class="help">
  Complete event history for asset <%= @asset.id %>, in chronological order.
</div>

<div class="info">
  <%- unless @asset.events.empty? %>
    <h3><%= pluralize @asset.events.size, "event" %></h3>
    <table width="100%" cellspacing="0" cellpadding="4" class="sortable" id="events">
      <tr>
        <th>Message</th>
        <th>Content</th>
        <th>Created at</th>
        <th>Created by</th>
      </tr>
      <%= render partial: "requests/event", collection: @asset.events.sort{ |a,b| a.id <=> b.id  } %>
    </table>
  <%- else %>
    <%= display_user_guide("No events registered") %>
  <%- end %>
</div>

<div class="info">
  <%- if @asset.try(:asset_audits).present? %>
    <h3>Activity Logging</h3>
    <table width="100%" cellspacing="0" cellpadding="4" class="sortable" id="asset_audits">
      <tr>
        <th>Message</th>
        <th>Key</th>
        <th>Created at</th>
        <th>Created by</th>
      </tr>
      <% @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>
        </tr>
      <% end %>

    </table>
  <%- else %>
    <%= display_user_guide("No events registered") %>
  <%- end %>
</div>