commentaries: move search form to /artist_commentaries page.

* Move the commentary search form to the /artist_commentaries page.
* Add Order field for changing the sort order.
This commit is contained in:
evazion
2022-06-05 14:15:18 -05:00
parent 05df3a194c
commit 907194fc6f
6 changed files with 30 additions and 6 deletions

View File

@@ -56,10 +56,26 @@ class ArtistCommentary < ApplicationRecord
q = q.where("(translated_title = '') and (translated_description = '')")
end
q = q.deleted if params[:is_deleted] == "yes"
q = q.undeleted if params[:is_deleted] == "no"
if params[:is_deleted].to_s.truthy?
q = q.deleted
elsif params[:is_deleted].to_s.falsy?
q = q.undeleted
end
q.apply_default_order(params)
case params[:order]
when "id_asc"
q = q.order(id: :asc)
when "post_id", "post_id_desc"
q = q.order(post_id: :desc)
when "post_id_asc"
q = q.order(post_id: :asc)
when "updated_at", "updated_at_desc"
q = q.order(updated_at: :desc, id: :desc)
when "updated_at_asc"
q = q.order(updated_at: :asc, id: :asc)
else
q = q.apply_default_order(params)
end
end
end