From ef5e3b283ed1825e2409db2d89fefed8b606abe6 Mon Sep 17 00:00:00 2001 From: Sara Weiss Date: Thu, 5 Dec 2019 13:23:13 +0200 Subject: Show previous instantiations button in new service modal Issue-ID: VID-724 Signed-off-by: Sara Weiss Change-Id: I18633adbabbc22c68f9bcd712427033deaffd33c --- .../service/service.popup.service.spec.ts | 27 ++++++++++++++++++++++ .../service/service.popup.service.ts | 26 +++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) (limited to 'vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices') diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts index ccfaacd0d..ebea695f7 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts @@ -2140,6 +2140,33 @@ describe('Service popup service', () => { expect(service.closeDialogEvent.next).toHaveBeenCalledWith(that); }); + test('showPreviousInstantiations should trigger postMessage', () => { + let that = { + parentElementClassName: 'content', + _iframeService: iframeService, + resetPopupData : () =>{ }, + serviceModel:{ + uuid:'1111' + } + + }; + + let expectedMessage= { + eventId: 'showPreviousInstantiations', + data: { + serviceModelId: that.serviceModel.uuid + } + }; + + jest.spyOn(window.parent, 'postMessage'); + + service.showPreviousInstantiations(that, fb.group({})); + + expect( window.parent.postMessage).toHaveBeenCalledWith(expectedMessage,"*") + + }); + + test('getDynamicInputs should return list of controls' ,() => { const result: FormControlModel[] = service.getDynamicInputs('6b528779-44a3-4472-bdff-9cd15ec93450'); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts index e2033aa74..3e7e8c1e5 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.ts @@ -59,7 +59,12 @@ export class ServicePopupService implements GenericPopupInterface { this.getDynamicInputs(serviceId), this.modelInformations, (that, form: FormGroup) => {that.onSubmit(that, form);}, - (that: any, form: FormGroup) => {that.onCancel(that, form); } + (that: any, form: FormGroup) => { + that.onCancel(that, form); + }, + (that: any, form: FormGroup) => { + that.showPreviousInstantiations(that, form); + } ); } @@ -123,13 +128,24 @@ export class ServicePopupService implements GenericPopupInterface { onSubmit(that, form: FormGroup, ...args): void { form = that.updateExtraValues(that, form); that.storeServiceInstance(form.value, args[0], [], new ModelInfo(that.serviceModel), that.serviceModel); - window.parent.postMessage( { - eventId: 'submitIframe', + const eventId = 'submitIframe'; + this.postMessageToWindowParent(eventId, that.serviceModel.uuid); + this.onCancel(that, form); + } + + showPreviousInstantiations(that, form: FormGroup,): void { + const eventId = 'showPreviousInstantiations'; + this.postMessageToWindowParent(eventId, that.serviceModel.uuid); + this.onCancel(that, form); + } + + private postMessageToWindowParent(eventId: string, serviceModelId:string) { + window.parent.postMessage({ + eventId: eventId, data: { - serviceModelId: that.serviceModel.uuid + serviceModelId } }, "*"); - this.onCancel(that, form); } updateExtraValues = (that, form) : any => { -- cgit 1.2.3-korg