summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-10 02:13:02 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-10 02:13:02 +0200
commitc2b2648d327e1c1749c37fe2e58cd051ed871547 (patch)
treee8d3c48eb01b8d6b512d20603a1db8f910ec110c /app
parent205e6216fc7850fe717122c189e5003d1f9e8afe (diff)
Destroying Draft or Discarding Autosave drops you where you left
Diffstat (limited to 'app')
-rw-r--r--app/controllers/nodes_controller.rb5
-rw-r--r--app/views/nodes/show.html.erb1
-rw-r--r--app/views/revisions/diff.html.erb1
3 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
index d1538e1..6fcd930 100644
--- a/app/controllers/nodes_controller.rb
+++ b/app/controllers/nodes_controller.rb
@@ -128,7 +128,10 @@ class NodesController < ApplicationController
128 def revert 128 def revert
129 @node.lock_for_editing!(current_user) 129 @node.lock_for_editing!(current_user)
130 @node.revert!(current_user) 130 @node.revert!(current_user)
131 if @node.draft 131
132 if params[:return_to].present?
133 redirect_to safe_return_to(params[:return_to])
134 elsif @node.draft
132 redirect_to edit_node_path(@node) 135 redirect_to edit_node_path(@node)
133 else 136 else
134 redirect_to node_path(@node) 137 redirect_to node_path(@node)
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb
index 2469310..8b9e98b 100644
--- a/app/views/nodes/show.html.erb
+++ b/app/views/nodes/show.html.erb
@@ -53,6 +53,7 @@
53 <div class="node_info_item"> 53 <div class="node_info_item">
54 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'), 54 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'),
55 revert_node_path(@node), method: :put, 55 revert_node_path(@node), method: :put,
56 params: { return_to: request.path },
56 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %> 57 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %>
57 </div> 58 </div>
58 <% end %> 59 <% end %>
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb
index 3157dca..490cf17 100644
--- a/app/views/revisions/diff.html.erb
+++ b/app/views/revisions/diff.html.erb
@@ -36,6 +36,7 @@
36 <% if !@locked_by_other && (@node.autosave || @node.draft) %> 36 <% if !@locked_by_other && (@node.autosave || @node.draft) %>
37 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'), 37 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'),
38 revert_node_path(@node), method: :put, 38 revert_node_path(@node), method: :put,
39 params: { return_to: request.fullpath },
39 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %> 40 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %>
40 <% end %> 41 <% end %>
41 </p> 42 </p>