summaryrefslogtreecommitdiff
path: root/app/views/revisions/index.html.erb
blob: 4f854518db8c70f2b33ec4a177be343290b9a8d2 (plain)
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
59
60
61
62
63
64
65
66
67
68
<h2><%= t(".title", :path => @node.unique_name) %></h2>

<p class="node_action_bar">
  <%= link_to t(".back_to_node"), node_path(@node) %>
</p>

<% if Page.non_default_locales.any? %>
  <p class="diff_locale_toggle">
    <%= t("revisions.locale_label") %>
    <% ([I18n.default_locale] + Page.non_default_locales).each_with_index do |locale, i| %>
      <%= " &middot; ".html_safe if i > 0 %>
      <% if locale == @translation_locale %>
        <strong><%= locale.to_s.upcase %></strong>
      <% else %>
        <%= link_to locale.to_s.upcase, node_revisions_path(@node, :translation_locale => locale) %>
      <% end %>
    <% end %>
  </p>
<% end %>

<% pages = (@pages || @node.pages.all).reverse %>

<table id="revisions" class="admin_table revisions_table">
  <thead>
    <tr class="header">
      <th><%= t("admin.columns.rev") %></th>
      <th><%= t("admin.columns.title") %></th>
      <th><%= t("admin.columns.editor") %></th>
      <th><%= t("admin.columns.date") %></th>
      <th></th>
      <th></th>
    </tr>
    <tr class="diff_sticky_bar">
      <td colspan="6">
        <%= form_tag diff_node_revisions_path(@node), :method => :post,
              :id => "diff_form", :class => "button_to computation" do %>
          <%= hidden_field_tag :translation_locale, @translation_locale %>
          <%= hidden_field_tag :start_revision, pages[1]&.revision %>
          <%= hidden_field_tag :end_revision,   pages[0]&.revision %>
          <%= submit_tag t(".diff_revisions") %>
          <span id="diff_selection_label" aria-live="polite">
            <%= t(".diff_selection_html",
                  :from => tag.span(:id => "diff_from"),
                  :to   => tag.span(:id => "diff_to")) %>
          </span>
          <label><%= radio_button_tag :view, 'inline', true %> <%= t("revisions.inline") %></label>
          <label><%= radio_button_tag :view, 'side_by_side', false %> <%= t("revisions.side_by_side") %></label>
        <% end %>
      </td>
    </tr>
  </thead>
  <tbody>
  <% pages.each do |page| %>
    <tr data-revision="<%= page.revision %>" tabindex="0" aria-pressed="false">
      <td class="revision"><%= page.revision %></td>
      <td class="title"><%= page.translations.find_by(:locale => @translation_locale)&.title || "—" %></td>
      <td class="user"><%= page.editor.try(:login) %></td>
      <td class="date"><%= admin_datetime(page.updated_at) %></td>
      <td><%= link_to t(".show_link"), node_revision_path(@node, page, :translation_locale => @translation_locale) %></td>
      <td>
        <%= button_to t(".restore_link"), restore_node_revision_path(@node, page),
              method: :put,
              form: { data: { confirm: t(".confirm_restore") }, class: 'button_to state_changing' } %>
      </td>
    </tr>
  <% end %>
  </tbody>
</table>