Rework post version view
- Added a changes column explicitly listing all of the changes -- This makes it more in line with the other views now
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
module PostVersionsHelper
|
||||
def post_versions_listing_type
|
||||
params.dig(:search, :post_id).present? ? :revert : :standard
|
||||
end
|
||||
|
||||
def post_version_diff(post_version)
|
||||
diff = post_version.diff(post_version.previous)
|
||||
html = '<span class="diff-list">'
|
||||
|
||||
@@ -10,9 +10,4 @@ body.c-post-versions.a-index {
|
||||
.advanced-search-link {
|
||||
margin: 0 1em;
|
||||
}
|
||||
|
||||
#p-revert-listing {
|
||||
display: flex;
|
||||
table#post-versions-table { flex: 1; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,15 @@ class PostArchive < ApplicationRecord
|
||||
post&.visible?
|
||||
end
|
||||
|
||||
def self.status_fields
|
||||
{
|
||||
tags: "Tags",
|
||||
rating: "Rating",
|
||||
parent_id: "Parent",
|
||||
source: "Source",
|
||||
}
|
||||
end
|
||||
|
||||
def diff(version = nil)
|
||||
if post.nil?
|
||||
latest_tags = tag_array
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="p-<%= post_versions_listing_type %>-listing">
|
||||
<% if post_versions_listing_type == :revert %>
|
||||
<div id="p-<%= listing_type(:post_id) %>-listing">
|
||||
<% if listing_type(:post_id) == :revert %>
|
||||
<%= PostPresenter.preview(@post_versions.first.post, show_deleted: true) %>
|
||||
<% end %>
|
||||
|
||||
@@ -9,17 +9,20 @@
|
||||
<input type="checkbox" class="post-version-select-checkbox" <%= "disabled" unless post_version.can_undo?(CurrentUser.user) %>>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if post_versions_listing_type == :standard %>
|
||||
<% if listing_type(:post_id) == :standard %>
|
||||
<% t.column "Post" do |post_version| %>
|
||||
<%= PostPresenter.preview(post_version.post, show_deleted: true) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% t.column "Version" do |post_version| %>
|
||||
<%= link_to "#{post_version.post_id}.#{post_version.version}", post_versions_path(search: { post_id: post_version.post_id }, anchor: "post-version-#{post_version.id}") %>
|
||||
<%= link_to "#{post_version.post_id}.#{post_version.version}", post_versions_path(search: { post_id: post_version.post_id }, anchor: "post-archive-#{post_version.id}") %>
|
||||
<% end %>
|
||||
<% t.column "Tags", td: {class: "col-expand"} do |post_version| %>
|
||||
<%= post_version_diff(post_version) %>
|
||||
<% end %>
|
||||
<% t.column "Changes" do |post_version| %>
|
||||
<%= status_diff_html(post_version) %>
|
||||
<% end %>
|
||||
<% t.column "Updated" do |post_version| %>
|
||||
<%= link_to_user post_version.updater %>
|
||||
<%= link_to "»", post_versions_path(search: params[:search].merge({ updater_name: post_version.updater&.name })) %>
|
||||
@@ -31,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_versions_listing_type == :revert && post_version.can_revert_to?(CurrentUser.user) %>
|
||||
<% if listing_type(:post_id) == :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 %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div id="c-post-versions">
|
||||
<div id="a-index">
|
||||
<% if post_versions_listing_type == :revert && @post_versions.present? %>
|
||||
<% if listing_type(:post_id) == :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>
|
||||
|
||||
Reference in New Issue
Block a user