templates button - rename from hasTemplates to isInstantiationTemplateExists on the...
[vid.git] / vid-webpack-master / src / app / shared / components / genericFormPopup / instantiationTemplatesModal / instantiation.templates.modal.service.ts
1 import {Injectable} from "@angular/core";
2 import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model";
3 import {Router} from "@angular/router";
4 import * as _ from 'lodash';
5
6 @Injectable()
7 export class InstantiationTemplatesModalService {
8   constructor(private _router : Router){
9
10   }
11   convertResponseToUI = (jobsResponse: any[]): InstantiationTemplatesRowModel[] => {
12     let tableRows: InstantiationTemplatesRowModel[] = [];
13
14     jobsResponse.forEach((job) => {
15       tableRows.push(new InstantiationTemplatesRowModel(job));
16     });
17
18     return tableRows;
19   };
20
21
22   filterByUserId = (userId: string, originalTableData: InstantiationTemplatesRowModel[]): InstantiationTemplatesRowModel[] => {
23     if (!_.isNil(originalTableData)) {
24       return originalTableData.filter((item: InstantiationTemplatesRowModel) => {
25         return item.userId === userId;
26       });
27     }
28     return [];
29   };
30
31
32   navigateToNewServiceModal(serviceModelId: string) {
33      this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true, isInstantiationTemplateExists : true}, queryParamsHandling: 'merge' });
34   }
35
36 }