diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 471c8a320..ccd0c6ff3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/helpers/artist_versions_helper.rb b/app/helpers/artist_versions_helper.rb index 0322e6a33..e6fc03b05 100644 --- a/app/helpers/artist_versions_helper.rb +++ b/app/helpers/artist_versions_helper.rb @@ -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) diff --git a/app/views/application/_diff_list.html.erb b/app/views/application/_diff_list.html.erb index d15654a03..a909f16ed 100644 --- a/app/views/application/_diff_list.html.erb +++ b/app/views/application/_diff_list.html.erb @@ -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 %>