diff --git a/helix-front/client/app/app.module.ts b/helix-front/client/app/app.module.ts index 1cedb009b6..596713537f 100644 --- a/helix-front/client/app/app.module.ts +++ b/helix-front/client/app/app.module.ts @@ -1,6 +1,6 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { Angulartics2Module, Angulartics2Piwik } from 'angulartics2'; @@ -26,6 +26,7 @@ import { DashboardModule } from './dashboard/dashboard.module'; imports: [ BrowserModule, FormsModule, + ReactiveFormsModule, HttpClientModule, AppRoutingModule, Angulartics2Module.forRoot([ Angulartics2Piwik ]), diff --git a/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.html b/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.html index ff8ef68210..bd080c4ec8 100644 --- a/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.html +++ b/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.html @@ -17,7 +17,7 @@ ~ under the License. --> -
+

{{ title }}

@@ -25,26 +25,26 @@

{{ title }}

- {{ values[name].label }}: + {{ value.values[name].label }}: - {{ values[name].value ? 'True' : 'False' }} + formControlName="values[name].value"> + {{ value.values[name].value ? 'True' : 'False' }}
diff --git a/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.ts b/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.ts index d09800829c..2b10039f1d 100644 --- a/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.ts +++ b/helix-front/client/app/shared/dialog/input-dialog/input-dialog.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Inject } from '@angular/core'; import { MatDialogRef } from '@angular/material'; import { MAT_DIALOG_DATA } from '@angular/material'; +import { FormControl, FormGroup } from '@angular/forms'; @Component({ selector: 'hi-input-dialog', @@ -11,7 +12,8 @@ export class InputDialogComponent implements OnInit { title: string; message: string; - values: any[]; + // values: any[]; + myForm: FormGroup; constructor( @Inject(MAT_DIALOG_DATA) protected data: any, @@ -21,16 +23,33 @@ export class InputDialogComponent implements OnInit { ngOnInit() { this.title = (this.data && this.data.title) || 'Input'; this.message = (this.data && this.data.message) || 'Please enter:'; - this.values = (this.data && this.data.values) || { - 'input': { - label: 'Anything you want', - type: 'input' - } - }; + // this.values = (this.data && this.data.values) || { + // 'input': { + // label: 'Anything you want', + // type: 'input' + // } + // }; + this.myForm = new FormGroup({ + values: new FormControl((this.data && this.data.values) || { + 'input': { + label: 'Anything you want', + type: 'input' + } + }) + }) + console.log(this.myForm) } - onSubmit() { - this.dialogRef.close(this.values); + // onSubmit() { + // this.dialogRef.close(this.values); + // } + + onSubmit(form: FormGroup) { + this.dialogRef.close(form.value.values); + console.log('Form Valid?', form.valid) + console.log('Title', form.value.title) + console.log('Message', form.value.message) + console.log('Values', JSON.stringify(form.value.values)) } onCancel() { diff --git a/helix-front/client/app/shared/shared.module.ts b/helix-front/client/app/shared/shared.module.ts index 0aa75d1ea5..b7fa761ce1 100644 --- a/helix-front/client/app/shared/shared.module.ts +++ b/helix-front/client/app/shared/shared.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; import { FlexLayoutModule } from '@angular/flex-layout'; -import { FormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { NgxJsonViewerModule } from 'ngx-json-viewer'; @@ -28,6 +28,7 @@ import { DisabledLabelComponent } from './disabled-label/disabled-label.componen MaterialModule, FlexLayoutModule, FormsModule, + ReactiveFormsModule, NgxDatatableModule, NgxJsonViewerModule ],