From 30393199fe6ef9f79b86ce3f78acdf9f71b78060 Mon Sep 17 00:00:00 2001 From: Darko Date: Thu, 24 Oct 2024 15:59:11 -0400 Subject: [PATCH] I18N-1326 - Add pagination size dropdown in Branch page for Branches with large text unit count Added pagination size dropdown for Branches with large text unit count --- .../BranchTextUnitsPaginatorActions.js | 2 +- .../branches/BranchesSearchResults.js | 64 +++++++++++++++---- .../branches/BranchTextUnitsPaginatorStore.js | 5 ++ 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/webapp/src/main/resources/public/js/actions/branches/BranchTextUnitsPaginatorActions.js b/webapp/src/main/resources/public/js/actions/branches/BranchTextUnitsPaginatorActions.js index 55e04a53f..3a75f753f 100644 --- a/webapp/src/main/resources/public/js/actions/branches/BranchTextUnitsPaginatorActions.js +++ b/webapp/src/main/resources/public/js/actions/branches/BranchTextUnitsPaginatorActions.js @@ -5,7 +5,7 @@ class BranchTextUnitsPaginatorActions { this.generateActions( "goToNextPage", "goToPreviousPage", - "changeCurrentPageNumber" + "changePageSize", ); } } diff --git a/webapp/src/main/resources/public/js/components/branches/BranchesSearchResults.js b/webapp/src/main/resources/public/js/components/branches/BranchesSearchResults.js index bda7a9165..658f5735a 100644 --- a/webapp/src/main/resources/public/js/components/branches/BranchesSearchResults.js +++ b/webapp/src/main/resources/public/js/components/branches/BranchesSearchResults.js @@ -1,7 +1,19 @@ import React from "react"; import PropTypes from 'prop-types'; import {FormattedDate, FormattedMessage, FormattedNumber, injectIntl} from "react-intl"; -import {Button, Col, Collapse, Glyphicon, Grid, Label, OverlayTrigger, Row, Tooltip} from "react-bootstrap"; +import { + Button, + Col, + Collapse, + DropdownButton, + Glyphicon, + Grid, + Label, + MenuItem, + OverlayTrigger, + Row, + Tooltip +} from "react-bootstrap"; import {Link, withRouter} from "react-router"; import ClassNames from "classnames"; import {withAppConfig} from "../../utils/AppConfig"; @@ -12,6 +24,7 @@ import BranchTextUnitsPaginatorStore from "../../stores/branches/BranchTextUnits import BranchTextUnitsPaginatorActions from "../../actions/branches/BranchTextUnitsPaginatorActions"; import BranchTextUnitsPageActions from "../../actions/branches/BranchTextUnitsPageActions"; import BranchesPageActions from "../../actions/branches/BranchesPageActions"; +import BranchesPaginatorActions from "../../actions/branches/BranchesPaginatorActions"; class BranchesSearchResults extends React.Component { @@ -72,21 +85,44 @@ class BranchesSearchResults extends React.Component { } renderBranchTextUnitsPagination() { + const branchTextUnitsPaginatorState = BranchTextUnitsPaginatorStore.getState(); + let pageSizes = []; + for (let i of [10, 25, 50, 100]) { + pageSizes.push( + { + BranchTextUnitsPaginatorActions.changePageSize(s); + BranchTextUnitsPageActions.getBranchTextUnits(); + } + }> + {i} + + ); + } + const title = ; return ( - - { - BranchesPageActions.changeSelectedBranchTextUnitIds([]); - BranchTextUnitsPaginatorActions.goToPreviousPage(); - BranchTextUnitsPageActions.getBranchTextUnits(); - }} - onNextPageClicked={() => { - BranchesPageActions.changeSelectedBranchTextUnitIds([]); - BranchTextUnitsPaginatorActions.goToNextPage(); - BranchTextUnitsPageActions.getBranchTextUnits(); - }}/> - +
+ + {pageSizes} + + + { + BranchesPageActions.changeSelectedBranchTextUnitIds([]); + BranchTextUnitsPaginatorActions.goToPreviousPage(); + BranchTextUnitsPageActions.getBranchTextUnits(); + }} + onNextPageClicked={() => { + BranchesPageActions.changeSelectedBranchTextUnitIds([]); + BranchTextUnitsPaginatorActions.goToNextPage(); + BranchTextUnitsPageActions.getBranchTextUnits(); + }}/> + +
); } diff --git a/webapp/src/main/resources/public/js/stores/branches/BranchTextUnitsPaginatorStore.js b/webapp/src/main/resources/public/js/stores/branches/BranchTextUnitsPaginatorStore.js index 83be33c4d..2ecc5a67e 100644 --- a/webapp/src/main/resources/public/js/stores/branches/BranchTextUnitsPaginatorStore.js +++ b/webapp/src/main/resources/public/js/stores/branches/BranchTextUnitsPaginatorStore.js @@ -35,6 +35,11 @@ class BranchTextUnitsPaginatorStore extends PaginatorStore { this.resetBranchTextUnitsSearchParams(); } } + + changePageSize(pageSize) { + this.resetBranchTextUnitsSearchParams(); + this.limit = pageSize; + } } export default alt.createStore(BranchTextUnitsPaginatorStore, 'BranchTextUnitsPaginatorStore');