|
|
|
@ -17,8 +17,6 @@ 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();
|
|
|
|
|
}
|
|
|
|
@ -35,6 +33,7 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
|
|
|
|
|
return this._maxResultCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _skipCount = 0;
|
|
|
|
|
private _page = 0;
|
|
|
|
|
set page(value: number) {
|
|
|
|
|
if (value === this._page) return;
|
|
|
|
@ -81,6 +80,7 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get = () => {
|
|
|
|
|
this.resetPageWhenUnchanged();
|
|
|
|
|
this._query$.next(({
|
|
|
|
|
filter: this._filter || undefined,
|
|
|
|
|
maxResultCount: this._maxResultCount,
|
|
|
|
@ -110,6 +110,15 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.destroy$.next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private resetPageWhenUnchanged() {
|
|
|
|
|
const skipCount = this._page * this._maxResultCount;
|
|
|
|
|
|
|
|
|
|
if (skipCount === this._skipCount) {
|
|
|
|
|
this._page = 0;
|
|
|
|
|
this._skipCount = 0;
|
|
|
|
|
} else this._skipCount = skipCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type QueryStreamCreatorCallback<T, QueryParamsType = ABP.PageQueryParams> = (
|
|
|
|
|