nilbus/handoff

View on GitHub
app/views/handoffs/index.html.erb

Summary

Maintainability
Test Coverage
<div class="col-md-10 col-md-offset-1">
  <h1>My Handoffs</h1>
  <% if @handoffs.size > 0 %>
    <table id="handoffs">
      <thead>
        <tr><th></th><th>Name</th><th>Reason</th><th>Initiated By</th><th>Last Modified</th></tr>
      </thead>
      <tbody>
      <% @handoffs.each do |handoff| %>
        <%
          share = Share.find_by(handoff_id: handoff.id, user_id: current_user.id)
        %>
        <tr>
          <td>
            <% if share.last_view == nil or share.last_view < handoff.last_modified %>
              <span class="glyphicon glyphicon-flag" aria-hidden="true" title="New activity on this handoff!" style="color: red"></span>
            <% end %>
          </td>
          <td><%= link_to handoff.name, handoff %></td>
          <td><%= handoff.description %></td>
          <td><%= handoff.creator_id == current_user.id ? "You" : User.find(handoff.creator_id).email %></td>
          <td><%= handoff.last_modified.strftime("%B %d, %Y at %I:%M%p") %></td>
        </tr>
      <% end %>
      </tbody>
    </table>
    <% content_for :body_end do %>
      <script type="text/javascript">
    $(document).ready(function() {
        $('#handoffs').dataTable({
          "bLengthChange": false,
          "iDisplayLength": 50,
          "order": [[ 4, "desc" ]]
        });
    } );
      </script>
    <% end %>
  <% else %>
    <div>
      You don't have any Handoff's yet! To get started, visit <%= link_to "Patient Records", :patients %>.
    </div>
  <% end %>
</div>