blob: d2eaef0391bd035de4abb66a8c11a5b45277a77c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import { Pipe, PipeTransform } from '@angular/core';
import { DerivedFEProperty } from 'app/models';
@Pipe({
name: 'filterChildProperties',
})
export class FilterChildPropertiesPipe implements PipeTransform {
public transform(childProperties: Array<DerivedFEProperty>, parentId: string) {
if (!parentId || !childProperties) return childProperties;
let validParents: Array<string> = [parentId];
while (parentId.lastIndexOf('#') > 0) {
parentId = parentId.substring(0, parentId.lastIndexOf('#'));
validParents.push(parentId);
}
return childProperties.filter(derivedProp => validParents.indexOf(derivedProp.parentName) > -1);
}
}
|