Properties group filtering support

This commit is contained in:
BoykoAlex
2020-01-15 10:40:43 -05:00
parent f4cf3cd8f2
commit abe9b929f4
3 changed files with 14 additions and 1 deletions

View File

@@ -1,3 +1,3 @@
<div *ngIf="propertiesGroupModel && !propertiesGroupModel.isLoading" class="properties-group-container" [formGroup]="form">
<df-property *ngFor="let model of propertiesGroupModel.getControlsModels()" [model]="model" [form]="form" class="property-row"></df-property>
<df-property *ngFor="let model of controlModelsToDisplay" [model]="model" [form]="form" class="property-row"></df-property>
</div>

View File

@@ -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));
}
}

View File

@@ -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;