From 4b6268ecb0e609fafb3cf3b8f693fdb2836d40d8 Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Wed, 2 Aug 2023 17:28:39 +0300 Subject: [PATCH] making page persistent after edit/delete --- .../packages/core/src/lib/services/list.service.ts | 7 ++++--- .../proxy/src/lib/proxy/identity/identity-user.service.ts | 7 +++---- .../identity/src/lib/components/users/users.component.ts | 5 +---- .../extensible-table/extensible-table.component.ts | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/list.service.ts b/npm/ng-packs/packages/core/src/lib/services/list.service.ts index 9395f87d5a..aff51daa1c 100644 --- a/npm/ng-packs/packages/core/src/lib/services/list.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/list.service.ts @@ -132,15 +132,16 @@ export class ListService implements } private resetPageWhenUnchanged() { - const skipCount = this._page * this._maxResultCount; // 10 + const maxPage = Number(Number(this._totalCount / this._maxResultCount).toFixed()) // 2 + const skipCount = this._page * this._maxResultCount; // 20 if(skipCount === this._totalCount){ - if(this.page > 0){ + if(this.page === maxPage && this.page > 0){ + this._skipCount = skipCount - this._maxResultCount this.page = this.page - 1; } }else{ this._skipCount = skipCount; } - } private next() { diff --git a/npm/ng-packs/packages/identity/proxy/src/lib/proxy/identity/identity-user.service.ts b/npm/ng-packs/packages/identity/proxy/src/lib/proxy/identity/identity-user.service.ts index b7951bca10..c3b6f203f2 100644 --- a/npm/ng-packs/packages/identity/proxy/src/lib/proxy/identity/identity-user.service.ts +++ b/npm/ng-packs/packages/identity/proxy/src/lib/proxy/identity/identity-user.service.ts @@ -52,15 +52,14 @@ export class IdentityUserService { }, { apiName: this.apiName }); - getList = (input: GetIdentityUsersInput) => { - console.log({input}); - return this.restService.request>({ + getList = (input: GetIdentityUsersInput) => + this.restService.request>({ method: 'GET', url: '/api/identity/users', params: { filter: input.filter, sorting: input.sorting, skipCount: input.skipCount, maxResultCount: input.maxResultCount }, }, { apiName: this.apiName }); - } + getRoles = (id: string) => diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts index 447a2a4d92..6dd1ab9f17 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts @@ -184,10 +184,7 @@ export class UsersComponent implements OnInit { } private hookToQuery() { - this.list.hookToQuery(query => this.service.getList(query)).subscribe(res => { - this.data = res; - this.list.totalCount = res.totalCount - }); + this.list.hookToQuery(query => this.service.getList(query)).subscribe(res => (this.data = res)); } openPermissionsModal(providerKey: string, entityDisplayName?: string) { diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts index 21dec03838..ae76565aa8 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts @@ -150,7 +150,7 @@ export class ExtensibleTableComponent implements OnChanges { ngOnChanges({ data }: SimpleChanges) { if (!data?.currentValue) return; - + this.list.totalCount = this.recordsTotal this.data = data.currentValue.map((record: any, index: number) => { this.propList.forEach(prop => { const propData = { getInjected: this.getInjected, record, index } as any;