pools: switch from search[name_matches] to search[name_contains].
The previous commit changed it so that `/pools?search[name_matches]` does a full-text search. So for example, `search[name_matches]=smiling` will now match pool names containing any of the words "smiling", "smile", "smiles", or "smiled". This commit adds a `/pools?search[name_contains]` param that does what `name_matches` did before, and switches to it in search forms. So for example, `search[name_contains]=smiling` will only match pool names containing the exact substring "smiling". This change is so that `<field>_matches` works consistently across the site, and so that it's possible to search pool names by either an exact substring match, or by a looser natural language match. This is a minor breaking API change. API users can replace `/pools?search[name_matches]` with `/pools?search[name_contains]` to get the same behavior as before. The same applies to /favorite_groups.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<div id="c-favorite-groups">
|
||||
<div id="a-index">
|
||||
<%= search_form_for(favorite_groups_path) do |f| %>
|
||||
<%= f.input :name_matches, label: "Name", input_html: { value: params.dig(:search, :name_matches), "data-autocomplete": "favorite-group" } %>
|
||||
<%= f.input :name_contains, label: "Name", input_html: { value: params.dig(:search, :name_contains), "data-autocomplete": "favorite-group" } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params.dig(:search, :creator_name), "data-autocomplete": "user" } %>
|
||||
<%= f.input :order, collection: [%w[Created created_at], %w[Updated updated_at], %w[Name name], %w[Post\ count post_count]], include_blank: true, selected: params.dig(:search, :order) %>
|
||||
<%= f.submit "Search" %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<%= quick_search_form_for(:name_matches, pool_versions_path, "pools", autocomplete: "pool") %>
|
||||
<%= quick_search_form_for(:name_contains, pool_versions_path, "pools", autocomplete: "pool") %>
|
||||
<%= subnav_link_to "Listing", pool_versions_path %>
|
||||
<%= subnav_link_to "Search", search_pool_versions_path %>
|
||||
<% end %>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<%= search_form_for(pool_versions_path) do |f| %>
|
||||
<%= f.input :updater_name, label: "Updater", input_html: { value: params.dig(:search, :updater_name), "data-autocomplete": "user" } %>
|
||||
<%= f.input :name_matches, label: "Pool", input_html: { value: params.dig(:search, :name_matches), "data-autocomplete": "pool" } %>
|
||||
<%= f.input :name_contains, label: "Pool", input_html: { value: params.dig(:search, :name_contains), "data-autocomplete": "pool" } %>
|
||||
<%= f.input :category, label: "Category", collection: [["Series", "series"], ["Collection", "collection"]], include_blank: true %>
|
||||
<%= f.input :is_new, label: "New?", collection: [["Yes", true], ["No", false]], include_blank: true %>
|
||||
<%= f.input :name_changed, label: "Name changed?", collection: [["Yes", true], ["No", false]], include_blank: true %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= search_form_for(path) do |f| %>
|
||||
<%= f.input :name_matches, label: "Name", input_html: { value: params.dig(:search, :name_matches), "data-autocomplete": "pool" } %>
|
||||
<%= f.input :name_contains, label: "Name", input_html: { value: params.dig(:search, :name_contains), "data-autocomplete": "pool" } %>
|
||||
<%= f.input :description_matches, label: "Description", input_html: { value: params.dig(:search, :description_matches) } %>
|
||||
<%= f.input :post_tags_match, label: "Post tags", input_html: { value: params.dig(:search, :post_tags_match), "data-autocomplete": "tag-query" } %>
|
||||
<%= f.input :is_deleted, label: "Deleted?", as: :select, include_blank: true, selected: params[:search][:is_deleted] %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<%= quick_search_form_for(:name_matches, pools_path, "pools", autocomplete: "pool", redirect: true) %>
|
||||
<%= quick_search_form_for(:name_contains, pools_path, "pools", autocomplete: "pool", redirect: true) %>
|
||||
<%= subnav_link_to "Gallery", gallery_pools_path %>
|
||||
<%= subnav_link_to "Listing", pools_path %>
|
||||
<% if policy(Pool).create? %>
|
||||
|
||||
Reference in New Issue
Block a user