<%= render "shared/page_actions", :title => t(".title"), :icon_name => "file-plus", :label => t(".create_at_root"), :options => [[t(".create_at_root"), new_node_path(:parent_id => Node.root.id)]] %>
<% open_details = [] # levels with a currently-open
world_icon = icon("world", library: "tabler", "aria-hidden": true) create_icon = icon("file-plus", library: "tabler", "aria-hidden": true) show_icon = icon("eye", library: "tabler", "aria-hidden": true) %> <% @sitemap.each_with_index do |(node, level), index| %> <% while open_details.any? && open_details.last >= level %> <% closing = open_details.pop %> <% if closing.zero? %>
<% else %><% end %> <% end %> <% unless level.zero? %>
<%= flag("file-text-shield", t(".flag_restricted"), :tier => :attention) if node.restricted? %>
<%= link_to title_for_node(node), node_path(node) %>
<%= world_icon %> <%= link_to_path(node.unique_name, node.unique_name) %>
<%= link_to new_node_path(:parent_id => node.id), "aria-label" => t(".create_child"), title: t(".create_child") do %> <%= create_icon %> <% end %> <%= link_to node_path(node), "aria-label" => t("admin.common.show"), title: t("admin.common.show") do %> <%= show_icon %> <% end %>
<% end %> <% next_level = @sitemap[index + 1]&.last %> <% if next_level && next_level > level %> <% if level.zero? %> <%# Root's children are the top level: a tree does not hide its own first rank behind a toggle. A plain div keeps the closing-tag bookkeeping symmetric with the details branches. %>
<% else %>
<%= t(".descendants", :count => @sitemap_descendant_counts[node.id]) %> <% end %> <% open_details.push(level) %> <% end %> <% end %> <% while open_details.any? %> <% closing = open_details.pop %> <% if closing.zero? %>
<% else %><% end %> <% end %>