From b2c60183d5d654b945a24ec5564807e4f691c6e8 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Mon, 7 Aug 2017 07:05:40 +0300 Subject: [SDC] code sync Change-Id: I576dd69504722c341b0f41a1f6232ed3f4bee8df Signed-off-by: Michael Lando --- .../dynamic-property/dynamic-property.component.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts') diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts index 59811b582d..3982e4e8dc 100644 --- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts +++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts @@ -112,7 +112,9 @@ export class DynamicPropertyComponent { //grab the cumulative value for the new item from parent PropertyFEModel and assign that value to DerivedFEProp[0] (which is the list or map parent with UUID of the set we just added) let parentNames = (this.property).getParentNamesArray(newProps[0].propertiesName, []); newProps[0].valueObj = _.get(this.property.valueObj, parentNames.join('.')); - this.valueChanged.emit(this.property.name); + if ( newProps[0].mapKey ) {//prevent saving if it is map item, whem it is list item- the map key is the es type (it will be saved only after user enter key) + this.valueChanged.emit(this.property.name); + } } } } @@ -122,7 +124,9 @@ export class DynamicPropertyComponent { if (this.property instanceof PropertyFEModel) { // will always be the case this.property.childPropUpdated(property); this.dataTypeService.checkForCustomBehavior(this.property); - this.valueChanged.emit(this.property.name); + if (this.property.getParentNamesArray(property.propertiesName, []).indexOf('') === -1) {//If one of the parents is empty key -don't save + this.valueChanged.emit(this.property.name); + } } } @@ -142,6 +146,9 @@ export class DynamicPropertyComponent { let oldKey = item.mapKey; if (target && typeof target.value == 'string') { //allow saving empty string let replaceKey:string = target.value; + if (!replaceKey) {//prevent delete map key + return; + } if(Object.keys(itemParent.valueObj).indexOf(replaceKey) > -1){//the key is exists target.setCustomValidity('This key is already exists.'); return; @@ -156,11 +163,12 @@ export class DynamicPropertyComponent { let itemIndex: number = this.property.flattenedChildren.filter(prop => prop.parentName == item.parentName).map(prop => prop.propertiesName).indexOf(item.propertiesName); itemParent.valueObj.splice(itemIndex, 1); } - - if (itemParent instanceof PropertyFEModel) { //direct child - this.valueChanged.emit(this.property.name); - } else { //nested child - need to update parent prop by getting flattened name (recurse through parents and replace map/list keys, etc) - this.childValueChanged(itemParent); + if (item.mapKey) {//prevent going to BE if user tries to delete map item without key (it was not saved in BE) + if (itemParent instanceof PropertyFEModel) { //direct child + this.valueChanged.emit(this.property.name); + } else { //nested child - need to update parent prop by getting flattened name (recurse through parents and replace map/list keys, etc) + this.childValueChanged(itemParent); + } } } } -- cgit 1.2.3-korg