diff --git a/app/helpers/note_versions_helper.rb b/app/helpers/note_versions_helper.rb index c29996ef0..e020b5c45 100644 --- a/app/helpers/note_versions_helper.rb +++ b/app/helpers/note_versions_helper.rb @@ -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 += '(body not changed)' - 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 = '' + html + '' - html.html_safe + "#{previous.width}x#{previous.height} -> " + html end end end diff --git a/app/models/note_version.rb b/app/models/note_version.rb index 3cc1c56ea..0e65e5738 100644 --- a/app/models/note_version.rb +++ b/app/models/note_version.rb @@ -18,4 +18,30 @@ class NoteVersion < ApplicationRecord end @previous.first end + + def self.status_fields + { + body: "Body", + was_moved: "Moved", + was_resized: "Resized", + was_deleted: "Deleted", + was_undeleted: "Undeleted", + } + end + + def was_moved + x != previous.x || y != previous.y + end + + def was_resized + width != previous.width || height != previous.height + end + + def was_deleted + !is_active && previous.is_active + end + + def was_undeleted + is_active && !previous.is_active + end end diff --git a/app/views/note_versions/_listing.html.erb b/app/views/note_versions/_listing.html.erb index eb95d5c6e..8449b678d 100644 --- a/app/views/note_versions/_listing.html.erb +++ b/app/views/note_versions/_listing.html.erb @@ -1,35 +1,39 @@ -