Virtual metadata on item delete - filter relationship types without relationships

This commit is contained in:
Samuel
2020-01-28 15:35:55 +01:00
parent cff3a6f010
commit b352690cca

View File

@@ -107,13 +107,20 @@ export class ItemDeleteComponent
getSucceededRemoteData(),
getRemoteDataPayload(),
map((relationshipTypes) => relationshipTypes.page),
map((types) => types.reduce<RelationshipType[]>((includedTypes, type) => {
if (!includedTypes.some((includedType) => includedType.id === type.id)) {
return [...includedTypes, type];
} else {
return includedTypes;
}
}, [])),
switchMap((types) =>
combineLatest(types.map((type) => this.getRelationships(type))).pipe(
map((relationships) =>
types.reduce<RelationshipType[]>((includedTypes, type, index) => {
if (!includedTypes.some((includedType) => includedType.id === type.id)
&& !(relationships[index].length === 0)) {
return [...includedTypes, type];
} else {
return includedTypes;
}
}, [])
),
)
),
);
this.types$.pipe(