1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<% content_for :subnavigation do %>
<%= link_to 'Edit', edit_node_path(@node) %>
<% end %>
<h2>Revisions for Node: <%= @node.unique_name %></h2>
<table id="revisions">
<tr class="header">
<th>First</th>
<th>Last</th>
<th>Rev.</th>
<th>Title</th>
<th>Editor</th>
<th>Date</th>
<th></th>
<th></th>
</tr>
<% (@pages || @node.pages.all).reverse.each do |page| %>
<tr>
<td><%= radio_button_tag :start_revision, page.revision %></td>
<td><%= radio_button_tag :end_revision, page.revision %></td>
<td class="revision"><%= page.revision %></td>
<td class="title"><%= page.title %></td>
<td class="user"><%= page.editor.try(:login) %></td>
<td class="date"><%= page.updated_at %></td>
<td><%= link_to 'show', node_revision_path(@node, page) %></td>
<td>
<%= button_to 'restore', restore_node_revision_path(@node, page),
method: :put,
form: { data: { confirm: "Restore this revision?" } } %>
</td>
</tr>
<% end %>
<tr class="no_hover">
<td colspan="8" class="right">
<%= button_to 'Diff revisions', diff_node_revisions_path(@node),
method: :post,
form: { id: 'diff_form' } %>
</td>
</tr>
</table>
<script>
document.getElementById('diff_form').addEventListener('submit', function(e) {
var start = document.querySelector('input[name="start_revision"]:checked');
var end = document.querySelector('input[name="end_revision"]:checked');
if (start) {
var s = document.createElement('input');
s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value;
this.appendChild(s);
}
if (end) {
var en = document.createElement('input');
en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value;
this.appendChild(en);
}
});
</script>
|