SI-533 box-unbox problem fix Signed-off-by: Dimitrios Chalepakis <dimitrios.chalepakis@pta.de>
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 6790233..4f8b755 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
@@ -247,7 +247,7 @@ if (this.currentFormState.isValid) { this.appState$.dispatch( gridFailureActions.saveGridFailure({ - payload: new GridFailure({ ...unboxProperties(this.currentFormState.value) }), + payload: unboxProperties(this.currentFormState.value) as GridFailure, }) ); this.actionsSubject.pipe(ofType(gridFailureActions.saveGridFailureSuccess), take(1), takeUntil(this._endSubscriptions$)).subscribe(() => {
diff --git a/projects/grid-failure-information-app/src/app/shared/constants/globals.ts b/projects/grid-failure-information-app/src/app/shared/constants/globals.ts index cef950c..16c63f2 100644 --- a/projects/grid-failure-information-app/src/app/shared/constants/globals.ts +++ b/projects/grid-failure-information-app/src/app/shared/constants/globals.ts
@@ -26,4 +26,6 @@ lessThan: 'ist kleiner als', inRange: 'ist zwischen', }; + + public static PROPERTIES_TO_BOX: string[] = ['addressPolygonPoints']; }
diff --git a/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts b/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts index d1f4ca0..f0a68a7 100644 --- a/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts +++ b/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts
@@ -10,7 +10,8 @@ * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ -import { Boxed } from 'ngrx-forms'; +import { Boxed, box } from 'ngrx-forms'; +import { Globals } from '@grid-failure-information-app/shared/constants/globals'; export class GridFailure { public id: string = null; @@ -59,9 +60,15 @@ public failureInformationCondensedId: string = null; public addressPolygonPoints: Array<[Number, Number]> | Boxed<Array<[Number, Number]>> = null; - public constructor(data: Partial<GridFailure> = null) { + public constructor(data: any = null) { Object.keys(data || {}) .filter(property => this.hasOwnProperty(property)) - .forEach(property => (this[property] = data[property])); + .forEach(property => { + if (Globals.PROPERTIES_TO_BOX.includes(property)) { + this[property] = box(data[property]); + } else { + this[property] = data[property]; + } + }); } }