This is an automated email from the ASF dual-hosted git repository. riemer pushed a commit to branch STREAMPIPES-145 in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 13d06444da027a29861e197b95f2393bde2c79db Author: Dominik Riemer <[email protected]> AuthorDate: Sat Jul 18 01:00:35 2020 +0200 [STREAMPIPES-145] Migrate static property alternatives --- .../base/abstract-validated-static-property.ts | 10 +++++- .../static-alternatives.component.html | 12 ++----- .../static-alternatives.component.ts | 41 ++++------------------ .../static-group/static-group.component.html | 8 +++-- .../static-property.component.html | 8 +++-- 5 files changed, 28 insertions(+), 51 deletions(-) diff --git a/ui/src/app/connect/static-properties/base/abstract-validated-static-property.ts b/ui/src/app/connect/static-properties/base/abstract-validated-static-property.ts index 629e708..3a74d07 100644 --- a/ui/src/app/connect/static-properties/base/abstract-validated-static-property.ts +++ b/ui/src/app/connect/static-properties/base/abstract-validated-static-property.ts @@ -19,8 +19,10 @@ import {StaticProperty} from "../../../core-model/gen/streampipes-model"; import {AbstractStaticPropertyRenderer} from "./abstract-static-property"; import {FormControl, ValidatorFn} from "@angular/forms"; +import {OnDestroy} from "@angular/core"; -export abstract class AbstractValidatedStaticPropertyRenderer<T extends StaticProperty> extends AbstractStaticPropertyRenderer<T> { +export abstract class AbstractValidatedStaticPropertyRenderer<T extends StaticProperty> + extends AbstractStaticPropertyRenderer<T> implements OnDestroy { errorMessage = "Please enter a value"; fieldValid: boolean; @@ -48,4 +50,10 @@ export abstract class AbstractValidatedStaticPropertyRenderer<T extends StaticPr abstract onValueChange(value: any); abstract onStatusChange(status: any); + + ngOnDestroy(): void { + if (this.parentForm) { + this.parentForm.removeControl(this.fieldName); + } + } } \ No newline at end of file diff --git a/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.html b/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.html index 4d0778c..f79921f 100644 --- a/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.html +++ b/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.html @@ -17,11 +17,6 @@ --> <div id="formWrapper" fxFlex="100" fxLayout="column"> - <div> - <p>{{staticProperty.label}}: <br> - <mat-hint class="description">{{staticProperty.description}}</mat-hint> - </p> - </div> <div fxFlex fxLayout="column" class="content"> <div> <mat-radio-group *ngIf="staticProperty.alternatives.length > 1" @@ -44,14 +39,11 @@ <div *ngFor="let alternative of staticProperty.alternatives"> <div *ngIf="alternative.selected == true && alternative.staticProperty != null"> - <div class="assemblyOptions sp-blue-bg"> - {{alternative.label}} - </div> - - <div class="sp-blue-border" style="padding-top: 0px; padding-bottom: 0px; + <div style="padding-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 10px"> <app-static-property [adapterId]="adapterId" [eventSchemas]="eventSchemas" + [parentForm]="parentForm" [staticProperty]="alternative.staticProperty" [displayRecommended]="displayRecommended" (validateEmitter)="valueChange($event)" diff --git a/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.ts b/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.ts index daa6e89..c36f27e 100644 --- a/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.ts +++ b/ui/src/app/connect/static-properties/static-alternatives/static-alternatives.component.ts @@ -16,7 +16,7 @@ * */ -import {Component, EventEmitter, OnInit, Output} from '@angular/core'; +import {ChangeDetectorRef, Component, EventEmitter, OnInit, Output} from '@angular/core'; import {AbstractStaticPropertyRenderer} from "../base/abstract-static-property"; import { StaticPropertyAlternatives, @@ -34,52 +34,25 @@ export class StaticAlternativesComponent @Output() inputEmitter: EventEmitter<Boolean> = new EventEmitter<Boolean>(); - private hasInput: Boolean; private errorMessage = "Please select a option"; - ngOnInit(): void { - this.staticProperty.alternatives.forEach( alternative => alternative.selected = false); - // TODO: Remove hack - if (this.staticProperty.alternatives.length === 1) { - this.hasInput = true; - this.inputEmitter.emit(this.hasInput); - } + constructor(private changeDetectorRef: ChangeDetectorRef) { + super(); } - valueChange(inputValue) { - // TODO: Remove hack - if (this.staticProperty.alternatives.length === 1) { - this.hasInput = true; - } else { - - this.hasInput = false; - let alternative = this.staticProperty.alternatives.find(alternative => alternative.selected == true); - if (alternative !== undefined) { - if (alternative.staticProperty !== undefined) { - var childsAreValid = true; - (<StaticPropertyGroup> alternative.staticProperty).staticProperties.forEach(property => { - if (!(property as any).isValid) { - childsAreValid = false - } - }); - this.hasInput = childsAreValid; - } else { - this.hasInput = true; - } - } - } - this.inputEmitter.emit(this.hasInput); + ngOnInit(): void { + this.staticProperty.alternatives.forEach( alternative => alternative.selected = false); } radioSelectionChange(event) { this.staticProperty.alternatives.forEach(alternative => { - if (alternative.elementId == event.value.id) { + if (alternative.elementId == event.value.elementId) { alternative.selected = true; } else { alternative.selected = false; } }); - this.valueChange(event); + this.changeDetectorRef.detectChanges(); } } \ No newline at end of file diff --git a/ui/src/app/connect/static-properties/static-group/static-group.component.html b/ui/src/app/connect/static-properties/static-group/static-group.component.html index fbd0375..32d30f6 100644 --- a/ui/src/app/connect/static-properties/static-group/static-group.component.html +++ b/ui/src/app/connect/static-properties/static-group/static-group.component.html @@ -16,10 +16,12 @@ ~ --> -<div *ngIf="!staticProperty.horizontalRendering" class="padding" fxLayout="column"> +<div *ngIf="!staticProperty.horizontalRendering" fxLayout="column"> <app-static-property *ngFor="let property of staticProperty.staticProperties" [adapterId]="adapterId" + [parentForm]="parentForm" [staticProperties]="staticProperties" + [fieldName]="property.internalName" [eventSchemas]="eventSchemas" [staticProperty]="property" [displayRecommended]="displayRecommended" @@ -28,11 +30,11 @@ </div> -<div *ngIf="staticProperty.horizontalRendering" class="padding" fxLayout="row" fxLayoutAlign="space-between center"> +<div *ngIf="staticProperty.horizontalRendering" fxLayout="row" fxLayoutAlign="space-between center"> <ng-container *ngFor="let property of staticProperty.staticProperties; let i = index"> <span *ngIf="i > 0" style="margin-left: 10px;"></span> <app-static-property - [adapterId]="adapterId" [staticProperties]="staticProperties" [eventSchema]="eventSchema" + [adapterId]="adapterId" [staticProperties]="staticProperties" [eventSchemas]="eventSchemas" [staticProperty]="property" (validateEmitter)="valueChange($event)" class="test fullWidth"> </app-static-property> </ng-container> diff --git a/ui/src/app/connect/static-properties/static-property.component.html b/ui/src/app/connect/static-properties/static-property.component.html index b96e235..dc5762f 100644 --- a/ui/src/app/connect/static-properties/static-property.component.html +++ b/ui/src/app/connect/static-properties/static-property.component.html @@ -17,12 +17,12 @@ --> <div fxFlex="100" fxLayout="column"> - <div fxFlex="100" fxLayout="row" class="static-property-panel"> - <div fxFlex="30" fxLayout="column"> + <div fxFlex="100" fxLayout="column" class="static-property-panel"> + <div fxFlex="100" fxLayout="column" style="margin-bottom:10px;"> <b>{{staticProperty.label}}</b> <mat-hint class="description">{{staticProperty.description}}</mat-hint> </div> - <div fxFlex="70"> + <div fxFlex="100"> <app-static-code-input *ngIf="isCodeInputStaticProperty(staticProperty)" [staticProperty]="staticProperty" [parentForm]="parentForm" @@ -99,6 +99,7 @@ <app-static-alternatives *ngIf="isAlternativesStaticProperty(staticProperty)" [adapterId]="adapterId" [eventSchemas]="eventSchemas" + [parentForm]="parentForm" [staticProperty]="staticProperty" [displayRecommended]="displayRecommended" class="test fullWidth" @@ -108,6 +109,7 @@ <app-static-group *ngIf="isGroupStaticProperty(staticProperty)" [adapterId]="adapterId" [eventSchemas]="eventSchemas" + [parentForm]="parentForm" [staticProperty]="staticProperty" [displayRecommended]="displayRecommended" class="test fullWidth"
