Add alternate comparison types to versions

- The types are:
-- Previous: The default and the previously used type
-- Subsequent: Compares against the next version
-- Current: Compares against the current version
- Allow switching between comparison types in index and diff views
-- Have links vary depending upon current comparison type
This commit is contained in:
BrokenEagle
2020-03-17 07:23:42 +00:00
parent a95e57d938
commit e23ee170f5
41 changed files with 488 additions and 221 deletions

View File

@@ -2,7 +2,7 @@
<%= form_tag(diff_wiki_page_versions_path, :method => :get) do %>
<%= table_for @wiki_page_versions.includes(:updater, :tag), width: "100%" do |t| %>
<% t.column column: "diff", width: "3%" do |wiki_page_version, i| %>
<%= link_to_if wiki_version_show_diff(wiki_page_version), "diff", diff_wiki_page_versions_path(otherpage: wiki_page_version.previous.try(:id), thispage: wiki_page_version.id) %>
<%= link_to_if wiki_version_show_diff(wiki_page_version, params[:type]), "diff", diff_wiki_page_versions_path(thispage: wiki_page_version.id, type: params[:type]) %>
<% end %>
<% if listing_type(:wiki_page_id, member_check: false, types: [:page, :global]) == :page %>
@@ -20,10 +20,10 @@
<%= link_to wiki_page_version.title, wiki_page_version %>
<%= link_to "»", wiki_page_versions_path(search: { wiki_page_id: wiki_page_version.wiki_page_id }) %>
</span>
<%= wiki_version_title_diff(wiki_page_version) %>
<%= wiki_version_title_diff(wiki_page_version, params[:type]) %>
<% end %>
<% t.column "Changes", width: "5%" do |wiki_page_version| %>
<%= status_diff_html(wiki_page_version) %>
<%= status_diff_html(wiki_page_version, params[:type]) %>
<% end %>
<% t.column "Updated", width: "26%" do |wiki_page_version| %>
<%= compact_time(wiki_page_version.updated_at) %>

View File

@@ -4,21 +4,33 @@
<%= render "wiki_pages/sidebar" %>
<% content_for(:content) do %>
<h1>Wiki Page Version Comparison: <%= link_to @thispage.title, wiki_page_versions_path(search: { wiki_page_id: @thispage.wiki_page_id }, anchor: "wiki-page-version-#{@thispage.id}"), class: "tag-type-#{@thispage.wiki_page.category_name}" %></h1>
<h1>Wiki Page Version Comparison: <%= link_to @thispage.title, wiki_page_versions_path(search: { wiki_page_id: @thispage.wiki_page_id }, type: params[:type], anchor: "wiki-page-version-#{@thispage.id}"), class: "tag-type-#{@thispage.wiki_page.category_name}" %></h1>
<p>Showing differences between <%= compact_time @thispage.updated_at %> (<%= link_to_user @thispage.updater %>) and <%= compact_time @otherpage.updated_at %> (<%= link_to_user @otherpage.updater %>)</p>
<% if wiki_version_show_other_names(@thispage, @otherpage) %>
<p><%= wiki_version_other_names_diff(@thispage, @otherpage) %></p>
<% else %>
<p><em>No changes to other names.</em></p>
<% if params[:type].present? %>
<%= render "versions/types" %>
<% end %>
<% if @thispage.body != @otherpage.body %>
<div class="diff-body">
<%= diff_body_html(@thispage, @otherpage, :body) %>
</div>
<% if @otherpage.present? %>
<% if @thispage.id != @otherpage.id %>
<p>Showing differences between <%= compact_time @thispage.updated_at %> (<%= link_to_user @thispage.updater %>) and <%= compact_time @otherpage.updated_at %> (<%= link_to_user @otherpage.updater %>)</p>
<% if wiki_version_show_other_names(@thispage, @otherpage) %>
<p><%= wiki_version_other_names_diff(@thispage, @otherpage) %></p>
<% else %>
<p><em>No changes to other names.</em></p>
<% end %>
<% if @thispage.body != @otherpage.body %>
<div class="diff-body">
<%= diff_body_html(@thispage, @otherpage, :body) %>
</div>
<% else %>
<p><em>No changes to body.</em></p>
<% end %>
<% else %>
<p><em>Version is latest!</em></p>
<% end %>
<% else %>
<p><em>No changes to body.</em></p>
<p><em>No versions to compare!</em></p>
<% end %>
<% end %>

View File

@@ -3,6 +3,8 @@
<% content_for(:content) do %>
<h1>Wiki Page History</h1>
<%= render "versions/types" %>
<%= render "listing" %>
<%= numbered_paginator(@wiki_page_versions) %>