Browse Source
Merge pull request #5431 from abpframework/fix/5429
Resolve filter problem in ListService
pull/5434/head
Mehmet Erim
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
0 deletions
-
npm/ng-packs/packages/core/src/lib/services/list.service.ts
-
npm/ng-packs/packages/theme-shared/src/lib/directives/ngx-datatable-list.directive.ts
|
|
|
@ -17,6 +17,8 @@ import { LIST_QUERY_DEBOUNCE_TIME } from '../tokens/list.token'; |
|
|
|
export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDestroy { |
|
|
|
private _filter = ''; |
|
|
|
set filter(value: string) { |
|
|
|
if (this._filter !== value) this._page = 0; |
|
|
|
|
|
|
|
this._filter = value; |
|
|
|
this.get(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -18,6 +18,7 @@ import { Subscription } from 'rxjs'; |
|
|
|
}) |
|
|
|
export class NgxDatatableListDirective implements OnChanges, OnDestroy, OnInit { |
|
|
|
private subscription = new Subscription(); |
|
|
|
private querySubscription = new Subscription(); |
|
|
|
|
|
|
|
@Input() list: ListService; |
|
|
|
|
|
|
|
@ -66,16 +67,28 @@ export class NgxDatatableListDirective implements OnChanges, OnDestroy, OnInit { |
|
|
|
this.subscription.add(sub); |
|
|
|
} |
|
|
|
|
|
|
|
private subscribeToQuery() { |
|
|
|
this.querySubscription.add( |
|
|
|
this.list.query$.subscribe(() => { |
|
|
|
if (this.list.page !== this.table.offset) this.table.offset = this.list.page; |
|
|
|
}), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnChanges({ list }: SimpleChanges) { |
|
|
|
if (!list.firstChange) return; |
|
|
|
|
|
|
|
const { maxResultCount, page } = list.currentValue; |
|
|
|
this.table.limit = maxResultCount; |
|
|
|
this.table.offset = page; |
|
|
|
|
|
|
|
this.querySubscription.unsubscribe(); |
|
|
|
this.subscribeToQuery(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy() { |
|
|
|
this.subscription.unsubscribe(); |
|
|
|
this.querySubscription.unsubscribe(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|