ede8aa2512732cab4c75347a2bef115a242975ff
[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   @Output() passEntry: EventEmitter<any> = new EventEmitter();
16   modalPopupTitle: string;
17   selectedRowData: any;
18   public columnsInfoList = [];
19
20   constructor(public activeModal: NgbActiveModal, public rdpDataTableService: RdpDataTableService) { }
21
22   ngOnInit() {
23     this.modalPopupTitle = "Edit";
24     if (this.rowdata) {
25       this.selectedRowData = JSON.stringify(this.rowdata);
26     }
27     if (this.settings) {
28       if (this.settings.modalPopupTitle) {
29         this.modalPopupTitle = this.settings.modalPopupTitle;
30       }
31       for (var index in this.settings.columns) {
32         this.columnsInfoList.push(this.settings.columns[index]);
33       }
34     }
35   }
36
37   saveChanges() {
38     this.passEntry.emit(this.rowdata);
39     this.activeModal.close();
40   }
41
42   columnDataChanged($event, columnTitle) {
43     this.rowdata[columnTitle] = $event;
44   }
45
46 }