mod actions: update /mod_actions index.
* Add newest and oldest order options. * Rearrange columns to match /user_actions page.
This commit is contained in:
@@ -82,7 +82,14 @@ class ModAction < ApplicationRecord
|
|||||||
q = search_attributes(params, :id, :created_at, :updated_at, :category, :description, :creator)
|
q = search_attributes(params, :id, :created_at, :updated_at, :category, :description, :creator)
|
||||||
q = q.text_attribute_matches(:description, params[:description_matches])
|
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
|
end
|
||||||
|
|
||||||
def category_id
|
def category_id
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<%= search_form_for(mod_actions_path) do |f| %>
|
<%= 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 :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 :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" %>
|
<%= f.submit "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -5,14 +5,16 @@
|
|||||||
<%= render "search" %>
|
<%= render "search" %>
|
||||||
|
|
||||||
<%= table_for @mod_actions, class: "striped autofit" do |t| %>
|
<%= table_for @mod_actions, class: "striped autofit" do |t| %>
|
||||||
|
<% t.column "Message", td: {class: "col-expand"} do |mod_action| %>
|
||||||
|
<div class="prose">
|
||||||
|
<%= link_to_user mod_action.creator %> <%= format_text(mod_action.description.chomp(".").strip, inline: true) %>.
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% t.column "Category" do |mod_action| %>
|
<% t.column "Category" do |mod_action| %>
|
||||||
<%= link_to mod_action.category.humanize, mod_actions_path(search: { category: mod_action.category_id }) %>
|
<%= link_to mod_action.category.humanize, mod_actions_path(search: { category: mod_action.category_id }) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% t.column "Message", td: {class: "col-expand"} do |mod_action| %>
|
|
||||||
<div class="prose">
|
|
||||||
<%= format_text(mod_action.description) %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% t.column "Created" do |mod_action| %>
|
<% t.column "Created" do |mod_action| %>
|
||||||
<%= link_to_user mod_action.creator %>
|
<%= link_to_user mod_action.creator %>
|
||||||
<%= link_to "»", mod_actions_path(search: { creator_name: mod_action.creator.name }) %>
|
<%= link_to "»", mod_actions_path(search: { creator_name: mod_action.creator.name }) %>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% when "ModAction" %>
|
<% when "ModAction" %>
|
||||||
<div class="prose">
|
<div class="prose">
|
||||||
<%= link_to_user user %> <%= format_text(model.description, inline: true) %>.
|
<%= link_to_user user %> <%= format_text(model.description.chomp(".").strip, inline: true) %>.
|
||||||
</div>
|
</div>
|
||||||
<% when "ModerationReport" %>
|
<% when "ModerationReport" %>
|
||||||
<div class="prose">
|
<div class="prose">
|
||||||
|
|||||||
Reference in New Issue
Block a user