From 51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Sun, 10 Dec 2017 18:55:03 +0200 Subject: Final commit to master merge from Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman --- .../env-parameters-form/env-parameters-form.html | 5 +++-- .../env-parameters-form/env-parameters-form.less | 4 +++- .../forms/env-parameters-form/env-parameters-form.ts | 19 +++++++++++++++---- .../property-form-view-model.ts | 3 ++- 4 files changed, 23 insertions(+), 8 deletions(-) (limited to 'catalog-ui/src/app/view-models/forms') diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html index ae13844532..5fd57f6b24 100644 --- a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html @@ -46,7 +46,8 @@
*
- diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less index a25a2c5f62..e797093271 100644 --- a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less @@ -1,4 +1,3 @@ - .sdc-env-form-container{ .w-sdc-modal-body{ padding: 20px 10px 2px 10px; @@ -110,6 +109,9 @@ width: 100%; display: inline-flex; padding-right: 33px; + &.default-value{ + border-color: @func_color_h; + } } .action-button{ border-left: solid 1px @main_color_o; diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts index f5962a2f79..a30fd15c63 100644 --- a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts @@ -37,6 +37,7 @@ export interface IEnvParametersFormViewModelScope extends ng.IScope { getValidationPattern(type:string):RegExp; isInstance():boolean; validateJson(json:string):boolean; + onValueChanged(parameter: HeatParameterModel):void; close():void; save():void; openDescPopover(selectedParam:HeatParameterModel):void; @@ -86,7 +87,10 @@ export class EnvParametersFormViewModel { this.$scope.envParametersModal = this.$uibModalInstance; this.$scope.artifactResource = this.artifact; this.$scope.heatParameters = angular.copy(this.artifact.heatParameters); - + //if param does not have a value - display the default + this.$scope.heatParameters.forEach((heatParam) => { + heatParam.currentValue = heatParam.currentValue || heatParam.defaultValue; + }); this.$scope.tableHeadersList = [ {title: "Parameter", property: "name"}, {title: "Default Value", property: "defaultValue", info: "DEFAULT_VALUE_INFO"}, @@ -114,13 +118,13 @@ export class EnvParametersFormViewModel { this.$scope.save = ():void => { this.$scope.buttons[0].disabled = true;//prevent double click (DE246266) this.$scope.isLoading = true; - this.artifact.heatParameters = this.$scope.heatParameters; + this.artifact.heatParameters = angular.copy(this.$scope.heatParameters); this.artifact.heatParameters.forEach((parameter:any):void => { if ("" === parameter.currentValue) { //[Bug 154465] - Update and erase current value field in Env parameters form return empty String ("") instead of null. parameter.currentValue = null; - }else if (!parameter.currentValue && parameter.defaultValue) { - parameter.currentValue = parameter.defaultValue; + } else if (parameter.defaultValue && parameter.defaultValue == parameter.currentValue) { + parameter.currentValue = undefined; } }); @@ -143,6 +147,13 @@ export class EnvParametersFormViewModel { this.component.addOrUpdateArtifact(this.$scope.artifactResource).then(success, error); }; + this.$scope.onValueChanged = (parameter: HeatParameterModel):void => { + parameter.filterTerm = parameter.name + ' ' + parameter.currentValue + ' ' + parameter.defaultValue + ' ' +parameter.description + if('json'==parameter.type){ + this.$scope.forms.editForm[parameter.name].$setValidity('pattern', this.$scope.validateJson(parameter.currentValue)); + } + } + this.$scope.close = ():void => { //this.artifact.heatParameters.forEach((parameter:any):void => { // if (!parameter.currentValue && parameter.defaultValue) { diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts index ee2e94f934..0ad55715db 100644 --- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts +++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts @@ -112,6 +112,7 @@ export class PropertyFormViewModel { private initResource = ():void => { this.$scope.editPropertyModel.property = new PropertyModel(this.property); this.$scope.editPropertyModel.property.type = this.property.type ? this.property.type : null; + this.$scope.editPropertyModel.property.value = this.$scope.editPropertyModel.property.value || this.$scope.editPropertyModel.property.defaultValue; this.setMaxLength(); this.initAddOnLabels(); }; @@ -241,7 +242,7 @@ export class PropertyFormViewModel { let onPropertySuccess = (propertyFromBE:PropertyModel):void => { console.info('onPropertyResourceSuccess : ', propertyFromBE); this.$scope.isLoading = false; - + this.filteredProperties[this.$scope.currentPropertyIndex] = propertyFromBE; if (!doNotCloseModal) { this.$uibModalInstance.close(propertyFromBE); } else { -- cgit 1.2.3-korg