mirror of https://github.com/apache/nifi.git
NIFI-12743: (#8358)
- Updating property editing so that Shift-Enter inserts a new line and Enter commits the edit. - Fixing bug that prevented deleting a Property and then re-adding a new Property with the same name. This closes #8358
This commit is contained in:
parent
8f63e928a9
commit
91f339bf0f
|
@ -163,7 +163,12 @@ export class NfEditor implements OnDestroy {
|
|||
mode: this.mode,
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
extraKeys: { 'Ctrl-Space': 'autocomplete' }
|
||||
extraKeys: {
|
||||
'Ctrl-Space': 'autocomplete',
|
||||
Enter: () => {
|
||||
this.okClicked();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -285,12 +285,41 @@ export class PropertyTable implements AfterViewInit, ControlValueAccessor {
|
|||
}
|
||||
|
||||
newPropertyClicked(): void {
|
||||
const existingProperties: string[] = this.dataSource.data.map((item) => item.descriptor.name);
|
||||
// filter out deleted properties in case the user needs to re-add one
|
||||
const existingProperties: string[] = this.dataSource.data
|
||||
.filter((item) => !item.deleted)
|
||||
.map((item) => item.descriptor.name);
|
||||
|
||||
// create the new property
|
||||
this.createNewProperty(existingProperties, this.supportsSensitiveDynamicProperties)
|
||||
.pipe(take(1))
|
||||
.subscribe((property) => {
|
||||
const currentPropertyItems: PropertyItem[] = this.dataSource.data;
|
||||
|
||||
const itemIndex: number = currentPropertyItems.findIndex(
|
||||
(existingItem: PropertyItem) => existingItem.property == property.property
|
||||
);
|
||||
if (itemIndex > -1) {
|
||||
const currentItem: PropertyItem = currentPropertyItems[itemIndex];
|
||||
const updatedItem: PropertyItem = {
|
||||
...currentItem,
|
||||
...property,
|
||||
triggerEdit: true,
|
||||
deleted: false,
|
||||
added: true,
|
||||
dirty: true,
|
||||
type: property.descriptor.required
|
||||
? 'required'
|
||||
: property.descriptor.dynamic
|
||||
? 'userDefined'
|
||||
: 'optional'
|
||||
};
|
||||
|
||||
this.itemLookup.set(property.property, updatedItem);
|
||||
|
||||
// if the user had previously deleted the property, replace the matching property item
|
||||
currentPropertyItems[itemIndex] = updatedItem;
|
||||
} else {
|
||||
const i: number = currentPropertyItems.length;
|
||||
const item: PropertyItem = {
|
||||
...property,
|
||||
|
@ -308,8 +337,9 @@ export class PropertyTable implements AfterViewInit, ControlValueAccessor {
|
|||
|
||||
this.itemLookup.set(property.property, item);
|
||||
|
||||
const propertyItems: PropertyItem[] = [...currentPropertyItems, item];
|
||||
this.setPropertyItems(propertyItems);
|
||||
// if this is a new property, add it to the list
|
||||
this.setPropertyItems([...currentPropertyItems, item]);
|
||||
}
|
||||
|
||||
this.handleChanged();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue