Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spam2: pagination added #8063

Merged
merged 13 commits into from
Jun 30, 2020
17 changes: 10 additions & 7 deletions app/assets/javascripts/spam2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
function table_main(id) {
var table = $(id).DataTable({
"order": [[1, "desc"]],
"stateSave": false,
"autoWidth": false,
"search": {
"regex": true
},
"scrollX": true
"scrollX": true,
"paging": false,
"info": false,
"language": {
"search": "Search in this page"
}
});
$('#selectall').click(function () {
$('.selectedId').prop('checked', this.checked);
Expand All @@ -27,11 +31,10 @@ function table_main(id) {
return table;
}

function disable_buttons(id){
if ($(id).is(":checked")){
function disable_buttons(id) {
if ($(id).is(":checked")) {
$("#batch-spam, #batch-publish, #delete-batch, #batch-ban, #batch-unban").removeClass("disabled");
}
else {
} else {
$("#batch-spam, #batch-publish, #delete-batch, #batch-ban, #batch-unban").addClass("disabled");
}
}
}
5 changes: 5 additions & 0 deletions app/assets/stylesheets/spam2.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
margin-top:2px;
}

.page-table{
width:100%;
VladimirMikulic marked this conversation as resolved.
Show resolved Hide resolved
margin-top:2%;
}

@media (max-width: 750px) {
#table-card, #bulk-nav, .nav_top,
#card-top {
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/spam2_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Spam2Controller < ApplicationController

def _spam
if logged_in_as(%w(moderator admin))
@nodes = Node.order('nid DESC')
@nodes = Node.order('nid DESC').paginate(page: params[:page])
VladimirMikulic marked this conversation as resolved.
Show resolved Hide resolved
@nodes = if params[:type] == 'wiki'
@nodes.where(type: 'page', status: 1)
else
Expand All @@ -21,7 +21,7 @@ def _spam

def _spam_revisions
if logged_in_as(%w(admin moderator))
@revisions = Revision.where(status: 0)
@revisions = Revision.where(status: 0).paginate(page: params[:page])
VladimirMikulic marked this conversation as resolved.
Show resolved Hide resolved
.order('timestamp DESC')
render template: 'spam2/_spam'
else
Expand All @@ -32,7 +32,7 @@ def _spam_revisions

def _spam_comments
if logged_in_as(%w(moderator admin))
@comments = Comment.order('timestamp DESC')
@comments = Comment.order('timestamp DESC').paginate(page: params[:page])
.where(status: 0)
render template: 'spam2/_spam'
else
Expand Down
8 changes: 7 additions & 1 deletion app/views/spam2/_comments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ $(document).ready(function () {
</tbody>
</table>
</div>
</div>
</div>
<div class="page-table">
VladimirMikulic marked this conversation as resolved.
Show resolved Hide resolved
<div class="float-right">
<%= will_paginate @comments, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @comments.empty?%>
</div>
<div class="float-left">At Page <%= @comments.current_page%> of <%= @comments.total_pages %> total pages</div>
<div>
VladimirMikulic marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 10 additions & 1 deletion app/views/spam2/_nodes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ $(document).ready(function () {
</select>
</li>
<% end %>
<li class="nav-item">
<a class="btn nav-link text-dark"><%= page_entries_info(@nodes) %></a>
</li>
</ul>
</div>
<div class="card-body" style="overflow-x:hidden;">
Expand Down Expand Up @@ -226,4 +229,10 @@ $(document).ready(function () {
</tbody>
</table>
</div>
</div>
</div>
<div class="page-table">
<div class="float-right">
<%= will_paginate @nodes, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @nodes.empty?%>
</div>
<div class="float-left">At Page <%= @nodes.current_page%> of <%= @nodes.total_pages %> total pages</div>
<div>
8 changes: 7 additions & 1 deletion app/views/spam2/_revisions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ $(document).ready(function () {
</tbody>
</table>
</div>
</div>
</div>
<div class="page-table">
<div class="float-right">
<%= will_paginate @revisions, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated || @revisions.empty?%>
</div>
<div class="float-left">At Page <%= @revisions.current_page%> of <%= @revisions.total_pages %> total pages</div>
<div>