Pagination for collections & Process feedback

This commit is contained in:
Marie Verdonck
2019-10-16 15:00:46 +02:00
parent adfe881a81
commit 84326ef564
20 changed files with 1420 additions and 457 deletions

View File

@@ -1,33 +1,35 @@
import {CommunityListAdapter, FlatNode} from './community-list-adapter';
import {CollectionViewer, DataSource} from '@angular/cdk/typings/collections';
import {BehaviorSubject, Observable,} from 'rxjs';
import {finalize, take,} from 'rxjs/operators';
import { CommunityListService, FlatNode } from './community-list-service';
import { CollectionViewer, DataSource } from '@angular/cdk/typings/collections';
import { BehaviorSubject, Observable, } from 'rxjs';
import { finalize, take, } from 'rxjs/operators';
export class CommunityListDatasource implements DataSource<FlatNode> {
private communityList$ = new BehaviorSubject<FlatNode[]>([]);
private loading$ = new BehaviorSubject<boolean>(false);
private communityList$ = new BehaviorSubject<FlatNode[]>([]);
public loading$ = new BehaviorSubject<boolean>(false);
constructor(private communityListService: CommunityListAdapter) {
}
constructor(private communityListService: CommunityListService) {
}
connect(collectionViewer: CollectionViewer): Observable<FlatNode[]> {
this.loadCommunities(null);
return this.communityList$.asObservable();
}
connect(collectionViewer: CollectionViewer): Observable<FlatNode[]> {
this.loadCommunities(null);
return this.communityList$.asObservable();
}
loadCommunities(expandedNodes: FlatNode[]) {
this.loading$.next(true);
loadCommunities(expandedNodes: FlatNode[]) {
this.loading$.next(true);
this.communityListService.loadCommunities(expandedNodes).pipe(
take(1),
finalize(() => this.loading$.next(false)),
).subscribe((flatNodes: FlatNode[]) => this.communityList$.next(flatNodes));
}
this.communityListService.loadCommunities(expandedNodes).pipe(
take(1),
finalize(() => this.loading$.next(false)),
).subscribe((flatNodes: FlatNode[]) => {
this.communityList$.next(flatNodes);
});
}
disconnect(collectionViewer: CollectionViewer): void {
this.communityList$.complete();
this.loading$.complete();
}
disconnect(collectionViewer: CollectionViewer): void {
this.communityList$.complete();
this.loading$.complete();
}
}