Fix #1898: Include alias predicates in non-empty Tags search.

Make searches on the /tags index includes aliases too. Show matching
aliases like this:

   Name: gray*

   ? 75098 grey_hair <- gray_hair
   ? 35345 grey_eyes <- gray_eyes
This commit is contained in:
evazion
2020-02-23 00:20:09 -06:00
parent a8e5412d9c
commit a181e6d0db
5 changed files with 26 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
<%= search_form_for(tags_path) do |f| %>
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches], data: { autocomplete: "tag" } } %>
<%= f.input :name_or_alias_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_or_alias_matches], data: { autocomplete: "tag" } } %>
<%= f.input :category, label: "Category", collection: TagCategory.canonical_mapping.to_a, include_blank: true,selected: params[:search][:category] %>
<%= f.input :order, collection: [%w[Newest date], %w[Count count], %w[Name name]], include_blank: false, selected: params[:search][:order] %>
<%= f.input :hide_empty, label: "Hide empty?", collection: %w[yes no], selected: params[:search][:hide_empty] %>

View File

@@ -9,6 +9,13 @@
<% t.column "Name", td: {class: "col-expand"} do |tag| %>
<%= link_to_wiki "?", tag.name, class: tag_class(tag) %>
<%= link_to tag.name, posts_path(tags: tag.name), class: tag_class(tag) %>
<% pattern = params.dig(:search, :name_or_alias_matches).to_s %>
<% tag_alias = tag.consequent_aliases.find { |tag_alias| tag_alias.antecedent_name.ilike?(pattern) } %>
<% if tag_alias.present? %>
← <%= link_to tag_alias.antecedent_name, tag_alias, class: "fineprint" %>
<% end %>
<% end %>
<% t.column column: "control" do |tag| %>
<%= link_to_if tag.editable_by?(CurrentUser.user), "Edit", edit_tag_path(tag) %> |