From d15dc3f1d2c9421c44d2c82c08b44d84459fcaaf Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 15 Aug 2026 00:34:14 +0200 Subject: Restore from and redesign the trash list --- app/views/nodes/trashed.html.erb | 74 ++++++++++++++++++++++++++++------------ config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ public/stylesheets/admin.css | 1 + 4 files changed, 57 insertions(+), 22 deletions(-) diff --git a/app/views/nodes/trashed.html.erb b/app/views/nodes/trashed.html.erb index a3c2cf41..39fc965f 100644 --- a/app/views/nodes/trashed.html.erb +++ b/app/views/nodes/trashed.html.erb @@ -4,37 +4,67 @@

<%= t(".empty") %>

<% else %> <%= will_paginate @nodes %> - - - - - - - +
<%= t("admin.columns.title") %><%= t(".was_at") %><%= t(".trashed") %><%= t("admin.columns.actions") %>
+ <% @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? %> - <% doomed_below = node.descendants.count %> - - - - <% end %> +
- <%= link_to (node.draft&.title || node.slug), node_path(node) %><%= " " + t(".beneath", :count => doomed_below) if doomed_below > 0 %> - <%= entry&.metadata&.dig("path", "from") %> + +
+ <%= link_to title, node_path(node) %><%= " " + t(".beneath", :count => doomed_below) if doomed_below > 0 %> +
+
+ <%= t(".was_at") %> <%= entry&.metadata&.dig("path", "from") %> +
<% if entry %> - <%= t(".trashed_by", :time => entry.occurred_at.strftime("%Y-%m-%d %H:%M"), :actor => entry.actor_name) %> +
+ <%= t(".trashed_by", :time => admin_datetime(entry.occurred_at), + :actor => entry.actor_name) %> +
<% end %>
- <%= button_to node_path(node), method: :delete, - form: { data: { confirm: t(".confirm_delete", :title => (node.draft&.title || node.slug), :count => doomed_below) }, - class: 'button_to destructive' } do %> - <%= icon("trash-x", library: "tabler", "aria-hidden": true) %> - <%= t(".delete_permanently") %> - <% end %> + +
+ + <%= 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 %> + + + <% if target_missing %> + " + aria-label="<%= t(".restore_target_missing") %>"> + <%= icon("arrow-back-up", library: "tabler", "aria-hidden": true) %> + + <% 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 %> + + + <%= 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 %> + +
<%= will_paginate @nodes %> -

<%= t(".restore_hint") %>

+ <% if @nodes.any? { |n| (n.draft || n.head)&.parent_node_missing? } %> +

<%= t(".restore_hint") %>

+ <% end %> <% end %> diff --git a/config/locales/de.yml b/config/locales/de.yml index 4e19bcc1..c6082bcd 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -562,6 +562,8 @@ de: empty: "Der Papierkorb ist leer." was_at: "War unter" trashed: "Gelöscht" + restore_here: "Hierhin wiederherstellen" + restore_target_missing: "Kann nicht von hier aus wiederhergestellt werden, das der alte Eltern-Node nicht mehr existiert." beneath: one: "(+ 1 darunter)" other: "(+ %{count} darunter)" diff --git a/config/locales/en.yml b/config/locales/en.yml index 83373bcd..5aafb612 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -514,6 +514,8 @@ en: empty: "The Trash is empty." was_at: "Was at" trashed: "Trashed" + restore_here: "Restore here" + restore_target_missing: "Can not restore from here. Old parent is gone." beneath: one: "(+ 1 beneath)" other: "(+ %{count} beneath)" diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 6471090e..4afe0cfa 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -888,6 +888,7 @@ form.button_to svg { .events_table .action_grid { grid-template-columns: repeat(2, auto); } .assets_table .action_grid { grid-template-columns: repeat(3, auto); } .revisions_table .action_grid { grid-template-columns: repeat(2, auto); } +.trashed_node_list .action_grid { grid-template-columns: repeat(3, auto); } /* min-height keeps a row the same height whether or not the viewer may see the lower controls. */ -- cgit v1.3