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,23 +1,36 @@
module NoteVersionsHelper
def note_version_position_diff(note_version)
previous = note_version.previous
def note_version_position_diff(note_version, type)
other = note_version.send(type)
html = "#{note_version.x},#{note_version.y}"
if previous.nil? || (note_version.x == previous.x && note_version.y == previous.y)
if other.nil? || (note_version.x == other.x && note_version.y == other.y)
html
elsif type == "previous"
"#{other.x},#{other.y} -> " + html
else
"#{previous.x},#{previous.y} -> " + html
html + " -> #{other.x},#{other.y}"
end
end
def note_version_size_diff(note_version)
previous = note_version.previous
def note_version_size_diff(note_version, type)
other = note_version.send(type)
html = "#{note_version.width}x#{note_version.height}"
if previous.nil? || (note_version.width == previous.width && note_version.height == previous.height)
if other.nil? || (note_version.width == other.width && note_version.height == other.height)
html
elsif type == "previous"
"#{other.width}x#{other.height} -> " + html
else
"#{previous.width}x#{previous.height} -> " + html
html + " -> #{other.width}x#{other.height}"
end
end
def note_version_body_diff(note_version, type)
other = note_version.send(params[:type])
if type == "previous"
diff_body_html(note_version, other, :body)
else
diff_body_html(other, note_version, :body)
end
end
end