summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models/forms
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-ui/src/app/view-models/forms
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/view-models/forms')
-rw-r--r--catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html5
-rw-r--r--catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less4
-rw-r--r--catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts19
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts3
4 files changed, 23 insertions, 8 deletions
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 @@
<div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm[parameter.name].$dirty && forms.editForm[parameter.name].$invalid), required: (parameter.defaultValue)}">
<span class="required-symbol">*</span>
<div class="input-parameter">
- <input class="i-sdc-form-input" data-ng-class="{error: (forms.editForm[parameter.name].$invalid)}"
+ <input class="i-sdc-form-input" data-ng-class="{error: (forms.editForm[parameter.name].$invalid),
+ 'default-value':(parameter.defaultValue && parameter.currentValue === parameter.defaultValue)}"
data-ng-model-options="{ debounce: 200 }"
data-ng-model="parameter.currentValue"
value="{{parameter.currentValue}}"
@@ -54,7 +55,7 @@
name="{{parameter.name}}"
data-ng-pattern="getValidationPattern(parameter.type, 'heat')"
data-ng-required="parameter.defaultValue"
- data-ng-change="'json'==parameter.type && forms.editForm[parameter.name].$setValidity('pattern', validateJson(parameter.currentValue))"
+ data-ng-change="onValueChanged(parameter)"
data-ng-blur="(forms.editForm[parameter.name].$error.required && (parameter.currentValue=parameter.defaultValue))"
data-tests-id="value-field-of-{{parameter.name}}"/>
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 {