allow LOB multi-selection for vnf -fix test
[vid.git] / vid-webpack-master / src / app / shared / components / genericFormPopup / generic-form-popup.component.ts
index 3939e44..7368dd6 100644 (file)
@@ -8,13 +8,14 @@ import * as _ from "lodash";
 import {NgRedux} from "@angular-redux/store";
 import {AppState} from "../../store/reducers";
 import {ServicePopupService} from "./genericFormServices/service/service.popup.service";
-import {ActivatedRoute} from "@angular/router";
+import {ActivatedRoute, Router} from "@angular/router";
 import {AaiService} from "../../services/aaiService/aai.service";
 import {GenericFormPopupService} from "./generic-form-popup.service";
 import {FormControlModel} from "../../models/formControlModels/formControl.model";
 import {FormGeneralErrorsService} from "../formGeneralErrors/formGeneralErrors.service";
 import {FeatureFlagsService, Features} from "../../services/featureFlag/feature-flags.service";
 import {InstantiationTemplatesModalComponent} from "./instantiationTemplatesModal/instantiation.templates.modal.component";
+import {updateCurrentModalModeAction} from "../../storeUtil/utils/global/global.actions";
 
 
 export interface PopupModel {
@@ -46,13 +47,12 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
   type: PopupType;
   uuidData: UUIDData;
   showTemplateBtn: boolean = false;
-  isShowPreviousInstantiationBtn: boolean = false;
   isUpdateMode: boolean;
   node: ITreeNode = null;
   hasGeneralApiError: boolean = false;
   parentElementClassName = 'content';
   errorMsg = 'Page contains errors. Please see details next to the relevant fields.';
-
+  serviceModelId : string;
   servicesQty = 1;
   quantityOptions = _.range(1, 51)
 
@@ -64,29 +64,31 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
               private _aaiService: AaiService,
               private _dialogService: DialogService,
               private _route: ActivatedRoute,
+              private _router : Router,
               private _genericFormPopupService: GenericFormPopupService) {
     super(dialogService);
   }
 
   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 {
     return this.formPopupDetails && this.formPopupDetails.UUIDData['bulkSize'] > 1
   }
 
+  clearModalIsUpdateMode() : void {
+    this._store.dispatch(updateCurrentModalModeAction(null));
+  }
+
   ngOnInit(): void {
+    this._store.dispatch(updateCurrentModalModeAction(this.isUpdateMode));
     this._route
       .queryParams
       .subscribe(params => {
-        console.log('changed');
-        if (params['serviceModelId'] && params['isCreate'] == "true") {
-          this.onInitForCreateNewServicePopup();
+        this.serviceModelId = params['serviceModelId'];
+        if (this.serviceModelId && params['isCreate'] == "true") {
+          this.onInitForCreateNewServicePopup(params['isInstantiationTemplateExists']);
         }
       });
 
@@ -104,7 +106,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
     }
   }
 
-  private onInitForCreateNewServicePopup() {
+  private onInitForCreateNewServicePopup(isInstantiationTemplateExists : boolean) {
     this._genericFormPopupService.initReduxOnCreateNewService().then((serviceModelId: string) => {
       this.uuidData = <any>{
         bulkSize: 1,
@@ -113,9 +115,8 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
         serviceId: serviceModelId,
         popupService: this._servicePopupService,
       };
-      this.showTemplateBtn = !!this._store.getState().global.flags["FLAG_2004_INSTANTIATION_TEMPLATES_POPUP"];
 
-      this.isShowPreviousInstantiationBtn = !!this._store.getState().global.flags["FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER"];
+      this.showTemplateBtn = this._genericFormPopupService.shouldShowTemplateBtn(isInstantiationTemplateExists);
 
       this.uuidData.popupService.closeDialogEvent.subscribe((that) => {
         this.closeDialog(that);
@@ -152,7 +153,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
 
 
   openTemplateModal = (): void => {
-    this._dialogService.addDialog(InstantiationTemplatesModalComponent, {});
+    this._router.navigate(['/instantiationTemplatesPopup'], { queryParams: { serviceModelId: this.serviceModelId}, queryParamsHandling: 'merge' });
   }
 
 }