# frozen_string_literal: true
module ArtistVersionsHelper
def artist_version_other_names_diff(artist_version, type, show_unchanged: false)
other = artist_version.send(type)
this_names = artist_version.other_names
if other.present?
other_names = other.other_names
elsif type == "subsequent"
other_names = this_names
else
other_names = []
end
if type == "previous"
diff_list_html(this_names, other_names, show_unchanged: show_unchanged)
else
diff_list_html(other_names, this_names, show_unchanged: show_unchanged)
end
end
def artist_version_urls_diff(artist_version, type, show_unchanged: false)
other = artist_version.send(type)
this_urls = artist_version.urls
if other.present?
other_urls = other.urls
elsif type == "subsequent"
other_urls = this_urls
else
other_urls = []
end
if type == "previous"
diff_list_html(this_urls, other_urls, show_unchanged: show_unchanged)
else
diff_list_html(other_urls, this_urls, show_unchanged: show_unchanged)
end
end
def artist_version_name_diff(artist_version, type)
other = artist_version.send(type)
if other.present? && (artist_version.name != other.name)
if type == "previous"
name_diff = diff_name_html(artist_version.name, other.name)
else
name_diff = diff_name_html(other.name, artist_version.name)
end
%{
Rename:
#{name_diff}