diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 23:33:11 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 23:33:11 +0200 |
| commit | 8eab68f2c5a3c126e2fec2ecdfa7ace87ce0937b (patch) | |
| tree | f446ebc26a7707c7b64a937aa51a155df146c80a /app/views/revisions/index.html.erb | |
| parent | 42714c697273a7117c6b355fab26c8c35e336ad1 (diff) | |
| parent | cdf5d9941ca866d437612d2f863eac6eb0b3db12 (diff) | |
Merge branch 'erdgeist-revive-events'
Diffstat (limited to 'app/views/revisions/index.html.erb')
| -rw-r--r-- | app/views/revisions/index.html.erb | 112 |
1 files changed, 74 insertions, 38 deletions
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb index b875a4fa..4680ae27 100644 --- a/app/views/revisions/index.html.erb +++ b/app/views/revisions/index.html.erb | |||
| @@ -1,49 +1,80 @@ | |||
| 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 | <p class="node_action_bar standalone_action_bar"> |
| 8 | <tr class="header"> | 4 | <%= link_to 'Back to node', node_path(@node) %> |
| 9 | <th>First</th> | 5 | </p> |
| 10 | <th>Last</th> | 6 | |
| 11 | <th>Rev.</th> | 7 | <table id="revisions" class="revisions_table"> |
| 12 | <th>Title</th> | 8 | <thead> |
| 13 | <th>Editor</th> | 9 | <tr class="header"> |
| 14 | <th>Date</th> | 10 | <th>First</th> |
| 15 | <th></th> | 11 | <th>Last</th> |
| 16 | <th></th> | 12 | <th>Rev.</th> |
| 17 | </tr> | 13 | <th>Title</th> |
| 18 | <% (@pages || @node.pages.all).reverse.each do |page| %> | 14 | <th>Editor</th> |
| 19 | <tr> | 15 | <th>Date</th> |
| 20 | <td><%= radio_button_tag :start_revision, page.revision %></td> | 16 | <th></th> |
| 21 | <td><%= radio_button_tag :end_revision, page.revision %></td> | 17 | <th></th> |
| 22 | <td class="revision"><%= page.revision %></td> | 18 | </tr> |
| 23 | <td class="title"><%= page.title %></td> | 19 | <tr class="no_hover diff_sticky_bar"> |
| 24 | <td class="user"><%= page.editor.try(:login) %></td> | 20 | <td colspan="8"> |
| 25 | <td class="date"><%= page.updated_at %></td> | 21 | <%= button_to 'Diff revisions', diff_node_revisions_path(@node), |
| 26 | <td><%= link_to 'show', node_revision_path(@node, page) %></td> | 22 | method: :post, |
| 27 | <td> | 23 | form: { id: 'diff_form', class: 'button_to computation' }, |
| 28 | <%= button_to 'restore', restore_node_revision_path(@node, page), | 24 | disabled: true %> |
| 29 | method: :put, | 25 | <span id="diff_selection_label"></span> |
| 30 | form: { data: { confirm: "Restore this revision?" } } %> | 26 | <label><%= radio_button_tag :view, 'inline', true %> Inline</label> |
| 31 | </td> | 27 | <label><%= radio_button_tag :view, 'side_by_side', false %> Side by side</label> |
| 32 | </tr> | 28 | </td> |
| 33 | <% end %> | 29 | </tr> |
| 34 | <tr class="no_hover"> | 30 | </thead> |
| 35 | <td colspan="8" class="right"> | 31 | <tbody> |
| 36 | <%= button_to 'Diff revisions', diff_node_revisions_path(@node), | 32 | <% pages = (@pages || @node.pages.all).reverse %> |
| 37 | method: :post, | 33 | <% pages.each_with_index do |page, index| %> |
| 38 | form: { id: 'diff_form' } %> | 34 | <tr> |
| 39 | </td> | 35 | <td><%= radio_button_tag :start_revision, page.revision, index == 1 %></td> |
| 40 | </tr> | 36 | <td><%= radio_button_tag :end_revision, page.revision, index == 0 %></td> |
| 37 | <td class="revision"><%= page.revision %></td> | ||
| 38 | <td class="title"><%= page.title %></td> | ||
| 39 | <td class="user"><%= page.editor.try(:login) %></td> | ||
| 40 | <td class="date"><%= page.updated_at %></td> | ||
| 41 | <td><%= link_to 'show', node_revision_path(@node, page) %></td> | ||
| 42 | <td> | ||
| 43 | <%= button_to 'restore', restore_node_revision_path(@node, page), | ||
| 44 | method: :put, | ||
| 45 | form: { data: { confirm: "Restore this revision?" }, class: 'button_to state_changing' } %> | ||
| 46 | </td> | ||
| 47 | </tr> | ||
| 48 | <% end %> | ||
| 49 | </tbody> | ||
| 41 | </table> | 50 | </table> |
| 42 | 51 | ||
| 43 | <script> | 52 | <script> |
| 53 | function update_diff_button_state() { | ||
| 54 | var start = document.querySelector('input[name="start_revision"]:checked'); | ||
| 55 | var end = document.querySelector('input[name="end_revision"]:checked'); | ||
| 56 | var valid = start && end && start.value !== end.value; | ||
| 57 | document.querySelector('#diff_form button[type="submit"]').disabled = !valid; | ||
| 58 | |||
| 59 | var label = document.getElementById('diff_selection_label'); | ||
| 60 | if (start && end) { | ||
| 61 | label.textContent = start.value + ' against ' + end.value; | ||
| 62 | } else if (start || end) { | ||
| 63 | label.textContent = (start || end).value + ' selected'; | ||
| 64 | } else { | ||
| 65 | label.textContent = ''; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | document.querySelectorAll('input[name="start_revision"], input[name="end_revision"]') | ||
| 70 | .forEach(function(radio) { radio.addEventListener('change', update_diff_button_state); }); | ||
| 71 | |||
| 72 | update_diff_button_state(); | ||
| 73 | |||
| 44 | document.getElementById('diff_form').addEventListener('submit', function(e) { | 74 | document.getElementById('diff_form').addEventListener('submit', function(e) { |
| 45 | var start = document.querySelector('input[name="start_revision"]:checked'); | 75 | var start = document.querySelector('input[name="start_revision"]:checked'); |
| 46 | var end = document.querySelector('input[name="end_revision"]:checked'); | 76 | var end = document.querySelector('input[name="end_revision"]:checked'); |
| 77 | var view = document.querySelector('input[name="view"]:checked'); | ||
| 47 | if (start) { | 78 | if (start) { |
| 48 | var s = document.createElement('input'); | 79 | var s = document.createElement('input'); |
| 49 | s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value; | 80 | s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value; |
| @@ -54,5 +85,10 @@ | |||
| 54 | en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value; | 85 | en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value; |
| 55 | this.appendChild(en); | 86 | this.appendChild(en); |
| 56 | } | 87 | } |
| 88 | if (view) { | ||
| 89 | var v = document.createElement('input'); | ||
| 90 | v.type = 'hidden'; v.name = 'view'; v.value = view.value; | ||
| 91 | this.appendChild(v); | ||
| 92 | } | ||
| 57 | }); | 93 | }); |
| 58 | </script> | 94 | </script> |
