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:
Matt Gilman 2024-02-06 10:49:10 -05:00 committed by GitHub
parent 8f63e928a9
commit 91f339bf0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 19 deletions

View File

@ -163,7 +163,12 @@ export class NfEditor implements OnDestroy {
mode: this.mode, mode: this.mode,
lineNumbers: true, lineNumbers: true,
matchBrackets: true, matchBrackets: true,
extraKeys: { 'Ctrl-Space': 'autocomplete' } extraKeys: {
'Ctrl-Space': 'autocomplete',
Enter: () => {
this.okClicked();
}
}
}; };
} }

View File

@ -285,31 +285,61 @@ export class PropertyTable implements AfterViewInit, ControlValueAccessor {
} }
newPropertyClicked(): void { 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) this.createNewProperty(existingProperties, this.supportsSensitiveDynamicProperties)
.pipe(take(1)) .pipe(take(1))
.subscribe((property) => { .subscribe((property) => {
const currentPropertyItems: PropertyItem[] = this.dataSource.data; const currentPropertyItems: PropertyItem[] = this.dataSource.data;
const i: number = currentPropertyItems.length; const itemIndex: number = currentPropertyItems.findIndex(
const item: PropertyItem = { (existingItem: PropertyItem) => existingItem.property == property.property
...property, );
id: i, if (itemIndex > -1) {
triggerEdit: true, const currentItem: PropertyItem = currentPropertyItems[itemIndex];
deleted: false, const updatedItem: PropertyItem = {
added: true, ...currentItem,
dirty: true, ...property,
type: property.descriptor.required triggerEdit: true,
? 'required' deleted: false,
: property.descriptor.dynamic added: true,
? 'userDefined' dirty: true,
: 'optional' type: property.descriptor.required
}; ? 'required'
: property.descriptor.dynamic
? 'userDefined'
: 'optional'
};
this.itemLookup.set(property.property, item); this.itemLookup.set(property.property, updatedItem);
const propertyItems: PropertyItem[] = [...currentPropertyItems, item]; // if the user had previously deleted the property, replace the matching property item
this.setPropertyItems(propertyItems); currentPropertyItems[itemIndex] = updatedItem;
} else {
const i: number = currentPropertyItems.length;
const item: PropertyItem = {
...property,
id: i,
triggerEdit: true,
deleted: false,
added: true,
dirty: true,
type: property.descriptor.required
? 'required'
: property.descriptor.dynamic
? 'userDefined'
: 'optional'
};
this.itemLookup.set(property.property, item);
// if this is a new property, add it to the list
this.setPropertyItems([...currentPropertyItems, item]);
}
this.handleChanged(); this.handleChanged();
}); });