From 37937ffa155244652adc207953b5adbc27dc4709 Mon Sep 17 00:00:00 2001 From: Rob Fellows Date: Fri, 3 May 2024 14:09:20 -0400 Subject: [PATCH] [NIFI-13129] - Fix: selected prioritizer order is not honored when displayed in the UI (#8736) This closes #8736 --- .../prioritizers/prioritizers.component.ts | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/prioritizers/prioritizers.component.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/prioritizers/prioritizers.component.ts index 08168f146c..76be8331ac 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/prioritizers/prioritizers.component.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/prioritizers/prioritizers.component.ts @@ -28,10 +28,10 @@ import { DocumentedType } from '../../../../../../../state/shared'; import { NifiTooltipDirective } from '../../../../../../../ui/common/tooltips/nifi-tooltip.directive'; import { TextTip } from '../../../../../../../ui/common/tooltips/text-tip/text-tip.component'; import { - DragDropModule, CdkDrag, CdkDragDrop, CdkDropList, + DragDropModule, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; @@ -76,7 +76,7 @@ export class Prioritizers implements ControlValueAccessor { onTouched!: () => void; onChange!: (selectedPrioritizers: string[]) => void; - _allPrioritizers: DocumentedType[] = []; + private _allPrioritizers: DocumentedType[] = []; availablePrioritizers: DocumentedType[] = []; selectedPrioritizers: DocumentedType[] = []; @@ -86,20 +86,26 @@ export class Prioritizers implements ControlValueAccessor { constructor(private nifiCommon: NiFiCommon) {} private processPrioritizers(): void { - this.availablePrioritizers = []; - this.selectedPrioritizers = []; - if (this._allPrioritizers && this.value) { - this._allPrioritizers.forEach((prioritizer) => { - const selected: boolean = this.value.some( - (selectedPrioritizerType) => prioritizer.type == selectedPrioritizerType + const selected: DocumentedType[] = []; + this.value.forEach((selectedPrioritizerType: string) => { + // look up the selected prioritizer in the list of all known prioritizers + const found = this._allPrioritizers.find( + (prioritizer: DocumentedType) => prioritizer.type === selectedPrioritizerType ); - if (selected) { - this.selectedPrioritizers.push(prioritizer); - } else { - this.availablePrioritizers.push(prioritizer); + if (found) { + selected.push(found); } }); + + const available = this._allPrioritizers.filter((prioritizer: DocumentedType) => { + return !selected.some( + (selectedPrioritizer: DocumentedType) => prioritizer.type === selectedPrioritizer.type + ); + }); + + this.selectedPrioritizers = [...selected]; + this.availablePrioritizers = [...available]; } }