diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 02:03:19 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 02:03:19 +0200 |
| commit | 205e6216fc7850fe717122c189e5003d1f9e8afe (patch) | |
| tree | 8627354f3577f0a974949e759b0e93662840ade7 /app/views | |
| parent | 81769557804ce59ce3e4603e8f47e731b61b180d (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')
| -rw-r--r-- | app/views/admin/index.html.erb | 13 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 9 | ||||
| -rw-r--r-- | app/views/nodes/show.html.erb | 12 | ||||
| -rw-r--r-- | app/views/revisions/diff.html.erb | 40 |
4 files changed, 64 insertions, 10 deletions
diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index 77b45f4..c67ccb3 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb | |||
| @@ -82,9 +82,9 @@ | |||
| 82 | </div> | 82 | </div> |
| 83 | 83 | ||
| 84 | <div id="current_drafts_table"> | 84 | <div id="current_drafts_table"> |
| 85 | 85 | ||
| 86 | <h2>Current Drafts (<%= @drafts_count %>)</h2> | 86 | <h2>Current Drafts & Autosaves (<%= @drafts_count %>)</h2> |
| 87 | 87 | ||
| 88 | <table class="node_table"> | 88 | <table class="node_table"> |
| 89 | <tr class="header"> | 89 | <tr class="header"> |
| 90 | <th class="node_id">ID</th> | 90 | <th class="node_id">ID</th> |
| @@ -92,6 +92,7 @@ | |||
| 92 | <th class="actions">Actions</th> | 92 | <th class="actions">Actions</th> |
| 93 | <th class="editor">Locked by</th> | 93 | <th class="editor">Locked by</th> |
| 94 | <th class="revision">Rev.</th> | 94 | <th class="revision">Rev.</th> |
| 95 | <th class="autosave">Autosave</th> | ||
| 95 | </tr> | 96 | </tr> |
| 96 | <% @drafts.each do |node| %> | 97 | <% @drafts.each do |node| %> |
| 97 | <tr class="<%= cycle("even", "odd") %>"> | 98 | <tr class="<%= cycle("even", "odd") %>"> |
| @@ -103,6 +104,9 @@ | |||
| 103 | <td class="actions"> | 104 | <td class="actions"> |
| 104 | <%= link_to 'show', node_path(node) %> | 105 | <%= link_to 'show', node_path(node) %> |
| 105 | <%= link_to 'Revisions', node_revisions_path(node) %> | 106 | <%= link_to 'Revisions', node_revisions_path(node) %> |
| 107 | <% if pair = node.available_layer_pairs.last %> | ||
| 108 | <%= link_to 'diff', diff_node_revisions_path(node, start_revision: pair.first, end_revision: pair.last) %> | ||
| 109 | <% end %> | ||
| 106 | </td> | 110 | </td> |
| 107 | <td> | 111 | <td> |
| 108 | <%= node.lock_owner.login if node.lock_owner %> | 112 | <%= node.lock_owner.login if node.lock_owner %> |
| @@ -110,6 +114,9 @@ | |||
| 110 | <td> | 114 | <td> |
| 111 | <%= link_to ( node.draft ? node.draft.revision : (node.head ? node.head.revision : "EMPTY" ) ), node_revisions_path(node) %> | 115 | <%= link_to ( node.draft ? node.draft.revision : (node.head ? node.head.revision : "EMPTY" ) ), node_revisions_path(node) %> |
| 112 | </td> | 116 | </td> |
| 117 | <td class="autosave"> | ||
| 118 | <%= node.autosave ? "unsaved changes" : "" %> | ||
| 119 | </td> | ||
| 113 | </tr> | 120 | </tr> |
| 114 | <% end %> | 121 | <% end %> |
| 115 | </table> | 122 | </table> |
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> |
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb index d7bb528..3157dca 100644 --- a/app/views/revisions/diff.html.erb +++ b/app/views/revisions/diff.html.erb | |||
| @@ -4,11 +4,41 @@ | |||
| 4 | <%= link_to 'Revisions', node_revisions_path(@node) %> | 4 | <%= link_to 'Revisions', node_revisions_path(@node) %> |
| 5 | </p> | 5 | </p> |
| 6 | 6 | ||
| 7 | <%= form_tag diff_node_revisions_path do %> | 7 | <p class="diff_comparison_label"> |
| 8 | <%= select_tag :start_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:start_revision].to_i) %> | 8 | Comparing <strong><%= describe_page_reference(params[:start_revision]) %></strong> |
| 9 | <%= select_tag :end_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:end_revision].to_i) %> | 9 | against <strong><%= describe_page_reference(params[:end_revision]) %></strong> |
| 10 | <%= select_tag :view, options_for_select([['Inline', 'inline'], ['Side by side', 'side_by_side']], @diff_view) %> | 10 | </p> |
| 11 | <%= submit_tag 'Diff' %> | 11 | |
| 12 | <% numeric_comparison = params[:start_revision].to_s =~ /\A\d+\z/ && params[:end_revision].to_s =~ /\A\d+\z/ %> | ||
| 13 | |||
| 14 | <% if numeric_comparison %> | ||
| 15 | <%= form_tag diff_node_revisions_path do %> | ||
| 16 | <%= select_tag :start_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:start_revision].to_i) %> | ||
| 17 | <%= select_tag :end_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:end_revision].to_i) %> | ||
| 18 | <%= select_tag :view, options_for_select([['Inline', 'inline'], ['Side by side', 'side_by_side']], @diff_view) %> | ||
| 19 | <%= submit_tag 'Diff' %> | ||
| 20 | <% end %> | ||
| 21 | <% else %> | ||
| 22 | <p class="node_action_bar standalone_action_bar"><%= link_to 'Compare two numbered revisions instead', node_revisions_path(@node) %></p> | ||
| 23 | <% end %> | ||
| 24 | |||
| 25 | <% if @available_layer_pairs.present? %> | ||
| 26 | <p class="node_action_bar standalone_action_bar"> | ||
| 27 | <% @available_layer_pairs.each do |pair| %> | ||
| 28 | <% next if [params[:start_revision].to_s, params[:end_revision].to_s].sort == pair.map(&:to_s).sort %> | ||
| 29 | <%= button_to "Diff #{pair.first.to_s.capitalize} vs. #{pair.last.to_s.capitalize}", | ||
| 30 | diff_node_revisions_path(@node), | ||
| 31 | method: :get, | ||
| 32 | params: { start_revision: pair.first, end_revision: pair.last, view: @diff_view }, | ||
| 33 | form: { class: 'button_to computation' } %> | ||
| 34 | <% end %> | ||
| 35 | |||
| 36 | <% if !@locked_by_other && (@node.autosave || @node.draft) %> | ||
| 37 | <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'), | ||
| 38 | revert_node_path(@node), method: :put, | ||
| 39 | form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } %> | ||
| 40 | <% end %> | ||
| 41 | </p> | ||
| 12 | <% end %> | 42 | <% end %> |
| 13 | 43 | ||
| 14 | <div id="diffview"> | 44 | <div id="diffview"> |
