Browse Source

Merge pull request #17258 from abpframework/issue-17077

ngx-datatable - stay current page after editing/deleting record.
pull/17377/head
Mahmut Gundogdu 3 years ago
committed by GitHub
parent
commit
fee536410e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      npm/ng-packs/packages/core/src/lib/services/list.service.ts
  2. 4
      npm/ng-packs/packages/identity/proxy/src/lib/proxy/identity/identity-user.service.ts
  3. 4
      npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts

25
npm/ng-packs/packages/core/src/lib/services/list.service.ts

@ -52,6 +52,17 @@ export class ListService<QueryParamsType = ABP.PageQueryParams | any> implements
return this._page;
}
private _totalCount = 0
set totalCount(value: number) {
if (value === this._totalCount) return;
this._totalCount = value;
this.get();
}
get totalCount(): number {
return this._totalCount;
}
private _sortKey = '';
set sortKey(value: string) {
this._sortKey = value;
@ -121,12 +132,18 @@ export class ListService<QueryParamsType = ABP.PageQueryParams | any> implements
}
private resetPageWhenUnchanged() {
const maxPage = Number(Number(this.totalCount / this._maxResultCount).toFixed());
const skipCount = this._page * this._maxResultCount;
if (skipCount === this._skipCount) {
this._page = 0;
this._skipCount = 0;
} else this._skipCount = skipCount;
if (skipCount !== this._totalCount) {
this._skipCount = skipCount;
return;
}
if (this.page === maxPage && this.page > 0) {
this._skipCount = skipCount - this._maxResultCount;
this.page = this.page - 1;
}
}
private next() {

4
npm/ng-packs/packages/identity/proxy/src/lib/proxy/identity/identity-user.service.ts

@ -52,13 +52,15 @@ export class IdentityUserService {
},
{ apiName: this.apiName });
getList = (input: GetIdentityUsersInput) =>
getList = (input: GetIdentityUsersInput) =>
this.restService.request<any, PagedResultDto<IdentityUserDto>>({
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) =>
this.restService.request<any, ListResultDto<IdentityRoleDto>>({

4
npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts

@ -150,6 +150,10 @@ export class ExtensibleTableComponent<R = any> implements OnChanges {
ngOnChanges({ data }: SimpleChanges) {
if (!data?.currentValue) return;
if (data.currentValue.length < 1) {
this.list.totalCount = this.recordsTotal
}
this.data = data.currentValue.map((record: any, index: number) => {
this.propList.forEach(prop => {

Loading…
Cancel
Save