diff options
author | 2017-08-07 07:05:40 +0300 | |
---|---|---|
committer | 2017-08-07 07:05:40 +0300 | |
commit | b2c60183d5d654b945a24ec5564807e4f691c6e8 (patch) | |
tree | d6cdc354fa7ce27ea1e0ce60e6c57aa7c1ef20b6 /catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts | |
parent | d1d771bed17c6a5beea19af8da0bf9113972f25a (diff) |
[SDC] code sync
Change-Id: I576dd69504722c341b0f41a1f6232ed3f4bee8df
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts | 22 |
1 files changed, 15 insertions, 7 deletions
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 = (<PropertyFEModel>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); + } } } } |