|
|
|
@ -18,6 +18,7 @@ import { Subscription } from 'rxjs'; |
|
|
|
}) |
|
|
|
export class NgxDatatableListDirective implements OnChanges, OnDestroy, OnInit { |
|
|
|
private subscription = new Subscription(); |
|
|
|
private querySubscription: Subscription; |
|
|
|
|
|
|
|
@Input() list: ListService; |
|
|
|
|
|
|
|
@ -66,12 +67,21 @@ export class NgxDatatableListDirective implements OnChanges, OnDestroy, OnInit { |
|
|
|
this.subscription.add(sub); |
|
|
|
} |
|
|
|
|
|
|
|
private subscribeToQuery() { |
|
|
|
this.querySubscription = 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; |
|
|
|
|
|
|
|
if (this.querySubscription) this.querySubscription.unsubscribe(); |
|
|
|
this.subscribeToQuery(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy() { |
|
|
|
|