mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 12:19:52 +01:00
Refactor mod inbox to use a Turbo Stream-backed pagination
This commit is contained in:
parent
8226198f76
commit
8c14fb5423
5 changed files with 18 additions and 20 deletions
|
@ -12,7 +12,7 @@ class Moderation::InboxController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js { render layout: false }
|
||||
format.turbo_stream
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
= render "header", user: @user, hidden: true
|
||||
|
||||
.container-lg.container--main
|
||||
#entries
|
||||
- @inboxes.each do |i|
|
||||
= render "inbox/entry", i: i
|
||||
= turbo_frame_tag "moderation_inbox" do
|
||||
#entries
|
||||
- @inboxes.each do |i|
|
||||
= render "inbox/entry", i: i
|
||||
|
||||
= render "shared/cursored_pagination_dummy", more_data_available: @more_data_available, last_id: @inbox_last_id
|
||||
|
||||
- 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: @inbox_last_id } }
|
||||
= t("voc.load")
|
||||
- if @more_data_available
|
||||
.d-flex.justify-content-center.justify-content-sm-start#paginator
|
||||
= button_to mod_inbox_index_path(@user, last_id: @inbox_last_id), class: "btn btn-light" do
|
||||
= t("voc.load")
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
$('#entries').append('<% @inboxes.each do |i|
|
||||
%><%= j render 'inbox/entry', i: i
|
||||
%><% end %>');
|
||||
<% if @more_data_available %>
|
||||
$('#pagination').html('<%= j render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @inbox_last_id %>');
|
||||
<% else %>
|
||||
$('#pagination, #load-more-btn').remove();
|
||||
<% end %>
|
8
app/views/moderation/inbox/index.turbo_stream.haml
Normal file
8
app/views/moderation/inbox/index.turbo_stream.haml
Normal file
|
@ -0,0 +1,8 @@
|
|||
= turbo_stream.append "entries" do
|
||||
- @inboxes.each do |i|
|
||||
= render "inbox/entry", i: i
|
||||
|
||||
= turbo_stream.update "paginator" do
|
||||
- if @more_data_available
|
||||
= button_to mod_inbox_index_path(@user, last_id: @inbox_last_id), class: "btn btn-light" do
|
||||
= t("voc.load")
|
|
@ -25,7 +25,7 @@ Rails.application.routes.draw 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" }
|
||||
get "/moderation/inbox/:user", to: "moderation/inbox#index", as: :mod_inbox_index
|
||||
match "/moderation/inbox/:user", to: "moderation/inbox#index", via: [:get, :post], as: :mod_inbox_index
|
||||
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 a new issue