Show previous instantiations button in new service modal
Issue-ID: VID-724
Signed-off-by: Sara Weiss <sara.weiss@intl.att.com>
Change-Id: I18633adbabbc22c68f9bcd712427033deaffd33c
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html
index 5b8dfa9..f9da426 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html
@@ -61,6 +61,13 @@
(click)="openTemplateModal()"
><span>Template</span></button>
<button
+ *ngIf=isInstantiationStatusFilterFlagOn()
+ [attr.data-tests-id]="'ShowPreviousInstancesButton'"
+ type="button" class="btn btn-success submit"
+ (click)="formPopupDetails.onOtherAction(formPopupDetails.that, dynamicForm)">
+ <span>Previous Instantiation</span>
+ </button>
+ <button
[attr.data-tests-id]="'cancelButton'"
type="button" class="btn btn-default cancel"
(click)="formPopupDetails.onCancel(formPopupDetails.that, dynamicForm)"><span>Cancel</span></button>
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 cadce7d..159871f 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
@@ -13,6 +13,7 @@
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";
@@ -146,6 +147,10 @@
openTemplateModal = (): void => {
this._dialogService.addDialog(InstantiationTemplatesModalComponent, {});
}
+
+ isInstantiationStatusFilterFlagOn() {
+ return FeatureFlagsService.getFlagState(Features.FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER, this._store);
+ }
}
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 ccfaacd..ebea695 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 @@
expect(service.closeDialogEvent.next).toHaveBeenCalledWith(that);
});
+ test('showPreviousInstantiations should trigger postMessage', () => {
+ let that = <any>{
+ 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 e2033aa..3e7e8c1 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 @@
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 @@
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 => {
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss
index 23c950c..ef8d01a 100644
--- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss
+++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss
@@ -114,7 +114,7 @@
}
.submit {
- width: 120px;
+ min-width: 120px;
height: 36px;
background: #009fdb;
border-radius: 2px;
diff --git a/vid-webpack-master/src/app/shared/models/formControlModels/formPopupDetails.model.ts b/vid-webpack-master/src/app/shared/models/formControlModels/formPopupDetails.model.ts
index 0a7e610..40d74d6 100644
--- a/vid-webpack-master/src/app/shared/models/formControlModels/formPopupDetails.model.ts
+++ b/vid-webpack-master/src/app/shared/models/formControlModels/formPopupDetails.model.ts
@@ -14,6 +14,8 @@
modelInformationItems: ModelInformationItem[];
onSubmit : (that : any, form: FormGroup , ...args) => void;
onCancel : (that : any, form: FormGroup) => void;
+ onOtherAction: (that: any, form: FormGroup) => void;
+
constructor(that : any,
popupTypeName : PopupType ,
@@ -25,7 +27,8 @@
dynamicInputsControlList : FormControlModel[],
modelInformationItems : ModelInformationItem[],
onSubmit : (that : any, form : FormGroup, ...args) => void,
- onCancel : (that : any, form : FormGroup) => void){
+ onCancel: (that: any, form: FormGroup) => void,
+ onOtherAction?: (that: any, form: FormGroup) => void) {
this.title = title;
this.leftSubTitle = leftSubTitle;
this.rightSubTitle = rightSubTitle;
@@ -34,6 +37,7 @@
this.modelInformationItems = modelInformationItems;
this.onSubmit = onSubmit;
this.onCancel = onCancel;
+ this.onOtherAction = onOtherAction;
this.popupTypeName = popupTypeName;
this.UUIDData = UUIDData;
this.that = that;
diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts
index 2fb39e8..8570b08 100644
--- a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts
+++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts
@@ -14,6 +14,7 @@
FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT',
FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS',
FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER',
+ FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER ='FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER',
}
@Injectable()