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

update search count #22988

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 6 additions & 4 deletions client/app/components/Pagination/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be best not to use a nested ternary operator.

// 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);
cacevesva marked this conversation as resolved.
Show resolved Hide resolved
// Create the range
let currentCaseRange = `${beginningCaseNumber}-${endingCaseNumber}`;
// Create the entire summary
Expand Down Expand Up @@ -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;
9 changes: 8 additions & 1 deletion client/app/queue/QueueTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<Pagination
pageSize={casesPerPage || DEFAULT_CASES_PER_PAGE}
currentPage={this.state.currentPage + 1}
currentCases={rowObjects ? rowObjects.length : 0}
currentCases={currentCases}
totalPages={numberOfPages}
totalCases={totalTaskCount}
updatePage={(newPage) => this.updateCurrentPage(newPage)}
searchValue={searchValue}
/>
);
}
Expand Down
Loading