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

feat: Pagination on iPad #550

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions frontend/src/app/components/common/complaint-pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Form } from "react-bootstrap";
import Select from "react-select";
import Pagination from "react-bootstrap/Pagination";
import Option from "../../types/app/option";
import config from "../../../config";

interface ComplaintPaginationProps {
currentPage: number;
Expand Down Expand Up @@ -54,8 +55,8 @@ const ComplaintPagination: React.FC<ComplaintPaginationProps> = ({
const items = [];

// Calculate the range of pages to display based on the current page
const startPage = Math.max(1, lastPage > 10 ? currentPage - 4 : 1);
const endPage = Math.min(lastPage, startPage + 9);
const startPage = Math.max(1, lastPage > 5 ? currentPage - 4 : 1);
const endPage = Math.min(lastPage, startPage + 5);

// Render the ellipsis if necessary
if (startPage > 1) {
Expand All @@ -70,7 +71,7 @@ const ComplaintPagination: React.FC<ComplaintPaginationProps> = ({
);
}

if (startPage > 1 && lastPage > 10) {
if (startPage > 1 && lastPage > 5) {
items.push(
<Pagination.Ellipsis
key="ellipsis-start"
Expand Down Expand Up @@ -141,13 +142,15 @@ const ComplaintPagination: React.FC<ComplaintPaginationProps> = ({

<div className="pagination_controls_end">
{/* Select total viewable records */}
<Select
menuPlacement="top"
id="resultsPerPageSelect"
options={pageSizeOptions}
classNamePrefix="comp-select"
defaultValue={defaultOption}
/>
{config.SHOW_EXPERIMENTAL_FEATURES === "true" && (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentional? @afwilcox you want to put feature flag for this?

<Select
menuPlacement="top"
id="resultsPerPageSelect"
options={pageSizeOptions}
classNamePrefix="comp-select"
defaultValue={defaultOption}
/>
)}

{/* Go to specific page */}
<div className="pagination_specific_page">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/sass/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ button.modal-buttons {
height: 38px;
}

@include media-breakpoint-down(xl) {
@include media-breakpoint-down(lg) {
.page-item:not(:first-of-type):not(:last-of-type):not(.active) {
display: none;
}
Expand Down
Loading