diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss
index aa1b112aa..973865dce 100644
--- a/app/assets/stylesheets/specific/posts.css.scss
+++ b/app/assets/stylesheets/specific/posts.css.scss
@@ -286,7 +286,7 @@ div#c-posts {
}
}
-div#c-post-versions {
+div#c-post-versions, div#c-artist-versions {
div#a-index {
a {
word-wrap: break-word
diff --git a/app/helpers/artist_versions_helper.rb b/app/helpers/artist_versions_helper.rb
index 7f21d83ff..e9efe98fc 100644
--- a/app/helpers/artist_versions_helper.rb
+++ b/app/helpers/artist_versions_helper.rb
@@ -1,2 +1,31 @@
module ArtistVersionsHelper
+ def artist_version_other_names_diff(artist_version)
+ diff = artist_version.other_names_diff(artist_version.previous)
+ html = []
+ diff[:added_names].each do |name|
+ html << '' + name + ''
+ end
+ diff[:removed_names].each do |name|
+ html << '' + name + ''
+ end
+ diff[:unchanged_names].each do |name|
+ html << '' + name + ''
+ end
+ return html.join(" ").html_safe
+ end
+
+ def artist_version_urls_diff(artist_version)
+ diff = artist_version.urls_diff(artist_version.previous)
+ html = []
+ diff[:added_urls].each do |url|
+ html << '
' + url + ''
+ end
+ diff[:removed_urls].each do |url|
+ html << '' + url + ''
+ end
+ diff[:unchanged_urls].each do |url|
+ html << '' + url + ''
+ end
+ return html.join(" ").html_safe
+ end
end
diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb
index 1e5b15a3c..de50888b8 100644
--- a/app/models/artist_version.rb
+++ b/app/models/artist_version.rb
@@ -27,6 +27,36 @@ class ArtistVersion < ActiveRecord::Base
url_string.scan(/\S+/)
end
+ def other_names_array
+ other_names.scan(/\S+/)
+ end
+
+ def urls_diff(version)
+ new_urls = url_array
+ old_urls = version.present? ? version.url_array : []
+
+ return {
+ :added_urls => new_urls - old_urls,
+ :removed_urls => old_urls - new_urls,
+ :unchanged_urls => new_urls & old_urls,
+ }
+ end
+
+ def other_names_diff(version)
+ new_names = other_names_array
+ old_names = version.present? ? version.other_names_array : []
+
+ return {
+ :added_names => new_names - old_names,
+ :removed_names => old_names - new_names,
+ :unchanged_names => new_names & old_names,
+ }
+ end
+
+ def previous
+ ArtistVersion.where("artist_id = ? and updated_at < ?", artist_id, updated_at).order("updated_at desc").first
+ end
+
def updater_name
User.id_to_name(updater_id).tr("_", " ")
end
diff --git a/app/views/artist_versions/index.html.erb b/app/views/artist_versions/index.html.erb
index 1df403f22..762b5fb52 100644
--- a/app/views/artist_versions/index.html.erb
+++ b/app/views/artist_versions/index.html.erb
@@ -24,16 +24,14 @@
<%= link_to artist_version.name, artist_versions_path(:search => {:artist_id => artist_version.artist_id}) %>
<%= link_to "artist", artist_path(artist_version.artist) %> |
- <%= artist_version.other_names %> |
+ <%= artist_version_other_names_diff(artist_version) %> |
<%= artist_version.group_name %> |
<%= compact_time artist_version.created_at %> |
<%= link_to artist_version.updater_name, user_path(artist_version.updater_id) %> |
<%= artist_version.is_active? %> |
- <% artist_version.url_array.each do |url| %>
- - <%= url %>
- <% end %>
+ <%= artist_version_urls_diff(artist_version) %>
|
|