Merge pull request #4369 from BrokenEagle/post-version-fixes

Various post version fixes
This commit is contained in:
evazion
2020-04-04 02:55:37 -05:00
committed by GitHub
9 changed files with 119 additions and 53 deletions

View File

@@ -3,34 +3,44 @@
<%= PostPresenter.preview(@post_versions.first.post, show_deleted: true) %>
<% end %>
<%= table_for @post_versions, {id: "post-versions-table", class: "striped autofit"} do |t| %>
<%= table_for @post_versions, id: "post-versions-table", class: "striped autofit", width: "100%" do |t| %>
<% if policy(@post_versions).can_mass_undo? %>
<% t.column tag.label(tag.input type: :checkbox, id: "post-version-select-all-checkbox", class: "post-version-select-checkbox"), column: "post-version-select" do |post_version| %>
<% t.column tag.label(tag.input type: :checkbox, id: "post-version-select-all-checkbox", class: "post-version-select-checkbox"), column: "post-version-select", width: "1%" do |post_version| %>
<input type="checkbox" class="post-version-select-checkbox" <%= "disabled" unless policy(post_version).undo? %>>
<% end %>
<% end %>
<% if listing_type(:post_id) == :standard %>
<% t.column "Post" do |post_version| %>
<% t.column "Post", width: "1%" 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}") %>
<% t.column "Version", width: "1%" do |post_version| %>
<%= link_to "#{post_version.post_id}.#{post_version.version}", post_versions_path(search: { post_id: post_version.post_id }, type: params[:type], anchor: "post-version-#{post_version.id}") %>
<% end %>
<% t.column "Tags", td: {class: "col-expand"} do |post_version| %>
<% t.column "Tags", td: {class: "col-expand"}, width: "40%" do |post_version| %>
<div>
<%= post_version_field(post_version, :rating) %>
<%= post_version_field(post_version, :parent_id) %>
</div>
<div><b>Tags:</b> <%= TagSetPresenter.new(post_version.tag_array).inline_tag_list_html %></div>
<div>
<%= post_version_field(post_version, :source) %>
</div>
<% end %>
<% t.column "Edits", td: {class: "col-expand"}, width: "40%" do |post_version| %>
<%= post_version_diff(post_version, params[:type]) %>
<% end %>
<% t.column "Changes" do |post_version| %>
<% t.column "Changes", width: "5%" do |post_version| %>
<%= status_diff_html(post_version, params[:type]) %>
<% end %>
<% t.column "Updated" do |post_version| %>
<% t.column "Updated", width: "5%" do |post_version| %>
<%= link_to_user post_version.updater %>
<%= link_to "»", post_versions_path(search: params[:search].merge({ updater_name: post_version.updater&.name })) %>
<div>
<%= compact_time(post_version.updated_at) %>
</div>
<% end %>
<% t.column do |post_version| %>
<% t.column column: "action", width: "5%" do |post_version| %>
<% if policy(post_version).undo? %>
<%= link_to "Undo", undo_post_version_path(post_version), method: :put, remote: true, class: "post-version-undo-link" %>
<% end %>

View File

@@ -15,7 +15,7 @@
<%= 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" %>
<%= link_to "Advanced", search_post_versions_path(params.except(:controller, :action, :index, :commit, :type).permit!), class: "advanced-search-link" %>
<% end %>
<%= render "posts/partials/common/inline_blacklist" %>

View File

@@ -3,19 +3,21 @@
<h1>Search Changes</h1>
<%= 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 :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 %>
<%= f.input :source_ilike, label: "Source", hint: "Use * for wildcard" %>
<%= f.input :version %>
<%= f.input :rating_changed, as: :select %>
<%= f.input :parent_changed, as: :select %>
<%= f.input :source_changed, as: :select %>
<%= f.input :updated_at, label: "Date", input_html: { value: params.dig(:search, :updated_at) } %>
<%= f.input :updater_name, label: "Updater", input_html: { value: params.dig(:search, :updater_name), "data-autocomplete": "user" } %>
<%= f.input :added_tags_include_all, label: "Added tags", input_html: { value: params.dig(:search, :added_tags_include_all), "data-autocomplete": "tag-query" } %>
<%= f.input :removed_tags_include_all, label: "Removed tags", input_html: { value: params.dig(:search, :removed_tags_include_all), "data-autocomplete": "tag-query" } %>
<%= f.input :changed_tags, label: "Changed tags", input_html: { value: params.dig(:search, :changed_tags), "data-autocomplete": "tag-query" } %>
<%= f.input :post_id, input_html: { value: params.dig(:search, :post_id) } %>
<%= f.input :parent_id, input_html: { value: params.dig(:search, :parent_id) } %>
<%= f.input :rating, input_html: { value: params.dig(:search, :rating) } %>
<%= f.input :source_ilike, label: "Source", input_html: { value: params.dig(:search, :source_ilike) }, hint: "Use * for wildcard" %>
<%= f.input :tag_matches, input_html: { value: params.dig(:search, :tag_matches) }, hint: "Single tag, use * for wildcard" %>
<%= f.input :version, input_html: { value: params.dig(:search, :version) } %>
<%= f.input :is_new, label: "Include uploads?", collection: [["Yes", nil], ["No", false], ["Only", true]], include_blank: false, selected: params.dig(:search, :is_new), hint: "I.e. the 1st version of a post" %>
<%= f.input :rating_changed, as: :select, include_blank: true, selected: params.dig(:search, :rating_changed) %>
<%= f.input :parent_changed, as: :select, include_blank: true, selected: params.dig(:search, :parent_changed) %>
<%= f.input :source_changed, as: :select, include_blank: true, selected: params.dig(:search, :source_changed) %>
<%= f.submit "Search" %>
<% end %>
</div>