aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/view-models')
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts40
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html3
2 files changed, 37 insertions, 6 deletions
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 614f1583cb..eda5efcd49 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
@@ -69,6 +69,7 @@ interface IPropertyFormViewModelScope extends ng.IScope {
constraints:string[];
modelNameFilter:string;
isGetFunctionValueType: boolean;
+ invalidMandatoryFields: boolean;
validateJson(json:string):boolean;
save(doNotCloseModal?:boolean):void;
@@ -404,17 +405,21 @@ export class PropertyFormViewModel {
this.$scope.$watch("forms.editForm.$invalid", (newVal) => {
if (this.$scope.editPropertyModel.hasGetFunctionValue) {
- this.$scope.footerButtons[0].disabled = newVal || !this.$scope.editPropertyModel.property.toscaFunction || this.isViewOnly;
+ this.$scope.invalidMandatoryFields = !newVal || !this.$scope.editPropertyModel.property.toscaFunction || this.isViewOnly;
+ this.$scope.footerButtons[0].disabled = this.$scope.invalidMandatoryFields;
} else {
- this.$scope.footerButtons[0].disabled = newVal || this.isViewOnly;
+ this.$scope.invalidMandatoryFields = !newVal || this.isViewOnly;
+ this.$scope.footerButtons[0].disabled = this.$scope.invalidMandatoryFields;
}
});
this.$scope.$watch("forms.editForm.$valid", (newVal) => {
if (this.$scope.editPropertyModel.hasGetFunctionValue) {
- this.$scope.footerButtons[0].disabled = !newVal || !this.$scope.editPropertyModel.property.toscaFunction || this.isViewOnly;
+ this.$scope.invalidMandatoryFields = !newVal || !this.$scope.editPropertyModel.property.toscaFunction || this.isViewOnly;
+ this.$scope.footerButtons[0].disabled = this.$scope.invalidMandatoryFields;
} else {
- this.$scope.footerButtons[0].disabled = !newVal || this.isViewOnly;
+ this.$scope.invalidMandatoryFields = !newVal || this.isViewOnly;
+ this.$scope.footerButtons[0].disabled = this.$scope.invalidMandatoryFields;
}
});
@@ -460,6 +465,21 @@ export class PropertyFormViewModel {
}
}
+ this.$scope.onConstraintChange = (constraints: any): void => {
+ if (!this.$scope.invalidMandatoryFields) {
+ this.$scope.footerButtons[0].disabled = !constraints.valid;
+ } else {
+ this.$scope.footerButtons[0].disabled = this.$scope.invalidMandatoryFields;
+ }
+ if (!constraints.constraints || constraints.constraints.length == 0) {
+ this.$scope.editPropertyModel.property.propertyConstraints = null;
+ this.$scope.editPropertyModel.property.constraints = null;
+ return;
+ }
+ this.$scope.editPropertyModel.property.propertyConstraints = this.serializePropertyConstraints(constraints.constraints);
+ this.$scope.editPropertyModel.property.constraints = constraints.constraints;
+ }
+
this.$scope.onGetFunctionValidFunction = (toscaGetFunction: ToscaGetFunction): void => {
this.$scope.editPropertyModel.property.toscaFunction = toscaGetFunction;
}
@@ -471,9 +491,19 @@ export class PropertyFormViewModel {
}
this.$scope.editPropertyModel.isGetFunctionValid = undefined;
}
-
};
+ private serializePropertyConstraints(constraints: any[]): string[] {
+ if (constraints) {
+ let stringConstrsints = new Array();
+ constraints.forEach((constraint) => {
+ stringConstrsints.push(JSON.stringify(constraint));
+ })
+ return stringConstrsints;
+ }
+ return null;
+ }
+
private setEmptyValue() {
const property1 = this.$scope.editPropertyModel.property;
property1.value = undefined;
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html
index 35e3932586..2f67474d4f 100644
--- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html
+++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html
@@ -264,8 +264,9 @@
<div class="constraints-section i-sdc-form-item" data-ng-if="editPropertyModel.property.constraints || !(isViewOnly || componentMetadata.isService)">
<label class="i-sdc-form-label">Constraints</label>
<ng-container>
- <app-constraints [property]="editPropertyModel.property"
+ <app-constraints [property-constraints]="editPropertyModel.property.constraints"
[is-view-only]="isViewOnly || componentMetadata.isService"
+ [property-type]="editPropertyModel.property.type"
(on-constraint-change)="onConstraintChange($event)">
</app-constraints>
</ng-container>