Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#46116] Pages have unnecessary "..." collapsing between 1st and 2nd page

Dombi Attilaf7b874de16fd
diff --git a/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts b/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts
index e3e11b5eb4c..77a77cced60 100644
--- a/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts
+++ b/frontend/src/app/shared/components/table-pagination/table-pagination.component.ts
@@ -163,13 +163,23 @@ export class TablePaginationComponent extends UntilDestroyedMixin implements OnI
}
// This avoids a truncation when there are not enough elements to truncate for the first elements
- const startingDiff = currentPage - 2 * truncSize;
- if (startingDiff >= 0 && startingDiff <= 1) {
- this.postPageNumbers = this.truncatePageNums(pageNumbers, pageNumbers.length >= maxVisible + (truncSize * 2), maxVisible + truncSize, pageNumbers.length, 0);
- } else {
- this.prePageNumbers = this.truncatePageNums(pageNumbers, currentPage >= maxVisible, 0, Math.min(currentPage - Math.ceil(maxVisible / 2), pageNumbers.length - maxVisible), truncSize);
- this.postPageNumbers = this.truncatePageNums(pageNumbers, pageNumbers.length >= maxVisible + (truncSize * 2), maxVisible, pageNumbers.length, 0);
- }
+ const preVisible = Math.min(currentPage - Math.ceil(maxVisible / 2), pageNumbers.length - maxVisible);
+
+ this.prePageNumbers = this.truncatePageNums(
+ pageNumbers,
+ (currentPage >= maxVisible) && (pageNumbers.length >= maxVisible + (truncSize * 2)),
+ 0,
+ preVisible,
+ truncSize,
+ );
+
+ this.postPageNumbers = this.truncatePageNums(
+ pageNumbers,
+ pageNumbers.length >= maxVisible + (truncSize * 2),
+ maxVisible,
+ pageNumbers.length,
+ 0,
+ );
}
this.pageNumbers = pageNumbers;
@@ -181,7 +191,7 @@ export class TablePaginationComponent extends UntilDestroyedMixin implements OnI
&& this.pagination.total > this.perPageOptions[0];
}
- private truncatePageNums(pageNumbers:any, perform:any, disectFrom:any, disectLength:any, truncateFrom:any) {
+ private truncatePageNums(pageNumbers:number[], perform:boolean, disectFrom:number, disectLength:number, truncateFrom:number):number[] {
if (perform) {
const truncationSize = this.paginationService.getOptionsTruncationSize();
const truncatedNums = pageNumbers.splice(disectFrom, disectLength);