Implement report filtering interface
This commit is contained in:
parent
6211747ec4
commit
50126cc4c4
|
@ -2,6 +2,8 @@
|
|||
|
||||
class Moderation::ReportsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :set_filter_enabled
|
||||
before_action :set_type_options
|
||||
|
||||
def index
|
||||
filter = ReportFilter.new(filter_params)
|
||||
|
@ -20,4 +22,21 @@ class Moderation::ReportsController < ApplicationController
|
|||
def filter_params
|
||||
params.slice(*ReportFilter::KEYS).permit(*ReportFilter::KEYS)
|
||||
end
|
||||
|
||||
def set_filter_enabled
|
||||
@filter_enabled = params.slice(*ReportFilter::KEYS)
|
||||
.reject! { |_, value| value.empty? || value.nil? }
|
||||
.values
|
||||
.any?
|
||||
end
|
||||
|
||||
def set_type_options
|
||||
@type_options = [
|
||||
[t("voc.all"), ""],
|
||||
[t("activerecord.models.answer.one"), :answer],
|
||||
[t("activerecord.models.comment.one"), :comment],
|
||||
[t("activerecord.models.question.one"), :question],
|
||||
[t("activerecord.models.user.one"), :user]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
.card
|
||||
.card-body
|
||||
.dropdown
|
||||
%button.btn.dropdown-toggle{ class: @filter_enabled ? "btn-primary" : "btn-light", type: :button, data: { bs_toggle: :dropdown }, aria: { expanded: :false }}
|
||||
%i.fa.fa-filter
|
||||
= t("voc.filter")
|
||||
.dropdown-menu{ style: "min-width: 300px;" }
|
||||
= bootstrap_form_tag url: moderation_reports_path, method: :get, html: { class: "px-3 py-2" } do |f|
|
||||
= f.select :type, options_for_select(@type_options, params[:type]), {}, { class: "form-control" }
|
||||
= f.text_field :user, value: params[:user]
|
||||
= f.text_field :target_user, value: params[:target_user]
|
||||
.d-flex.flex-row-reverse
|
||||
= f.primary t("voc.filter")
|
||||
|
||||
#reports
|
||||
- if @reports.empty?
|
||||
= render "shared/empty", icon: "fa-regular fa-smile-beam", translation_key: ".moderation.reports"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
en:
|
||||
voc:
|
||||
add: "Add"
|
||||
all: "All"
|
||||
answer: "Answer"
|
||||
block: "Block"
|
||||
block_site_wide: "Block user site-wide"
|
||||
|
@ -9,6 +10,7 @@ en:
|
|||
confirm: "Are you sure?"
|
||||
delete: "Delete"
|
||||
edit: "Edit"
|
||||
filter: "Filter"
|
||||
follow: "Follow"
|
||||
format_markdown: "Styling with Markdown is supported"
|
||||
load: "Load more"
|
||||
|
|
Loading…
Reference in New Issue