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

@@ -1,25 +1,28 @@
module WikiPageVersionsHelper
def wiki_version_show_diff(wiki_page_version)
previous = wiki_page_version.previous
previous.present? && ((wiki_page_version.body != previous.body) || wiki_page_version.other_names_changed)
def wiki_version_show_diff(wiki_page_version, type)
other = wiki_page_version.send(type)
other.present? && ((wiki_page_version.body != other.body) || wiki_page_version.other_names_changed(type))
end
def wiki_version_show_other_names(new_version, old_version)
((new_version.other_names - old_version.other_names) | (old_version.other_names - new_version.other_names)).length > 0
def wiki_version_show_other_names(this_version, other_version)
((this_version.other_names - other_version.other_names) | (other_version.other_names - this_version.other_names)).length.positive?
end
def wiki_version_other_names_diff(new_version, old_version)
new_names = new_version.other_names
old_names = old_version.other_names
latest_names = new_version.wiki_page.other_names
def wiki_version_other_names_diff(this_version, other_version)
this_names = this_version.other_names
other_names = other_version.other_names
diff_list_html(new_names, old_names, latest_names, ul_class: ["wiki-other-names-diff-list list-inline"], li_class: ["wiki-other-name"])
diff_list_html(this_names, other_names, ul_class: ["wiki-other-names-diff-list list-inline"], li_class: ["wiki-other-name"])
end
def wiki_version_title_diff(wiki_page_version)
previous = wiki_page_version.previous
if previous.present? && (wiki_page_version.title != previous.title)
name_diff = diff_name_html(wiki_page_version.title, previous.title)
def wiki_version_title_diff(wiki_page_version, type)
other = wiki_page_version.send(type)
if other.present? && (wiki_page_version.title != other.title)
if type == "previous"
name_diff = diff_name_html(wiki_page_version.title, other.title)
else
name_diff = diff_name_html(other.title, wiki_page_version.title)
end
%((<b>Rename:</b>&ensp;#{name_diff})).html_safe
else
""