|
|
@ -35,6 +35,8 @@ export class EntitiesDataSource<T extends BaseData<HasId>, P extends PageLink = |
|
|
|
|
|
|
|
|
public currentEntity: T = null; |
|
|
public currentEntity: T = null; |
|
|
|
|
|
|
|
|
|
|
|
public dataLoading = true; |
|
|
|
|
|
|
|
|
constructor(private fetchFunction: EntitiesFetchFunction<T, P>, |
|
|
constructor(private fetchFunction: EntitiesFetchFunction<T, P>, |
|
|
protected selectionEnabledFunction: EntityBooleanFunction<T>, |
|
|
protected selectionEnabledFunction: EntityBooleanFunction<T>, |
|
|
protected dataLoadedFunction: (col?: number, row?: number) => void) {} |
|
|
protected dataLoadedFunction: (col?: number, row?: number) => void) {} |
|
|
@ -56,6 +58,7 @@ export class EntitiesDataSource<T extends BaseData<HasId>, P extends PageLink = |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
loadEntities(pageLink: P): Observable<PageData<T>> { |
|
|
loadEntities(pageLink: P): Observable<PageData<T>> { |
|
|
|
|
|
this.dataLoading = true; |
|
|
const result = new ReplaySubject<PageData<T>>(); |
|
|
const result = new ReplaySubject<PageData<T>>(); |
|
|
this.fetchFunction(pageLink).pipe( |
|
|
this.fetchFunction(pageLink).pipe( |
|
|
tap(() => { |
|
|
tap(() => { |
|
|
@ -68,6 +71,7 @@ export class EntitiesDataSource<T extends BaseData<HasId>, P extends PageLink = |
|
|
this.pageDataSubject.next(pageData); |
|
|
this.pageDataSubject.next(pageData); |
|
|
result.next(pageData); |
|
|
result.next(pageData); |
|
|
this.dataLoadedFunction(); |
|
|
this.dataLoadedFunction(); |
|
|
|
|
|
this.dataLoading = false; |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
return result; |
|
|
return result; |
|
|
|