diff --git a/app/helpers/artist_commentary_versions_helper.rb b/app/helpers/artist_commentary_versions_helper.rb deleted file mode 100644 index 0a52fed5d..000000000 --- a/app/helpers/artist_commentary_versions_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module ArtistCommentaryVersionsHelper - def artist_commentary_versions_listing_type - params.dig(:search, :post_id).present? ? :revert : :standard - end -end diff --git a/app/javascript/src/styles/specific/artist_commentary_versions.scss b/app/javascript/src/styles/specific/artist_commentary_versions.scss new file mode 100644 index 000000000..c60410940 --- /dev/null +++ b/app/javascript/src/styles/specific/artist_commentary_versions.scss @@ -0,0 +1,15 @@ +div#c-artist-commentary-versions { + #a-index { + div.commentary-body-section { + padding: 0.5em; + margin-bottom: 0.5em; + border: var(--footer-border); + } + + td.original-column, + td.translated-column { + padding-top: 0.5em; + vertical-align: top; + } + } +} diff --git a/app/models/artist_commentary_version.rb b/app/models/artist_commentary_version.rb index 8ce732caa..e362821cb 100644 --- a/app/models/artist_commentary_version.rb +++ b/app/models/artist_commentary_version.rb @@ -14,4 +14,17 @@ class ArtistCommentaryVersion < ApplicationRecord end @previous.first end + + def self.status_fields + { + original_title: "OrigTitle", + original_description: "OrigDesc", + translated_title: "TransTitle", + translated_description: "TransDesc", + } + end + + def unchanged_empty?(field) + self[field].strip.empty? && (previous.nil? || previous[field].strip.empty?) + end end diff --git a/app/views/artist_commentary_versions/_listing.html.erb b/app/views/artist_commentary_versions/_listing.html.erb index 2f2e1f18d..fd4fb089d 100644 --- a/app/views/artist_commentary_versions/_listing.html.erb +++ b/app/views/artist_commentary_versions/_listing.html.erb @@ -1,33 +1,60 @@ -
+
- <%= table_for @commentary_versions, {class: "striped autofit", width: "100%"} do |t| %> - <% t.column "Post", width: "5%" do |commentary_version| %> - <% if artist_commentary_versions_listing_type == :revert %> - <%= link_to commentary_version.post_id, post_path(commentary_version.post_id) %> - <% else %> - <%= PostPresenter.preview(commentary_version.post, :tags => "status:any") %> + <% if listing_type(:post_id) == :revert %> + <%= PostPresenter.preview(@commentary_versions.first.post, show_deleted: true) %> + <% end %> + + <%= table_for @commentary_versions, {class: "striped", width: "100%"} do |t| %> + <% if listing_type(:post_id) == :standard %> + <% t.column "Post", width: "1%" do |commentary_version| %> + <%= PostPresenter.preview(commentary_version.post, :tags => "status:any") %> <% end %> <% end %> - <% if artist_commentary_versions_listing_type == :standard %> - <% t.column "Version" do |commentary_version| %> - <%= link_to "#{commentary_version.post_id}.#{commentary_version.id}»", artist_commentary_versions_path(search: {post_id: commentary_version.post_id}) %> + <% if listing_type(:post_id) == :standard %> + <% t.column "Version", width: "3%" do |commentary_version| %> + <%= link_to "#{commentary_version.post_id}.#{commentary_version.id}»", artist_commentary_versions_path(search: {post_id: commentary_version.post_id}, anchor: "artist-commentary-version-#{commentary_version.id}") %> <% end %> <% end %> - <% t.column "Original" do |commentary_version| %> - <%= format_commentary_title(commentary_version.original_title) %> - <%= format_commentary_description(commentary_version.original_description) %> + <% t.column "Original", width: "40%", td: {class: "diff-body"} do |commentary_version| %> + <% if !commentary_version.unchanged_empty?(:original_title) %> + Title: +
+ <%= diff_body_html(commentary_version, commentary_version.previous, :original_title) %> +
+ <% end %> + <% if !commentary_version.unchanged_empty?(:original_description) %> + Description: +
+ <%= diff_body_html(commentary_version, commentary_version.previous, :original_description) %> +
+ <% end %> <% end %> - <% t.column "Translated" do |commentary_version| %> - <%= format_commentary_title(commentary_version.translated_title) %> - <%= format_commentary_description(commentary_version.translated_description) %> + <% t.column "Translated", width: "40%", td: {class: "diff-body"} do |commentary_version| %> + <% if !commentary_version.unchanged_empty?(:translated_title) %> + Title: +
+ <%= diff_body_html(commentary_version, commentary_version.previous, :translated_title) %> +
+ <% end %> + <% if !commentary_version.unchanged_empty?(:translated_description) %> + Description: +
+ <%= diff_body_html(commentary_version, commentary_version.previous, :translated_description) %> +
+ <% end %> <% end %> - <% t.column "Edited by", width: "10%" do |commentary_version| %> + <% t.column "Changes", width: "3%" do |commentary_version| %> + <%= status_diff_html(commentary_version) %> + <% end %> + <% t.column "Updated", width: "10%" do |commentary_version| %> +
+ <%= compact_time commentary_version.updated_at %> +
+ by <%= link_to_user commentary_version.updater %> + <%= link_to "»", artist_commentary_versions_path(search: params[:search].merge({ updater_id: commentary_version.updater_id })) %> <% end %> - <% t.column "Date", width: "10%" do |commentary_version| %> - <%= compact_time commentary_version.updated_at %> - <% end %> - <% if artist_commentary_versions_listing_type == :revert %> + <% if listing_type(:post_id) == :revert %> <% t.column column: "control", width: "7%" do |commentary_version| %> <%= link_to "Revert to", revert_artist_commentary_path(commentary_version.post_id, :version_id => commentary_version.id), :remote => true, :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %> <% end %>