From d41ee504caedbe858e24ab2a23c7a804454c64c8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 18 Jul 2026 02:15:29 +0200 Subject: Add Trash affordances: cockpit, listing, dashboard entry nodes#show gains a Trash section on trashed nodes: provenance from the trash entry, a restore form whose parent picker pre-fills the old parent while it still lives, and permanent deletion. A Move-to-Trash button joins the status actions on living nodes. nodes#trashed lists trashed subtree roots with weight, provenance, and deletion; the dashboard housekeeping row links to it, and trash/destroy redirect there. Deletion from Trash now removes the whole subtree, deepest first, each node through a real destroy! so every per-node cascade runs -- amending the never-recursive rule for this one sanctioned path (both confirms state the count; the root entry carries destroyed_descendants). Bare Node#destroy still refuses children. --- app/controllers/nodes_controller.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/controllers/nodes_controller.rb') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 9ea66ad..021f8ff 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -144,7 +144,7 @@ class NodesController < ApplicationController def trash if @node.trash!(current_user) flash[:notice] = "Page has been moved to the Trash" - redirect_to node_path(Node.trash) + redirect_to trashed_nodes_path else flash[:notice] = "Page is already in the Trash" redirect_to node_path(@node) @@ -170,7 +170,8 @@ class NodesController < ApplicationController def destroy @node.destroy_from_trash!(current_user) flash[:notice] = "Page has been permanently deleted" - redirect_to node_path(Node.trash) + redirect_to trashed_nodes_path + rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e flash[:error] = e.message redirect_to node_path(@node) @@ -247,6 +248,11 @@ class NodesController < ApplicationController @sitemap_descendant_counts = descendant_counts_for(@sitemap) end + def trashed + @nodes = Node.trash.children.order(:slug) + .paginate(:page => params[:page], :per_page => 50) + end + private def slug_for(title) -- cgit v1.3