diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index 4978e0c0e..841aa80d2 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -82,7 +82,14 @@ class ModAction < ApplicationRecord q = search_attributes(params, :id, :created_at, :updated_at, :category, :description, :creator) q = q.text_attribute_matches(:description, params[:description_matches]) - q.apply_default_order(params) + case params[:order] + when "created_at_asc" + q = q.order(created_at: :asc, id: :asc) + else + q = q.apply_default_order(params) + end + + q end def category_id diff --git a/app/views/mod_actions/_search.html.erb b/app/views/mod_actions/_search.html.erb index 7f6f30a0b..f9000b1a7 100644 --- a/app/views/mod_actions/_search.html.erb +++ b/app/views/mod_actions/_search.html.erb @@ -1,6 +1,7 @@ <%= search_form_for(mod_actions_path) do |f| %> <%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %> - <%= f.input :description_matches, label: "Description" %> + <%= f.input :description_matches, label: "Description", input_html: { value: params[:search][:description_matches] } %> <%= f.input :category, label: "Category", collection: ModAction.categories.map {|k,v| [k.capitalize.tr("_"," "), v]}, include_blank: true,selected: params[:search][:category] %> + <%= f.input :order, collection: [%w[Newest created_at], %w[Oldest created_at_asc]], include_blank: true, selected: params[:search][:order] %> <%= f.submit "Search" %> <% end %> diff --git a/app/views/mod_actions/index.html.erb b/app/views/mod_actions/index.html.erb index f5533704b..5bc064a9f 100644 --- a/app/views/mod_actions/index.html.erb +++ b/app/views/mod_actions/index.html.erb @@ -5,14 +5,16 @@ <%= render "search" %> <%= table_for @mod_actions, class: "striped autofit" do |t| %> + <% t.column "Message", td: {class: "col-expand"} do |mod_action| %> +
+ <%= link_to_user mod_action.creator %> <%= format_text(mod_action.description.chomp(".").strip, inline: true) %>. +
+ <% end %> + <% t.column "Category" do |mod_action| %> <%= link_to mod_action.category.humanize, mod_actions_path(search: { category: mod_action.category_id }) %> <% end %> - <% t.column "Message", td: {class: "col-expand"} do |mod_action| %> -
- <%= format_text(mod_action.description) %> -
- <% end %> + <% t.column "Created" do |mod_action| %> <%= link_to_user mod_action.creator %> <%= link_to "ยป", mod_actions_path(search: { creator_name: mod_action.creator.name }) %> diff --git a/app/views/user_actions/index.html.erb b/app/views/user_actions/index.html.erb index 9d0d23ea5..d4c672cd9 100644 --- a/app/views/user_actions/index.html.erb +++ b/app/views/user_actions/index.html.erb @@ -62,7 +62,7 @@ <% end %> <% when "ModAction" %>
- <%= link_to_user user %> <%= format_text(model.description, inline: true) %>. + <%= link_to_user user %> <%= format_text(model.description.chomp(".").strip, inline: true) %>.
<% when "ModerationReport" %>