From e71a31eb2b7f471b1b898a80b537b5825ad5977d Mon Sep 17 00:00:00 2001 From: CloudNiner Date: Fri, 22 Dec 2017 15:28:08 -0500 Subject: [PATCH] Directly update freq/intensity form controls The ngx-bootstrap button group btnRadio directive is busted for reactive forms, so we just implement directly with events for now instead: https://github.com/valor-software/ngx-bootstrap/issues/2581 --- .../steps/hazard-step.component.html | 22 ++++++++++--------- .../steps/hazard-step.component.ts | 8 ++++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.html b/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.html index 69e45b35d..735534526 100644 --- a/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.html +++ b/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.html @@ -23,21 +23,23 @@
Probability
Frequency
- +
Intensity
- +
diff --git a/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.ts b/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.ts index 589311941..59942e402 100644 --- a/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.ts +++ b/src/angular/planit/src/app/risk-wizard/steps/hazard-step.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { FormBuilder, FormGroup } from '@angular/forms'; +import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { OrgRiskDirectionalOption, @@ -46,6 +46,7 @@ export class HazardStepComponent extends WizardStepComponent implements On super.ngOnInit(); this.risk = this.session.getData() || new Risk({}); this.setupForm(this.fromModel(this.risk)); + this.form.get('intensity').valueChanges.subscribe(v => console.log('intensity: ', v)); } save() { @@ -57,6 +58,11 @@ export class HazardStepComponent extends WizardStepComponent implements On this.session.setDataForKey(this.key, data); } + updateDirectionalControl(control: FormControl, value: OrgRiskDirectionalOption) { + control.setValue(value); + control.markAsDirty(); + } + setupForm(data: HazardStepFormModel) { this.form = this.fb.group({ 'frequency': [data.frequency, []],