summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts
blob: c17591845c476355c1448f4ffe7a0e9baef727ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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[] = [];

    jobsResponse.forEach((job) => {
      tableRows.push(new InstantiationTemplatesRowModel(job));
    });

    return tableRows;
  };


  filterByUserId = (userId: string, originalTableData: InstantiationTemplatesRowModel[]): InstantiationTemplatesRowModel[] => {
    if (!_.isNil(originalTableData)) {
      return originalTableData.filter((item: InstantiationTemplatesRowModel) => {
        return item.userId === userId;
      });
    }
    return [];
  };


  navigateToNewServiceModal(serviceModelId: string) {
     this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true}, queryParamsHandling: 'merge' });
  }

}