Browse Source

setting total count on service. (find a better way)

pull/17258/head
Sinan997 3 years ago
parent
commit
c26ee586b2
  1. 29
      npm/ng-packs/packages/core/src/lib/services/list.service.ts
  2. 4
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

29
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,15 +132,15 @@ export class ListService<QueryParamsType = ABP.PageQueryParams | any> implements
}
private resetPageWhenUnchanged() {
console.log('this.page',this._page);
console.log('this._maxResultCount',this._maxResultCount);
console.log('this._skipCount',this._skipCount);
const skipCount = this._page * this._maxResultCount;
console.log({skipCount});
this._skipCount = skipCount;
console.log('this.page',this._page);
console.log('this._maxResultCount',this._maxResultCount);
console.log('this._skipCount',this._skipCount);
const skipCount = this._page * this._maxResultCount; // 10
if(skipCount === this._totalCount){
if(this.page > 0){
this.page = this.page - 1;
}
}else{
this._skipCount = skipCount;
}
}
private next() {

4
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -185,8 +185,8 @@ export class UsersComponent implements OnInit {
private hookToQuery() {
this.list.hookToQuery(query => this.service.getList(query)).subscribe(res => {
(this.data = res)
console.log(this.data);
this.data = res;
this.list.totalCount = res.totalCount
});
}

Loading…
Cancel
Save