/post_versions: add search form, tweak layout.

* Add search form above table.
* Move thumbnail to left of table when viewing history of single post.
* Remove unrelated links from subnav menu.
* Fix bugs with changed_tags search.
This commit is contained in:
evazion
2019-09-28 23:16:50 -05:00
parent e3b49a2a6d
commit dade1e67b0
6 changed files with 30 additions and 11 deletions

View File

@@ -6,4 +6,13 @@ body.c-post-versions.a-index {
.post-version-select-column {
min-width: 2em;
}
.advanced-search-link {
margin: 0 1em;
}
#p-revert-listing {
display: flex;
table#post-versions-table { flex: 1; }
}
}

View File

@@ -183,7 +183,7 @@ class ApplicationRecord < ActiveRecord::Base
relation = relation.where_array_includes_any(name, items)
elsif params[:"#{name}_include_all"]
items = params[:"#{name}_include_any"].to_s.scan(/[^[:space:]]+/)
items = params[:"#{name}_include_all"].to_s.scan(/[^[:space:]]+/)
items = items.map(&:to_i) if type == :integer
relation = relation.where_array_includes_all(name, items)

View File

@@ -1,5 +1,9 @@
<div id="p-<%= post_version_listing %>-listing">
<table class="striped autofit">
<% if post_version_listing == :revert %>
<%= PostPresenter.preview(@post_versions.first.post, show_deleted: true) %>
<% end %>
<table id="post-versions-table" class="striped autofit">
<thead>
<tr>
<% if CurrentUser.user.is_builder? %>
@@ -33,7 +37,7 @@
<td class="col-expand"><%= post_version_diff(post_version) %></td>
<td>
<%= link_to_user post_version.updater %>
<%= link_to "»", post_versions_path(search: { updater_name: post_version.updater&.name }) %>
<%= link_to "»", post_versions_path(search: params[:search].merge({ updater_name: post_version.updater&.name })) %>
<div>
<%= compact_time(post_version.updated_at) %>
<% if CurrentUser.is_moderator? %>

View File

@@ -1,10 +1,7 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:changed_tags, post_versions_path, "versions", autocomplete: "tag-query") %>
<%= subnav_link_to "Listing", posts_path %>
<%= subnav_link_to "Upload", new_upload_path %>
<%= quick_search_form_for(:changed_tags, post_versions_path, "by tags", autocomplete: "tag-query") %>
<%= subnav_link_to "Listing", post_versions_path %>
<%= subnav_link_to "Search", search_post_versions_path %>
<%= subnav_link_to "Changes", post_versions_path %>
<%= subnav_link_to "Help", wiki_pages_path(:title => "help:posts") %>
<% if params[:action] == "index" %>
| <%= subnav_link_to "Undo selected", "" %>
<% end %>

View File

@@ -1,12 +1,21 @@
<div id="c-post-versions">
<div id="a-index">
<% if post_version_listing == :revert %>
<% if post_version_listing == :revert && @post_versions.present? %>
<h1>Tag History: <%= link_to "Post ##{params.dig(:search, :post_id)}", @post_versions[0].post %></h1>
<%= PostPresenter.preview(@post_versions[0].post, show_deleted: true) %>
<% else %>
<h1>Tag History</h1>
<% end %>
<%= search_form_for(post_versions_path, classes: "inline-form") do |f| %>
<%= f.input :post_id, label: "Post", input_html: { value: params.dig(:search, :post_id) } %>
<%= f.input :updater_name, label: "Updater", input_html: { "data-autocomplete": "user", value: params.dig(:search, :updater_name) } %>
<%= f.input :added_tags_include_all, label: "Added Tags", input_html: { "data-autocomplete": "tag-query", value: params.dig(:search, :added_tags_include_all) } %>
<%= f.input :removed_tags_include_all, label: "Removed Tags", input_html: { "data-autocomplete": "tag-query", value: params.dig(:search, :removed_tags_include_all) } %>
<%= f.input :changed_tags, label: "Changed Tags", input_html: { "data-autocomplete": "tag-query", value: params.dig(:search, :changed_tags) } %>
<%= f.submit "Search" %>
<%= link_to "Advanced", search_post_versions_path, class: "advanced-search-link" %>
<% end %>
<%= render "posts/partials/common/inline_blacklist" %>
<p class="fineprint">Recent updates may not have been processed yet. The most recently processed version was <%= time_ago_in_words_tagged(PostArchive.maximum(:updated_at)) %>.</p>

View File

@@ -5,9 +5,9 @@
<%= search_form_for(post_versions_path) do |f| %>
<%= f.input :updated_at, label: "Date" %>
<%= f.input :updater_name, label: "Updater", input_html: { "data-autocomplete": "user" } %>
<%= f.input :changed_tags_include_all, label: "Changed tags", input_html: { "data-autocomplete": "tag-query" } %>
<%= f.input :added_tags_include_all, label: "Added tags", input_html: { "data-autocomplete": "tag-query" } %>
<%= f.input :removed_tags_include_all, label: "Removed tags", input_html: { "data-autocomplete": "tag-query" } %>
<%= f.input :changed_tags, label: "Changed tags", input_html: { "data-autocomplete": "tag-query" } %>
<%= f.input :post_id %>
<%= f.input :parent_id %>
<%= f.input :rating %>