diff --git a/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/form/form.component.ts b/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/form/form.component.ts index a52da6d578fa7617a4cb26369e9c3405cb90426e..fabae1f0973511ad9cb06a3690eaa9dc4063c519 100644 --- a/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/form/form.component.ts +++ b/projects/nshmp-apps/src/app/internal/aws/submit-haz-jobs/components/form/form.component.ts @@ -116,7 +116,7 @@ export class FormComponent implements OnInit, OnDestroy { /** Control form state */ form = this.service.formGroup; - private overrideSubscription = new Subscription(); + private subscriptions: Subscription[] = []; constructor( public service: AppService, @@ -132,9 +132,9 @@ export class FormComponent implements OnInit, OnDestroy { } ngOnInit(): void { - const {nshmpConfig} = this.form.controls; + const {mapConfig, nshmpConfig} = this.form.controls; - this.overrideSubscription = + const overrideSubscription = this.form.controls.overrideNshmpLib.valueChanges.subscribe( overrideNshmpLib => { if (overrideNshmpLib) { @@ -150,10 +150,26 @@ export class FormComponent implements OnInit, OnDestroy { } }, ); + + this.subscriptions.push(overrideSubscription); + + const mapSubscription = mapConfig.controls.createMap.valueChanges.subscribe( + createMap => { + if (createMap) { + mapConfig.controls.region.enable(); + mapConfig.controls.title.enable(); + } else { + mapConfig.controls.region.disable(); + mapConfig.controls.title.disable(); + } + }, + ); + + this.subscriptions.push(mapSubscription); } ngOnDestroy(): void { - this.overrideSubscription.unsubscribe(); + this.subscriptions.forEach(subscription => subscription.unsubscribe()); } /**