1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 import { Component, OnInit, Inject, Output, Input } from '@angular/core';
\r
18 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
\r
19 import { AppGlobals } from 'app/app.global';
\r
20 import { HttpClient } from '@angular/common/http';
\r
21 import { TestInstanceService } from '../../services/test-instance.service';
\r
22 import { TestDefinitionService } from '../../services/test-definition.service';
\r
25 selector: 'app-test-instance-modal',
\r
26 templateUrl: './test-instance-modal.component.pug',
\r
27 styleUrls: ['./test-instance-modal.component.scss']
\r
29 export class TestInstanceModalComponent implements OnInit {
\r
31 @Output() editInstance;
\r
32 public findInstance = true;
\r
33 @Input() childEvent;
\r
37 public dialogRef: MatDialogRef<TestInstanceModalComponent>,
\r
38 private http: HttpClient,
\r
39 private testDefintionService: TestDefinitionService,
\r
40 private testInstanceService: TestInstanceService,
\r
41 @Inject(MAT_DIALOG_DATA) public inputInstanceId) { }
\r
44 if(!this.inputInstanceId){
\r
45 this.findInstance = false;
\r
47 //if the user is creating an Instance from a test definition page. Pull all data and populate testHeads
\r
48 else if(this.inputInstanceId["td"]){
\r
49 this.testDefintionService.get(this.inputInstanceId.td,{$populate: ['bpmnInstances.testHeads.testHeadId']}).subscribe((result) => {
\r
50 this.editInstance = {
\r
52 testDefinition: result,
\r
56 this.findInstance = false;
\r
60 else if (this.inputInstanceId["ti"]) {
\r
61 this.testInstanceService.get(this.inputInstanceId.ti, {$populate: ['testDefinitionId']}).subscribe((result) => {
\r
63 this.editInstance = {};
\r
64 this.editInstance.testInstance = result;
\r
65 if(this.inputInstanceId.isEdit){
\r
66 this.editInstance.isEdit = true;
\r
68 this.editInstance.isEdit = false;
\r
70 this.findInstance = false;
\r
73 this.findInstance = false
\r
78 this.dialogRef.close();
\r