Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,31 +285,61 @@ 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 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);

const propertyItems: PropertyItem[] = [...currentPropertyItems, item];
this.setPropertyItems(propertyItems);
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,
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();
});
Expand Down