Fix #5211: Using tab to autocomplete tags in tag implication/alias search adds a space making it return no results.
Fix the alias and implication search forms not normalizing tags before search.
This commit is contained in:
@@ -70,6 +70,14 @@ class TagRelationship < ApplicationRecord
|
||||
where_ilike(:antecedent_name, name).or(where_ilike(:consequent_name, name))
|
||||
end
|
||||
|
||||
def consequent_name_matches(name)
|
||||
where_like(:consequent_name, Tag.normalize_name(name))
|
||||
end
|
||||
|
||||
def antecedent_name_matches(name)
|
||||
where_like(:antecedent_name, Tag.normalize_name(name))
|
||||
end
|
||||
|
||||
def status_matches(status)
|
||||
where(status: status.downcase)
|
||||
end
|
||||
@@ -81,6 +89,14 @@ class TagRelationship < ApplicationRecord
|
||||
q = q.name_matches(params[:name_matches])
|
||||
end
|
||||
|
||||
if params[:consequent_name_matches].present?
|
||||
q = q.consequent_name_matches(params[:consequent_name_matches])
|
||||
end
|
||||
|
||||
if params[:antecedent_name_matches].present?
|
||||
q = q.antecedent_name_matches(params[:antecedent_name_matches])
|
||||
end
|
||||
|
||||
if params[:status].present?
|
||||
q = q.status_matches(params[:status])
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<%# url %>
|
||||
|
||||
<%= search_form_for(url) do |f| %>
|
||||
<%= f.input :antecedent_name_ilike, label: "From", input_html: { value: params[:search][:antecedent_name_ilike], data: { autocomplete: "tag" } } %>
|
||||
<%= f.input :consequent_name_ilike, label: "To", input_html: { value: params[:search][:consequent_name_ilike], data: { autocomplete: "tag" } } %>
|
||||
<%= f.input :antecedent_name_matches, label: "From", input_html: { value: params[:search][:antecedent_name_matches], data: { autocomplete: "tag" } } %>
|
||||
<%= f.input :consequent_name_matches, label: "To", input_html: { value: params[:search][:consequent_name_matches], data: { autocomplete: "tag" } } %>
|
||||
<%= f.input :reason_ilike, label: "Reason", input_html: { value: params[:search][:reason_ilike] } %>
|
||||
<%= f.simple_fields_for :antecedent_tag do |fa| %>
|
||||
<%= fa.input :category, label: "From Category", collection: TagCategory.canonical_mapping.to_a, include_blank: true, selected: params.dig(:search, :antecedent_tag, :category) %>
|
||||
|
||||
Reference in New Issue
Block a user