Properties group filtering support
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user