diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-09 02:25:56 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-09 02:25:56 +0200 |
| commit | 332ffbeed90cf07342925b82ed3fda1762346be2 (patch) | |
| tree | f507b6af5f467fd0aeb89286561e6af3b78f8ce1 /app/views | |
| parent | 168ff3f8b6037bc3c2b5bce74adac37e48366dac (diff) | |
Restyle revisions#index: sticky diff bar, computation button style, pre-selected defaults
Adds a fourth button category, .computation -- teal, matching Preview's
existing color -- for actions that compute a view without changing state,
the first case in the app that didn't fit reversible/state-changing/
destructive. Diff revisions now starts disabled and only enables once two
distinct revisions are selected, matching the disabled-state pattern
already used for Unlock + Back.
The header row is wrapped in a real <thead> (previously flat inside the
table alongside data rows) so a sticky diff bar can sit above the fold on
long revision lists -- selecting a comparison pair no longer requires
scrolling back up to find the button, or back down to confirm what's
selected, both surfaced live via one shared JS function.
The two most recent revisions are pre-selected by default, covering the
most common comparison (current against previous) with no extra clicks.
Deliberately scoped to numbered revisions only -- comparing draft/head or
autosave/draft was raised and set aside, since neither exists as a row in
this table by design and extending the comparison to them is a separate
feature, not a default on this one.
Also drops the dead "Edit" subnav link, redundant with nodes#show's
Status section covering the same action with state-aware labeling this
static link could never have.
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/revisions/index.html.erb | 100 |
1 files changed, 62 insertions, 38 deletions
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb index 26a9ff4..a6a981a 100644 --- a/app/views/revisions/index.html.erb +++ b/app/views/revisions/index.html.erb | |||
| @@ -1,46 +1,70 @@ | |||
| 1 | <% content_for :subnavigation do %> | ||
| 2 | <%= link_to 'Edit', edit_node_path(@node) %> | ||
| 3 | <% end %> | ||
| 4 | |||
| 5 | <h2>Revisions for Node: <%= @node.unique_name %></h2> | 1 | <h2>Revisions for Node: <%= @node.unique_name %></h2> |
| 6 | 2 | ||
| 7 | <table id="revisions"> | 3 | <table id="revisions" class="revisions_table"> |
| 8 | <tr class="header"> | 4 | <thead> |
| 9 | <th>First</th> | 5 | <tr class="header"> |
| 10 | <th>Last</th> | 6 | <th>First</th> |
| 11 | <th>Rev.</th> | 7 | <th>Last</th> |
| 12 | <th>Title</th> | 8 | <th>Rev.</th> |
| 13 | <th>Editor</th> | 9 | <th>Title</th> |
| 14 | <th>Date</th> | 10 | <th>Editor</th> |
| 15 | <th></th> | 11 | <th>Date</th> |
| 16 | <th></th> | 12 | <th></th> |
| 17 | </tr> | 13 | <th></th> |
| 18 | <% (@pages || @node.pages.all).reverse.each do |page| %> | 14 | </tr> |
| 19 | <tr> | 15 | <tr class="no_hover diff_sticky_bar"> |
| 20 | <td><%= radio_button_tag :start_revision, page.revision %></td> | 16 | <td colspan="8"> |
| 21 | <td><%= radio_button_tag :end_revision, page.revision %></td> | 17 | <%= button_to 'Diff revisions', diff_node_revisions_path(@node), |
| 22 | <td class="revision"><%= page.revision %></td> | 18 | method: :post, |
| 23 | <td class="title"><%= page.title %></td> | 19 | form: { id: 'diff_form', class: 'button_to computation' }, |
| 24 | <td class="user"><%= page.editor.try(:login) %></td> | 20 | disabled: true %> |
| 25 | <td class="date"><%= page.updated_at %></td> | 21 | <span id="diff_selection_label"></span> |
| 26 | <td><%= link_to 'show', node_revision_path(@node, page) %></td> | 22 | </td> |
| 27 | <td> | 23 | </tr> |
| 28 | <%= button_to 'restore', restore_node_revision_path(@node, page), | 24 | </thead> |
| 29 | method: :put, | 25 | <tbody> |
| 30 | form: { data: { confirm: "Restore this revision?" }, class: 'button_to state_changing' } %> | 26 | <% pages = (@pages || @node.pages.all).reverse %> |
| 31 | </td> | 27 | <% pages.each_with_index do |page, index| %> |
| 32 | </tr> | 28 | <tr> |
| 33 | <% end %> | 29 | <td><%= radio_button_tag :start_revision, page.revision, index == 1 %></td> |
| 34 | <tr class="no_hover"> | 30 | <td><%= radio_button_tag :end_revision, page.revision, index == 0 %></td> |
| 35 | <td colspan="8" class="right"> | 31 | <td class="revision"><%= page.revision %></td> |
| 36 | <%= button_to 'Diff revisions', diff_node_revisions_path(@node), | 32 | <td class="title"><%= page.title %></td> |
| 37 | method: :post, | 33 | <td class="user"><%= page.editor.try(:login) %></td> |
| 38 | form: { id: 'diff_form' } %> | 34 | <td class="date"><%= page.updated_at %></td> |
| 39 | </td> | 35 | <td><%= link_to 'show', node_revision_path(@node, page) %></td> |
| 40 | </tr> | 36 | <td> |
| 37 | <%= button_to 'restore', restore_node_revision_path(@node, page), | ||
| 38 | method: :put, | ||
| 39 | form: { data: { confirm: "Restore this revision?" }, class: 'button_to state_changing' } %> | ||
| 40 | </td> | ||
| 41 | </tr> | ||
| 42 | <% end %> | ||
| 43 | </tbody> | ||
| 41 | </table> | 44 | </table> |
| 42 | 45 | ||
| 43 | <script> | 46 | <script> |
| 47 | function update_diff_button_state() { | ||
| 48 | var start = document.querySelector('input[name="start_revision"]:checked'); | ||
| 49 | var end = document.querySelector('input[name="end_revision"]:checked'); | ||
| 50 | var valid = start && end && start.value !== end.value; | ||
| 51 | document.querySelector('#diff_form button[type="submit"]').disabled = !valid; | ||
| 52 | |||
| 53 | var label = document.getElementById('diff_selection_label'); | ||
| 54 | if (start && end) { | ||
| 55 | label.textContent = start.value + ' against ' + end.value; | ||
| 56 | } else if (start || end) { | ||
| 57 | label.textContent = (start || end).value + ' selected'; | ||
| 58 | } else { | ||
| 59 | label.textContent = ''; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | document.querySelectorAll('input[name="start_revision"], input[name="end_revision"]') | ||
| 64 | .forEach(function(radio) { radio.addEventListener('change', update_diff_button_state); }); | ||
| 65 | |||
| 66 | update_diff_button_state(); | ||
| 67 | |||
| 44 | document.getElementById('diff_form').addEventListener('submit', function(e) { | 68 | document.getElementById('diff_form').addEventListener('submit', function(e) { |
| 45 | var start = document.querySelector('input[name="start_revision"]:checked'); | 69 | var start = document.querySelector('input[name="start_revision"]:checked'); |
| 46 | var end = document.querySelector('input[name="end_revision"]:checked'); | 70 | var end = document.querySelector('input[name="end_revision"]:checked'); |
