diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2020-01-01 10:39:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-01 10:39:51 +0000 |
commit | 5a3532bc41b580fea966f4be79d0b5462ef7434d (patch) | |
tree | b67bdb1f72aba6f9aa9929600089aa5586be1032 /vid-webpack-master/src | |
parent | 42e59f3f3af996a2de92186203d67231c994fa9e (diff) | |
parent | 51d9784740b2fa457fe39046de222930d07da0c1 (diff) |
Merge "Show Templates popup when deploying from "SDC Catalog""
Diffstat (limited to 'vid-webpack-master/src')
6 files changed, 55 insertions, 13 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts index 3cd633de6..eb608652c 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts @@ -70,11 +70,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole } closeDialog(that): void { - this._iframeService.removeClassCloseModal(that.parentElementClassName); - this.dialogService.removeDialog(this); - setTimeout(() => { - window.parent.postMessage("closeIframe", "*"); - }, 15); + this._iframeService.closeIframe(this.dialogService, this); } shouldShowNotification(): boolean { diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html index 07fc7ab22..e2922b2a2 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html @@ -2,6 +2,7 @@ <div class="modal-content"> <div class="modal-header"> <button type="button" + [attr.data-tests-id]="'closeModal'" class="close" (click)="closeModal()">× </button> diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts index 6a734161f..20655d54a 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts @@ -68,6 +68,6 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string }; closeModal(): void { - this.dialogService.removeDialog(this); + this._iframeService.closeIframe(this.dialogService, this); } } diff --git a/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts b/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts index 211f59337..47f849059 100644 --- a/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts +++ b/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts @@ -60,11 +60,7 @@ export class SearchElementsModalComponent extends DialogComponent<{ modalInforma closeDialog(): void { this._iframeService.removeFullScreen(); - this._iframeService.removeClassCloseModal(this.parentElementClassName); - this.dialogService.removeDialog(this); - setTimeout(() => { - window.parent.postMessage("closeIframe", "*"); - }, 15); + this._iframeService.closeIframe(this.dialogService, this); } selectedMembersAmountChange(selectedMembersAmount: number): void { diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts new file mode 100644 index 000000000..fd5fe0e65 --- /dev/null +++ b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts @@ -0,0 +1,40 @@ +import {getTestBed, TestBed} from "@angular/core/testing"; +import {IframeService} from "./iframe.service"; +import {DialogService} from "ng2-bootstrap-modal"; + +export class DialogServiceMock extends DialogService { + removeDialog: (that) => ({}) +} + +describe('Iframe service', () => { + let injector; + let service: IframeService; + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + providers : [ + IframeService + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + service = injector.get(IframeService); + + })().then(done).catch(done.fail)); + + + test('service should be defined', ()=>{ + expect(service).toBeDefined(); + }); + + test('closeIframe: should call removeClassCloseModal', ()=>{ + const dialogService = new DialogServiceMock(null, null, null, null); + spyOn(service, 'removeClassCloseModal'); + spyOn(dialogService, 'removeDialog'); + service.closeIframe(dialogService, {}) + + expect(service.removeClassCloseModal).toBeCalledWith('content'); + expect(dialogService.removeDialog).toBeCalledWith({}); + }); + +}); diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.ts index 4c699825f..ab93d1ac8 100644 --- a/vid-webpack-master/src/app/shared/utils/iframe.service.ts +++ b/vid-webpack-master/src/app/shared/utils/iframe.service.ts @@ -1,22 +1,31 @@ import {Injectable} from "@angular/core"; +import {DialogService} from "ng2-bootstrap-modal"; @Injectable() export class IframeService { addClassOpenModal(elementClassName: string) { - var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; + const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; if (parentBodyElement) { parentBodyElement.classList.add("modal-open"); } } removeClassCloseModal(elementClassName: string) { - var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; + const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; if (parentBodyElement) { parentBodyElement.classList.remove("modal-open"); } } + closeIframe(dialogService : DialogService, that){ + this.removeClassCloseModal('content'); + dialogService.removeDialog(that); + setTimeout(() => { + window.parent.postMessage("closeIframe", "*"); + }, 15); + } + addFullScreen(){ let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0]; |