Refactor moderation to use a Turbo Stream-backed pagination
This commit is contained in:
parent
ae607ac840
commit
1375293f31
|
@ -11,7 +11,7 @@ class Moderation::ReportsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js { render layout: false }
|
||||
format.turbo_stream
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#reports
|
||||
- @reports.each do |r|
|
||||
= render "moderation/moderationbox", report: r
|
||||
|
||||
- unless @reports.count.zero?
|
||||
= render "shared/cursored_pagination_dummy", more_data_available: @more_data_available, last_id: @reports_last_id, permitted_params: %i[type]
|
||||
= turbo_frame_tag "moderation_reports" do
|
||||
#reports
|
||||
- @reports.each do |r|
|
||||
= render "moderation/moderationbox", report: r
|
||||
|
||||
- if @more_data_available
|
||||
.d-flex.justify-content-center.justify-content-sm-start
|
||||
%button.btn.btn-light#load-more-btn{ type: :button, data: { last_id: @reports_last_id } }
|
||||
.d-flex.justify-content-center.justify-content-sm-start#paginator
|
||||
= button_to moderation_reports_path(last_id: @reports_last_id, type: params[:type]), class: "btn btn-light" do
|
||||
= t("voc.load")
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
= turbo_stream.append "reports" do
|
||||
- @reports.each do |r|
|
||||
= render "moderation/moderationbox", report: r
|
||||
|
||||
= turbo_stream.update "paginator" do
|
||||
- if @more_data_available
|
||||
= button_to moderation_reports_path(last_id: @reports_last_id, type: params[:type]), class: "btn btn-light" do
|
||||
= t("voc.load")
|
|
@ -24,8 +24,8 @@ Rails.application.routes.draw do
|
|||
authenticate :user, ->(user) { user.mod? } do
|
||||
post "/moderation/unmask", to: "moderation#toggle_unmask", as: :moderation_toggle_unmask
|
||||
get "/moderation/blocks", to: "moderation/anonymous_block#index", as: :mod_anon_block_index
|
||||
get "/moderation/reports(/:type)", to: "moderation/reports#index", as: :moderation_reports, defaults: { type: "all" }
|
||||
match "/moderation/inbox/:user", to: "moderation/inbox#index", via: [:get, :post], as: :mod_inbox_index
|
||||
match "/moderation/reports(/:type)", to: "moderation/reports#index", via: [:get, :post], as: :moderation_reports, defaults: { type: "all" }
|
||||
get "/moderation/questions/:author_identifier", to: "moderation/questions#show", as: :moderation_questions
|
||||
namespace :ajax do
|
||||
post "/mod/destroy_report", to: "moderation#destroy_report", as: :mod_destroy_report
|
||||
|
|
Loading…
Reference in New Issue