| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2020 TATA ELXSI |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the 'License'); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in) |
| 17 | */ |
| 18 | /** |
| 19 | * @file Projects Action Component |
| 20 | */ |
| 21 | import { Component, Injector } from '@angular/core'; |
| 22 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; |
| 23 | import { MODALCLOSERESPONSEDATA } from 'CommonModel'; |
| 24 | import { DeleteComponent } from 'DeleteComponent'; |
| 25 | import { ProjectCreateUpdateComponent } from 'ProjectCreateUpdate'; |
| 26 | import { ProjectData } from 'ProjectModel'; |
| 27 | import { SharedService } from 'SharedService'; |
| 28 | |
| 29 | /** |
| 30 | * Creating component |
| 31 | * @Component takes ProjectsActionComponent.html as template url |
| 32 | */ |
| 33 | @Component({ |
| 34 | selector: 'app-projects-action', |
| 35 | templateUrl: './ProjectsActionComponent.html', |
| 36 | styleUrls: ['./ProjectsActionComponent.scss'] |
| 37 | }) |
| 38 | /** Exporting a class @exports ProjectsActionComponent */ |
| 39 | export class ProjectsActionComponent { |
| 40 | /** To get the value from the nspackage via valuePrepareFunction default Property of ng-smarttable @public */ |
| 41 | public value: ProjectData; |
| 42 | |
| 43 | /** To inject services @public */ |
| 44 | public injector: Injector; |
| 45 | |
| 46 | /** Instance of the modal service @private */ |
| 47 | private modalService: NgbModal; |
| 48 | |
| 49 | /** Contains all methods related to shared @private */ |
| 50 | private sharedService: SharedService; |
| 51 | |
| 52 | constructor(injector: Injector) { |
| 53 | this.injector = injector; |
| 54 | this.modalService = this.injector.get(NgbModal); |
| 55 | this.sharedService = this.injector.get(SharedService); |
| 56 | } |
| 57 | |
| 58 | /** Delete project @public */ |
| 59 | public projectDelete(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 60 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 61 | const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); |
| 62 | modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { |
| 63 | if (result) { |
| 64 | this.sharedService.callData(); |
| 65 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 66 | }).catch((): void => { |
| 67 | // Catch Navigation Error |
| 68 | }); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /** Edit project @public */ |
| 72 | public projectEdit(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 73 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| Barath Kumar R | 2e02e7d | 2021-06-09 09:18:17 +0530 | [diff] [blame] | 74 | const modalRef: NgbModalRef = this.modalService.open(ProjectCreateUpdateComponent, { size: 'lg', backdrop: 'static' }); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 75 | modalRef.componentInstance.projectType = 'Edit'; |
| 76 | modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { |
| 77 | if (result) { |
| 78 | this.sharedService.callData(); |
| 79 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 80 | }).catch((): void => { |
| 81 | // Catch Navigation Error |
| 82 | }); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 83 | } |
| 84 | } |