summaryrefslogtreecommitdiff
path: root/app/views/nodes
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-10 02:03:19 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-10 02:03:19 +0200
commit205e6216fc7850fe717122c189e5003d1f9e8afe (patch)
tree8627354f3577f0a974949e759b0e93662840ade7 /app/views/nodes
parent81769557804ce59ce3e4603e8f47e731b61b180d (diff)
Add head/draft/autosave layer comparison at three UI entry points
Node#resolve_page_reference and #available_layer_pairs let Page#diff_against compare named layers (head/draft/autosave), not just numbered revisions -- autosave was never part of Node#pages, so this was the missing piece. Wired into nodes#show's Status section, nodes#edit right after an autosave gets resurrected ("What changed?"), and the admin wizard's current-drafts table, which now also lists autosave-only nodes it previously never showed. revisions#diff hides the numbered-revision picker when comparing named layers (it can't represent them), shows a plain label instead, and offers buttons to switch between whichever other pairs make sense for the node's current state. Destroying the topmost layer is available directly from the diff view, reusing the existing revert! path. "Discard changes" is renamed "Discard Autosave" everywhere it appears, to match "Destroy Draft".
Diffstat (limited to 'app/views/nodes')
-rw-r--r--app/views/nodes/edit.html.erb9
-rw-r--r--app/views/nodes/show.html.erb12
2 files changed, 19 insertions, 2 deletions
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb
index cdc9b36..1c19410 100644
--- a/app/views/nodes/edit.html.erb
+++ b/app/views/nodes/edit.html.erb
@@ -6,9 +6,16 @@
6 disabled: @node.autosave.present? %> 6 disabled: @node.autosave.present? %>
7 7
8 <% if @node.autosave || (@node.draft && @node.head) %> 8 <% if @node.autosave || (@node.draft && @node.head) %>
9 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard changes'), 9 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'),
10 revert_node_path(@node), method: :put, 10 revert_node_path(@node), method: :put,
11 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %> 11 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %>
12 <% if pair = @node.available_layer_pairs.find { |p| p.include?(:autosave) } %>
13 <%= button_to 'What changed?',
14 diff_node_revisions_path(@node),
15 method: :get,
16 params: { start_revision: pair.first, end_revision: pair.last },
17 form: { class: 'button_to computation' } %>
18 <% end %>
12 <% end %> 19 <% end %>
13 20
14 <%= submit_tag "Save Draft", form: dom_id(@node, :edit) %> 21 <%= submit_tag "Save Draft", form: dom_id(@node, :edit) %>
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb
index 036caf2..2469310 100644
--- a/app/views/nodes/show.html.erb
+++ b/app/views/nodes/show.html.erb
@@ -32,6 +32,16 @@
32 <% end %> 32 <% end %>
33 </div> 33 </div>
34 34
35 <% @node.available_layer_pairs.each do |pair| %>
36 <div class="node_info_item">
37 <%= button_to "Diff #{pair.first.to_s.capitalize} vs. #{pair.last.to_s.capitalize}",
38 diff_node_revisions_path(@node),
39 method: :get,
40 params: { start_revision: pair.first, end_revision: pair.last },
41 form: { class: 'button_to computation' } %>
42 </div>
43 <% end %>
44
35 <% unless locked_by_other %> 45 <% unless locked_by_other %>
36 <% if @node.draft && !@node.autosave %> 46 <% if @node.draft && !@node.autosave %>
37 <div class="node_info_item"> 47 <div class="node_info_item">
@@ -41,7 +51,7 @@
41 <% end %> 51 <% end %>
42 <% if @node.draft || @node.autosave %> 52 <% if @node.draft || @node.autosave %>
43 <div class="node_info_item"> 53 <div class="node_info_item">
44 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard changes'), 54 <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'),
45 revert_node_path(@node), method: :put, 55 revert_node_path(@node), method: :put,
46 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %> 56 form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %>
47 </div> 57 </div>