pagination fix
This commit is contained in:
@@ -36,6 +36,7 @@ const PaginationControl = (props) => {
|
|||||||
const paginationNumbers = (currentPage, pageCount) => {
|
const paginationNumbers = (currentPage, pageCount) => {
|
||||||
//console.log(currentPage);
|
//console.log(currentPage);
|
||||||
let delta;
|
let delta;
|
||||||
|
|
||||||
if (pageCount <= 7) {
|
if (pageCount <= 7) {
|
||||||
// delta === 7: [1 2 3 4 5 6 7]
|
// delta === 7: [1 2 3 4 5 6 7]
|
||||||
delta = 7;
|
delta = 7;
|
||||||
@@ -43,7 +44,7 @@ const PaginationControl = (props) => {
|
|||||||
// delta === 2: [1 ... 4 5 6 ... 10]
|
// delta === 2: [1 ... 4 5 6 ... 10]
|
||||||
// delta === 4: [1 2 3 4 5 ... 10]
|
// delta === 4: [1 2 3 4 5 ... 10]
|
||||||
//delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4;
|
//delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4;
|
||||||
delta = currentPage > 4 && currentPage < pageCount - 3 ? 2 : 4;
|
delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
const range = {
|
const range = {
|
||||||
@@ -79,15 +80,17 @@ const PaginationControl = (props) => {
|
|||||||
return pages;
|
return pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginationArray = paginationNumbers(currentPage, pagesCount);
|
const paginationArray = paginationNumbers(
|
||||||
|
props.currentView.currentPage,
|
||||||
|
pagesCount
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{pagesCount > 1 && (
|
{pagesCount > 1 && (
|
||||||
<div className="govuk-!-margin-bottom-7 ">
|
<div className="govuk-!-margin-bottom-7 ">
|
||||||
<div className="govuk-grid-row paginationWrapper">
|
<div className="govuk-grid-row paginationWrapper">
|
||||||
<div className="govuk-grid-column-one-quarter paginationPrevious">
|
<div className="govuk-grid-column-one-quarter paginationPrevious">
|
||||||
{currentPage != 1 ? (
|
{props.currentView.currentPage != 1 ? (
|
||||||
<span
|
<span
|
||||||
className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem leftTextButton"
|
className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem leftTextButton"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -114,7 +117,7 @@ const PaginationControl = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="govuk-grid-column-one-half paginationContainer">
|
<div className="govuk-grid-column-one-half paginationContainer">
|
||||||
{paginationArray.map((e, i) =>
|
{paginationArray.map((e, i) =>
|
||||||
props.currentView.currentPage == i + 1 ? (
|
props.currentView.currentPage == e ? (
|
||||||
<span
|
<span
|
||||||
key={i}
|
key={i}
|
||||||
className=" govuk-body govuk-!-padding-2 govuk-!-font-weight-bold "
|
className=" govuk-body govuk-!-padding-2 govuk-!-font-weight-bold "
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ const PaginationControl = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const paginationNumbers = (currentPage, pageCount) => {
|
const paginationNumbers = (currentPage, pageCount) => {
|
||||||
|
//console.log(currentPage);
|
||||||
let delta;
|
let delta;
|
||||||
|
|
||||||
if (pageCount <= 7) {
|
if (pageCount <= 7) {
|
||||||
@@ -43,7 +44,7 @@ const PaginationControl = (props) => {
|
|||||||
// delta === 2: [1 ... 4 5 6 ... 10]
|
// delta === 2: [1 ... 4 5 6 ... 10]
|
||||||
// delta === 4: [1 2 3 4 5 ... 10]
|
// delta === 4: [1 2 3 4 5 ... 10]
|
||||||
//delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4;
|
//delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4;
|
||||||
delta = currentPage > 4 && currentPage < pageCount - 3 ? 2 : 4;
|
delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
const range = {
|
const range = {
|
||||||
@@ -79,10 +80,12 @@ const PaginationControl = (props) => {
|
|||||||
return pages;
|
return pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginationArray = paginationNumbers(currentPage, pagesCount);
|
const paginationArray = paginationNumbers(
|
||||||
|
props.currentView.currentPage,
|
||||||
|
pagesCount
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{" "}
|
|
||||||
{pagesCount > 1 && (
|
{pagesCount > 1 && (
|
||||||
<div className="govuk-!-margin-bottom-7 ">
|
<div className="govuk-!-margin-bottom-7 ">
|
||||||
<div className="govuk-grid-row paginationWrapper">
|
<div className="govuk-grid-row paginationWrapper">
|
||||||
|
|||||||
Reference in New Issue
Block a user