Skip to content

Commit

Permalink
[TM-1603] change the quantity of elements shown in tables in site rep…
Browse files Browse the repository at this point in the history
…orts landing pages (#854)
  • Loading branch information
cesarLima1 authored Jan 29, 2025
1 parent 562bddb commit 4deebec
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/elements/ImageGallery/ImageGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ const ImageGallery = ({
defaultPageSize={defaultPageSize}
hasPageSizeSelector
invertSelect
isImageGallery
galleryType={"imageGallery"}
/>
</div>
</>
Expand Down
5 changes: 4 additions & 1 deletion src/components/elements/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface TableProps<TData>
onRowClick?: (row: TData) => void;
contentClassName?: string;
classNameTableWrapper?: string;
galleryType?: string;
}

export interface TableState {
Expand Down Expand Up @@ -91,6 +92,7 @@ function Table<TData extends RowData>({
resetOnDataChange = true, // maintains default behavior
onRowClick,
contentClassName,
galleryType,
...props
}: TableProps<TData>) {
const t = useT();
Expand Down Expand Up @@ -300,10 +302,11 @@ function Table<TData extends RowData>({
previousPage={previousPage}
setPageIndex={setPageIndex}
setPageSize={setPageSize}
defaultPageSize={initialTableState?.pagination?.pageSize || 5}
defaultPageSize={galleryType === "treeSpeciesPD" ? 8 : initialTableState?.pagination?.pageSize || 5}
containerClassName="mt-6"
hasPageSizeSelector
invertSelect={invertSelectPagination}
galleryType={galleryType}
/>
)}
</div>
Expand Down
18 changes: 16 additions & 2 deletions src/components/extensive/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,25 @@ export interface PaginationProps extends PageSelectorProps {
setPageSize?: (count: number) => void;
variant?: VariantPagination;
invertSelect?: boolean;
isImageGallery?: boolean;
galleryType?: string;
}

function getPageSizeOptions(galleryType?: string) {
if (galleryType === undefined) {
return [5, 10, 15, 20, 50];
}
if (galleryType === "imageGallery") {
return [3, 6, 12, 30, 60];
}
if (galleryType === "treeSpeciesPD") {
return [8, 16, 24, 40, 56];
}
return [5, 10, 15, 20, 50];
}

function Pagination(props: PaginationProps) {
const t = useT();
const pageSizeOptions = getPageSizeOptions(props.galleryType);
return (
<div
className={classNames(
Expand All @@ -28,7 +42,7 @@ function Pagination(props: PaginationProps) {
{props.hasPageSizeSelector ? (
<PerPageSelector
label={t(props.variant?.labelText || "Per page")}
options={props.isImageGallery ? [3, 6, 12, 30, 60] : [5, 10, 15, 20, 50]}
options={pageSizeOptions}
variantText={props.variant?.VariantPrePageText}
defaultValue={props.defaultPageSize}
onChange={props.setPageSize!}
Expand Down
3 changes: 3 additions & 0 deletions src/components/extensive/Tables/TreeSpeciesTablePD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface TreeSpeciesTablePDProps {
| "treeCountSite"
| "saplingsCount";
visibleRows?: number;
galleryType?: string;
}

export interface TreeSpeciesTableRowData {
Expand All @@ -61,6 +62,7 @@ const TreeSpeciesTablePD = ({
secondColumnWidth = "",
typeTable,
visibleRows = 5,
galleryType,
data
}: TreeSpeciesTablePDProps) => {
const queryParams: any = {};
Expand Down Expand Up @@ -436,6 +438,7 @@ const TreeSpeciesTablePD = ({
hasPagination
invertSelectPagination
visibleRows={visibleRows}
galleryType={galleryType}
/>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions src/pages/reports/site-report/[uuid].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ const SiteReportDetailPage = () => {
modelUUID={siteReportUUID}
collection="tree-planted"
framework={siteReport.framework_key}
visibleRows={8}
galleryType={"treeSpeciesPD"}
/>
</div>
</ContextCondition>
Expand All @@ -195,6 +197,8 @@ const SiteReportDetailPage = () => {
modelUUID={siteReportUUID}
collection="tree-planted"
framework={siteReport.framework_key}
visibleRows={8}
galleryType={"treeSpeciesPD"}
/>
</div>
</ContextCondition>
Expand All @@ -221,6 +225,8 @@ const SiteReportDetailPage = () => {
modelUUID={siteReportUUID}
collection="seeding"
framework={siteReport.framework_key}
visibleRows={8}
galleryType={"treeSpeciesPD"}
/>
</div>
</ContextCondition>
Expand All @@ -247,6 +253,8 @@ const SiteReportDetailPage = () => {
modelUUID={siteReportUUID}
collection="non-tree"
framework={siteReport.framework_key}
visibleRows={8}
galleryType={"treeSpeciesPD"}
/>
</div>
</ContextCondition>
Expand All @@ -273,6 +281,8 @@ const SiteReportDetailPage = () => {
modelUUID={siteReportUUID}
collection="replanting"
framework={siteReport.framework_key}
visibleRows={8}
galleryType={"treeSpeciesPD"}
/>
</div>
</ContextCondition>
Expand Down

0 comments on commit 4deebec

Please sign in to comment.