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:
@@ -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> #{name_diff})).html_safe
|
||||
else
|
||||
""
|
||||
|
||||
Reference in New Issue
Block a user