mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
Fix for incorrect total number of apps
This commit is contained in:
parent
0b7360036a
commit
e6198809ba
2 changed files with 26 additions and 27 deletions
|
|
@ -7,20 +7,20 @@ class AppsController < ApplicationController
|
|||
folder_id = params[:folder]
|
||||
|
||||
if folder_id.blank?
|
||||
@apps = App.where(organization: @current_user.organization)
|
||||
@scope = App.where(organization: @current_user.organization)
|
||||
else
|
||||
@folder = Folder.find folder_id
|
||||
@apps = @folder.apps
|
||||
@scope = @folder.apps
|
||||
end
|
||||
|
||||
@apps = @apps.order('created_at desc')
|
||||
@apps = @scope.order('created_at desc')
|
||||
.page(params[:page])
|
||||
.per(10)
|
||||
.includes(:user)
|
||||
|
||||
@meta = {
|
||||
total_pages: @apps.total_pages,
|
||||
count: App.count,
|
||||
count: @scope.count,
|
||||
current_page: @apps.current_page
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,37 +3,36 @@ import React from 'react';
|
|||
export const Pagination = function Pagination({
|
||||
currentPage, count, totalPages, pageChanged
|
||||
}) {
|
||||
function renderPageItem(i) {
|
||||
return <li onClick={() => gotoPage(i + 1)} className={`page-item ${currentPage === i + 1 ? 'active' : ''}`}><a className="page-link">{i + 1}</a></li>;
|
||||
}
|
||||
|
||||
function renderPageItem(i) {
|
||||
return <li onClick={() => gotoPage(i + 1)} className={`page-item ${currentPage === i + 1 ? 'active' : ''}`}><a className="page-link">{i + 1}</a></li>
|
||||
}
|
||||
function gotoPage(page) {
|
||||
pageChanged(page);
|
||||
}
|
||||
|
||||
function gotoPage(page) {
|
||||
pageChanged(page)
|
||||
}
|
||||
function gotoNextPage() {
|
||||
gotoPage(currentPage + 1);
|
||||
}
|
||||
|
||||
function gotoNextPage() {
|
||||
gotoPage(currentPage + 1);
|
||||
}
|
||||
function gotoPreviousPage() {
|
||||
gotoPage(currentPage - 1);
|
||||
}
|
||||
|
||||
function gotoPreviousPage() {
|
||||
gotoPage(currentPage - 1);
|
||||
}
|
||||
|
||||
return (<div className="card-footer d-flex align-items-center">
|
||||
<p className="m-0 text-muted">Showing <span>{ (currentPage - 1) * 10 + 1}</span> to <span>{currentPage * 10}</span> of <span>{count}</span> entries</p>
|
||||
return (<div className="card-footer d-flex align-items-center">
|
||||
<p className="m-0 text-muted">Showing <span>{ (currentPage - 1) * 10 + 1}</span> to <span>{currentPage * 10}</span> of <span>{count}</span></p>
|
||||
<ul className="pagination m-0 ms-auto">
|
||||
<li className={`page-item ${currentPage === 1 ? 'disabled' : ''}`}>
|
||||
<a style={{cursor: 'pointer'}} className="page-link" onClick={gotoPreviousPage}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><polyline points="15 6 9 12 15 18"></polyline></svg>
|
||||
<li className={`page-item ${currentPage === 1 ? 'disabled' : ''}`}>
|
||||
<a style={{ cursor: 'pointer' }} className="page-link" onClick={gotoPreviousPage}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="icon" width="24" height="24" viewBox="0 0 24 24" strokeWidth="2" stroke="currentColor" fill="none" strokeLinecap="round" strokeLinejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><polyline points="15 6 9 12 15 18"></polyline></svg>
|
||||
</a>
|
||||
</li>
|
||||
{Array.from(Array(totalPages).keys()).map((i) => ( renderPageItem(i) ) )}
|
||||
{Array.from(Array(totalPages).keys()).map((i) => (renderPageItem(i)))}
|
||||
<li className={`page-item ${currentPage === totalPages ? 'disabled' : ''}`}>
|
||||
<a style={{cursor: 'pointer'}} className="page-link" onClick={gotoNextPage}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><polyline points="9 6 15 12 9 18"></polyline></svg>
|
||||
<a style={{ cursor: 'pointer' }} className="page-link" onClick={gotoNextPage}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="icon" width="24" height="24" viewBox="0 0 24 24" strokeWidth="2" stroke="currentColor" fill="none" strokeLinecap="round" strokeLinejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><polyline points="9 6 15 12 9 18"></polyline></svg>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>)
|
||||
}
|
||||
</div>);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue