app/views/content/display/sidebar/_references.html.erb
<%
creating = defined?(creating) && creating
editing = defined?(editing) && editing
%>
<%
raw_model = content.is_a?(ContentSerializer) ? content.raw_model : content
%>
<% related_documents = content.documents.select { |doc| (current_user || User.new).can_read?(doc) } %>
<%
show_in_this_universe_tab = !creating && !editing && raw_model.is_a?(Universe)
show_associations_tab = !creating && !editing
show_gallery_tab = creating || editing || raw_model.image_uploads.any? || @basil_images.any?
show_documents_tab = !creating && !editing && related_documents.any?
show_shares_tab = !creating && !editing && raw_model.content_page_shares.any?
show_collections_tab = !creating && !editing && raw_model.page_collection_submissions.accepted.any?
show_timelines_tab = !creating && !editing && raw_model.timelines.any? && user_signed_in? && current_user == raw_model.user
show_references_section = [
show_in_this_universe_tab,
show_associations_tab,
show_gallery_tab,
show_documents_tab,
show_shares_tab,
show_collections_tab,
show_timelines_tab
].any?
%>
<% if show_references_section %>
<ul class="collection content-tabs">
<li class="active center grey-text uppercase">
References
</li>
<% if show_in_this_universe_tab %>
<li class="collection-item tab">
<a href="#in_this_universe_panel">
<i class="material-icons left"><%= Universe.icon %></i>
In this universe
<span class="badge hide-on-med-and-down"><%= @sidelinks_in_this_universe_count %></span>
</a>
</li>
<% end %>
<% if show_associations_tab %>
<li class="collection-item tab">
<a href="#associations_panel">
<i class="material-icons left">link</i>
Associations
</a>
</li>
<% end %>
<% if show_gallery_tab %>
<li class="collection-item tab">
<a href="#gallery_panel">
<i class="material-icons left">photo_library</i>
Gallery
<span class="badge hide-on-med-and-down">
<%= raw_model.image_uploads.count + @basil_images.count %>
</span>
</a>
</li>
<% end %>
<% if show_timelines_tab %>
<li class="collection-item tab">
<a href="#timelines_panel">
<i class="material-icons left"><%= Timeline.icon %></i>
Timelines
<span class="badge hide-on-med-and-down"><%= raw_model.timelines.count %></span>
</a>
</li>
<% end %>
<% if show_documents_tab %>
<li class="collection-item tab">
<a href="#documents_panel">
<i class="material-icons left"><%= Document.icon %></i>
Documents
<span class="badge hide-on-med-and-down"><%= related_documents.count %></span>
</a>
</li>
<% end %>
<% if show_shares_tab %>
<li class="collection-item tab">
<a href="#shares_panel">
<i class="material-icons left"><%= ContentPageShare.icon %></i>
Shares
<span class="badge hide-on-med-and-down"><%= raw_model.content_page_shares.count %></span>
</a>
</li>
<% end %>
<% if show_collections_tab %>
<li class="collection-item tab">
<a href="#collections_panel">
<i class="material-icons left"><%= PageCollection.icon %></i>
Collections
<span class="badge hide-on-med-and-down"><%= raw_model.page_collection_submissions.accepted.count %></span>
</a>
</li>
<% end %>
</ul>
<% end %>