diff --git a/app/helpers/artist_versions_helper.rb b/app/helpers/artist_versions_helper.rb index acd1c685e..1f55b471e 100644 --- a/app/helpers/artist_versions_helper.rb +++ b/app/helpers/artist_versions_helper.rb @@ -1,8 +1,4 @@ module ArtistVersionsHelper - def artist_versions_listing_type - (params.dig(:search, :artist_id).present? && CurrentUser.is_member?) ? :revert : :standard - end - def artist_version_other_names_diff(artist_version) new_names = artist_version.other_names old_names = artist_version.previous.try(:other_names) diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 8f015064b..d8486cae3 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -29,4 +29,41 @@ class ArtistVersion < ApplicationRecord end @previous.first end + + def self.status_fields + { + name: "Renamed", + urls_changed: "URLs", + other_names_changed: "OtherNames", + group_name: "GroupName", + was_deleted: "Deleted", + was_undeleted: "Undeleted", + was_banned: "Banned", + was_unbanned: "Unbanned", + } + end + + def other_names_changed + ((other_names - previous.other_names) | (previous.other_names - other_names)).length > 0 + end + + def urls_changed + ((urls - previous.urls) | (previous.urls - urls)).length > 0 + end + + def was_deleted + !is_active && previous.is_active + end + + def was_undeleted + is_active && !previous.is_active + end + + def was_banned + is_banned && !previous.is_banned + end + + def was_unbanned + !is_banned && previous.is_banned + end end diff --git a/app/views/artist_versions/_listing.html.erb b/app/views/artist_versions/_listing.html.erb index 0275adff0..5051698cd 100644 --- a/app/views/artist_versions/_listing.html.erb +++ b/app/views/artist_versions/_listing.html.erb @@ -1,24 +1,22 @@ -
+
<%= table_for @artist_versions, {class: "striped autofit", width: "100%"} do |t| %> <% t.column "Name" do |artist_version| %> <%= link_to artist_version.name, artist_path(artist_version.artist_id) %> - <%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}) %> - - <% if !artist_version.is_active? %> - (deleted) - <% end %> - - <% if artist_version.group_name.present? %> -

(group: <%= artist_version.group_name %>)

- <% end %> + <%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}, anchor: "artist-version-#{artist_version.id}") %> <% end %> <% t.column "Other Names" do |artist_version| %> + <% if artist_version.group_name.present? %> +

Group:
 <%= artist_version.group_name %>

+ <% end %> <%= artist_version_other_names_diff(artist_version) %> <% end %> <% t.column "URLs", td: {class: "col-expand"} do |artist_version| %> <%= artist_version_urls_diff(artist_version) %> <% end %> + <% t.column "Changes" do |artist_version| %> + <%= status_diff_html(artist_version) %> + <% end %> <% t.column "Updated" do |artist_version| %> <%= link_to_user artist_version.updater %> <%= link_to "»", artist_versions_path(search: { updater_name: artist_version.updater.name }) %> @@ -26,7 +24,7 @@ <%= compact_time(artist_version.updated_at) %>

<% end %> - <% if artist_versions_listing_type == :revert %> + <% if listing_type(:artist_id) == :revert %> <% t.column column: "control" do |artist_version| %> <%= link_to "Revert to", revert_artist_path(artist_version.artist_id, version_id: artist_version.id), method: :put, "data-confirm": "Are you sure you want to revert to this version?" %> <% end %>