[MNT-24028] edit aspects dialog counter bug (#9539)

* [MNT-24028] fix dialog counter bug

* [MNT-24028] update docs

* [MNT-24028] remove fit
This commit is contained in:
Grzegorz Jaśkowski
2024-04-12 09:25:15 +02:00
committed by GitHub
parent 503cdc40b2
commit 29757e4ee4
6 changed files with 28 additions and 13 deletions

View File

@@ -5,11 +5,11 @@
<div class="adf-aspect-list-dialog-information">
<p id="aspect-list-dialog-over-table-message">{{overTableMessage | translate}}</p>
<p id="aspect-list-dialog-counter">{{currentAspectSelection ? currentAspectSelection.length : 0}}
<p id="aspect-list-dialog-counter">{{counter}}
{{'ADF-ASPECT-LIST.DIALOG.SELECTED' | translate}}</p>
</div>
<mat-dialog-content class="adf-aspect-dialog-content">
<adf-aspect-list #aspectList (valueChanged)="onValueChanged($event)" [nodeId]="currentNodeId" [excludedAspects]="data.excludedAspects">
<adf-aspect-list #aspectList (valueChanged)="onValueChanged($event)" (updateCounter)="onUpdateCounter($event)" [nodeId]="currentNodeId" [excludedAspects]="data.excludedAspects">
</adf-aspect-list>
</mat-dialog-content>

View File

@@ -31,6 +31,7 @@ export class AspectListDialogComponent implements OnInit {
description: string;
currentNodeId: string;
overTableMessage: string;
counter = 0;
currentAspectSelection: string[] = [];
@@ -57,7 +58,11 @@ export class AspectListDialogComponent implements OnInit {
}
onValueChanged(aspectList: string[]) {
this.currentAspectSelection = aspectList;
this.currentAspectSelection = aspectList;
}
onUpdateCounter(count: number) {
this.counter = count;
}
close() {

View File

@@ -240,16 +240,18 @@ describe('AspectListComponent', () => {
expect(component.nodeAspects.length).toBe(0);
});
it('should store not listed aspects and emit all aspects on value change', async () => {
it('should store not listed aspects and emit all aspects and count of only visible aspects on change', async () => {
const storedAspect = ['stored:aspect'];
expect(component.notDisplayedAspects).toEqual(storedAspect);
spyOn(component.valueChanged, 'emit');
spyOn(component.updateCounter, 'emit');
const panel = (await loader.getAllHarnesses(MatExpansionPanelHarness))[1];
const checkbox = await panel.getHarness(MatCheckboxHarness);
await checkbox.toggle();
fixture.detectChanges();
expect(component.valueChanged.emit).toHaveBeenCalledWith(['frs:AspectOne', 'frs:SecondAspect', ...storedAspect]);
expect(component.updateCounter.emit).toHaveBeenCalledWith(2);
});
});

View File

@@ -43,6 +43,10 @@ export class AspectListComponent implements OnInit, OnDestroy {
@Output()
valueChanged: EventEmitter<string[]> = new EventEmitter<string[]>();
/** Emitted every time the number of selected aspects changes */
@Output()
updateCounter: EventEmitter<number> = new EventEmitter<number>();
propertyColumns: string[] = ['name', 'title', 'dataType'];
aspects$: Observable<AspectEntry[]> = null;
nodeAspects: string[] = [];
@@ -74,6 +78,7 @@ export class AspectListComponent implements OnInit, OnDestroy {
this.nodeAspectStatus = [ ...this.nodeAspects ];
this.notDisplayedAspects = node.aspectNames.filter((aspect) => !this.aspectListService.getVisibleAspects().includes(aspect) && !customAspects.includes(aspect));
this.valueChanged.emit([...this.nodeAspects, ...this.notDisplayedAspects]);
this.updateCounter.emit(this.nodeAspects.length);
}),
concatMap(() => this.aspectListService.getAspects()),
takeUntil(this.onDestroy$));
@@ -97,6 +102,7 @@ export class AspectListComponent implements OnInit, OnDestroy {
}
this.updateEqualityOfAspectList();
this.valueChanged.emit([...this.nodeAspects, ...this.notDisplayedAspects]);
this.updateCounter.emit(this.nodeAspects.length);
}
reset() {
@@ -104,6 +110,7 @@ export class AspectListComponent implements OnInit, OnDestroy {
this.nodeAspects.splice(0, this.nodeAspects.length, ...this.nodeAspectStatus);
this.hasEqualAspect = true;
this.valueChanged.emit([...this.nodeAspects, ...this.notDisplayedAspects]);
this.updateCounter.emit(this.nodeAspects.length);
} else {
this.clear();
}
@@ -113,6 +120,7 @@ export class AspectListComponent implements OnInit, OnDestroy {
this.nodeAspects = [];
this.updateEqualityOfAspectList();
this.valueChanged.emit([...this.nodeAspects, ...this.notDisplayedAspects]);
this.updateCounter.emit(this.nodeAspects.length);
}
getId(aspect: any): string {