diff --git a/app/controllers/moderation/reports_controller.rb b/app/controllers/moderation/reports_controller.rb index 75ba4693..a3b128a1 100644 --- a/app/controllers/moderation/reports_controller.rb +++ b/app/controllers/moderation/reports_controller.rb @@ -11,7 +11,7 @@ class Moderation::ReportsController < ApplicationController respond_to do |format| format.html - format.js { render layout: false } + format.turbo_stream end end diff --git a/app/views/moderation/reports/index.haml b/app/views/moderation/reports/index.haml index 0bcb623a..db76c1f1 100644 --- a/app/views/moderation/reports/index.haml +++ b/app/views/moderation/reports/index.haml @@ -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") diff --git a/app/views/moderation/reports/index.turbo_stream.haml b/app/views/moderation/reports/index.turbo_stream.haml new file mode 100644 index 00000000..3d276d1e --- /dev/null +++ b/app/views/moderation/reports/index.turbo_stream.haml @@ -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") diff --git a/config/routes.rb b/config/routes.rb index 36d48e24..c7e2426f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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