Revise display on note versions index

- Body now uses the diff builder to highlight changes
-- A generalized diff-body class was added instead of something specific
- The status changes are now verbalized instead of being shown with styles
- The position and sizes are now split up
-- Changes directly reference the previous version
- The date and user columns were combined
-- This is more in line with other indexes, plus it saves space
This commit is contained in:
BrokenEagle
2020-02-07 23:23:48 +00:00
parent 154849a501
commit d8fd1c212e
3 changed files with 57 additions and 38 deletions

View File

@@ -1,34 +1,23 @@
module NoteVersionsHelper
def note_versions_listing_type
((params.dig(:search, :post_id).present? || params.dig(:search, :note_id).present?) && CurrentUser.is_member?) ? :revert : :standard
end
def note_version_body_diff_info(note_version)
previous = note_version.previous
if previous.nil?
return ""
end
html = ""
if note_version.body == previous.body
html += '<span class="inactive">(body not changed)</span>'
end
html.html_safe
end
def note_version_position_diff(note_version)
previous = note_version.previous
html = "#{note_version.width}x#{note_version.height}"
html += " #{note_version.x},#{note_version.y}"
html = "#{note_version.x},#{note_version.y}"
if previous.nil?
html
elsif note_version.x == previous.x && note_version.y == previous.y && note_version.width == previous.width && note_version.height == previous.height
else
"#{previous.x},#{previous.y} -> " + html
end
end
def note_version_size_diff(note_version)
previous = note_version.previous
html = "#{note_version.width}x#{note_version.height}"
if previous.nil?
html
else
html = '<span style="text-decoration: underline;">' + html + '</span>'
html.html_safe
"#{previous.width}x#{previous.height} -> " + html
end
end
end