summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-18 02:15:29 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-18 02:15:29 +0200
commitd41ee504caedbe858e24ab2a23c7a804454c64c8 (patch)
treeeb3ec7c8f44d15fea40292d0a9e7358e41640edc /app/controllers
parent5dced8b4b624aabf4215ba21b13957080345c326 (diff)
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.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/nodes_controller.rb10
1 files changed, 8 insertions, 2 deletions
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
144 def trash 144 def trash
145 if @node.trash!(current_user) 145 if @node.trash!(current_user)
146 flash[:notice] = "Page has been moved to the Trash" 146 flash[:notice] = "Page has been moved to the Trash"
147 redirect_to node_path(Node.trash) 147 redirect_to trashed_nodes_path
148 else 148 else
149 flash[:notice] = "Page is already in the Trash" 149 flash[:notice] = "Page is already in the Trash"
150 redirect_to node_path(@node) 150 redirect_to node_path(@node)
@@ -170,7 +170,8 @@ class NodesController < ApplicationController
170 def destroy 170 def destroy
171 @node.destroy_from_trash!(current_user) 171 @node.destroy_from_trash!(current_user)
172 flash[:notice] = "Page has been permanently deleted" 172 flash[:notice] = "Page has been permanently deleted"
173 redirect_to node_path(Node.trash) 173 redirect_to trashed_nodes_path
174
174 rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e 175 rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e
175 flash[:error] = e.message 176 flash[:error] = e.message
176 redirect_to node_path(@node) 177 redirect_to node_path(@node)
@@ -247,6 +248,11 @@ class NodesController < ApplicationController
247 @sitemap_descendant_counts = descendant_counts_for(@sitemap) 248 @sitemap_descendant_counts = descendant_counts_for(@sitemap)
248 end 249 end
249 250
251 def trashed
252 @nodes = Node.trash.children.order(:slug)
253 .paginate(:page => params[:page], :per_page => 50)
254 end
255
250 private 256 private
251 257
252 def slug_for(title) 258 def slug_for(title)