diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts b/catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts new file mode 100644 index 0000000000..d2eaef0391 --- /dev/null +++ b/catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts @@ -0,0 +1,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); + } +}
\ No newline at end of file |