Commit d62f7e78 authored by BrokenEagle's avatar BrokenEagle

Revise display on artist commentary versions index

- All text fields are now shown in their non-rendered form
-- This allows changes to be highlighted with the diff builder
-- The different fields were labeled and separated for easier discernment
-- Fields are only shown if they have text in either the current or previous versions
- Various changes are also verbalized for easier discovery
- The date and the user columns were combined
-- This is more in line with other indexes, plus it saves on space
- The revert listing was changed to use a thumbnail instead of post ID links
-- This makes it more in line with the post versions index
parent d8fd1c21
module ArtistCommentaryVersionsHelper
def artist_commentary_versions_listing_type
params.dig(:search, :post_id).present? ? :revert : :standard
end
end
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;
}
}
}
......@@ -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
<div id="p-<%= artist_commentary_versions_listing_type %>-listing">
<div id="p-<%= listing_type(:post_id) %>-listing">
<%= 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 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 %>
<% 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}) %>
<% t.column "Original", width: "40%", td: {class: "diff-body"} do |commentary_version| %>
<% if !commentary_version.unchanged_empty?(:original_title) %>
<b>Title:</b>
<div class="commentary-body-section">
<%= diff_body_html(commentary_version, commentary_version.previous, :original_title) %>
</div>
<% end %>
<% if !commentary_version.unchanged_empty?(:original_description) %>
<b>Description:</b>
<div class="commentary-body-section">
<%= diff_body_html(commentary_version, commentary_version.previous, :original_description) %>
</div>
<% end %>
<% end %>
<% t.column "Original" do |commentary_version| %>
<%= format_commentary_title(commentary_version.original_title) %>
<%= format_commentary_description(commentary_version.original_description) %>
<% t.column "Translated", width: "40%", td: {class: "diff-body"} do |commentary_version| %>
<% if !commentary_version.unchanged_empty?(:translated_title) %>
<b>Title:</b>
<div class="commentary-body-section">
<%= diff_body_html(commentary_version, commentary_version.previous, :translated_title) %>
</div>
<% end %>
<% if !commentary_version.unchanged_empty?(:translated_description) %>
<b>Description:</b>
<div class="commentary-body-section">
<%= diff_body_html(commentary_version, commentary_version.previous, :translated_description) %>
</div>
<% end %>
<% end %>
<% t.column "Translated" do |commentary_version| %>
<%= format_commentary_title(commentary_version.translated_title) %>
<%= format_commentary_description(commentary_version.translated_description) %>
<% t.column "Changes", width: "3%" do |commentary_version| %>
<%= status_diff_html(commentary_version) %>
<% end %>
<% t.column "Edited by", width: "10%" do |commentary_version| %>
<% t.column "Updated", width: "10%" do |commentary_version| %>
<div>
<%= compact_time commentary_version.updated_at %>
</div>
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 %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment