post replacements: add tag match field to search form.
This commit is contained in:
@@ -69,6 +69,10 @@ class PostReplacement < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
|
def post_tags_match(query)
|
||||||
|
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||||
|
end
|
||||||
|
|
||||||
def search(params = {})
|
def search(params = {})
|
||||||
q = all
|
q = all
|
||||||
|
|
||||||
@@ -88,6 +92,10 @@ class PostReplacement < ApplicationRecord
|
|||||||
q = q.where(post_id: params[:post_id].split(",").map(&:to_i))
|
q = q.where(post_id: params[:post_id].split(",").map(&:to_i))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:post_tags_match].present?
|
||||||
|
q = q.post_tags_match(params[:post_tags_match])
|
||||||
|
end
|
||||||
|
|
||||||
q = q.order("created_at DESC")
|
q = q.order("created_at DESC")
|
||||||
|
|
||||||
q
|
q
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<%= simple_form_for(:search, url: post_replacements_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
<%= simple_form_for(:search, url: post_replacements_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||||
<%= f.input :creator_name, label: "Replacer", input_html: { value: params[:search][:creator_name] } %>
|
<%= f.input :creator_name, label: "Replacer", input_html: { value: params[:search][:creator_name] } %>
|
||||||
|
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
|
||||||
<%= f.submit "Search" %>
|
<%= f.submit "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user