scinote-web/app/views/shared/navigation/_breadcrumbs.html.erb
2023-03-30 21:22:33 +02:00

52 lines
2.1 KiB
Text

<% if @breadcrumbs_items&.length %>
<% @breadcrumbs_items.each { |item| item[:label] = "(A) #{item[:label]}" if item[:archived] }%>
<% shortened = @breadcrumbs_items.length > 4 %>
<% if shortened %>
<% first_breadcrumb_item = @breadcrumbs_items.shift
last_breadcrumb_items = @breadcrumbs_items.pop(2) %>
<%= link_to(first_breadcrumb_item[:label], first_breadcrumb_item[:url],
class: "breadcrumbs-link #{first_breadcrumb_item[:class]}",
title: first_breadcrumb_item[:label],
data: first_breadcrumb_item[:data]) %>
<span class="delimiter">&gt;</span>
<span class="breadcrumbs-collapsed-container">
<span class="show-breadcrumbs" data-toggle="dropdown" title="<%= t('projects.index.breadcrumbs_collapsed') %>">
•••
<span class="caret pull-right"></span>
</span>
<ul class="dropdown-menu breadcrumbs-dropdown" role="menu">
<% @breadcrumbs_items.each do |item| %>
<li>
<%= link_to(item[:label] + ' >', item[:url],
data: item[:data]) %>
</li>
<% end %>
</ul>
</span>
<span class="delimiter">&gt;</span>
<% item = last_breadcrumb_items.first %>
<%= link_to(item[:label], item[:url],
class: "breadcrumbs-link #{item[:class]}",
title: item[:label],
data: item[:data]) %>
<span class="delimiter">&gt;</span>
<% last_item = last_breadcrumb_items.last %>
<span class="breadcrumbs-link <%= last_item[:class] %>" title="<%= last_item[:label] %>">
<%= last_item[:label] %>
</span>
<% else %>
<% last_item = @breadcrumbs_items.pop %>
<% @breadcrumbs_items.each do |item| %>
<%= link_to(item[:label], item[:url],
class: "breadcrumbs-link #{item[:class]}",
title: item[:label],
data: item[:data]) %>
<span class="delimiter">&gt;</span>
<% end %>
<span class="breadcrumbs-link <%= last_item[:class] %>" title="<%= last_item[:label] %>">
<%= last_item[:label] %>
</span>
<% end %>
<% end %>