[SI-1170]
BugFix
- Versions not loaded
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 0f591c4..30107a5 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
@@ -120,7 +120,7 @@
service['gridFailureId'] = 'id';
service.maxVersionNumber = 0;
service.loadGridFailureVersion('1');
- expect(appState.dispatch).toHaveBeenCalledTimes(3);
+ expect(appState.dispatch).toHaveBeenCalledTimes(2);
});
it('should clear form state when current change is canceled and form state is pristine', () => {
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 4dd9f9b..eb229c7 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
@@ -209,25 +209,17 @@
public loadGridFailureVersion(versionNumber: string): void {
if (!!versionNumber && +versionNumber < this.maxVersionNumber) {
+ this.appState$.dispatch(gridFailureActions.loadGridFailureVersion({ gridFailureId: this._gridFailureId, versionNumber: +versionNumber }));
this.appState$.dispatch(gridFailureActions.loadHistGridFailureStations({ failureId: this._gridFailureId, versionNumber: versionNumber }));
-
!this.currentFormState.isDisabled && this.appState$.dispatch(new DisableAction(FORM_ID));
this.oldVersion = true;
} else {
+ this.appState$.dispatch(gridFailureActions.loadGridFailureDetail({ payload: this._gridFailureId }));
this.appState$.dispatch(gridFailureActions.loadGridFailureStations({ payload: this._gridFailureId }));
- this.appState$.dispatch(new EnableAction(FORM_ID));
+ this.currentFormState.isDisabled && this.appState$.dispatch(new EnableAction(FORM_ID));
this.oldVersion = false;
}
- this.actionsSubject.pipe(ofType(gridFailureActions.loadGridFailureBranchesSuccess), take(1), takeUntil(this._endSubscriptions$)).subscribe(() => {
- if (!!versionNumber && +versionNumber === this.maxVersionNumber) {
- //necessary because of not-versioned publication properties
- this.appState$.dispatch(gridFailureActions.loadGridFailureDetail({ payload: this._gridFailureId }));
- } else {
- this.appState$.dispatch(gridFailureActions.loadGridFailureVersion({ gridFailureId: this._gridFailureId, versionNumber: +versionNumber }));
- }
- });
-
this._setGridFailureStations(versionNumber);
}
@@ -774,21 +766,14 @@
}
private _setGridFailureStations(versionNumber: string) {
- if (+versionNumber < this.maxVersionNumber) {
- this.histGridFailureStations$.pipe(take(1), takeUntil(this._endSubscriptions$)).subscribe(stations => {
- this.gridFailureStations = stations;
- if (this.gridFailureStations && !!this.gridFailureStations.length) {
- this._calculatePolygon(this.gridFailureStations.map(station => station.id));
- }
- });
- } else {
- this.gridFailureStations$.pipe(take(1), takeUntil(this._endSubscriptions$)).subscribe(stations => {
- this.gridFailureStations = stations;
- if (this.gridFailureStations && !!this.gridFailureStations.length) {
- this._calculatePolygon(this.gridFailureStations.map(station => station.id));
- }
- });
- }
+ const stationsService = +versionNumber < this.maxVersionNumber ? this.histGridFailureStations$ : this.gridFailureStations$;
+
+ stationsService.pipe(take(1), takeUntil(this._endSubscriptions$)).subscribe(stations => {
+ this.gridFailureStations = stations;
+ if (this.gridFailureStations && !!this.gridFailureStations.length) {
+ this._calculatePolygon(this.gridFailureStations.map(station => station.id));
+ }
+ });
}
private _showButtonsByState(state: string): void {