diff options
author | andre.schmid <andre.schmid@est.tech> | 2022-07-07 17:17:52 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-07-18 14:22:12 +0000 |
commit | 68733163804ed2efed8223a04ab0a7a0714a8b33 (patch) | |
tree | 013f4d25042aa776120971a612a52d64db52f7a7 /catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts | |
parent | 4e4ec8e9c21acf7f9210aaebf8f13a60542737fc (diff) |
Support for concat TOSCA function
Adds support for the concat TOSCA function in an instance property.
Refactors the TOSCA function structure so it can be more generic to
support other functions in the future.
Change-Id: I338e4138d26afe21779da57c4eeb3f2d486c20a9
Issue-ID: SDC-4095
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts index 9f721d5cdd..2ae5ce8c09 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -61,13 +61,12 @@ import {UnsavedChangesComponent} from "app/ng2/components/ui/forms/unsaved-chang import {PropertyCreatorComponent} from "./property-creator/property-creator.component"; import {ModalService} from "../../services/modal.service"; import {DeclareListComponent} from "./declare-list/declare-list.component"; -import {ToscaFunctionComponent} from "./tosca-function/tosca-function.component"; +import {ToscaFunctionComponent, ToscaFunctionValidationEvent} from "./tosca-function/tosca-function.component"; import {CapabilitiesGroup, Capability} from "../../../models/capability"; import {ToscaPresentationData} from "../../../models/tosca-presentation"; import {Observable} from "rxjs"; import {TranslateService} from "../../shared/translator/translate.service"; -import {ToscaGetFunctionDtoBuilder} from '../../../models/tosca-get-function-dto'; -import {ToscaGetFunction} from "../../../models/tosca-get-function"; +import {ToscaFunction} from "../../../models/tosca-function"; const SERVICE_SELF_TITLE = "SELF"; @Component({ @@ -539,36 +538,37 @@ export class PropertiesAssignmentComponent { const modalTitle = this.translateService.translate('TOSCA_FUNCTION_MODAL_TITLE'); const modalButtons = []; let disableSaveButtonFlag = true; + const modal = this.modalService.createCustomModal(new ModalModel( + 'sm', + modalTitle, + null, + modalButtons, + null /* type */ + )); modalButtons.push(new ButtonModel(this.translateService.translate('MODAL_SAVE'), 'blue', () => { - const toscaGetFunction: ToscaGetFunction = modal.instance.dynamicContent.instance.toscaGetFunction; - if (toscaGetFunction.functionType) { - this.updateCheckedInstancePropertyGetFunctionValue(toscaGetFunction); + const toscaGetFunction: ToscaFunction = modal.instance.dynamicContent.instance.toscaFunctionForm.value; + if (toscaGetFunction) { + this.updateCheckedInstancePropertyFunctionValue(toscaGetFunction); } else { this.clearCheckedInstancePropertyValue(); } - modal.instance.close(); + this.modalService.closeCurrentModal(); }, (): boolean => { return disableSaveButtonFlag } )); const checkedInstanceProperty = this.buildCheckedInstanceProperty(); modalButtons.push(new ButtonModel(this.translateService.translate('MODAL_CANCEL'), 'outline grey', () => { - modal.instance.close(); + this.modalService.closeCurrentModal(); })); - const modal = this.modalService.createCustomModal(new ModalModel( - 'sm', - modalTitle, - null, - modalButtons, - null /* type */ - )); + this.modalService.addDynamicContentToModalAndBindInputs(modal, ToscaFunctionComponent, { 'property': checkedInstanceProperty, 'componentInstanceMap': this.componentInstanceMap }); - modal.instance.dynamicContent.instance.onValidityChange.subscribe(isValid => { - disableSaveButtonFlag = !isValid; + modal.instance.dynamicContent.instance.onValidityChange.subscribe((validationEvent: ToscaFunctionValidationEvent) => { + disableSaveButtonFlag = !validationEvent.isValid; }); modal.instance.open(); } @@ -577,23 +577,13 @@ export class PropertiesAssignmentComponent { const checkedInstanceProperty: PropertyBEModel = this.buildCheckedInstanceProperty(); checkedInstanceProperty.getInputValues = null; checkedInstanceProperty.value = null; - checkedInstanceProperty.toscaGetFunction = null; + checkedInstanceProperty.toscaFunction = null; this.updateInstanceProperty(checkedInstanceProperty); } - private updateCheckedInstancePropertyGetFunctionValue(toscaGetFunction: ToscaGetFunction) { - const toscaGetFunctionBuilder: ToscaGetFunctionDtoBuilder = - new ToscaGetFunctionDtoBuilder() - .withPropertyUniqueId(toscaGetFunction.propertyUniqueId) - .withFunctionType(toscaGetFunction.functionType) - .withPropertySource(toscaGetFunction.propertySource) - .withPropertyName(toscaGetFunction.propertyName) - .withSourceName(toscaGetFunction.sourceName) - .withSourceUniqueId(toscaGetFunction.sourceUniqueId) - .withPropertyPathFromSource(toscaGetFunction.propertyPathFromSource); - + private updateCheckedInstancePropertyFunctionValue(toscaFunction: ToscaFunction) { const checkedProperty: PropertyBEModel = this.buildCheckedInstanceProperty(); - checkedProperty.toscaGetFunction = toscaGetFunctionBuilder.build(); + checkedProperty.toscaFunction = toscaFunction; this.updateInstanceProperty(checkedProperty); } |