From a7a7c4538ade1f673de40c992e5626e7be5c59f8 Mon Sep 17 00:00:00 2001 From: Jozef Daxner Date: Thu, 3 Jul 2025 09:37:53 +0200 Subject: [PATCH] [NAE-2122] Implement Structured and Efficient Pagination in gRPC - Enable proper task pagination handling - Added a pagination view flag and adjusted task loading logic to properly handle paginated data in task and case views. --- .../abstract-task-list-pagination.component.ts | 2 ++ .../abstract-case-list-paginator.component.ts | 2 +- .../src/lib/view/task-view/service/task-view.service.ts | 8 ++++++++ .../task-list-pagination.component.html | 3 +-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts b/projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts index 04ec4b9fc..96dfff5c9 100644 --- a/projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts +++ b/projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts @@ -23,6 +23,8 @@ export abstract class AbstractTaskListPaginationComponent extends AbstractDefaul @Input() public disabled: boolean; @Input() set tasks$(tasks: Observable>) { + this._taskViewService.paginationView = true; + this._taskViewService.nextPagePagination(this.pageSize, this.pageIndex); this._tasks$ = tasks.pipe((tap(() => { this.length = this._taskViewService.pagination.totalElements; this.pageIndex = this._taskViewService.pagination.number; diff --git a/projects/netgrif-components-core/src/lib/view/case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts b/projects/netgrif-components-core/src/lib/view/case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts index deb0a335d..e8c89c34c 100644 --- a/projects/netgrif-components-core/src/lib/view/case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts +++ b/projects/netgrif-components-core/src/lib/view/case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts @@ -26,8 +26,8 @@ export abstract class AbstractCaseListPaginatorComponent extends AbstractDefault @Optional() @Inject(NAE_TAB_DATA) injectedTabData: InjectedTabData, protected route?: ActivatedRoute) { super(_caseViewService, _log, injectedTabData, route); - this._caseViewService.nextPagePagination(this.pageSize, this.pageIndex); this._caseViewService.paginationView = true; + this._caseViewService.nextPagePagination(this.pageSize, this.pageIndex); this.cases$ = this._caseViewService.cases$.pipe(tap(() => { this.length = this._caseViewService.pagination.totalElements; this.pageIndex = this._caseViewService.pagination.number; diff --git a/projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts b/projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts index dcf51183c..e35032327 100644 --- a/projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts +++ b/projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts @@ -51,6 +51,7 @@ export class TaskViewService extends AbstractSortableViewComponent implements On protected _allowMultiOpen: boolean; private readonly _initializing: boolean = true; + protected _paginationView: boolean = false; constructor(protected _taskService: TaskResourceService, private _userService: UserService, @@ -127,6 +128,9 @@ export class TaskViewService extends AbstractSortableViewComponent implements On if (pageLoadResult.requestContext !== null) { this._loading$.off(pageLoadResult.requestContext.filter); } + if (this._paginationView) { + return pageLoadResult.tasks; + } return result; }, {}) ); @@ -202,6 +206,10 @@ export class TaskViewService extends AbstractSortableViewComponent implements On return this._allowMultiOpen; } + public set paginationView(value: boolean) { + this._paginationView = value; + } + public loadPage(requestContext: PageLoadRequestContext): Observable { if (requestContext === null || requestContext.pageNumber < 0) { return of({tasks: {}, requestContext}); diff --git a/projects/netgrif-components/src/lib/panel/task-panel-list-pagination/task-list-pagination.component.html b/projects/netgrif-components/src/lib/panel/task-panel-list-pagination/task-list-pagination.component.html index 74eb50653..11d8705bd 100644 --- a/projects/netgrif-components/src/lib/panel/task-panel-list-pagination/task-list-pagination.component.html +++ b/projects/netgrif-components/src/lib/panel/task-panel-list-pagination/task-list-pagination.component.html @@ -11,8 +11,7 @@