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.component.html | 4 ++-- .../dynamic-property/dynamic-property.component.ts | 22 +++++++++++++++------- .../resource-instance-name-model.ts | 3 ++- .../view-models/workspace/workspace-view-model.ts | 4 +++- 4 files changed, 22 insertions(+), 11 deletions(-) (limited to 'catalog-ui/src') diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html index 95cc79dce9..57da7d90e4 100644 --- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html +++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html @@ -10,7 +10,7 @@
{{property.name}}
- +
@@ -23,7 +23,7 @@ [name]="property.name" [path]="property.propertiesName" (valueChange)="valueChanged.emit();" - [readonly]="readonly||property.isDeclared||property.isDisabled" + [readonly]="readonly || property.isDeclared || property.isDisabled" > 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); + } } } } diff --git a/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts index 3f0838cabc..fa027296d6 100644 --- a/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts +++ b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts @@ -109,7 +109,8 @@ export class ResourceInstanceNameViewModel { ]; this.$scope.$watch("[forms.editNameForm.$invalid,componentInstanceModel.name,isAlreadyPressed]", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editNameForm.$invalid || this.$scope.isAlreadyPressed || this.$scope.componentInstanceModel.name === this.$scope.oldName; + //if the name is invalid or if user pressed ok and didn't try to change name again or the new name = source name + this.$scope.footerButtons[0].disabled = this.$scope.forms.editNameForm.$invalid || (this.$scope.isAlreadyPressed && newVal[1] === oldVal[1]) || this.$scope.componentInstanceModel.name === this.$scope.oldName; }); } } diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts index 97a58402de..a3af8ca68e 100644 --- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts @@ -616,8 +616,10 @@ export class WorkspaceViewModel { }; this.$scope.updateSelectedMenuItem = (state:string):void => { + let stateArray:Array = state.split('.'); + let stateWithoutInternalNavigate:string = stateArray[0] + '.' + stateArray[1]; let selectedItem:MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item:MenuItem) => { - return item.state === state; + return _.startsWith(item.state, stateWithoutInternalNavigate); }); this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0; }; -- cgit 1.2.3-korg