From a352a67305f05c587707a3fdc99ea0599895f3a7 Mon Sep 17 00:00:00 2001 From: Deepak Date: Thu, 26 Sep 2024 13:18:55 -0400 Subject: [PATCH 1/2] update search count --- client/app/components/Pagination/Pagination.jsx | 10 ++++++---- client/app/queue/QueueTable.jsx | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/app/components/Pagination/Pagination.jsx b/client/app/components/Pagination/Pagination.jsx index abf002945bb..1433978bdce 100644 --- a/client/app/components/Pagination/Pagination.jsx +++ b/client/app/components/Pagination/Pagination.jsx @@ -46,16 +46,17 @@ class Pagination extends React.PureComponent { currentPage, pageSize, totalCases, - currentCases + currentCases, + searchValue } = this.props; // If there are no pages, there is no data, so the range should be 0-0. // Otherwise, the beginning of the range is the previous amount of cases + 1 - const beginningCaseNumber = totalCases === 0 ? 0 : ((currentPage * pageSize) - pageSize + 1); + const beginningCaseNumber = searchValue ? (totalCases === 0 ? 0 : 1) : (totalCases === 0 ? 0 : ((currentPage * pageSize) - pageSize + 1)); // If there are no pages, there is no data, so the range should be 0-0. // Otherwise, the end of the range is the previous amount of cases + // the amount of data in the current page. - const endingCaseNumber = totalCases === 0 ? 0 : (beginningCaseNumber + currentCases - 1); + const endingCaseNumber = searchValue ? totalCases : totalCases === 0 ? 0 : (beginningCaseNumber + currentCases - 1); // Create the range let currentCaseRange = `${beginningCaseNumber}-${endingCaseNumber}`; // Create the entire summary @@ -147,7 +148,8 @@ Pagination.propTypes = { totalCases: PropTypes.number, updatePage: PropTypes.func.isRequired, table: PropTypes.oneOfType([PropTypes.instanceOf(Table), PropTypes.object]), - enableTopPagination: PropTypes.bool + enableTopPagination: PropTypes.bool, + searchValue: PropTypes.string }; export default Pagination; diff --git a/client/app/queue/QueueTable.jsx b/client/app/queue/QueueTable.jsx index 0217d421c08..b3b26dcc94f 100644 --- a/client/app/queue/QueueTable.jsx +++ b/client/app/queue/QueueTable.jsx @@ -780,16 +780,23 @@ export default class QueueTable extends React.PureComponent { } let paginationElements = null; + let currentCases; if (enablePagination && !this.state.loadingComponent) { + if (searchValue) { + currentCases = totalTaskCount = this.filterTasksFromSearchbar(rowObjects, searchValue)?.length + } else { + currentCases = rowObjects ? rowObjects.length : 0 + } paginationElements = ( this.updateCurrentPage(newPage)} + searchValue={searchValue} /> ); } From f38f95b7f9ab8b2126ddc119908e9575d5037778 Mon Sep 17 00:00:00 2001 From: Deepak Date: Thu, 3 Oct 2024 15:50:42 -0400 Subject: [PATCH 2/2] remove nested ternary operator --- .../app/components/Pagination/Pagination.jsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/client/app/components/Pagination/Pagination.jsx b/client/app/components/Pagination/Pagination.jsx index 1433978bdce..1c5f2c6fb0a 100644 --- a/client/app/components/Pagination/Pagination.jsx +++ b/client/app/components/Pagination/Pagination.jsx @@ -52,11 +52,25 @@ class Pagination extends React.PureComponent { // If there are no pages, there is no data, so the range should be 0-0. // Otherwise, the beginning of the range is the previous amount of cases + 1 - const beginningCaseNumber = searchValue ? (totalCases === 0 ? 0 : 1) : (totalCases === 0 ? 0 : ((currentPage * pageSize) - pageSize + 1)); + let beginningCaseNumber; + if (searchValue) { + beginningCaseNumber = totalCases === 0 ? 0 : 1; + } else if (totalCases === 0) { + beginningCaseNumber = 0; + } else { + beginningCaseNumber = currentPage * pageSize - pageSize + 1; + } // If there are no pages, there is no data, so the range should be 0-0. // Otherwise, the end of the range is the previous amount of cases + // the amount of data in the current page. - const endingCaseNumber = searchValue ? totalCases : totalCases === 0 ? 0 : (beginningCaseNumber + currentCases - 1); + let endingCaseNumber; + if (searchValue) { + endingCaseNumber = totalCases; + } else if (totalCases === 0) { + endingCaseNumber = 0; + } else { + endingCaseNumber = beginningCaseNumber + currentCases - 1; + } // Create the range let currentCaseRange = `${beginningCaseNumber}-${endingCaseNumber}`; // Create the entire summary