Files
danbooru/app/views/favorite_groups/index.html.erb
evazion 29a4ca0818 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.
2022-09-22 01:52:13 -05:00

41 lines
2.0 KiB
Plaintext

<div id="c-favorite-groups">
<div id="a-index">
<%= search_form_for(favorite_groups_path) do |f| %>
<%= 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" %>
<% end %>
<%= table_for @favorite_groups, width: "100%" do |t| %>
<% t.column "Name", width: "60%" do |favgroup| %>
<%= link_to favgroup.pretty_name, favorite_group_path(favgroup) %>
<% if favgroup.post_count > CurrentUser.user.per_page %>
<%= link_to "page #{favgroup.last_page}", favorite_group_path(favgroup, :page => favgroup.last_page), :class => "last-page" %>
<% end %>
<% end %>
<% t.column :post_count %>
<% t.column "Creator" do |favgroup| %>
<%= link_to_user favgroup.creator %>
<%= link_to "»", favorite_groups_path(search: { creator_name: favgroup.creator.name }) %>
<% end %>
<% t.column "Created" do |favgroup| %>
<%= time_ago_in_words_tagged(favgroup.created_at) %>
<% end %>
<% t.column "Updated" do |favgroup| %>
<%= time_ago_in_words_tagged(favgroup.updated_at) %>
<% end %>
<% t.column column: "control" do |favgroup| %>
<% if policy(favgroup).update? %>
<%= link_to "Edit", edit_favorite_group_path(favgroup) %> |
<%= link_to "Delete", favorite_group_path(favgroup), method: :delete, remote: true, "data-confirm": "Are you sure you want to delete this favgroup? This cannot be undone." %>
<% end %>
<% end %>
<% end %>
<%= numbered_paginator(@favorite_groups) %>
<%= render "secondary_links" %>
</div>
</div>