psu-libraries/psulib_blacklight

View on GitHub
app/components/browse/nearby_button.html.erb

Summary

Maintainability
Test Coverage
<% if call_numbers.length == 1 %>
  <a class="btn btn-outline-primary mb-2" href="<%= call_number_browse_path(nearby: call_numbers.first,
                                                                            classification: classification) %>">
    <i class="fas fa-book" aria-hidden="true"></i>
    Browse Nearby on Shelf
  </a>
<% else %>
  <span class="dropdown">
    <button
      class="btn btn-outline-primary dropdown-toggle mb-2"
      type="button"
      id="browse-nearby-btn"
      data-toggle="dropdown"
      aria-haspopup="true"
      aria-expanded="false">
      <i class="fas fa-book" aria-hidden="true"></i>
      Browse Nearby on Shelf
    </button>
    <div class="dropdown-menu" aria-labelledby="browse-nearby-btn">
      <% call_numbers.each do |call_number| %>
        <a href="<%= call_number_browse_path(nearby: call_number, classification: classification) %>" class="dropdown-item">
          <%= call_number %>
        </a>
      <% end %>
    </div>
  </span>
<% end %>