Combine version partials into one file

This commit is contained in:
BrokenEagle
2020-01-03 20:30:06 +00:00
parent 89df0a6ace
commit be92282990
15 changed files with 52 additions and 143 deletions

View File

@@ -0,0 +1,6 @@
module ArtistCommentaryVersionsHelper
def artist_commentary_versions_listing_type
params.dig(:search, :post_id).present? ? :revert : :standard
end
end

View File

@@ -1,4 +1,8 @@
module NoteVersionsHelper
def note_versions_listing_type
(params.dig(:search, :post_id).present? || params.dig(:search, :note_id).present?) && CurrentUser.is_member? ? :revert : :standard
end
def note_version_body_diff_info(note_version)
previous = note_version.previous
if previous.nil?

View File

@@ -0,0 +1,6 @@
module PoolVersionsHelper
def pool_versions_listing_type
params.dig(:search, :pool_id).present? ? :revert : :standard
end
end

View File

@@ -1,5 +1,5 @@
module PostVersionsHelper
def post_version_listing
def post_versions_listing_type
params.dig(:search, :post_id).present? ? :revert : :standard
end

View File

@@ -1,33 +0,0 @@
<div id="p-revert-listing">
<%= table_for @commentary_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column "Post", {width: "5%"} do |commentary_version| %>
<%= link_to commentary_version.post_id, post_path(commentary_version.post_id) %>
<% end %>
<% t.column "Original" do |commentary_version| %>
<%= format_commentary_title(commentary_version.original_title) %>
<%= format_commentary_description(commentary_version.original_description) %>
<% end %>
<% t.column "Translated" do |commentary_version| %>
<%= format_commentary_title(commentary_version.translated_title) %>
<%= format_commentary_description(commentary_version.translated_description) %>
<% end %>
<% if CurrentUser.is_moderator? %>
<% t.column "IP Address", {width: "10%"} do |commentary_version| %>
<%= link_to_ip commentary_version.updater_ip_addr %>
<% end %>
<% end %>
<% t.column "Edited by", {width: "10%"} do |commentary_version| %>
<%= link_to_user commentary_version.updater %>
<% end %>
<% t.column "Date", {width: "10%"} do |commentary_version| %>
<%= compact_time commentary_version.updated_at %>
<% end %>
<% if CurrentUser.is_member? %>
<% t.column "", {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>

View File

@@ -1,11 +1,17 @@
<div id="p-standard-listing">
<div id="p-<%= artist_commentary_versions_listing_type %>-listing">
<%= table_for @commentary_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column "Post", {width: "5%"} do |commentary_version| %>
<%= PostPresenter.preview(commentary_version.post, :tags => "status:any") %>
<% 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") %>
<% end %>
<% end %>
<% 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 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}) %>
<% end %>
<% end %>
<% t.column "Original" do |commentary_version| %>
<%= format_commentary_title(commentary_version.original_title) %>
@@ -26,6 +32,11 @@
<% t.column "Date", {width: "10%"} do |commentary_version| %>
<%= compact_time commentary_version.updated_at %>
<% end %>
<% if artist_commentary_versions_listing_type == :revert %>
<% t.column "", {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>

View File

@@ -4,11 +4,7 @@
<%= render "posts/partials/common/inline_blacklist" %>
<% if params.dig(:search, :post_id).present? %>
<%= render "revert_listing" %>
<% else %>
<%= render "standard_listing" %>
<% end %>
<%= render "standard_listing" %>
<%= numbered_paginator(@commentary_versions) %>

View File

@@ -1,45 +0,0 @@
<div id="p-revert-listing">
<%= table_for @note_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column %>
<% t.column "Post", {width: "5%"} do |note_version| %>
<%= link_to note_version.post_id, post_path(note_version.post_id) %>
<% if params.dig(:search, :note_id).present? %>
<%= link_to "»", note_versions_path(search: {post_id: note_version.post_id}) %>
<% end %>
<% end %>
<% t.column "Note", {width: "5%"} do |note_version| %>
<%= link_to "#{note_version.note_id}.#{note_version.version}", post_path(note_version.post_id, anchor: "note-#{note_version.note_id}") %>
<% if params.dig(:search, :post_id).present? %>
<%= link_to "»", note_versions_path(search: {note_id: note_version.note_id}) %>
<% end %>
<% end %>
<% t.column "Body", nil, {class: "col-expand"} do |note_version| %>
<%= h(note_version.body) %>
<% unless note_version.is_active? %>
<span class="inactive">(deleted)</span>
<% end %>
<%= note_version_body_diff_info(note_version) %>
<% end %>
<% t.column "Position", {width: "5%"} do |note_version| %>
<%= note_version_position_diff(note_version) %>
<% end %>
<% if CurrentUser.is_moderator? %>
<% t.column "IP Address", {width: "10%"} do |note_version| %>
<%= link_to_ip note_version.updater_ip_addr %>
<% end %>
<% end %>
<% t.column "Edited By", {width: "10%"} do |note_version| %>
<%= link_to_user note_version.updater %>
<% end %>
<% t.column "Date", {width: "10%"} do |note_version| %>
<%= compact_time note_version.updated_at %>
<% end %>
<% if CurrentUser.is_member? %>
<% t.column "", {width: "7%"} do |note_version| %>
<%= link_to "Revert to", revert_note_path(note_version.note_id, :version_id => note_version.id), :remote => true, :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
<% end %>
<% end %>
<% end %>
</div>

View File

@@ -1,4 +1,4 @@
<div id="p-standard-listing">
<div id="p-<%= note_versions_listing_type %>-listing">
<%= table_for @note_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column %>
@@ -35,6 +35,11 @@
<% t.column "Date", {width: "10%"} do |note_version| %>
<%= compact_time note_version.updated_at %>
<% end %>
<% if note_versions_listing_type == :revert %>
<% t.column "", {width: "7%"} do |note_version| %>
<%= link_to "Revert to", revert_note_path(note_version.note_id, :version_id => note_version.id), :remote => true, :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
<% end %>
<% end %>
<% end %>
</div>

View File

@@ -2,11 +2,7 @@
<div id="a-index">
<h1>Note Changes</h1>
<% if params.dig(:search, :post_id).present? || params.dig(:search, :note_id).present? %>
<%= render "revert_listing" %>
<% else %>
<%= render "standard_listing" %>
<% end %>
<%= render "standard_listing" %>
<%= numbered_paginator(@note_versions) %>

View File

@@ -1,38 +0,0 @@
<div id="p-revert-listing">
<%= table_for @pool_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column "Pool" do |pool_version| %>
<%= link_to pool_version.pretty_name, pool_path(pool_version.pool_id), class: "pool-category-#{pool_version.pool.category}" %>
<%= link_to "»", pool_versions_path(search: { pool_id: pool_version.pool_id }), class: "pool-category-#{pool_version.pool.category}" %>
<% end %>
<% t.column "Changes", class: "col-expand" do |pool_version| %>
<%= render "pool_versions/diff", diff: pool_version.build_diff %>
<% end %>
<% t.column "Post Count" do |pool_version| %>
<%= link_to pool_version.post_ids.size, pool_versions_path(search: { pool_id: pool_version.pool_id }) %>
<% end %>
<% t.column "Desc Chg" do |pool_version| %>
<%= link_to_if pool_version.description_changed, pool_version.description_changed, diff_pool_version_path(pool_version.id) %>
<% end %>
<% t.column "Updater" do |pool_version| %>
<% if pool_version.updater %>
<%= link_to_user pool_version.updater %>
<%= link_to "»", pool_versions_path(search: { updater_id: pool_version.updater_id }) %>
<% end %>
<% end %>
<% if CurrentUser.is_moderator? %>
<% t.column "IP Address" do |pool_version| %>
<%= link_to_ip pool_version.updater_ip_addr %>
<% end %>
<% end %>
<% t.column "Date" do |pool_version| %>
<%= compact_time pool_version.updated_at %>
<% end %>
<% if CurrentUser.is_member? %>
<% t.column "" do |pool_version| %>
<%= link_to "Revert to", revert_pool_path(pool_version.pool_id, :version_id => pool_version.id), :method => :put, :remote => true %>
<% end %>
<% end %>
<% end %>
</div>

View File

@@ -1,4 +1,4 @@
<div id="p-standard-listing">
<div id="p-<%= pool_versions_listing_type %>-listing">
<%= table_for @pool_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column "Pool" do |pool_version| %>
@@ -28,6 +28,11 @@
<% t.column "Date" do |pool_version| %>
<%= compact_time pool_version.updated_at %>
<% end %>
<% if pool_versions_listing_type == :revert %>
<% t.column "" do |pool_version| %>
<%= link_to "Revert to", revert_pool_path(pool_version.pool_id, :version_id => pool_version.id), :method => :put, :remote => true %>
<% end %>
<% end %>
<% end %>
</div>

View File

@@ -2,11 +2,7 @@
<div id="a-index">
<h1>Pool History</h1>
<% if params.dig(:search, :pool_id).present? %>
<%= render "revert_listing" %>
<% else %>
<%= render "standard_listing" %>
<% end %>
<%= render "standard_listing" %>
<%= numbered_paginator(@pool_versions) %>
</div>

View File

@@ -1,5 +1,5 @@
<div id="p-<%= post_version_listing %>-listing">
<% if post_version_listing == :revert %>
<div id="p-<%= post_versions_listing_type %>-listing">
<% if post_versions_listing_type == :revert %>
<%= PostPresenter.preview(@post_versions.first.post, show_deleted: true) %>
<% end %>
@@ -9,7 +9,7 @@
<input type="checkbox" class="post-version-select-checkbox" <%= "disabled" unless post_version.can_undo?(CurrentUser.user) %>>
<% end %>
<% end %>
<% if post_version_listing == :standard %>
<% if post_versions_listing_type == :standard %>
<% t.column "Post" do |post_version| %>
<%= PostPresenter.preview(post_version.post, show_deleted: true) %>
<% end %>
@@ -34,7 +34,7 @@
<% if post_version.can_undo?(CurrentUser.user) %>
<%= link_to "Undo", undo_post_version_path(post_version), method: :put, remote: true, class: "post-version-undo-link" %>
<% end %>
<% if post_version_listing == :revert && post_version.can_revert_to?(CurrentUser.user) %>
<% if post_versions_listing_type == :revert && post_version.can_revert_to?(CurrentUser.user) %>
| <%= link_to "Revert to", revert_post_path(post_version.post_id, version_id: post_version.id), method: :put, remote: true %>
<% end %>
<% end %>

View File

@@ -1,6 +1,6 @@
<div id="c-post-versions">
<div id="a-index">
<% if post_version_listing == :revert && @post_versions.present? %>
<% if post_versions_listing_type == :revert && @post_versions.present? %>
<h1>Tag History: <%= link_to "Post ##{params.dig(:search, :post_id)}", @post_versions[0].post %></h1>
<% else %>
<h1>Tag History</h1>