From 68b5bc7dd61a8cc47103df113de7de6fba00f879 Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Wed, 29 May 2024 14:52:32 +0300 Subject: [PATCH] pagination bug fix on how found-last-page gets calculated --- .../recent-edited-activity.component.html | 2 +- .../recent-edited-activity.component.ts | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html index d448831da..4f29d7ce1 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html @@ -37,7 +37,7 @@
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
-
+
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index 1f9fe1ec1..fde20dd7f 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -38,7 +38,6 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn currentPage: number = 0; pageSize: number = 5; listingItems: RecentActivityItem[]= []; - foundLastPage: boolean = false; // in case the total-items-count is equal to this.pageSize*this.currentPage @Input() type: string; @Input() includeDescriptions: boolean = false; @@ -171,27 +170,25 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn ] }; - const initItems = this.currentPage == 0; - this.loadMore({ size: initItems ? this.pageSize : this.pageSize*this.currentPage, offset: 0 }, initItems); + this.loadMore({ size: this.currentPage == 0 ? this.pageSize : this.pageSize*this.currentPage, offset: 0 }); } - loadMore(page?: Lookup.Paging, updatePage: boolean = true) { + loadMore(page?: Lookup.Paging) { if (!page) page = { size: this.pageSize, offset: this.pageSize*this.currentPage }; this.lookup.page = page; - this.loadItems(PaginationAction.LoadMore, updatePage); + this.loadItems(PaginationAction.LoadMore); } loadLess() { this.loadItems(PaginationAction.LoadLess); } - private loadItems(action: PaginationAction, updatePage: boolean = true){ + private loadItems(action: PaginationAction){ if (action == PaginationAction.LoadLess) { let latestBatchCount = this.listingItems.length%this.pageSize == 0 ? this.pageSize : this.listingItems.length%this.pageSize; this.listingItems = this.listingItems.slice(0, this.listingItems.length-latestBatchCount); this._setPage(this.currentPage-1); - this.foundLastPage = false; return; } @@ -221,7 +218,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn } }) - if (updatePage && response.length > 0 && this.listingItems.length >= this.currentPage*this.pageSize) this._setPage(this.currentPage+1); + if (this.lookup.page.offset != 0 && response.length > 0 && this.listingItems.length >= this.currentPage*this.pageSize) this._setPage(this.currentPage+1); else this._resetPagination(); }); } @@ -229,7 +226,6 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn private _resetPagination(): void { if (this.listingItems.length == 0) this.currentPage = 0; else this.currentPage = Math.ceil(this.listingItems.length/this.pageSize); - this.foundLastPage = true; this.updateUrl(); }