commentaries: move search form to /artist_commentaries page.
* Move the commentary search form to the /artist_commentaries page. * Add Order field for changing the sort order.
This commit is contained in:
@@ -56,10 +56,26 @@ class ArtistCommentary < ApplicationRecord
|
||||
q = q.where("(translated_title = '') and (translated_description = '')")
|
||||
end
|
||||
|
||||
q = q.deleted if params[:is_deleted] == "yes"
|
||||
q = q.undeleted if params[:is_deleted] == "no"
|
||||
if params[:is_deleted].to_s.truthy?
|
||||
q = q.deleted
|
||||
elsif params[:is_deleted].to_s.falsy?
|
||||
q = q.undeleted
|
||||
end
|
||||
|
||||
q.apply_default_order(params)
|
||||
case params[:order]
|
||||
when "id_asc"
|
||||
q = q.order(id: :asc)
|
||||
when "post_id", "post_id_desc"
|
||||
q = q.order(post_id: :desc)
|
||||
when "post_id_asc"
|
||||
q = q.order(post_id: :asc)
|
||||
when "updated_at", "updated_at_desc"
|
||||
q = q.order(updated_at: :desc, id: :desc)
|
||||
when "updated_at_asc"
|
||||
q = q.order(updated_at: :asc, id: :asc)
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<%= quick_search_form_for(:text_matches, artist_commentaries_path, "commentaries") %>
|
||||
<%= subnav_link_to "Search", search_artist_commentaries_path %>
|
||||
<%= subnav_link_to "Listing", artist_commentaries_path %>
|
||||
<%= subnav_link_to "Recent changes", artist_commentary_versions_path %>
|
||||
<%= subnav_link_to "Translation requests", artist_commentaries_path(:search => {:post_tags_match => "commentary_request"}) %>
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
<div id="a-index">
|
||||
<h1>Artist Commentary</h1>
|
||||
|
||||
<%= search_form_for(artist_commentaries_path) do |f| %>
|
||||
<%= f.input :text_matches, label: "Text", input_html: { value: params[:search][:text_matches] } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { data: { autocomplete: "tag-query" }, value: params[:search][:post_tags_match] } %>
|
||||
<%= f.input :original_present, label: "Original?", collection: ["Yes", "No"], include_blank: true, selected: params[:search][:original_present] %>
|
||||
<%= f.input :translated_present, label: "Translated?", collection: ["Yes", "No"], include_blank: true, selected: params[:search][:translated_present] %>
|
||||
<%= f.input :is_deleted, label: "Deleted?", collection: ["Yes", "No"], include_blank: true, selected: params[:search][:is_deleted] %>
|
||||
<%= f.input :order, collection: [%w[Newest id], %w[Oldest id_asc], %w[Updated updated_at_desc], %w[Uploaded post_id_desc]], include_blank: true, selected: params[:search][:order] %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
<%= render "posts/partials/common/inline_blacklist" %>
|
||||
|
||||
<%= table_for @commentaries, width: "100%" do |t| %>
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
<li><h2>Artist commentary</h2></li>
|
||||
<li><%= link_to_wiki "Help", "help:artist_commentary" %></li>
|
||||
<li><%= link_to("Listing", artist_commentaries_path) %></li>
|
||||
<li><%= link_to("Search", search_artist_commentaries_path) %></li>
|
||||
<li><%= link_to("Changes", artist_commentary_versions_path) %></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -227,7 +227,6 @@ Rails.application.routes.draw do
|
||||
resources :artist_commentaries, :only => [:index, :show] do
|
||||
collection do
|
||||
put :create_or_update
|
||||
get :search
|
||||
end
|
||||
member do
|
||||
put :revert
|
||||
|
||||
@@ -25,6 +25,7 @@ class ArtistCommentariesControllerTest < ActionDispatch::IntegrationTest
|
||||
should respond_to_search(original_present: "true").with { [@other_commentary, @commentary] }
|
||||
should respond_to_search(translated_present: "true").with { @commentary }
|
||||
should respond_to_search(is_deleted: "yes").with { @deleted_commentary }
|
||||
should respond_to_search(order: "id_asc").with { [@commentary, @other_commentary, @deleted_commentary] }
|
||||
|
||||
context "using includes" do
|
||||
should respond_to_search(post_id: 999).with { @commentary }
|
||||
|
||||
Reference in New Issue
Block a user