[SI-1566] - change condition check for condensation grid failure so we hold the branch of the condensed failure in a property
Signed-off-by: dtheinert <dietmar.theinert@pta.de>
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 48afa16..c7a8020 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
@@ -216,9 +216,18 @@
this._router.navigate(['/grid-failures', event.data.id]);
break;
case this._eventTypeEnum.Add:
- if ((this.sandbox.condensationList.length == 0 || event.data.branch === this.sandbox.condensationList[0].branch) && !event.data.condensed) {
+ const newCondensList: boolean = this.sandbox.condensationList.length === 0 && !!!this.sandbox.condenseId;
+ const editEmptyCondensList: boolean = (newCondensList || this.sandbox.condensationList.length === 0) && !!this.sandbox.condenseId;
+ const editCondensList: boolean = !newCondensList && !editEmptyCondensList && !!!this.sandbox.condenseId;
+ const gridFailureAlreadyCondensed = event.data.condensed;
+ const canAdd: boolean =
+ (newCondensList ||
+ (editCondensList && this.sandbox.condensationList[0].branch === event.data.branch) ||
+ (editEmptyCondensList && this.sandbox.condenseBranch === event.data.branch)) &&
+ !gridFailureAlreadyCondensed;
+ if (canAdd) {
this.sandbox.addItemToCondensationList(event.data);
- } else if (event.data.condensed) {
+ } else if (gridFailureAlreadyCondensed) {
break;
} else {
this._utilService.displayNotification('DifferentBranchesWarning', 'alert');
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts
index a44b273..b44b3c6 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts
@@ -45,6 +45,7 @@
public qualifierFilterIsActive: boolean = false;
public condensationList: GridFailure[] = new Array();
public condenseId: string = null;
+ public condenseBranch: string = null;
public StateEnum = StateEnum;
public RolesEnum = RolesEnum;
public isReminderActive$: Observable<boolean> = this.appState$.select(store.getGridFailureReminderData);
@@ -71,6 +72,7 @@
public clearGridFailureCondensation(): void {
this.condenseId = null;
+ this.condenseBranch = null;
this.condensationList = [];
this.loadGridFailures();
}
@@ -118,6 +120,7 @@
)
.subscribe((condensedGridFailures: GridFailure[]) => {
this.condensationList = condensedGridFailures;
+ this.condenseBranch = condensedGridFailures && condensedGridFailures.length > 0 ? condensedGridFailures[0].branch : null;
});
combineLatest(