mirror of https://github.com/apache/nifi.git
[NIFI-13129] - Fix: selected prioritizer order is not honored when displayed in the UI (#8736)
This closes #8736
This commit is contained in:
parent
57f684de97
commit
37937ffa15
|
@ -28,10 +28,10 @@ import { DocumentedType } from '../../../../../../../state/shared';
|
||||||
import { NifiTooltipDirective } from '../../../../../../../ui/common/tooltips/nifi-tooltip.directive';
|
import { NifiTooltipDirective } from '../../../../../../../ui/common/tooltips/nifi-tooltip.directive';
|
||||||
import { TextTip } from '../../../../../../../ui/common/tooltips/text-tip/text-tip.component';
|
import { TextTip } from '../../../../../../../ui/common/tooltips/text-tip/text-tip.component';
|
||||||
import {
|
import {
|
||||||
DragDropModule,
|
|
||||||
CdkDrag,
|
CdkDrag,
|
||||||
CdkDragDrop,
|
CdkDragDrop,
|
||||||
CdkDropList,
|
CdkDropList,
|
||||||
|
DragDropModule,
|
||||||
moveItemInArray,
|
moveItemInArray,
|
||||||
transferArrayItem
|
transferArrayItem
|
||||||
} from '@angular/cdk/drag-drop';
|
} from '@angular/cdk/drag-drop';
|
||||||
|
@ -76,7 +76,7 @@ export class Prioritizers implements ControlValueAccessor {
|
||||||
onTouched!: () => void;
|
onTouched!: () => void;
|
||||||
onChange!: (selectedPrioritizers: string[]) => void;
|
onChange!: (selectedPrioritizers: string[]) => void;
|
||||||
|
|
||||||
_allPrioritizers: DocumentedType[] = [];
|
private _allPrioritizers: DocumentedType[] = [];
|
||||||
|
|
||||||
availablePrioritizers: DocumentedType[] = [];
|
availablePrioritizers: DocumentedType[] = [];
|
||||||
selectedPrioritizers: DocumentedType[] = [];
|
selectedPrioritizers: DocumentedType[] = [];
|
||||||
|
@ -86,20 +86,26 @@ export class Prioritizers implements ControlValueAccessor {
|
||||||
constructor(private nifiCommon: NiFiCommon) {}
|
constructor(private nifiCommon: NiFiCommon) {}
|
||||||
|
|
||||||
private processPrioritizers(): void {
|
private processPrioritizers(): void {
|
||||||
this.availablePrioritizers = [];
|
|
||||||
this.selectedPrioritizers = [];
|
|
||||||
|
|
||||||
if (this._allPrioritizers && this.value) {
|
if (this._allPrioritizers && this.value) {
|
||||||
this._allPrioritizers.forEach((prioritizer) => {
|
const selected: DocumentedType[] = [];
|
||||||
const selected: boolean = this.value.some(
|
this.value.forEach((selectedPrioritizerType: string) => {
|
||||||
(selectedPrioritizerType) => prioritizer.type == selectedPrioritizerType
|
// look up the selected prioritizer in the list of all known prioritizers
|
||||||
|
const found = this._allPrioritizers.find(
|
||||||
|
(prioritizer: DocumentedType) => prioritizer.type === selectedPrioritizerType
|
||||||
);
|
);
|
||||||
if (selected) {
|
if (found) {
|
||||||
this.selectedPrioritizers.push(prioritizer);
|
selected.push(found);
|
||||||
} else {
|
|
||||||
this.availablePrioritizers.push(prioritizer);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const available = this._allPrioritizers.filter((prioritizer: DocumentedType) => {
|
||||||
|
return !selected.some(
|
||||||
|
(selectedPrioritizer: DocumentedType) => prioritizer.type === selectedPrioritizer.type
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.selectedPrioritizers = [...selected];
|
||||||
|
this.availablePrioritizers = [...available];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue