comments: put search form on same page as search results.

* Remove the /comment/search page. Instead put the comment search form
  on the same page as the search results, so you don't have to go back
  and forth to update your search.
* Add an "Edited?" search option, for finding comments that have been edited.
* Add options for sorting by oldest comments and lowest scoring comments.
This commit is contained in:
evazion
2022-09-22 20:56:10 -05:00
parent 0dd57a933b
commit dff27e3a3a
8 changed files with 42 additions and 30 deletions

View File

@@ -1,5 +1,19 @@
<div id="p-index-by-comment" class="comments-for-post">
<div class="list-of-comments list-of-messages">
<%= search_form_for(comments_path) do |f| %>
<%= hidden_field_tag "group_by", "comment", :id => "group_by_full" %>
<%= f.input :creator_name, label: "Commenter", input_html: { value: params[:search][:creator_name], "data-autocomplete": "user" } %>
<%= f.input :body_matches, label: "Text", input_html: { value: params[:search][:body_matches] } %>
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], "data-autocomplete": "tag-query" } %>
<%= f.input :score, input_html: { value: params[:search][:score] } %>
<%= f.input :is_edited, label: "Edited?", collection: %w[Yes No], include_blank: true, selected: params[:search][:is_edited] %>
<%= f.input :is_deleted, label: "Deleted?", collection: %w[Yes No], include_blank: true, selected: params[:search][:is_deleted] %>
<%= f.input :is_sticky, label: "Stickied?", collection: %w[Yes No], include_blank: true, selected: params[:search][:is_sticky] %>
<%= f.input :do_not_bump_post, label: "Bumped?", collection: [["Yes", false], ["No", true]], include_blank: true, selected: params[:search][:do_not_bump_post] %>
<%= f.input :order, collection: [["Newest", "id_desc"], ["Oldest", "id_asc"], ["Updated", "updated_at_desc"], ["Score (highest)", "score_desc"], ["Score (lowest)", "score_asc"]], include_blank: true, selected: params[:search][:order] %>
<%= f.submit "Search" %>
<% end %>
<% dtext_data = DText.preprocess(@comments.map(&:body)) %>
<% @comments.each do |comment| %>

View File

@@ -1,7 +1,7 @@
<% content_for(:secondary_links) do %>
<%= quick_search_form_for(:body_matches, comments_path, "comments") %>
<%= subnav_link_to "Listing", comments_path(:group_by => "post") %>
<%= subnav_link_to "Search", search_comments_path %>
<%= subnav_link_to "Search", comments_path(group_by: "comment") %>
<% if policy(CommentVote).can_see_votes? %>
<%= subnav_link_to "Votes", comment_votes_path %>
<% end %>

View File

@@ -1,20 +0,0 @@
<div id="c-comments">
<div id="a-search">
<h1>Search Comments</h1>
<%= search_form_for(comments_path) do |f| %>
<%= hidden_field_tag "group_by", "comment", :id => "group_by_full" %>
<%= f.input :creator_name, label: "Commenter", input_html: { data: { autocomplete: "user" } } %>
<%= f.input :body_matches, label: "Text" %>
<%= f.input :post_tags_match, label: "Tags", input_html: { data: { autocomplete: "tag-query" } } %>
<%= f.input :score %>
<%= f.input :is_deleted, label: "Deleted?", collection: [["Yes", true], ["No", false]] %>
<%= f.input :is_sticky, label: "Sticky?", collection: [["Yes", true], ["No", false]] %>
<%= f.input :do_not_bump_post, label: "Bumping?", collection: [["Yes", false], ["No", true]] %>
<%= f.input :order, collection: [%w(Created id_desc), %w(Updated updated_at_desc), %w(Score score_desc), %w(Post post_id_desc)] %>
<%= f.submit "Search" %>
<% end %>
</div>
</div>
<%= render "secondary_links" %>