Use turbo for pagination
This commit is contained in:
parent
c5aa012dc2
commit
edddaab122
20 changed files with 179 additions and 140 deletions
|
@ -24,6 +24,8 @@ class DiaryCommentsController < ApplicationController
|
|||
@params = params.permit(:display_name, :before, :after)
|
||||
|
||||
@comments, @newer_comments_id, @older_comments_id = get_page_items(comments, :includes => [:user])
|
||||
|
||||
render :partial => "page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
@ -60,6 +60,8 @@ class DiaryEntriesController < ApplicationController
|
|||
@params = params.permit(:display_name, :friends, :nearby, :language)
|
||||
|
||||
@entries, @newer_entries_id, @older_entries_id = get_page_items(entries, :includes => [:user, :language])
|
||||
|
||||
render :partial => "page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -65,6 +65,8 @@ class TracesController < ApplicationController
|
|||
|
||||
# final helper vars for view
|
||||
@target_user = target_user
|
||||
|
||||
render :partial => "page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -21,6 +21,11 @@ class UserBlocksController < ApplicationController
|
|||
user_blocks = UserBlock.all
|
||||
|
||||
@user_blocks, @newer_user_blocks_id, @older_user_blocks_id = get_page_items(user_blocks, :includes => [:user, :creator, :revoker])
|
||||
|
||||
@show_user_name = true
|
||||
@show_creator_name = true
|
||||
|
||||
render :partial => "blocks" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -118,6 +123,11 @@ class UserBlocksController < ApplicationController
|
|||
user_blocks = UserBlock.where(:user => @user)
|
||||
|
||||
@user_blocks, @newer_user_blocks_id, @older_user_blocks_id = get_page_items(user_blocks, :includes => [:user, :creator, :revoker])
|
||||
|
||||
@show_user_name = false
|
||||
@show_creator_name = true
|
||||
|
||||
render :partial => "blocks" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -128,6 +138,11 @@ class UserBlocksController < ApplicationController
|
|||
user_blocks = UserBlock.where(:creator => @user)
|
||||
|
||||
@user_blocks, @newer_user_blocks_id, @older_user_blocks_id = get_page_items(user_blocks, :includes => [:user, :creator, :revoker])
|
||||
|
||||
@show_user_name = true
|
||||
@show_creator_name = false
|
||||
|
||||
render :partial => "blocks" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -40,6 +40,8 @@ class UsersController < ApplicationController
|
|||
|
||||
@users_count = users.count
|
||||
@users, @newer_users_id, @older_users_id = get_page_items(users, :limit => 50)
|
||||
|
||||
render :partial => "page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
26
app/views/diary_comments/_page.html.erb
Normal file
26
app/views/diary_comments/_page.html.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<turbo-frame id="pagination" target="_top">
|
||||
<table class="table table-striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="25%"><%= t ".post" %></th>
|
||||
<th width="25%"><%= t ".when" %></th>
|
||||
<th width="50%"><%= t ".comment" %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @comments.each do |comment| -%>
|
||||
<tr>
|
||||
<td width="25%" class="<%= "text-body-secondary" unless comment.visible? %>"><%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %></td>
|
||||
<td width="25%" class="<%= "text-body-secondary" unless comment.visible? %>">
|
||||
<%= friendly_date_ago(comment.created_at) %>
|
||||
</td>
|
||||
<td width="50%" class="richtext text-break<%= " text-body-secondary" unless comment.visible? %>"><%= comment.body.to_html %></td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</table>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "diary_comments.page.newer_comments",
|
||||
:older_key => "diary_comments.page.older_comments",
|
||||
:newer_id => @newer_comments_id,
|
||||
:older_id => @older_comments_id %>
|
||||
</turbo-frame>
|
|
@ -5,30 +5,6 @@
|
|||
|
||||
<% if @comments.empty? %>
|
||||
<h4><%= t ".no_comments" %></h4>
|
||||
|
||||
<% else %>
|
||||
<table class="table table-striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="25%"><%= t ".post" %></th>
|
||||
<th width="25%"><%= t ".when" %></th>
|
||||
<th width="50%"><%= t ".comment" %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @comments.each do |comment| -%>
|
||||
<tr>
|
||||
<td width="25%" class="<%= "text-body-secondary" unless comment.visible? %>"><%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %></td>
|
||||
<td width="25%" class="<%= "text-body-secondary" unless comment.visible? %>">
|
||||
<%= friendly_date_ago(comment.created_at) %>
|
||||
</td>
|
||||
<td width="50%" class="richtext text-break<%= " text-body-secondary" unless comment.visible? %>"><%= comment.body.to_html %></td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</table>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "diary_comments.index.newer_comments",
|
||||
:older_key => "diary_comments.index.older_comments",
|
||||
:newer_id => @newer_comments_id,
|
||||
:older_id => @older_comments_id %>
|
||||
<%= render :partial => "page" %>
|
||||
<% end -%>
|
||||
|
|
11
app/views/diary_entries/_page.html.erb
Normal file
11
app/views/diary_entries/_page.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<turbo-frame id="pagination" target="_top">
|
||||
<h4><%= t ".recent_entries" %></h4>
|
||||
|
||||
<%= render @entries %>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "diary_entries.page.newer_entries",
|
||||
:older_key => "diary_entries.page.older_entries",
|
||||
:newer_id => @newer_entries_id,
|
||||
:older_id => @older_entries_id %>
|
||||
</turbo-frame>
|
|
@ -43,16 +43,8 @@
|
|||
<% if @entries.empty? %>
|
||||
<h4><%= t ".no_entries" %></h4>
|
||||
<% else %>
|
||||
<h4><%= t ".recent_entries" %></h4>
|
||||
|
||||
<%= render @entries %>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "diary_entries.index.newer_entries",
|
||||
:older_key => "diary_entries.index.older_entries",
|
||||
:newer_id => @newer_entries_id,
|
||||
:older_id => @older_entries_id %>
|
||||
<% end %>
|
||||
<%= render :partial => "page" %>
|
||||
<% end -%>
|
||||
|
||||
<% unless params[:friends] or params[:nearby] -%>
|
||||
<% content_for :auto_discovery_link_tag do -%>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% end %>
|
||||
<% if newer_id -%>
|
||||
<li class="page-item d-flex">
|
||||
<%= link_to newer_link_content, @params.merge(:before => nil, :after => newer_id), :class => link_class %>
|
||||
<%= link_to newer_link_content, @params.merge(:before => nil, :after => newer_id), :class => link_class, :data => { "turbo-frame" => "pagination", "turbo-action" => "advance" } %>
|
||||
</li>
|
||||
<% else -%>
|
||||
<li class="page-item d-flex disabled">
|
||||
|
@ -21,7 +21,7 @@
|
|||
<% end %>
|
||||
<% if older_id -%>
|
||||
<li class="page-item d-flex">
|
||||
<%= link_to older_link_content, @params.merge(:before => older_id, :after => nil), :class => link_class %>
|
||||
<%= link_to older_link_content, @params.merge(:before => older_id, :after => nil), :class => link_class, :data => { "turbo-frame" => "pagination", "turbo-action" => "advance" } %>
|
||||
</li>
|
||||
<% else -%>
|
||||
<li class="page-item d-flex disabled">
|
||||
|
|
19
app/views/traces/_page.html.erb
Normal file
19
app/views/traces/_page.html.erb
Normal file
|
@ -0,0 +1,19 @@
|
|||
<turbo-frame id="pagination" target="_top">
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "traces.page.newer",
|
||||
:older_key => "traces.page.older",
|
||||
:newer_id => @newer_traces_id,
|
||||
:older_id => @older_traces_id %>
|
||||
|
||||
<table id="trace_list" class="table table-borderless table-striped">
|
||||
<tbody>
|
||||
<%= render @traces %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "traces.page.newer",
|
||||
:older_key => "traces.page.older",
|
||||
:newer_id => @newer_traces_id,
|
||||
:older_id => @older_traces_id %>
|
||||
</turbo-frame>
|
|
@ -69,23 +69,7 @@
|
|||
<% end %>
|
||||
|
||||
<% if @traces.size > 0 %>
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "traces.trace_paging_nav.newer",
|
||||
:older_key => "traces.trace_paging_nav.older",
|
||||
:newer_id => @newer_traces_id,
|
||||
:older_id => @older_traces_id %>
|
||||
|
||||
<table id="trace_list" class="table table-borderless table-striped">
|
||||
<tbody>
|
||||
<%= render @traces %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "traces.trace_paging_nav.newer",
|
||||
:older_key => "traces.trace_paging_nav.older",
|
||||
:newer_id => @newer_traces_id,
|
||||
:older_id => @older_traces_id %>
|
||||
<%= render :partial => "page" %>
|
||||
<% else %>
|
||||
<h2><%= t ".empty_title" %></h2>
|
||||
<p><%= t ".empty_upload_html", :upload_link => link_to(t(".upload_new"), new_trace_path),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<tr>
|
||||
<% if show_user_name %>
|
||||
<% if @show_user_name %>
|
||||
<td><%= link_to block.user.display_name, block.user, :class => "username d-inline-block text-truncate text-wrap" %></td>
|
||||
<% end %>
|
||||
<% if show_creator_name %>
|
||||
<% if @show_creator_name %>
|
||||
<td><%= link_to block.creator.display_name, block.creator, :class => "username d-inline-block text-truncate text-wrap" %></td>
|
||||
<% end %>
|
||||
<td><%= h truncate(block.reason) %></td>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<td><%= link_to t(".show"), block %></td>
|
||||
<td><% if current_user && (current_user.id == block.creator_id ||
|
||||
current_user.id == block.revoker_id) %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %></td>
|
||||
<% if show_revoke_link %>
|
||||
<% if can?(:revoke, UserBlock) %>
|
||||
<td><% if block.active? %><%= link_to t(".revoke"), revoke_user_block_path(block) %><% end %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
<table id="block_list" class="table table-borderless table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if show_user_name %>
|
||||
<th><%= t ".display_name" %></th>
|
||||
<% end %>
|
||||
<% if show_creator_name %>
|
||||
<th><%= t ".creator_name" %></th>
|
||||
<% end %>
|
||||
<th><%= t ".reason" %></th>
|
||||
<th><%= t ".status" %></th>
|
||||
<th><%= t ".revoker_name" %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<% if show_revoke_link %>
|
||||
<th></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<%= render :partial => "block", :locals => { :show_revoke_link => show_revoke_link, :show_user_name => show_user_name, :show_creator_name => show_creator_name }, :collection => @user_blocks %>
|
||||
</table>
|
||||
<turbo-frame id="pagination" target="_top">
|
||||
<table id="block_list" class="table table-borderless table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if @show_user_name %>
|
||||
<th><%= t ".display_name" %></th>
|
||||
<% end %>
|
||||
<% if @show_creator_name %>
|
||||
<th><%= t ".creator_name" %></th>
|
||||
<% end %>
|
||||
<th><%= t ".reason" %></th>
|
||||
<th><%= t ".status" %></th>
|
||||
<th><%= t ".revoker_name" %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<% if can?(:revoke, UserBlock) %>
|
||||
<th></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<%= render :partial => "block", :collection => @user_blocks %>
|
||||
</table>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "user_blocks.blocks.newer",
|
||||
:older_key => "user_blocks.blocks.older",
|
||||
:newer_id => @newer_user_blocks_id,
|
||||
:older_id => @older_user_blocks_id %>
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "user_blocks.blocks.newer",
|
||||
:older_key => "user_blocks.blocks.older",
|
||||
:newer_id => @newer_user_blocks_id,
|
||||
:older_id => @older_user_blocks_id %>
|
||||
</turbo-frame>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @user_blocks.empty? %>
|
||||
<%= render :partial => "blocks", :locals => { :show_revoke_link => can?(:revoke, UserBlock), :show_user_name => true, :show_creator_name => false } %>
|
||||
<%= render :partial => "blocks" %>
|
||||
<% else %>
|
||||
<p><%= t ".empty", :name => @user.display_name %></p>
|
||||
<% end %>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @user_blocks.empty? %>
|
||||
<%= render :partial => "blocks", :locals => { :show_revoke_link => can?(:revoke, UserBlock), :show_user_name => false, :show_creator_name => true } %>
|
||||
<%= render :partial => "blocks" %>
|
||||
<% else %>
|
||||
<p><%= t ".empty", :name => @user.display_name %></p>
|
||||
<% end %>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @user_blocks.empty? %>
|
||||
<%= render :partial => "blocks", :locals => { :show_revoke_link => can?(:revoke, UserBlock), :show_user_name => true, :show_creator_name => true } %>
|
||||
<%= render :partial => "blocks" %>
|
||||
<% else %>
|
||||
<p><%= t ".empty" %></p>
|
||||
<% end %>
|
||||
|
|
50
app/views/users/_page.html.erb
Normal file
50
app/views/users/_page.html.erb
Normal file
|
@ -0,0 +1,50 @@
|
|||
<turbo-frame id="pagination" target="_top">
|
||||
<%= form_tag do %>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "users.page.newer",
|
||||
:older_key => "users.page.older",
|
||||
:newer_id => @newer_users_id,
|
||||
:older_id => @older_users_id %>
|
||||
</div>
|
||||
<div class="col col-auto">
|
||||
<%= t ".found_users", :count => @users_count %>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<%= hidden_field_tag :status, params[:status] if params[:status] %>
|
||||
<%= hidden_field_tag :ip, params[:ip] if params[:ip] %>
|
||||
<%= hidden_field_tag :page, params[:page] if params[:page] %>
|
||||
<table id="user_list" class="table table-borderless table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
</td>
|
||||
<td>
|
||||
<%= check_box_tag "user_all", "1", false %>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<%= render @users %>
|
||||
</table>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "users.page.newer",
|
||||
:older_key => "users.page.older",
|
||||
:newer_id => @newer_users_id,
|
||||
:older_id => @older_users_id %>
|
||||
</div>
|
||||
<div class="col col-auto">
|
||||
<%= t ".found_users", :count => @users_count %>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<div>
|
||||
<%= submit_tag t(".confirm"), :name => "confirm", :class => "btn btn-primary" %>
|
||||
<%= submit_tag t(".hide"), :name => "hide", :class => "btn btn-primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</turbo-frame>
|
|
@ -9,54 +9,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @users.empty? %>
|
||||
<%= form_tag do %>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "users.index.newer",
|
||||
:older_key => "users.index.older",
|
||||
:newer_id => @newer_users_id,
|
||||
:older_id => @older_users_id %>
|
||||
</div>
|
||||
<div class="col col-auto">
|
||||
<%= t ".found_users", :count => @users_count %>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<%= hidden_field_tag :status, params[:status] if params[:status] %>
|
||||
<%= hidden_field_tag :ip, params[:ip] if params[:ip] %>
|
||||
<%= hidden_field_tag :page, params[:page] if params[:page] %>
|
||||
<table id="user_list" class="table table-borderless table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
</td>
|
||||
<td>
|
||||
<%= check_box_tag "user_all", "1", false %>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<%= render @users %>
|
||||
</table>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<%= render "shared/pagination",
|
||||
:newer_key => "users.index.newer",
|
||||
:older_key => "users.index.older",
|
||||
:newer_id => @newer_users_id,
|
||||
:older_id => @older_users_id %>
|
||||
</div>
|
||||
<div class="col col-auto">
|
||||
<%= t ".found_users", :count => @users_count %>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<div>
|
||||
<%= submit_tag t(".confirm"), :name => "confirm", :class => "btn btn-primary" %>
|
||||
<%= submit_tag t(".hide"), :name => "hide", :class => "btn btn-primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= render :partial => "page" %>
|
||||
<% else %>
|
||||
<p><%= t ".empty" %></p>
|
||||
<% end %>
|
||||
|
|
|
@ -538,6 +538,7 @@ en:
|
|||
new_title: Compose a new entry in my user diary
|
||||
my_diary: My Diary
|
||||
no_entries: No diary entries
|
||||
page:
|
||||
recent_entries: "Recent diary entries"
|
||||
older_entries: Older Entries
|
||||
newer_entries: Newer Entries
|
||||
|
@ -604,6 +605,7 @@ en:
|
|||
heading: "%{user}'s Diary Comments"
|
||||
subheading_html: "Diary Comments added by %{user}"
|
||||
no_comments: "No diary comments"
|
||||
page:
|
||||
post: Post
|
||||
when: When
|
||||
comment: Comment
|
||||
|
@ -2522,9 +2524,6 @@ en:
|
|||
trace_not_found: "Trace not found!"
|
||||
visibility: "Visibility:"
|
||||
confirm_delete: "Delete this trace?"
|
||||
trace_paging_nav:
|
||||
older: "Older Traces"
|
||||
newer: "Newer Traces"
|
||||
trace:
|
||||
pending: "PENDING"
|
||||
count_points:
|
||||
|
@ -2556,6 +2555,9 @@ en:
|
|||
my_traces: "My Traces"
|
||||
traces_from: "Public Traces from %{user}"
|
||||
remove_tag_filter: "Remove Tag Filter"
|
||||
page:
|
||||
older: "Older Traces"
|
||||
newer: "Newer Traces"
|
||||
destroy:
|
||||
scheduled_for_deletion: "Trace scheduled for deletion"
|
||||
make_public:
|
||||
|
@ -2875,16 +2877,17 @@ en:
|
|||
index:
|
||||
title: Users
|
||||
heading: Users
|
||||
summary_html: "%{name} created from %{ip_address} on %{date}"
|
||||
summary_no_ip_html: "%{name} created on %{date}"
|
||||
empty: No matching users found
|
||||
page:
|
||||
older: "Older Users"
|
||||
newer: "Newer Users"
|
||||
found_users:
|
||||
one: "%{count} user found"
|
||||
other: "%{count} users found"
|
||||
summary_html: "%{name} created from %{ip_address} on %{date}"
|
||||
summary_no_ip_html: "%{name} created on %{date}"
|
||||
confirm: Confirm Selected Users
|
||||
hide: Hide Selected Users
|
||||
empty: No matching users found
|
||||
suspended:
|
||||
title: Account Suspended
|
||||
heading: Account Suspended
|
||||
|
|
Loading…
Add table
Reference in a new issue