<div id="p-<%= listing_type(:post_id) %>-listing">

  <% if listing_type(:post_id) == :revert && @commentary_versions.present? %>
    <%= post_preview(@commentary_versions.first.post, show_deleted: true) %>
  <% end %>

  <%= table_for @commentary_versions, class: "striped" do |t| %>
    <% if listing_type(:post_id) == :standard %>
      <% t.column "Post", width: "1%" do |commentary_version| %>
          <%= post_preview(commentary_version.post, show_deleted: true) %>
      <% 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}&nbsp;»".html_safe, artist_commentary_versions_path(search: {post_id: commentary_version.post_id}, anchor: "artist-commentary-version-#{commentary_version.id}") %>
      <% end %>
    <% end %>
    <% t.column "Original", width: "40%", td: { class: "diff-body align-top mt-2" } do |commentary_version| %>
      <% if !commentary_version.unchanged_empty?(:original_title) %>
        <p class="commentary-body-section font-bold">
          <%= commentary_version_field_diff(commentary_version, params[:type], :original_title) %>
        </p>
      <% end %>
      <% if !commentary_version.unchanged_empty?(:original_description) %>
        <p class="commentary-body-section">
          <%= commentary_version_field_diff(commentary_version, params[:type], :original_description) %>
        </p>
      <% end %>
    <% end %>
    <% t.column "Translated", width: "40%", td: { class: "diff-body align-top mt-4" } do |commentary_version| %>
      <% if !commentary_version.unchanged_empty?(:translated_title) %>
        <p class="commentary-body-section font-bold">
          <%= commentary_version_field_diff(commentary_version, params[:type], :translated_title) %>
        </p>
      <% end %>
      <% if !commentary_version.unchanged_empty?(:translated_description) %>
        <p class="commentary-body-section">
          <%= commentary_version_field_diff(commentary_version, params[:type], :translated_description) %>
        </p>
      <% end %>
    <% end %>
    <% t.column "Changes", width: "3%" do |commentary_version| %>
      <%= status_diff_html(commentary_version, params[:type]) %>
    <% end %>
    <% 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 %>
    <% 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 %>
    <% end %>
  <% end %>

</div>
