Commit ede7167b authored by BrokenEagle's avatar BrokenEagle

Rework pool versions index/diff views

- Changed to using the diff-body CSS class
-- Removed unneeded CSS style file
- Removed trailing whitespace after the >>> link
-- It was causing artifact line-throughs to appear after the link
- Changed the diff link to only render when a text field has changed
-- Because the post changes are already shown on the index view
- Specifically add <br> to statuses to cause line breaks
parent d62f7e78
module PoolVersionsHelper
def pool_versions_listing_type
params.dig(:search, :pool_id).present? ? :revert : :standard
end
def pool_version_status_diff(pool_version)
cur = pool_version
prev = pool_version.previous
return "New" if prev.blank?
status = []
status += ["Renamed"] if cur.name != prev.name
status += ["DescChanged"] if cur.description != prev.description
status += ["Deleted"] if cur.is_deleted? && !prev.is_deleted?
status += ["Undeleted"] if !cur.is_deleted? && prev.is_deleted?
status += ["Activated"] if cur.is_active? && !prev.is_active?
status += ["Deactivated"] if !cur.is_active? && prev.is_active?
status.join(" ")
end
def pool_page_diff(pool_version, other_version)
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
DiffBuilder.new(pool_version.description, other_version.description, pattern).build
end
end
div#c-pool-versions {
#a-diff {
del {
background: var(--wiki-page-versions-diff-del-background);
text-decoration: none;
}
ins {
background: var(--wiki-page-versions-diff-ins-background);
text-decoration: none;
}
span.paragraph-mark {
opacity: 0.25;
}
}
}
\ No newline at end of file
......@@ -114,6 +114,37 @@ class PoolArchive < ApplicationRecord
@previous.first
end
def self.status_fields
{
name: "Renamed",
description: "Description",
was_deleted: "Deleted",
was_undeleted: "Undeleted",
was_activated: "Activated",
was_deactivated: "Deactivated",
}
end
def was_deleted
is_deleted && !previous.is_deleted
end
def was_undeleted
!is_deleted && previous.is_deleted
end
def was_activated
is_active && !previous.is_active
end
def was_deactivated
!is_active && previous.is_active
end
def text_field_changed
previous.present? && (name_changed || description_changed)
end
def pretty_name
name.tr("_", " ")
end
......
......@@ -11,7 +11,7 @@
<% diff[:removed_post_ids].each do |post_id| %>
<del>
<%= link_to post_id, post_path(post_id) %><%#
%><%= link_to "»", pool_versions_path(search: { post_id: post_id }) %>
</del>
%><%= link_to "»", pool_versions_path(search: { post_id: post_id }) %><%#
%></del>
<% end %>
</span>
<div id="p-<%= pool_versions_listing_type %>-listing">
<div id="p-<%= listing_type(:pool_id) %>-listing">
<%= table_for @pool_versions, {class: "striped autofit", width: "100%"} do |t| %>
<% t.column column: "diff", width: "3%" do |pool_version| %>
<%= link_to_if pool_version.previous.present?, "diff", diff_pool_version_path(pool_version.id) %>
<%= link_to_if pool_version.text_field_changed, "diff", diff_pool_version_path(pool_version.id) %>
<% end %>
<% 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}" %>
<%= link_to "»", pool_versions_path(search: { pool_id: pool_version.pool_id }, anchor: "pool-archive-#{pool_version.id}"), class: "pool-category-#{pool_version.pool.category}" %>
<% end %>
<% t.column "Post Changes", td: { class: "col-expand" } do |pool_version| %>
<%= render "pool_versions/diff", diff: pool_version.build_diff %>
......@@ -14,19 +14,18 @@
<% 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 "Status", td: {class: "col-expand"} do |pool_version| %>
<%= pool_version_status_diff(pool_version) %>
<% t.column "Changes", td: {class: "col-expand"} do |pool_version| %>
<%= status_diff_html(pool_version) %>
<% 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 %>
<% t.column "Date" do |pool_version| %>
<%= compact_time pool_version.updated_at %>
<% t.column "Updated", width: "10%" do |pool_version| %>
<div>
<%= compact_time pool_version.updated_at %>
</div>
by
<%= link_to_user pool_version.updater %>
<%= link_to "»", pool_versions_path(search: params[:search].merge({ updater_id: pool_version.updater_id })) %>
<% end %>
<% if pool_versions_listing_type == :revert %>
<% if listing_type(:pool_id) == :revert %>
<% t.column column: "control" do |pool_version| %>
<%= link_to "Revert to", revert_pool_path(pool_version.pool_id, :version_id => pool_version.id), :method => :put, :remote => true %>
<% end %>
......
......@@ -7,7 +7,7 @@
<% if @other_version.present? %>
<p>Showing differences between <%= compact_time @pool_version.updated_at %> (<%= link_to_user @pool_version.updater %>) and <%= compact_time @other_version.updated_at %> (<%= link_to_user @other_version.updater %>)</p>
<div>
<div class="diff-body">
<h2>Name:</h2>
<p>
<% if @pool_version.name != @other_version.name %>
......@@ -21,11 +21,11 @@
<h2>Posts:</h2>
<p><%= render "pool_versions/diff", diff: @pool_version.build_diff(@other_version) %></p>
</div>
<div>
<div class="diff-body">
<h2>Description:</h2>
<p>
<% if @pool_version.description != @other_version.description %>
<%= pool_page_diff(@pool_version, @other_version) %>
<%= diff_body_html(@pool_version, @other_version, :description) %>
<% else %>
<i>Unchanged.</i>
<% 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