31c9e9d768b0ce67ca96053f46c64304c57236cc
[portal/sdk.git] /
1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2
3 @Component({
4   selector: 'rdp-input-editor',
5   styleUrls: ['./rdp-input-editor.component.scss'],
6   template: `
7       <input class="input-editor" [disabled]="isColumnDisabled"  
8       [(ngModel)]="columnValue" 
9       type="text" name="{{columntitle}}"  
10       id="{{columntitle}}"
11       (change)="detectChange(columnValue)">
12   `
13 })
14 export class RdpInputEditorComponent implements OnInit {
15
16   @Input() rowdata: any;
17   @Input() columntitle: any
18   @Input() disabled: boolean;
19
20   @Output() changedColumnValue = new EventEmitter<any>();
21
22   columnValue: any;
23   isColumnDisabled:boolean;
24
25   constructor() { }
26
27   ngOnInit() {
28     if (this.rowdata != null || this.rowdata != undefined) {
29       let rowObj = JSON.parse(this.rowdata);
30       let column = this.columntitle;
31       this.columnValue = rowObj[column];
32     } else {
33       this.columnValue = null;
34     }
35     this.isColumnDisabled = this.disabled;
36   }
37
38   detectChange(changedValue) {
39     this.changedColumnValue.emit(changedValue);
40   }
41
42 }