From abe9b929f4e012d535cbff064b54760437d39a36 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Wed, 15 Jan 2020 10:40:43 -0500 Subject: [PATCH] Properties group filtering support --- src/lib/properties/properties.group.component.html | 2 +- src/lib/properties/properties.group.component.ts | 9 +++++++++ src/lib/shared/flo-properties.ts | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/properties/properties.group.component.html b/src/lib/properties/properties.group.component.html index 4ed9674..8756723 100644 --- a/src/lib/properties/properties.group.component.html +++ b/src/lib/properties/properties.group.component.html @@ -1,3 +1,3 @@
- +
diff --git a/src/lib/properties/properties.group.component.ts b/src/lib/properties/properties.group.component.ts index 28b7a4a..9b1f07e 100644 --- a/src/lib/properties/properties.group.component.ts +++ b/src/lib/properties/properties.group.component.ts @@ -1,6 +1,8 @@ import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; import { FormGroup, FormControl } from '@angular/forms'; import { Properties } from '../shared/flo-properties'; +import Property = Properties.Property; +import PropertyFilter = Properties.PropertyFilter; @Component({ selector: 'properties-group', @@ -15,6 +17,9 @@ export class PropertiesGroupComponent implements OnInit { @Input() form: FormGroup; + @Input() + filter: PropertyFilter; + ngOnInit() { if (this.propertiesGroupModel.isLoading) { let subscription = this.propertiesGroupModel.loadedSubject.subscribe(loaded => { @@ -38,4 +43,8 @@ export class PropertiesGroupComponent implements OnInit { }) } + get controlModelsToDisplay() { + return this.propertiesGroupModel.getControlsModels().filter(c => !this.filter || this.filter.accept(c.property)); + } + } diff --git a/src/lib/shared/flo-properties.ts b/src/lib/shared/flo-properties.ts index 149d384..40bddb6 100644 --- a/src/lib/shared/flo-properties.ts +++ b/src/lib/shared/flo-properties.ts @@ -28,6 +28,10 @@ export namespace Properties { readonly [propName: string]: any; } + export interface PropertyFilter { + accept: (property: Property) => boolean; + } + export interface SelectOption { name: string; value: any;