saved searches: add more order options (#4171).
This commit is contained in:
@@ -104,7 +104,16 @@ class SavedSearch < ApplicationRecord
|
||||
q = q.labeled(params[:label])
|
||||
end
|
||||
|
||||
q.apply_default_order(params)
|
||||
case params[:order]
|
||||
when "query"
|
||||
q = q.order(:query).order(id: :desc)
|
||||
when "label"
|
||||
q = q.order(:labels).order(id: :desc)
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
|
||||
def populate(query, timeout: 10_000)
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
</h1>
|
||||
|
||||
<%= search_form_for(saved_searches_path) do |f| %>
|
||||
<%= f.input :query_ilike, label: "Query", input_html: { value: params[:search][:query_ilike] } %>
|
||||
<%= f.input :query_ilike, label: "Query", hint: "Use * for wildcard", input_html: { value: params[:search][:query_ilike] } %>
|
||||
<%= f.input :label, label: "Label", input_html: { value: params[:search][:label] } %>
|
||||
<%= f.input :order, collection: [%w[Newest id], %w[Query query], %w[Label label]], include_blank: false, selected: params[:search][:order] %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user