Template modal - Start from Scratch button + UT
Issue-ID: VID-739
Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
Change-Id: Ie390a53714212d4d943789d14bb2fb51f7311277
Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
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 e2922b2..84783c2 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
@@ -168,7 +168,7 @@
<button
[attr.data-tests-id]="'startFromScratchButton'"
type="button" class="btn btn-success submit startFromScratchButton"
- (click)="closeModal()"><span>Start from Scratch</span>
+ (click)="closeModalAndOpenNewServiceModal()"><span>Start from Scratch</span>
</button>
</div>
</div>
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 20655d5..1c86b3d 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
@@ -1,7 +1,7 @@
import {Component, OnDestroy, OnInit} from "@angular/core";
import {DialogComponent, DialogService} from "ng2-bootstrap-modal";
import {IframeService} from "../../../utils/iframe.service";
-import {ActivatedRoute} from "@angular/router";
+import {ActivatedRoute, Router} from "@angular/router";
import {ServiceInfoService} from "../../../server/serviceInfo/serviceInfo.service";
import {InstantiationTemplatesModalService} from "./instantiation.templates.modal.service";
import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model";
@@ -20,6 +20,7 @@
export class InstantiationTemplatesModalComponent extends DialogComponent<string, boolean> implements OnInit, OnDestroy {
+ serviceModelId: string = null;
selectedInstantiation: InstantiationTemplatesRowModel = null;
templateModalComponentService: InstantiationTemplatesModalService;
originalTableData: InstantiationTemplatesRowModel[] = [];
@@ -34,6 +35,7 @@
private _instantiationStatusComponentService: InstantiationStatusComponentService,
private _aaiService: AaiService,
private _store : NgRedux<AppState>,
+ private _router : Router,
private _route: ActivatedRoute) {
super(dialogService);
this.templateModalComponentService = _templateModalComponentService;
@@ -44,8 +46,8 @@
this._route
.queryParams
.subscribe(params => {
-
- const getServiceJobInfoRoute = this._serviceInfoService.getTemplatesInfo(true, params['serviceModelId']);
+ this.serviceModelId = params['serviceModelId'];
+ const getServiceJobInfoRoute = this._serviceInfoService.getTemplatesInfo(true, this.serviceModelId);
const getUserIdRoute = this._aaiService.getUserId();
forkJoin([getServiceJobInfoRoute, getUserIdRoute]).subscribe(([jobs]) => {
@@ -70,4 +72,9 @@
closeModal(): void {
this._iframeService.closeIframe(this.dialogService, this);
}
+
+
+ closeModalAndOpenNewServiceModal(): void {
+ this._templateModalComponentService.navigateToNewServiceModal(this.serviceModelId);
+ }
}
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts
index a17abed..308597a 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts
@@ -2,7 +2,7 @@
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {InstantiationTemplatesModalService} from "./instantiation.templates.modal.service";
import {AaiService} from "../../../services/aaiService/aai.service";
-import {ActivatedRoute} from "@angular/router";
+import {ActivatedRoute, Router} from "@angular/router";
import {IframeService} from "../../../utils/iframe.service";
import {NgRedux} from "@angular-redux/store";
import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
@@ -17,16 +17,25 @@
}
}
-class MockAppStore {
+//
-}
+
+class MockAppStore {}
describe('instantiation templates modal service', () => {
+ const serviceModelId :string = 'serviceModelId';
let injector;
let service: InstantiationTemplatesModalService;
let httpMock: HttpTestingController;
let _aaiService: AaiService;
let _activatedRoute: ActivatedRoute;
+ let _router : Router;
+
+
+
+ let router = {
+ navigate: jasmine.createSpy('navigate')
+ };
beforeAll(done => (async () => {
TestBed.configureTestingModule({
@@ -35,6 +44,7 @@
IframeService,
AaiService,
FeatureFlagsService,
+ { provide: Router, useValue: router },
{provide: ActivatedRoute, useClass: ActivatedRouteMock},
{provide: NgRedux, useClass: MockAppStore}
]
@@ -46,6 +56,7 @@
httpMock = injector.get(HttpTestingController);
_aaiService = injector.get(AaiService);
_activatedRoute = injector.get(ActivatedRoute);
+ _router = injector.get(Router);
})().then(done).catch(done.fail));
@@ -157,4 +168,12 @@
expect(result).toHaveLength(0);
});
+
+ test('navigateToNewServiceModal should navigate to new service modal', ()=>{
+
+ service.navigateToNewServiceModal(serviceModelId);
+
+ expect(_router.navigate).toBeCalledWith(["/servicePopup"], {"queryParams": {"isCreate": true, "serviceModelId": serviceModelId}, "queryParamsHandling": "merge"});
+ })
+
});
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts
index 36691fd..c175918 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts
@@ -1,10 +1,13 @@
import {Injectable} from "@angular/core";
import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model";
+import {Router} from "@angular/router";
import * as _ from 'lodash';
@Injectable()
export class InstantiationTemplatesModalService {
+ constructor(private _router : Router){
+ }
convertResponseToUI = (jobsResponse: any[]): InstantiationTemplatesRowModel[] => {
let tableRows: InstantiationTemplatesRowModel[] = [];
@@ -25,4 +28,9 @@
return [];
};
+
+ navigateToNewServiceModal(serviceModelId: string) {
+ this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true}, queryParamsHandling: 'merge' });
+ }
+
}
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 ab93d1a..e1ef59f 100644
--- a/vid-webpack-master/src/app/shared/utils/iframe.service.ts
+++ b/vid-webpack-master/src/app/shared/utils/iframe.service.ts
@@ -6,19 +6,19 @@
addClassOpenModal(elementClassName: string) {
const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
- if (parentBodyElement) {
+ if (parentBodyElement) {
parentBodyElement.classList.add("modal-open");
}
}
removeClassCloseModal(elementClassName: string) {
const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
- if (parentBodyElement) {
+ if (parentBodyElement) {
parentBodyElement.classList.remove("modal-open");
}
}
- closeIframe(dialogService : DialogService, that){
+ closeIframe(dialogService: DialogService, that) {
this.removeClassCloseModal('content');
dialogService.removeDialog(that);
setTimeout(() => {
@@ -27,16 +27,17 @@
}
- addFullScreen(){
- let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0];
- if (parentBodyElement) {
+
+ addFullScreen() {
+ let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0];
+ if (parentBodyElement) {
parentBodyElement.classList.add("full-screen");
}
}
- removeFullScreen(){
- let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0];
- if (parentBodyElement) {
+ removeFullScreen() {
+ let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0];
+ if (parentBodyElement) {
parentBodyElement.classList.remove("full-screen");
}
}