d92ce320ed573bd033544581a7da513d4c851c66
[portal/sdk.git] /
1 import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
2 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
3 import { RdpDataTableService } from '../../shared/rdp-data-table.service';
4
5 @Component({
6   selector: 'rdp-rdp-data-table-edit',
7   templateUrl: './rdp-data-table-edit.component.html',
8   styleUrls: ['./rdp-data-table-edit.component.scss']
9 })
10 export class RdpDataTableEditComponent implements OnInit {
11
12   @Input() settings: any;
13   @Input() rowdata: any;
14   @Input() isEditMode: boolean;
15   @Input() applicationService: any;
16   @Output() passEntry: EventEmitter<any> = new EventEmitter();
17   modalPopupTitle: string;
18   selectedRowData: any;
19   public columnsInfoList = [];
20
21   constructor(public activeModal: NgbActiveModal, public rdpDataTableService: RdpDataTableService) { }
22
23   ngOnInit() {
24     this.modalPopupTitle = "Edit";
25     if (this.rowdata) {
26       this.selectedRowData = JSON.stringify(this.rowdata);
27     }
28     if (this.settings) {
29       if (this.settings.modalPopupTitle) {
30         this.modalPopupTitle = this.settings.modalPopupTitle;
31       }
32       for (var index in this.settings.columns) {
33         this.columnsInfoList.push(this.settings.columns[index]);
34       }
35     }
36   }
37
38   saveChanges() {
39     this.applicationService.update(this.rowdata);
40     this.applicationService.statusResponse.subscribe(responseData => {
41       if (responseData == "200") {
42         console.log("Success")
43         this.applicationService.get();
44         this.applicationService.updatedData.subscribe(val => {
45           if (val) {
46             this.passEntry.emit(val);
47           }
48         })
49       }
50     })
51     this.activeModal.close();
52   }
53
54   columnDataChanged($event, columnTitle) {
55     this.rowdata[columnTitle] = $event;
56   }
57
58 }