From 268a01d3e921207ad8d0e743e3d1a23267afee15 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 17 Mar 2025 14:02:53 -0600 Subject: [PATCH] handle create map --- .../components/form/form.component.ts | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 a52da6d57..fabae1f09 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()); } /** -- GitLab