1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<%= 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)]] %>
<div id="sitemap">
<%
open_details = [] # levels with a currently-open <details>
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? %></div><% else %></details><% end %>
<% end %>
<% unless level.zero? %>
<div class="sitemap_node">
<div class="title_with_flags">
<span class="flag_stack">
<%= flag("file-text-shield", t(".flag_restricted"), :tier => :attention) if node.restricted? %>
</span>
<div class="title_body">
<div class="node_title"><%= link_to title_for_node(node), node_path(node) %></div>
<div class="node_path">
<%= world_icon %>
<%= link_to_path(node.unique_name, node.unique_name) %>
</div>
</div>
<div class="action_grid">
<span class="action_item">
<%= link_to new_node_path(:parent_id => node.id),
"aria-label" => t(".create_child"), title: t(".create_child") do %>
<%= create_icon %>
<% end %>
</span>
<span class="action_item">
<%= link_to node_path(node), "aria-label" => t("admin.common.show"),
title: t("admin.common.show") do %>
<%= show_icon %>
<% end %>
</span>
</div>
</div>
</div>
<% 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. %>
<div class="sitemap_children">
<% else %>
<details>
<summary>
<%= t(".descendants", :count => @sitemap_descendant_counts[node.id]) %>
</summary>
<% end %>
<% open_details.push(level) %>
<% end %>
<% end %>
<% while open_details.any? %>
<% closing = open_details.pop %>
<% if closing.zero? %></div><% else %></details><% end %>
<% end %>
</div>
|