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

I18N-1326 - Add pagination size dropdown in Branch page for Branches … #172

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class BranchTextUnitsPaginatorActions {
this.generateActions(
"goToNextPage",
"goToPreviousPage",
"changeCurrentPageNumber"
"changePageSize",
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 {
Expand Down Expand Up @@ -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(
<MenuItem
key={i}
eventKey={i}
active={i === branchTextUnitsPaginatorState.limit}
onSelect={(s, _) => {
BranchTextUnitsPaginatorActions.changePageSize(s);
BranchTextUnitsPageActions.getBranchTextUnits();
}
}>
{i}
</MenuItem>
);
}
const title = <FormattedMessage values={{"pageSize": branchTextUnitsPaginatorState.limit}} id="search.unitsPerPage" />;
return (
<Row>
<AltContainer store={BranchTextUnitsPaginatorStore}>
<Paginator
onPreviousPageClicked={() => {
BranchesPageActions.changeSelectedBranchTextUnitIds([]);
BranchTextUnitsPaginatorActions.goToPreviousPage();
BranchTextUnitsPageActions.getBranchTextUnits();
}}
onNextPageClicked={() => {
BranchesPageActions.changeSelectedBranchTextUnitIds([]);
BranchTextUnitsPaginatorActions.goToNextPage();
BranchTextUnitsPageActions.getBranchTextUnits();
}}/>
</AltContainer>
<div className="pull-right" style={{display: "flex", alignItems: "center", "gap": "15px"}}>
<DropdownButton id="branch-text-units-per-page" title={title}>
{pageSizes}
</DropdownButton>
<AltContainer store={BranchTextUnitsPaginatorStore}>
<Paginator
onPreviousPageClicked={() => {
BranchesPageActions.changeSelectedBranchTextUnitIds([]);
BranchTextUnitsPaginatorActions.goToPreviousPage();
BranchTextUnitsPageActions.getBranchTextUnits();
}}
onNextPageClicked={() => {
BranchesPageActions.changeSelectedBranchTextUnitIds([]);
BranchTextUnitsPaginatorActions.goToNextPage();
BranchTextUnitsPageActions.getBranchTextUnits();
}}/>
</AltContainer>
</div>
</Row>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class BranchTextUnitsPaginatorStore extends PaginatorStore {
this.resetBranchTextUnitsSearchParams();
}
}

changePageSize(pageSize) {
this.resetBranchTextUnitsSearchParams();
this.limit = pageSize;
}
}

export default alt.createStore(BranchTextUnitsPaginatorStore, 'BranchTextUnitsPaginatorStore');