From 6ab774194b4026a3dfc4dcc1b10185ad551db858 Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Thu, 23 Nov 2023 12:09:50 +0300 Subject: [PATCH 1/3] fix results and validation table pagination --- .../components/patient/SearchPatientForm.js | 47 +++++++++++++++---- .../components/resultPage/SearchResultForm.js | 25 ++++++++-- .../src/components/validation/Validation.js | 18 ++++--- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/patient/SearchPatientForm.js b/frontend/src/components/patient/SearchPatientForm.js index db7a8048d1..ff4134bea5 100644 --- a/frontend/src/components/patient/SearchPatientForm.js +++ b/frontend/src/components/patient/SearchPatientForm.js @@ -1,5 +1,5 @@ import React, { useContext, useState } from "react"; -import { FormattedMessage, injectIntl ,useIntl} from "react-intl"; +import { FormattedMessage, injectIntl, useIntl } from "react-intl"; import "../Style.css"; import { getFromOpenElisServer } from "../utils/Utils"; import { @@ -132,7 +132,10 @@ function SearchPatientForm(props) { {({ field }) => ( @@ -142,7 +145,10 @@ function SearchPatientForm(props) { {({ field, setFieldValue }) => ( { @@ -157,7 +163,10 @@ function SearchPatientForm(props) { {({ field }) => ( @@ -167,7 +176,10 @@ function SearchPatientForm(props) { {({ field }) => ( @@ -188,7 +200,10 @@ function SearchPatientForm(props) { @@ -200,18 +215,27 @@ function SearchPatientForm(props) { @@ -221,7 +245,10 @@ function SearchPatientForm(props) {
diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryDashboard.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryDashboard.js index e9fd6f1e08..1895882c97 100644 --- a/frontend/src/components/immunohistochemistry/ImmunohistochemistryDashboard.js +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryDashboard.js @@ -18,6 +18,7 @@ import { TableBody, TableCell, Section, + Pagination, } from "@carbon/react"; import { Search } from "@carbon/react"; import { @@ -50,6 +51,8 @@ function ImmunohistochemistryDashboard() { }); const { userSessionDetails } = useContext(UserSessionDetailsContext); const [loading, setLoading] = useState(true); + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); function formatDateToDDMMYYYY(date) { var day = date.getDate(); @@ -79,7 +82,15 @@ function ImmunohistochemistryDashboard() { formatDateToDDMMYYYY(currentDate) ); }; + const handlePageChange = (pageInfo) => { + if (page != pageInfo.page) { + setPage(pageInfo.page); + } + if (pageSize != pageInfo.pageSize) { + setPageSize(pageInfo.pageSize); + } + }; const tileList = [ { title: "Cases in Progress", count: counts.inProgress }, { @@ -313,7 +324,10 @@ function ImmunohistochemistryDashboard() { )} +
diff --git a/frontend/src/components/pathology/PathologyDashboard.js b/frontend/src/components/pathology/PathologyDashboard.js index a3773ac532..4d05c28c97 100644 --- a/frontend/src/components/pathology/PathologyDashboard.js +++ b/frontend/src/components/pathology/PathologyDashboard.js @@ -18,6 +18,7 @@ import { TableCell, Tile, Loading, + Pagination, } from "@carbon/react"; import UserSessionDetailsContext from "../../UserSessionDetailsContext"; import { Search } from "@carbon/react"; @@ -38,6 +39,8 @@ function PathologyDashboard() { const { userSessionDetails } = useContext(UserSessionDetailsContext); const [statuses, setStatuses] = useState([]); const [pathologyEntries, setPathologyEntries] = useState([]); + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); const [filters, setFilters] = useState({ searchTerm: "", myCases: false, @@ -74,6 +77,16 @@ function PathologyDashboard() { ); }; + const handlePageChange = (pageInfo) => { + if (page != pageInfo.page) { + setPage(pageInfo.page); + } + + if (pageSize != pageInfo.pageSize) { + setPageSize(pageInfo.pageSize); + } + }; + const renderCell = (cell, row) => { var status = row.cells.find((e) => e.info.header === "status").value; var pathologySampleId = row.id; @@ -303,7 +316,10 @@ function PathologyDashboard() { )} + diff --git a/frontend/src/components/resultPage/SearchResultForm.js b/frontend/src/components/resultPage/SearchResultForm.js index 5efe710320..cb800a2370 100644 --- a/frontend/src/components/resultPage/SearchResultForm.js +++ b/frontend/src/components/resultPage/SearchResultForm.js @@ -1033,13 +1033,6 @@ export function SearchResults(props) { } }; - // const paginationOptions = { - // rowsPerPageText: 'Rows per page:', - // rangeSeparatorText: 'of', - // selectAllRowsItem: true, - // selectAllRowsItemText: 'All', - // }; - return ( <> {notificationVisible === true ? : ""} @@ -1091,10 +1084,6 @@ export function SearchResults(props) { isSortable expandableRows expandableRowsComponent={renderReferral} - // pagination - // paginationPerPage={10} // Number of rows per page - // paginationRowsPerPageOptions={[10, 20, 30, 40, 50 ,100]} // Options for rows per page dropdown - // paginationComponentOptions={paginationOptions} > Date: Thu, 23 Nov 2023 13:24:30 +0300 Subject: [PATCH 3/3] add pagination for the workplan page --- frontend/src/components/workplan/Workplan.js | 179 +++++++++++-------- 1 file changed, 101 insertions(+), 78 deletions(-) diff --git a/frontend/src/components/workplan/Workplan.js b/frontend/src/components/workplan/Workplan.js index c11626ee30..4c7a6ccc6f 100644 --- a/frontend/src/components/workplan/Workplan.js +++ b/frontend/src/components/workplan/Workplan.js @@ -11,6 +11,7 @@ import { TableHead, TableHeader, TableRow, + Pagination, } from "@carbon/react"; import React, { useState, useContext } from "react"; import "../Style.css"; @@ -32,6 +33,8 @@ export default function Workplan(props) { const [configurationName, setConfigurationName] = useState(""); const [selectedValue, setSelectedValue] = useState(""); const [selectedLabel, setSelectedLabel] = useState(""); + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); const type = props.type; let title = ""; @@ -64,6 +67,15 @@ export default function Workplan(props) { const handleSelectedLabel = (val) => { setSelectedLabel(val); }; + const handlePageChange = (pageInfo) => { + if (page != pageInfo.page) { + setPage(pageInfo.page); + } + + if (pageSize != pageInfo.pageSize) { + setPageSize(pageInfo.pageSize); + } + }; const printWorkplan = () => { let form = { @@ -216,91 +228,102 @@ export default function Workplan(props) { - {testsList.map((row, index) => { - if (!(row.accessionNumber === currentAccessionNumber)) { - showAccessionNumber = true; - currentAccessionNumber = row.accessionNumber; - rowColorIndex++; - } else { - showAccessionNumber = false; - } - return ( - - {!row.servingAsTestGroupIdentifier && ( - - - disableEnableTest(e.target, index) - } - /> - - )} - {type === "test" && ( - - {row.nonconforming && ( - nonconforming { + if ( + !(row.accessionNumber === currentAccessionNumber) + ) { + showAccessionNumber = true; + currentAccessionNumber = row.accessionNumber; + rowColorIndex++; + } else { + showAccessionNumber = false; + } + return ( + + {!row.servingAsTestGroupIdentifier && ( + + + disableEnableTest(e.target, index) + } /> - )} - - )} - - {showAccessionNumber && ( - - - {convertAlphaNumLabNumForDisplay( - row.accessionNumber, - )} - - + + )} + {type === "test" && ( + + {row.nonconforming && ( + nonconforming + )} + )} - - {subjectOnWorkplan.toLowerCase() === "true" && ( - - {showAccessionNumber && row.patientInfo} - - )} - {nextVisitOnWorkplan.toLowerCase() === "true" && ( - - {showAccessionNumber && row.nextVisitDate} - - )} - {type !== "test" && ( - {row.nonconforming && ( - nonconforming + {showAccessionNumber && ( + + + {convertAlphaNumLabNumForDisplay( + row.accessionNumber, + )} + + )} - )} - {type !== "test" && ( - {row.testName} - )} - {row.receivedDate} - - ); - })} + {subjectOnWorkplan.toLowerCase() === "true" && ( + + {showAccessionNumber && row.patientInfo} + + )} + {nextVisitOnWorkplan.toLowerCase() === "true" && ( + + {showAccessionNumber && row.nextVisitDate} + + )} + {type !== "test" && ( + + {row.nonconforming && ( + nonconforming + )} + + )} + {type !== "test" && ( + {row.testName} + )} + {row.receivedDate} + + ); + })} +