summaryrefslogtreecommitdiff
path: root/app/views/revisions/index.html.erb
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/revisions/index.html.erb')
-rw-r--r--app/views/revisions/index.html.erb40
1 files changed, 27 insertions, 13 deletions
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb
index dc9ad51..b875a4f 100644
--- a/app/views/revisions/index.html.erb
+++ b/app/views/revisions/index.html.erb
@@ -4,7 +4,6 @@
4 4
5<h2>Revisions for Node: <%= @node.unique_name %></h2> 5<h2>Revisions for Node: <%= @node.unique_name %></h2>
6 6
7<% form_tag diff_node_revisions_path(@node) do %>
8<table id="revisions"> 7<table id="revisions">
9 <tr class="header"> 8 <tr class="header">
10 <th>First</th> 9 <th>First</th>
@@ -14,8 +13,9 @@
14 <th>Editor</th> 13 <th>Editor</th>
15 <th>Date</th> 14 <th>Date</th>
16 <th></th> 15 <th></th>
16 <th></th>
17 </tr> 17 </tr>
18<% @node.pages.reverse.each do |page| %> 18<% (@pages || @node.pages.all).reverse.each do |page| %>
19 <tr> 19 <tr>
20 <td><%= radio_button_tag :start_revision, page.revision %></td> 20 <td><%= radio_button_tag :start_revision, page.revision %></td>
21 <td><%= radio_button_tag :end_revision, page.revision %></td> 21 <td><%= radio_button_tag :end_revision, page.revision %></td>
@@ -23,22 +23,36 @@
23 <td class="title"><%= page.title %></td> 23 <td class="title"><%= page.title %></td>
24 <td class="user"><%= page.editor.try(:login) %></td> 24 <td class="user"><%= page.editor.try(:login) %></td>
25 <td class="date"><%= page.updated_at %></td> 25 <td class="date"><%= page.updated_at %></td>
26 <td><%= link_to 'show', node_revision_path(@node, page) %></td>
26 <td> 27 <td>
27 <%= link_to 'show', node_revision_path(@node, page) %> 28 <%= button_to 'restore', restore_node_revision_path(@node, page),
28 </td> 29 method: :put,
29 <td> 30 form: { data: { confirm: "Restore this revision?" } } %>
30 <%= link_to(
31 'restore',
32 restore_node_revision_path(@node, page),
33 :method => :put,
34 :confirm => "Restore this revision?"
35 ) %>
36 </td> 31 </td>
37 </tr> 32 </tr>
38<% end %> 33<% end %>
39 <tr class="no_hover"> 34 <tr class="no_hover">
40 <td colspan="8" class="right"><%= submit_tag 'Diff revisions' %></td> 35 <td colspan="8" class="right">
36 <%= button_to 'Diff revisions', diff_node_revisions_path(@node),
37 method: :post,
38 form: { id: 'diff_form' } %>
39 </td>
41 </tr> 40 </tr>
42</table> 41</table>
43 42
44<% end %> \ No newline at end of file 43<script>
44 document.getElementById('diff_form').addEventListener('submit', function(e) {
45 var start = document.querySelector('input[name="start_revision"]:checked');
46 var end = document.querySelector('input[name="end_revision"]:checked');
47 if (start) {
48 var s = document.createElement('input');
49 s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value;
50 this.appendChild(s);
51 }
52 if (end) {
53 var en = document.createElement('input');
54 en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value;
55 this.appendChild(en);
56 }
57 });
58</script>