LafayetteCollegeLibraries/spot

View on GitHub
app/views/hyrax/base/_relationships.html.erb

Summary

Maintainability
Test Coverage
<%#
  displays all of the collections a work is a part of. i'm a little confused as to why
  only collections are appearing in +#grouped_presenters+ when an work is a member of
  another work, and if so why is it necessary to group the other presenters? from
  what i can tell, this method goes back to the sufia days, so maybe it's something
  that's changed in the time since.

  BUT in the event that something else will appear here, we're set up to accept really
  any kind of presenter -- as long as that thing has a title.
%>
<% presenter.grouped_presenters.each_pair do |key, presenters| %>
  <% if presenters.present? %>
    <% thing = key.titleize %>
    <h2>Member of <%= thing.pluralize(presenters.size) %></h2>

    <%#
      putting 4 items in a row -- using 3 seemed a little too large.
      if this changes, you'll need to update the +#each_slice+ parameter
      as well as the size of the column (ex +<div class="col-md-3">+)
    %>
    <% presenters.each_slice(4) do |batch| %>
      <div class="row">
      <% batch.each do |item| %>
        <% item_type = item.model_name.human.underscore.to_sym %>
        <% url = polymorphic_url([item_type], id: item.id) %>
        <% text = (item.try(:abstract) || item.try(:description) || []).first %>
        <div class="col-md-3">
          <div class="thumbnail">
            <%= image_tag(item.thumbnail_path, alt: '') %>
            <div class="caption">
              <h3><%= item.title.first %></h3>
              <% if text.present? %>
              <p><%= text %></p>
              <% end %>
              <p>
                <a href="<%= url %>" class="btn btn-info btn-block">
                  View <%= thing %>
                </a>
              </p>
            </div>
          </div>
        </div> <%# /col-md-3 %>
      <% end %>
      </div>
    <% end %>
  <% end %>
<% end %>