summaryrefslogtreecommitdiff
path: root/app/views/nodes/trashed.html.erb
blob: 39fc965f4c1e917ed2ca3378f5eeb3963921ef28 (plain)
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
<h1><%= t(".title") %></h1>

<% if @nodes.empty? %>
  <p class="field_hint"><%= t(".empty") %></p>
<% else %>
  <%= will_paginate @nodes %>
  <table class="admin_table trashed_node_list">
    <tbody>
    <% @nodes.each do |node| %>
      <% entry = node.last_trash_entry %>
      <% doomed_below = node.descendants.count %>
      <% title = node.draft&.title || node.slug %>
      <% target_missing = (node.draft || node.head)&.parent_node_missing? %>
      <tr>
        <td class="title">
          <div class="row_primary">
            <%= link_to title, node_path(node) %><%= " " + t(".beneath", :count => doomed_below) if doomed_below > 0 %>
          </div>
          <div class="row_secondary">
            <%= t(".was_at") %> <%= entry&.metadata&.dig("path", "from") %>
          </div>
          <% if entry %>
            <div class="row_secondary">
              <%= t(".trashed_by", :time => admin_datetime(entry.occurred_at),
                                   :actor => entry.actor_name) %>
            </div>
          <% end %>
        </td>
        <td class="actions">
          <div class="action_grid">
            <span class="action_item">
              <%= link_to node_path(node), "aria-label" => t("admin.common.show"),
                    title: t("admin.common.show") do %>
                <%= icon("eye", library: "tabler", "aria-hidden": true) %>
              <% end %>
            </span>
            <span class="action_item">
              <% if target_missing %>
                <span class="disabled_action" title="<%= t(".restore_target_missing") %>"
                      aria-label="<%= t(".restore_target_missing") %>">
                  <%= icon("arrow-back-up", library: "tabler", "aria-hidden": true) %>
                </span>
              <% else %>
                <%= button_to restore_from_trash_node_path(node), method: :put,
                      form: { class: 'button_to state_changing' },
                      "aria-label" => t(".restore_here"), title: t(".restore_here") do %>
                  <%= icon("arrow-back-up", library: "tabler", "aria-hidden": true) %>
                <% end %>
              <% end %>
            </span>
            <span class="action_item">
              <%= button_to node_path(node), method: :delete,
                    form: { data: { confirm: t(".confirm_delete", :title => title, :count => doomed_below) },
                            class: 'button_to destructive' },
                    "aria-label" => t(".delete_permanently"),
                    title: t(".delete_permanently") do %>
                <%= icon("trash-x", library: "tabler", "aria-hidden": true) %>
              <% end %>
            </span>
          </div>
        </td>
      </tr>
    <% end %>
    </tbody>
  </table>
  <%= will_paginate @nodes %>
  <% if @nodes.any? { |n| (n.draft || n.head)&.parent_node_missing? } %>
    <p class="field_hint"><%= t(".restore_hint") %></p>
  <% end %>
<% end %>