summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src')
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/interface-operations.component.ts21
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts52
-rw-r--r--catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts25
3 files changed, 38 insertions, 60 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/interface-operations.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/interface-operations.component.ts
index 2a0dcd2182..1dc02a5e4f 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/interface-operations.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/interface-operations.component.ts
@@ -214,8 +214,21 @@ export class InterfaceOperationsComponent {
).length === 0;
}
- private enableOrDisableSaveButton = (isValid): boolean => {
- return isValid;
+ private disableSaveButton = (): boolean => {
+ let disable:boolean = true;
+ if(this.isViewOnly) {
+ return disable;
+ }
+
+ let enableAddArtifactImplementation = this.modalInstance.instance.dynamicContent.instance.enableAddArtifactImplementation;
+ if(enableAddArtifactImplementation) {
+ let toscaArtifactTypeSelected = this.modalInstance.instance.dynamicContent.instance.toscaArtifactTypeSelected;
+ let isToscaArtifactType:boolean = !(typeof toscaArtifactTypeSelected == 'undefined' || _.isEmpty(toscaArtifactTypeSelected));
+ disable = !isToscaArtifactType;
+ return disable;
+ }
+ disable = false;
+ return disable;
}
onSelectInterfaceOperation(interfaceModel: UIInterfaceModel, operation: InterfaceOperationModel) {
@@ -226,7 +239,7 @@ export class InterfaceOperationsComponent {
buttonList.push(closeButton);
} else {
const saveButton: ButtonModel = new ButtonModel(this.modalTranslation.SAVE_BUTTON, 'blue', () =>
- this.updateInterfaceOperation(), this.enableOrDisableSaveButton);
+ this.updateInterfaceOperation(), this.disableSaveButton);
const cancelButton: ButtonModel = new ButtonModel(this.modalTranslation.CANCEL_BUTTON, 'outline white', this.cancelAndCloseModal);
buttonList.push(saveButton);
buttonList.push(cancelButton);
@@ -242,7 +255,7 @@ export class InterfaceOperationsComponent {
toscaArtifactTypes: this.toscaArtifactTypes,
selectedInterface: interfaceModel ? interfaceModel : new UIInterfaceModel(),
selectedInterfaceOperation: operation ? operation : new InterfaceOperationModel(),
- validityChangedCallback: this.enableOrDisableSaveButton,
+ validityChangedCallback: this.disableSaveButton,
isViewOnly: this.isViewOnly,
isEdit: true,
modelName: this.componentMetaData.model
diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
index 6bfb09da9d..216dc3284e 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
@@ -18,7 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
+import {Component, EventEmitter, Output, ViewChild} from '@angular/core';
import {UIInterfaceModel} from "../interface-operations.component";
import {InputOperationParameter, InterfaceOperationModel, IOperationParamsList} from "../../../../../models/interfaceOperation";
import {TranslateService} from "../../../../shared/translator/translate.service";
@@ -65,7 +65,6 @@ export class InterfaceOperationHandlerComponent {
inputs: Array<InputOperationParameter> = [];
properties: Array<PropertyParamRowComponent> = [];
isLoading: boolean = false;
- readonly: boolean;
isViewOnly: boolean;
isEdit: boolean;
interfaceTypes: Array<DropdownValue> = [];
@@ -75,21 +74,15 @@ export class InterfaceOperationHandlerComponent {
interfaceOperationOptions: Array<DropDownOption> = [];
selectedInterfaceOperation: DropDownOption = undefined;
modelName: string;
-
toscaArtifactTypeSelected: string;
toscaArtifactTypeProperties: Array<PropertyBEModel> = [];
artifactTypeProperties: Array<InputOperationParameter> = [];
-
toscaArtifactTypes: Array<DropdownValue> = [];
-
enableAddArtifactImplementation: boolean;
-
propertyValueValid: boolean = true;
inputTypeOptions: any[];
constructor(private dataTypeService: DataTypeService, private componentServiceNg2: ComponentServiceNg2) {
-
-
}
ngOnInit() {
@@ -102,7 +95,6 @@ export class InterfaceOperationHandlerComponent {
this.modelName = this.input.modelName;
this.initInputs();
this.removeImplementationQuote();
- this.validityChanged();
this.loadInterfaceOperationImplementation();
this.dataTypeMap$ = new Observable<Map<string, DataTypeModel>>(subscriber => {
@@ -125,7 +117,6 @@ export class InterfaceOperationHandlerComponent {
this.inputs = Array.from(this.operationToUpdate.inputs.listToscaDataDefinition);
this.removeImplementationQuote();
- this.validityChanged();
this.loadInterfaceOperationImplementation();
this.loadInterfaceType();
}
@@ -208,7 +199,6 @@ export class InterfaceOperationHandlerComponent {
this.getArtifactTypesSelected();
}
this.enableAddArtifactImplementation = event;
- this.validateRequiredField();
}
onSelectToscaArtifactType(type: IDropDownOption) {
@@ -225,7 +215,6 @@ export class InterfaceOperationHandlerComponent {
this.operationToUpdate.implementation = artifact;
this.getArtifactTypesSelected();
}
- this.validateRequiredField();
}
onArtifactVersionChange(value: string | undefined) {
@@ -234,20 +223,16 @@ export class InterfaceOperationHandlerComponent {
onAddInput(inputOperationParameter: InputOperationParameter) {
this.addInput(inputOperationParameter);
- this.validityChanged();
}
propertyValueValidation = (propertyValue): void => {
this.onPropertyValueChange(propertyValue);
this.propertyValueValid = propertyValue.isValid;
- this.readonly = !this.propertyValueValid;
- this.validateRequiredField();
}
onRemoveInput = (inputParam: InputOperationParameter): void => {
let index = this.inputs.indexOf(inputParam);
this.inputs.splice(index, 1);
- this.validityChanged();
}
private removeImplementationQuote(): void {
@@ -265,14 +250,6 @@ export class InterfaceOperationHandlerComponent {
}
}
- validityChanged = () => {
- let validState = this.checkFormValidForSubmit();
- this.input.validityChangedCallback(validState);
- if (validState) {
- this.readonly = false;
- }
- }
-
private getArtifactTypesSelected() {
if (this.operationToUpdate.implementation && this.operationToUpdate.implementation.artifactType) {
this.artifactName =
@@ -284,33 +261,6 @@ export class InterfaceOperationHandlerComponent {
this.artifactTypeProperties = this.convertArtifactsPropertiesToInput();
this.enableAddArtifactImplementation = true;
}
- this.validateRequiredField();
- }
-
- validateRequiredField = () => {
- this.readonly = true;
- const isRequiredFieldSelected = this.isRequiredFieldsSelected();
- this.input.validityChangedCallback(isRequiredFieldSelected);
- if (isRequiredFieldSelected && this.propertyValueValid) {
- this.readonly = false;
- }
- }
-
- private isRequiredFieldsSelected() {
- return this.toscaArtifactTypeSelected && this.artifactName;
- }
-
- private checkFormValidForSubmit = (): boolean => {
- return this.operationToUpdate.name && this.artifactName && this.isParamsValid();
- }
-
- private isParamsValid = (): boolean => {
- const isInputValid = (input) => input.name && input.inputId && input.type;
- const isValid = this.inputs.every(isInputValid);
- if (!isValid) {
- this.readonly = true;
- }
- return isValid;
}
toDropDownOption(val: string) {
diff --git a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts
index eab8b18f44..b3f8dfc60c 100644
--- a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts
@@ -217,11 +217,26 @@ export class InterfaceDefinitionComponent {
}
private disableSaveButton = (): boolean => {
- return this.readonly ||
- (this.isEnableAddArtifactImplementation()
- && (!this.modalInstance.instance.dynamicContent.toscaArtifactTypeSelected ||
- !this.modalInstance.instance.dynamicContent.artifactName)
- );
+ let disable:boolean = true;
+ if(this.readonly) {
+ return disable;
+ }
+
+ let selectedInterfaceOperation = this.modalInstance.instance.dynamicContent.instance.selectedInterfaceOperation;
+ let isInterfaceOperation:boolean = !(typeof selectedInterfaceOperation == 'undefined' || _.isEmpty(selectedInterfaceOperation));
+ let selectedInterfaceType = this.modalInstance.instance.dynamicContent.instance.selectedInterfaceType;
+ let isInterfaceType:boolean = !(typeof selectedInterfaceType == 'undefined' || _.isEmpty(selectedInterfaceType));
+ let bothSet: boolean = isInterfaceOperation && isInterfaceType;
+
+ let enableAddArtifactImplementation = this.modalInstance.instance.dynamicContent.instance.enableAddArtifactImplementation;
+ if(enableAddArtifactImplementation) {
+ let toscaArtifactTypeSelected = this.modalInstance.instance.dynamicContent.instance.toscaArtifactTypeSelected;
+ let isToscaArtifactType:boolean = !(typeof toscaArtifactTypeSelected == 'undefined' || _.isEmpty(toscaArtifactTypeSelected));
+ disable = !bothSet || !isToscaArtifactType;
+ return disable;
+ }
+ disable = !bothSet;
+ return disable;
}
onSelectInterfaceOperation(interfaceModel: UIInterfaceModel, operation: InterfaceOperationModel) {