Skip to content

Commit 1c22e3d

Browse files
authored
Merge pull request #20 from manni497/main
Possibility to display CurrentItemPerPage in Pagination Dropdown
2 parents b614ca9 + 540e490 commit 1c22e3d

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- possibility to display CurrentItemPerPage in Pagination dropdown and to be re-selected after one change
13+
1014
## [2.1.1] - 2022-12-09
1115

12-
- Added styling for button groups
16+
- Added styling for button groups
1317

1418
## [2.1.0] - 2022-12-01
1519

1620
### Added
1721

18-
- Added new layout components: `AuthenticationLayout`, `SideBarLayout`
22+
- Added new layout components: `AuthenticationLayout`, `SideBarLayout`
1923

2024
### Changed
2125

22-
- Adjusted exports to be more consistent
26+
- Adjusted exports to be more consistent
2327

2428
## [2.0.2] - 2022-04-14
2529

2630
### Fixed
2731

28-
- Fix added for missing react import aftger microbundling
32+
- Fix added for missing react import aftger microbundling
2933

3034
## [2.0.1] - 2022-04-12
3135

3236
### Fixed
3337

34-
- Package doesn't use 'h()' anymore, replaced with 'React.createElement' instead
38+
- Package doesn't use 'h()' anymore, replaced with 'React.createElement' instead
3539

3640
## [2.0.0] - 2022-04-07
3741

3842
### Added
3943

40-
- created package :tada:
41-
- added tests
42-
43-
[Unreleased]: https://github.com/neolution-ch/react-pattern-ui/compare/2.1.1...HEAD
44+
- created package :tada:
45+
- added tests
4446

47+
[unreleased]: https://github.com/neolution-ch/react-pattern-ui/compare/2.1.1...HEAD
4548
[2.1.1]: https://github.com/neolution-ch/react-pattern-ui/compare/2.1.0...2.1.1
46-
4749
[2.1.0]: https://github.com/neolution-ch/react-pattern-ui/compare/2.0.2...2.1.0
48-
4950
[2.0.2]: https://github.com/neolution-ch/react-pattern-ui/compare/2.0.1...2.0.2
50-
5151
[2.0.1]: https://github.com/neolution-ch/react-pattern-ui/compare/2.0.0...2.0.1
52-
5352
[2.0.0]: https://github.com/neolution-ch/react-pattern-ui/compare/45cbeb76034667019da84605082679900f506d75...2.0.0

src/Paging/Paging.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ function Paging({
2626
currentRecordCount,
2727
pagingPossible = true,
2828
translations,
29-
possiblePageItemCounts = [25, 50, 100, 200],
29+
possiblePageItemCounts,
3030
maxPagesShown = 7,
3131
showControls = true,
3232
setItemsPerPage,
3333
setCurrentPage,
3434
}: PagingProps) {
3535
const maxPage = Math.ceil(totalRecords / currentItemsPerPage);
3636
const firstPageShown = Math.max(0, Math.min(currentPage - Math.ceil(maxPagesShown / 2), maxPage - maxPagesShown));
37+
38+
const possibleItemsPerPage = possiblePageItemCounts ?? [25, 50, 100, 200];
39+
40+
if (!possibleItemsPerPage.includes(currentItemsPerPage)) {
41+
possibleItemsPerPage.concat(currentItemsPerPage).sort((a, b) => a - b);
42+
}
43+
3744
return (
3845
<Row style={{ marginBottom: "20px" }}>
3946
<Col xs={6}>
@@ -44,7 +51,7 @@ function Paging({
4451
</DropdownToggle>
4552
<DropdownMenu>
4653
<DropdownItem header>{translations.itemsPerPageDropdown}</DropdownItem>
47-
{possiblePageItemCounts.map((pageItemCount) => (
54+
{possibleItemsPerPage.map((pageItemCount) => (
4855
<DropdownItem key={`pageItemCount_${pageItemCount}`} onClick={() => setItemsPerPage(pageItemCount)}>
4956
{pageItemCount}
5057
</DropdownItem>

0 commit comments

Comments
 (0)