@ -31,12 +31,10 @@ import { Injectable } from '@angular/core';
import { HttpHeaders } from '@angular/common/http' ;
import { from , Observable } from 'rxjs' ;
import {
catchError ,
groupBy ,
mergeMap ,
reduce ,
switchMap ,
map ,
tap ,
} from 'rxjs/operators' ;
@ -55,7 +53,7 @@ import idFromLink from 'core-app/features/hal/helpers/id-from-link';
export class FileLinksResourceService extends ResourceCollectionService < IFileLink > {
@InjectField ( ) toastService :ToastService ;
updateCollectionsForWorkPackage ( fileLinksSelfLink :string ) : Observable < void > {
updateCollectionsForWorkPackage ( fileLinksSelfLink :string ) : Observable < IFileLink [ ] > {
return this . http
. get < IHALCollection < IFileLink > > ( fileLinksSelfLink )
. pipe (
@ -72,14 +70,14 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin
return acc ;
} , seed ) ) ;
} ) ,
m ap( ( fileLinkCollections ) = > {
t ap( ( fileLinkCollections ) = > {
const storageId = idFromLink ( fileLinkCollections . storage ) ;
const collectionKey = ` ${ fileLinksSelfLink } ?filters=[{"storage":{"operator":"=","values":[" ${ storageId } "]}}] ` ;
const collection = { _embedded : { elements : fileLinkCollections.fileLinks } } as IHALCollection < IFileLink > ;
insertCollectionIntoState ( this . store , collection , collectionKey ) ;
} ) ,
catchError ( this . toastAndThrow . bind ( this ) ) ,
) as Observable < void > ;
reduce ( ( acc , group ) = > acc . concat ( group . fileLinks ) , [ ] as IFileLink [ ] ) ,
) ;
}
protected createStore ( ) : CollectionStore < IFileLink > {