artists: don't show unchanged URLs in artist history.

Only show changed URLs in the artist history, not unchanged URLs. Makes
the edit history more compact and easier to read by showing only the
things that changed on every edit.
This commit is contained in:
evazion
2022-01-19 23:24:20 -06:00
parent b9d4be16c8
commit 00f4fbe2d1
3 changed files with 13 additions and 11 deletions

View File

@@ -5,9 +5,9 @@ module ApplicationHelper
(fields.reduce(false) { |acc, field| acc || params.dig(:search, field).present? } && (!member_check || CurrentUser.is_member?) ? types[0] : types[1])
end
def diff_list_html(this_list, other_list, ul_class: ["diff-list"], li_class: [])
def diff_list_html(this_list, other_list, ul_class: ["diff-list"], li_class: [], show_unchanged: true)
diff = SetDiff.new(this_list, other_list)
render "diff_list", diff: diff, ul_class: ul_class, li_class: li_class
render "diff_list", diff: diff, ul_class: ul_class, li_class: li_class, show_unchanged: show_unchanged
end
def diff_name_html(this_name, other_name)

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
module ArtistVersionsHelper
def artist_version_other_names_diff(artist_version, type)
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?
@@ -13,13 +13,13 @@ module ArtistVersionsHelper
end
if type == "previous"
diff_list_html(this_names, other_names)
diff_list_html(this_names, other_names, show_unchanged: show_unchanged)
else
diff_list_html(other_names, this_names)
diff_list_html(other_names, this_names, show_unchanged: show_unchanged)
end
end
def artist_version_urls_diff(artist_version, type)
def artist_version_urls_diff(artist_version, type, show_unchanged: false)
other = artist_version.send(type)
this_urls = artist_version.urls
if other.present?
@@ -31,9 +31,9 @@ module ArtistVersionsHelper
end
if type == "previous"
diff_list_html(this_urls, other_urls)
diff_list_html(this_urls, other_urls, show_unchanged: show_unchanged)
else
diff_list_html(other_urls, this_urls)
diff_list_html(other_urls, this_urls, show_unchanged: show_unchanged)
end
end
@@ -53,7 +53,7 @@ module ArtistVersionsHelper
def artist_version_group_name_diff(artist_version, type)
other = artist_version.send(type)
if artist_version.group_name.present? || (other.present? && other.group_name.present?)
if artist_version.group_name.to_s != other&.group_name.to_s
other_group_name = (other.present? ? other.group_name : artist_version.group_name)
if type == "previous"
group_name_diff = diff_name_html(artist_version.group_name, other_group_name)

View File

@@ -15,7 +15,9 @@
<% end %>
<% end %>
<% diff.unchanged.each do |item| %>
<%= tag.li item, class: ["unchanged", *li_class] %>
<% if show_unchanged %>
<% diff.unchanged.each do |item| %>
<%= tag.li item, class: ["unchanged", *li_class] %>
<% end %>
<% end %>
<% end %>