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

@@ -3,6 +3,7 @@ class WikiPageVersionsController < ApplicationController
layout "sidebar"
def index
set_version_comparison
@wiki_page_versions = WikiPageVersion.paginated_search(params)
@wiki_page_versions = @wiki_page_versions.includes(:updater) if request.format.html?
@@ -16,15 +17,20 @@ class WikiPageVersionsController < ApplicationController
def diff
if params[:thispage].blank? || params[:otherpage].blank?
redirect_back fallback_location: wiki_pages_path, notice: "You must select two versions to diff"
return
end
@thispage = WikiPageVersion.find(params[:thispage])
@otherpage = WikiPageVersion.find(params[:otherpage])
if @thispage.id < @otherpage.id
@thispage, @otherpage = @otherpage, @thispage
page_id = params[:thispage] || params[:otherpage]
if page_id.blank?
redirect_back fallback_location: wiki_pages_path, notice: "You must select at least one version to diff"
return
end
set_version_comparison
@thispage = WikiPageVersion.find(page_id)
@otherpage = @thispage.send(params[:type])
else
@thispage = WikiPageVersion.find(params[:thispage])
@otherpage = WikiPageVersion.find(params[:otherpage])
if @thispage.id < @otherpage.id
@thispage, @otherpage = @otherpage, @thispage
end
end
respond_with([@thispage, @otherpage])