Merge branch 'SI-2564-close-button' 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 e12f078..90458ba 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
@@ -625,7 +625,7 @@
[mapOptions]="mapOptions"
[mapDetailData]="gridFailureDetailsSandbox.currentGridFailureDetailsCoords"
[setInteractionMode]="mapInteractionMode"
- (latLong)="gridFailureDetailsSandbox.latLonMapping($event)"
+ (latLong)="gridFailureDetailsSandbox.latLonMapping($event, false)"
></openk-grid-failure-information-map>
</div>
</div>
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts
index 812d661..aa52f6f 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts
@@ -51,6 +51,7 @@
deleteGridFailureStation() {},
setBranchState() {},
setFormStateDirty() {},
+ setFormStatePristine() {},
gridFailureDetailsFormState$: of({ ...INITIAL_STATE, gridFailureDetailsFormResponse } as any),
currentFormState: INITIAL_STATE,
disableStationAttributes: false,
@@ -366,7 +367,7 @@
expect(spy).toHaveBeenCalled();
});
it('should not call setViewStateForReqProps() after setLocationRegionToAddress() with same failureLocationView', () => {
- component.failureLocationView = Globals.FAILURE_LOCATION_NS;
+ component.failureLocationView = Globals.FAILURE_LOCATION_NS;
const spy = spyOn(component, 'setViewStateForReqProps').and.callThrough();
component.setLocationRegionToAddress();
expect(spy).not.toHaveBeenCalled();
@@ -378,7 +379,7 @@
expect(spy).toHaveBeenCalled();
});
it('should not call setViewStateForReqProps() after setLocationRegionToStation() with same failureLocationView', () => {
- component.failureLocationView = Globals.FAILURE_LOCATION_MS;
+ component.failureLocationView = Globals.FAILURE_LOCATION_MS;
const spy = spyOn(component, 'setViewStateForReqProps').and.callThrough();
component.setLocationRegionToStation();
expect(spy).not.toHaveBeenCalled();
@@ -390,7 +391,7 @@
expect(spy).toHaveBeenCalled();
});
it('should not call setViewStateForReqProps() after setLocationRegionToMap() with same failureLocationView', () => {
- component.failureLocationView = Globals.FAILURE_LOCATION_MAP;
+ component.failureLocationView = Globals.FAILURE_LOCATION_MAP;
const spy = spyOn(component, 'setViewStateForReqProps').and.callThrough();
component.setLocationRegionToMap();
expect(spy).not.toHaveBeenCalled();
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 a04bf79..0973a25 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
@@ -83,6 +83,7 @@
this.gridFailureDetailsSandbox.deleteGridFailureStation(event.data.id);
}
});
+ this.gridFailureDetailsSandbox.setFormStatePristine();
}
public setBranchValue(branchId: string) {
const branch = this.gridFailureDetailsSandbox.branches.find(b => b.id === branchId);
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 38aeb92..257d07c 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
@@ -349,14 +349,14 @@
(service.currentFormState as any).isValid = true;
(service.currentFormState as any).value = gfdetail;
- service.latLonMapping(null);
+ service.latLonMapping(null, false);
expect(dispatchSpy).not.toHaveBeenCalled();
const event = new FailureStation();
event.latitude = 1.24;
event.longitude = 1.23;
- service.latLonMapping(event);
+ service.latLonMapping(event, false);
expect(dispatchSpy).toHaveBeenCalled();
});
@@ -701,7 +701,12 @@
},
};
(service as any)._handleUserDefinedProperties(formState);
- const communities = gridFailureActions.loadAddressStreets({community:null, postcode: formState.value.postcode , branch: formState.value.branch, district: null});
+ const communities = gridFailureActions.loadAddressStreets({
+ community: null,
+ postcode: formState.value.postcode,
+ branch: formState.value.branch,
+ district: null,
+ });
expect(appState.dispatch).toHaveBeenCalledWith(communities);
});
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 4df16e3..3c18471 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
@@ -167,7 +167,7 @@
this.gridFailureStations$.pipe(take(1), takeUntil(this._endSubscriptions$)).subscribe(stations => {
this.gridFailureStations = stations;
// set coords if first element was inserted
- !!stations.length && this.latLonMapping({ longitude: stations[0].longitude, latitude: stations[0].latitude });
+ !!stations.length && this.latLonMapping({ longitude: stations[0].longitude, latitude: stations[0].latitude }, true);
if (this.gridFailureStations && !!this.gridFailureStations.length) {
this._calculatePolygon(this.gridFailureStations.map(station => station.id));
}
@@ -208,9 +208,7 @@
.pipe(skipWhile(([branches, formState]) => !this.currentFormState || branches.length === 0))
.subscribe(([branches, formState]) => {
let currentBranch = branches.find(branch => !!formState && branch.id === formState.value.branchId);
- this.currentFormState.value.branchId !== formState.value.branchId &&
- !!currentBranch &&
- this.appState$.dispatch(gridFailureActions.loadGridFailureExpectedReasons({ payload: currentBranch.name }));
+ this.currentFormState.value.branchId !== formState.value.branchId && !!currentBranch && this.loadGridFailureExpectedReasons(currentBranch);
});
combineLatest(this.gridFailureBranches$, this.gridFailureDetailsFormState$)
@@ -220,10 +218,14 @@
)
.subscribe(([branches, formState]) => {
let currentBranch = branches.find(branch => branch.id === formState.value.branchId);
- !!currentBranch && this.appState$.dispatch(gridFailureActions.loadGridFailureExpectedReasons({ payload: currentBranch.name }));
+ !!currentBranch && this.loadGridFailureExpectedReasons(currentBranch);
});
}
+ public loadGridFailureExpectedReasons(branch: models.FailureBranch): void {
+ this.appState$.dispatch(gridFailureActions.loadGridFailureExpectedReasons({ payload: !!branch ? branch.name : '' }));
+ }
+
public loadStations(): void {
this.appState$.dispatch(gridFailureActions.loadStations());
}
@@ -473,7 +475,7 @@
.subscribe((address: models.FailureAddress) => {
this.gridFailureAddress = address;
const event = { longitude: address.longitude, latitude: address.latitude };
- this.latLonMapping(event);
+ this.latLonMapping(event, false);
});
this.gridFailurePolygon$.subscribe((polygon: Array<[number, number]>) => {
@@ -535,7 +537,7 @@
this.appState$.dispatch(gridFailureActions.loadGridFailurePolygon({ payload: stationIds }));
}
- public latLonMapping(data: { longitude: number; latitude: number }): void {
+ public latLonMapping(data: { longitude: number; latitude: number }, isInitialLoading: boolean): void {
const isSelectedMapLocationDifferentToOldMapLocation =
!this.currentFormState.value.latitude ||
data.latitude !== this.currentFormState.value.latitude ||
@@ -549,7 +551,9 @@
latitude: data.latitude,
})
);
- this.setFormStateDirty();
+ if (!isInitialLoading) {
+ this.setFormStateDirty();
+ }
}
}
@@ -657,7 +661,7 @@
this.gridFailureStations = [...this.gridFailureStations, this._selectedStation];
if (this.gridFailureStations && !!this.gridFailureStations.length) {
- this.latLonMapping({ longitude: this.gridFailureStations[0].longitude, latitude: this.gridFailureStations[0].latitude });
+ this.latLonMapping({ longitude: this.gridFailureStations[0].longitude, latitude: this.gridFailureStations[0].latitude }, false);
this._calculatePolygon(this.gridFailureStations.map(station => station.id));
this.appState$.dispatch(new MarkAsDirtyAction(this.currentFormState.id));
@@ -677,7 +681,7 @@
this.appState$.dispatch(new MarkAsDirtyAction(this.currentFormState.id));
if (this.gridFailureStations && !!this.gridFailureStations.length) {
- this.latLonMapping({ longitude: this.gridFailureStations[0].longitude, latitude: this.gridFailureStations[0].latitude });
+ this.latLonMapping({ longitude: this.gridFailureStations[0].longitude, latitude: this.gridFailureStations[0].latitude }, false);
this._calculatePolygon(this.gridFailureStations.map(station => station.id));
}
}
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts
index 6c876d4..336a2fa 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts
@@ -13,6 +13,7 @@
import { DateTimeCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/date-time-cell-renderer/date-time-cell-renderer.component';
import { IconCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component';
import { dateTimeComparator } from '@grid-failure-information-app/shared/utility';
+import { stringInsensitiveComparator } from '@grid-failure-information-table-app/app/utilityHelpers';
export const GRID_FAILURE_COLDEF = [
{
@@ -20,6 +21,7 @@
colId: 'failureClassification',
headerName: 'GridFailure.FailureClassification',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -28,6 +30,7 @@
colId: 'responsibility',
headerName: 'GridFailure.Responsibility',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -37,6 +40,7 @@
headerName: 'GridFailure.Description',
maxWidth: 300,
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -45,6 +49,7 @@
colId: 'statusIntern',
headerName: 'GridFailure.StatusIntern',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -53,6 +58,7 @@
colId: 'statusExtern',
headerName: 'GridFailure.StatusExtern',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -61,6 +67,7 @@
colId: 'publicationStatus',
headerName: 'GridFailure.PublicationStatus',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -69,6 +76,7 @@
colId: 'branch',
headerName: 'GridFailure.Branch',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -77,6 +85,7 @@
colId: 'voltageLevel',
headerName: 'GridFailure.VoltageLevel',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -85,6 +94,7 @@
colId: 'pressureLevel',
headerName: 'GridFailure.PressureLevel',
sortable: true,
+ comparator: stringInsensitiveComparator,
filter: 'setFilterComponent',
suppressMovable: true,
},
@@ -138,6 +148,7 @@
colId: 'expectedReasonText',
headerName: 'GridFailure.ExpectedReason',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
},
@@ -146,6 +157,7 @@
colId: 'internalRemark',
headerName: 'GridFailure.InternalRemark',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
},
@@ -154,6 +166,7 @@
colId: 'postcode',
headerName: 'GridFailure.Postcode',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
valueGetter: params => (params.data.postcode ? params.data.postcode : params.data.freetextPostcode),
@@ -163,6 +176,7 @@
colId: 'city',
headerName: 'GridFailure.City',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
valueGetter: params => (params.data.city ? params.data.city : params.data.freetextCity),
@@ -172,6 +186,7 @@
colId: 'district',
headerName: 'GridFailure.District',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
valueGetter: params => (params.data.district ? params.data.district : params.data.freetextDistrict),
@@ -181,6 +196,7 @@
colId: 'street',
headerName: 'GridFailure.Street',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
},
@@ -189,6 +205,7 @@
colId: 'housenumber',
headerName: 'GridFailure.Housenumber',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
},
@@ -197,6 +214,7 @@
colId: 'radius',
headerName: 'GridFailure.RadiusInM',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
},
@@ -205,6 +223,7 @@
colId: 'stationDescription',
headerName: 'GridFailure.StationDescription',
sortable: true,
+ comparator: stringInsensitiveComparator,
suppressMovable: true,
filter: 'setFilterComponent',
valueSeparator: ', ',
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts
index a4c8300..9565aeb 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts
@@ -96,7 +96,10 @@
this.overviewColumnDefinition = this.overviewColumnDefinition.map(column => {
const fieldValueOfColDef: string = column['field'];
if (!!fieldValueOfColDef) {
- if (userRole === RolesEnum.PUBLISHER && (fieldValueOfColDef === Globals.STATUS_INTERN_FIELD || fieldValueOfColDef === Globals.STATUS_PUBLICATION_FIELD )) {
+ if (
+ userRole === RolesEnum.PUBLISHER &&
+ (fieldValueOfColDef === Globals.STATUS_INTERN_FIELD || fieldValueOfColDef === Globals.STATUS_PUBLICATION_FIELD)
+ ) {
this.sandbox.publisherFilterIsActive = checked;
return this.processFiltering(fieldValueOfColDef, checked, userRole, column);
} else if (userRole === RolesEnum.QUALIFIER && fieldValueOfColDef === Globals.STATUS_INTERN_FIELD) {
@@ -171,9 +174,14 @@
public addCompleteTable(): void {
let isNotificationAlreadyShown: boolean = false;
this._gridApi.forEachNodeAfterFilter(node => {
- if ((this.sandbox.condensationList.length == 0 || node.data.branch === this.sandbox.condensationList[0].branch) && !node.data.condensed) {
+ if (
+ (this.sandbox.condensationList.length == 0 || node.data.branch === this.sandbox.condensationList[0].branch) &&
+ !node.data.condensed &&
+ node.data.publicationStatus !== StateEnum.PUBLISHED &&
+ node.data.publicationStatus !== StateEnum.WITHDRAWN
+ ) {
this.sandbox.addItemToCondensationList(node.data);
- } else if (node.data.condensed) {
+ } else if (node.data.condensed || node.data.publicationStatus === StateEnum.PUBLISHED || node.data.publicationStatus === StateEnum.WITHDRAWN) {
return;
} else {
if (!isNotificationAlreadyShown) this._utilService.displayNotification('DifferentBranchesWarning', 'alert');
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.spec.ts
index 5f1e4d7..b6ffa45 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.spec.ts
@@ -37,6 +37,7 @@
loadDistributionGroups() {},
loadGridFailureDistributionGroups() {},
loadGridFailurePublicationChannels() {},
+ loadGridFailureExpectedReasons() {},
} as any;
});
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.ts
index b5d004b..6833f1e 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.resolver.ts
@@ -21,8 +21,9 @@
public resolve(route: ActivatedRouteSnapshot): void {
const gridFailureId: string = route.params['gridFailureId'];
- if (!gridFailureId) {
+ if (!gridFailureId || (gridFailureId && gridFailureId === 'new')) {
this._detailSandbox.setGridFailureId(null);
+ this._detailSandbox.loadGridFailureExpectedReasons(null);
this._sandbox.loadGridFailures();
} else if (gridFailureId && gridFailureId !== 'new') {
this._detailSandbox.setGridFailureId(gridFailureId);
diff --git a/projects/grid-failure-information-table-app/src/app/utilityHelpers.ts b/projects/grid-failure-information-table-app/src/app/utilityHelpers.ts
index 497764e..d7fbec7 100644
--- a/projects/grid-failure-information-table-app/src/app/utilityHelpers.ts
+++ b/projects/grid-failure-information-table-app/src/app/utilityHelpers.ts
@@ -30,3 +30,10 @@
return 1;
}
}
+
+export const stringInsensitiveComparator = (firstValue: string, secondValue: string) => {
+ firstValue = firstValue ? firstValue : '';
+ secondValue = secondValue ? secondValue : '';
+
+ return firstValue.toLowerCase().localeCompare(secondValue.toLowerCase());
+};