Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.frontend into DEVELOP
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 9c23438..3f96aac 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
@@ -267,6 +267,7 @@
                   type="text"
                   class="form-control"
                   id="voltageLevel"
+                  name="voltageLevel"
                   [ngrxFormControlState]="formState.controls['voltageLevel']"
                   (change)="gridFailureDetailsSandbox.resetFailureLocationValues(); setLocation()"
                 >
@@ -290,7 +291,13 @@
             >
               <label for="pressureLevel" class="col-sm-2 col-form-label">{{ 'GridFailure.PressureLevel' | translate }}</label>
               <div class="col-sm-4">
-                <select type="text" class="form-control" id="pressureLevel" [ngrxFormControlState]="formState.controls['pressureLevel']">
+                <select
+                  [required]="!gridFailureDetailsSandbox.oldVersion && !formState.isDisabled"
+                  type="text"
+                  class="form-control"
+                  id="pressureLevel"
+                  [ngrxFormControlState]="formState.controls['pressureLevel']"
+                >
                   <option [value]="null" selected>{{ 'SelectOption' | translate }}</option>
                   <option *ngFor="let enum of gridFailureDetailsSandbox.pressureLevelEnum | keyvalue" [value]="enum.key">{{ enum.value }}</option>
                 </select>
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts
index 5f9277e..c352742 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts
@@ -491,10 +491,12 @@
     service.noBranchId = '123';
     const spy1 = spyOn(service as any, '_setNoBranchId');
     const spy2 = spyOn(service as any, '_setGasBranchId');
+    const spy3 = spyOn(service as any, '_setPowerBranchId');
     (service as any)._setBranchIds();
     expect(service.noBranchId).toBe('123');
     expect(spy1).toHaveBeenCalled();
     expect(spy2).toHaveBeenCalled();
+    expect(spy3).toHaveBeenCalled();
   });
 
   it('should not set the noBranchId value null if not found OS Brnach', () => {
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts
index 3151017..25d423e 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts
@@ -27,6 +27,7 @@
   INITIAL_STATE,
   NO_BRANCH_ID_KEY,
   GAS_BRANCH_ID_KEY,
+  POWER_BRANCH_ID_KEY,
 } from '@grid-failure-information-app/shared/store/reducers/grid-failures/grid-failure-details-form.reducer';
 import { navigateHome, stationToStationDescriptionConverter, sortAlphaNum } from '@grid-failure-information-app/shared/utility';
 import { unboxProperties } from '@grid-failure-information-app/shared/utility/form-utils';
@@ -82,6 +83,7 @@
   public maxVersionNumber: number;
   public currentGridFailureDetailsCoords: models.FailureCoordsInformation = new models.FailureCoordsInformation();
   public noBranchId: string;
+  public powerBranchId: string;
   public isFieldRequiredDependingOnBranchId: boolean = false;
 
   public addressCommunities$: Observable<Array<string>> = this.actionsSubject.pipe(
@@ -803,6 +805,7 @@
       if (branches.length > 0) {
         this._setNoBranchId(branches);
         this._setGasBranchId(branches);
+        this._setPowerBranchId(branches);
       }
     });
   }
@@ -813,6 +816,12 @@
     this.appState$.dispatch(new SetUserDefinedPropertyAction(FORM_ID, NO_BRANCH_ID_KEY, this.noBranchId));
   }
 
+  private _setPowerBranchId(branches: models.FailureBranch[]): void {
+    const powerBranch: models.FailureBranch = branches.find(branch => branch.name === enums.BranchNameEnum.POWER);
+    this.powerBranchId = !!powerBranch ? powerBranch.id : null;
+    this.appState$.dispatch(new SetUserDefinedPropertyAction(FORM_ID, POWER_BRANCH_ID_KEY, this.powerBranchId));
+  }
+
   private _setGasBranchId(branches: models.FailureBranch[]): void {
     let gasBranchId: string;
     const gasBranch: models.FailureBranch = branches.find(branch => branch.name === enums.BranchNameEnum.GAS);
diff --git a/projects/grid-failure-information-app/src/app/shared/store/reducers/grid-failures/grid-failure-details-form.reducer.ts b/projects/grid-failure-information-app/src/app/shared/store/reducers/grid-failures/grid-failure-details-form.reducer.ts
index d65ebed..e28e50b 100644
--- a/projects/grid-failure-information-app/src/app/shared/store/reducers/grid-failures/grid-failure-details-form.reducer.ts
+++ b/projects/grid-failure-information-app/src/app/shared/store/reducers/grid-failures/grid-failure-details-form.reducer.ts
@@ -37,6 +37,7 @@
 export const FORM_CONTROLS: FormGroupControls<GridFailure> = INITIAL_STATE.controls;
 export const NO_BRANCH_ID_KEY: string = 'NO_BRANCH_ID';
 export const GAS_BRANCH_ID_KEY: string = 'GAS_BRANCH_ID';
+export const POWER_BRANCH_ID_KEY: string = 'POWER_BRANCH_ID';
 
 /**
  * Helper method checks if one of dependet fields (field nameIds passed as controlNames:string[]) is set to null.
@@ -106,7 +107,7 @@
   return validateForm(formState, currentAction);
 }
 
-export function requiredIf(propState: any, formState: any, controlId: string, dependencyPropertyKey: string): any {
+export function notRequiredIf(propState: any, formState: any, controlId: string, dependencyPropertyKey: string): any {
   const dependencyProperty: string = getDependencyPropertyFromControlId(controlId);
   if (formState.controls[dependencyProperty].value !== formState.userDefinedProperties[dependencyPropertyKey]) {
     return validate(propState, required);
@@ -114,6 +115,18 @@
   return validate(propState, item => null);
 }
 
+// Required if dependency property is dependencyPropertyKey or null (default behavior)
+export function requiredIf(propState: any, formState: any, controlId: string, dependencyPropertyKey: string): any {
+  const dependencyProperty: string = getDependencyPropertyFromControlId(controlId);
+  if (
+    formState.controls[dependencyProperty].value === formState.userDefinedProperties[dependencyPropertyKey] ||
+    formState.controls[dependencyProperty].value === null
+  ) {
+    return validate(propState, required);
+  }
+  return validate(propState, item => null);
+}
+
 export const validateForm: ActionReducer<FormState<GridFailure>> = createFormStateReducerWithUpdate<GridFailure>(
   updateGroup<GridFailure>(
     {
@@ -190,28 +203,34 @@
     },
     {
       postcode: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       city: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       street: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       latitude: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       longitude: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       district: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       housenumber: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
       },
       radiusId: (propState, formState): any => {
-        return requiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+        return notRequiredIf(propState, formState, formState.controls.branchId.id, NO_BRANCH_ID_KEY);
+      },
+      voltageLevel: (propState, formState): any => {
+        return requiredIf(propState, formState, formState.controls.branchId.id, POWER_BRANCH_ID_KEY);
+      },
+      pressureLevel: (propState, formState): any => {
+        return requiredIf(propState, formState, formState.controls.branchId.id, GAS_BRANCH_ID_KEY);
       },
     },
     {