saved searches: add more order options (#4171).
This commit is contained in:
@@ -104,7 +104,16 @@ class SavedSearch < ApplicationRecord
|
|||||||
q = q.labeled(params[:label])
|
q = q.labeled(params[:label])
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def populate(query, timeout: 10_000)
|
def populate(query, timeout: 10_000)
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<%= search_form_for(saved_searches_path) do |f| %>
|
<%= 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 :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" %>
|
<%= f.submit "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user