[SI-1379] - show address location form as default if valid for the selected branch and no station form available
- call setLocation() in onChange event of the branch ddl

Signed-off-by: dtheinert <dietmar.theinert@pta.de>
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html
index 50c144e..1008c0e 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html
@@ -142,6 +142,7 @@
                   type="text"
                   class="form-control"
                   [ngrxFormControlState]="formState.controls['branchId']"
+                  (change)="setLocation()"
                 >
                   <option [ngValue]="null" selected disabled>{{ 'SelectOption' | translate }}</option>
                   <option *ngFor="let branch of gridFailureDetailsSandbox.branches" [ngValue]="branch.id"> {{ branch.description }}</option>
@@ -374,14 +375,7 @@
                   {{ 'GridFailure.Address' | translate }}
                 </button>
                 <button
-                  *ngIf="
-                    formState.value.branch === Globals.BUSINESS_RULE_FIELDS.branch.telecommunication ||
-                    (formState.value.branch === Globals.BUSINESS_RULE_FIELDS.branch.power && formState.value.voltageLevel === Globals.FAILURE_LOCATION_MS) ||
-                    (formState.value.branch !== Globals.BUSINESS_RULE_FIELDS.branch.water &&
-                      formState.value.branch !== Globals.BUSINESS_RULE_FIELDS.branch.gas &&
-                      formState.value.branch !== Globals.BUSINESS_RULE_FIELDS.branch.secondaryTechnology &&
-                      formState.value.branch !== Globals.BUSINESS_RULE_FIELDS.branch.districtHeating)
-                  "
+                  *ngIf="isLocationButtonForStationVisible(formState.value.branch, formState.value.voltageLevel)"
                   class="btn btn-primary non-outline"
                   (click)="
                     failureLocationView = Globals.FAILURE_LOCATION_MS;
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts
index d4e8ea0..ad5570f 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts
@@ -133,6 +133,21 @@
     this._initialFailureLocationState();
   }
 
+  public isLocationButtonForStationVisible(branch: string, voltageLevel: string = '') {
+    if (branch === Globals.BUSINESS_RULE_FIELDS.branch.telecommunication) {
+      return true;
+    } else if (branch === Globals.BUSINESS_RULE_FIELDS.branch.power && voltageLevel === Globals.FAILURE_LOCATION_MS) {
+      return true;
+    } else if (
+      branch === Globals.BUSINESS_RULE_FIELDS.branch.water ||
+      branch === Globals.BUSINESS_RULE_FIELDS.branch.gas ||
+      branch === Globals.BUSINESS_RULE_FIELDS.branch.secondaryTechnology ||
+      branch === Globals.BUSINESS_RULE_FIELDS.branch.districtHeating
+    ) {
+      return false;
+    }
+  }
+
   private _initialFailureLocationState() {
     this.failureLocationView = Globals.FAILURE_LOCATION_NS;
     combineLatest(this.gridFailureDetailsSandbox.gridFailureDetailsFormState$, this.gridFailureDetailsSandbox.gridFailureStations$)