import {ModalService} from 'app/ng2/services/modal.service';
import {
+ ArtifactModel,
ButtonModel,
CapabilitiesGroup,
InputBEModel,
import {ComponentServiceNg2} from 'app/ng2/services/component-services/component.service';
import {TopologyTemplateService} from "../../services/component-services/topology-template.service";
import {InterfaceOperationModel} from "../../../models/interfaceOperation";
-import {
- InterfaceOperationHandlerComponent
-} from "../composition/interface-operatons/operation-creator/interface-operation-handler.component";
-import {
- DropdownValue
-} from "../../components/ui/form-components/dropdown/ui-element-dropdown.component";
+import {InterfaceOperationHandlerComponent} from "../composition/interface-operatons/operation-creator/interface-operation-handler.component";
+import {DropdownValue} from "../../components/ui/form-components/dropdown/ui-element-dropdown.component";
import {ToscaArtifactModel} from "../../../models/toscaArtifact";
import {ToscaArtifactService} from "../../services/tosca-artifact.service";
-import {
- InterfaceOperationComponent
-} from "../interface-operation/interface-operation.page.component";
+import {InterfaceOperationComponent} from "../interface-operation/interface-operation.page.component";
import {Observable} from "rxjs/Observable";
import {PluginsService} from 'app/ng2/services/plugins.service';
constructor(operation: OperationModel) {
super(operation);
-
if (!operation.description) {
this.description = '';
}
}
}
-// tslint:disable-next-line:max-classes-per-file
class ModalTranslation {
CREATE_TITLE: string;
EDIT_TITLE: string;
}
}
-// tslint:disable-next-line:max-classes-per-file
@Component({
selector: 'interface-definition',
templateUrl: './interface-definition.page.component.html',
modalTranslation: ModalTranslation;
workflows: any[];
capabilities: CapabilitiesGroup;
- isViewOnly: boolean;
openOperation: OperationModel;
enableWorkflowAssociation: boolean;
callback([]);
}
});
+ this.loadToscaArtifacts();
}
initInterfaces(interfaces: InterfaceModel[]): void {
}
private disableSaveButton = (): boolean => {
- return this.isViewOnly ||
+ return this.readonly ||
(this.isEnableAddArtifactImplementation()
&& (!this.modalInstance.instance.dynamicContent.toscaArtifactTypeSelected ||
!this.modalInstance.instance.dynamicContent.artifactName)
onSelectInterfaceOperation(interfaceModel: UIInterfaceModel, operation: InterfaceOperationModel) {
const isEdit = operation !== undefined;
- const cancelButton: ButtonModel = new ButtonModel(this.modalTranslation.CANCEL_BUTTON, 'outline white', this.cancelAndCloseModal);
- const saveButton: ButtonModel = new ButtonModel(this.modalTranslation.SAVE_BUTTON, 'blue',
- () => isEdit ? this.updateOperation() : this.createOperationCallback(),
- this.disableSaveButton
- );
+ const modalButtons = [];
+ if (!this.readonly) {
+ const saveButton: ButtonModel = new ButtonModel(this.modalTranslation.SAVE_BUTTON, 'blue',
+ () => isEdit ? this.updateOperation() : this.createOperationCallback(),
+ this.disableSaveButton
+ );
+ modalButtons.push(saveButton);
+ }
+ modalButtons.push(new ButtonModel(this.modalTranslation.CANCEL_BUTTON, 'outline white', this.cancelAndCloseModal));
const interfaceDataModal: ModalModel =
- new ModalModel('l', this.modalTranslation.EDIT_TITLE, '', [saveButton, cancelButton], 'custom');
+ new ModalModel('l', this.modalTranslation.EDIT_TITLE, '', modalButtons, 'custom');
this.modalInstance = this.modalServiceNg2.createCustomModal(interfaceDataModal);
this.modalServiceNg2.addDynamicContentToModal(
selectedInterface: interfaceModel ? interfaceModel : new UIInterfaceModel(),
selectedInterfaceOperation: operation ? operation : new InterfaceOperationModel(),
validityChangedCallback: this.disableSaveButton,
- isViewOnly: this.isViewOnly,
- isEdit: isEdit,
+ isViewOnly: this.readonly,
+ 'isEdit': isEdit,
interfaceTypesMap: this.interfaceTypesMap,
+ modelName: this.component.model
}
);
this.modalInstance.instance.open();
}
private updateOperation = (): void => {
- let operationToUpdate = this.modalInstance.instance.dynamicContent.instance.operationToUpdate;
+ this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = true;
+ const interfaceOperationHandlerComponentInstance: InterfaceOperationHandlerComponent = this.modalInstance.instance.dynamicContent.instance;
+ const operationToUpdate = this.modalInstance.instance.dynamicContent.instance.operationToUpdate;
+ const isArtifactChecked = interfaceOperationHandlerComponentInstance.enableAddArtifactImplementation;
+ if (!isArtifactChecked) {
+ const artifactName = interfaceOperationHandlerComponentInstance.artifactName ?
+ interfaceOperationHandlerComponentInstance.artifactName : '';
+ operationToUpdate.implementation = new ArtifactModel({'artifactName': artifactName, 'artifactVersion': ''} as ArtifactModel);
+ }
this.componentServiceNg2.updateComponentInterfaceOperation(this.component.uniqueId, operationToUpdate)
.subscribe((newOperation: InterfaceOperationModel) => {
let oldOpIndex;
}
});
});
- newOperation = this.handleEnableAddArtifactImplementation(newOperation);
oldInterf.operations.splice(oldOpIndex, 1);
oldInterf.operations.push(new InterfaceOperationModel(newOperation));
+ }, error => {
+ this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = false;
+ }, () => {
+ this.sortInterfaces();
+ this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = false;
+ this.modalServiceNg2.closeCurrentModal();
});
- this.modalServiceNg2.closeCurrentModal();
}
private createOperationCallback(): void {
+ this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = true;
const operationToUpdate = this.modalInstance.instance.dynamicContent.instance.operationToUpdate;
console.log('createOperationCallback', operationToUpdate);
console.log('this.component', this.component);
uiInterfaceModel.operations.push(new UIOperationModel(new OperationModel(newOperation)));
this.interfaces.push(uiInterfaceModel);
}
+ }, error => {
+ this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = false;
+ }, () => {
+ this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = false;
+ this.modalServiceNg2.closeCurrentModal();
});
- this.modalServiceNg2.closeCurrentModal();
}
private handleEnableAddArtifactImplementation = (newOperation: InterfaceOperationModel): InterfaceOperationModel => {
return this.interfaces.filter((interfaceData) => interfaceData.operations && interfaceData.operations.length > 0).length > 0;
}
- onRemoveOperation = (event: Event, operation: OperationModel): void => {
- event.stopPropagation();
+ onRemoveOperation(operation: OperationModel): void {
+ if (this.readonly) {
+ return;
+ }
const deleteButton: IModalButtonComponent = {
id: 'deleteButton',