import { Column } from './column' ; import { Row } from './row' ; import { SelectItem } from '../../common' ; export class Cell { get value ( ) : any { return this . _value ; } set value ( val ) { this . _value = val ; this . row [ this . column . name ] = val ; } private _value : any ; oldValue : any ; viewValue : any ; hasError : boolean ; get isChanged ( ) : boolean { return ( this . row && this . row . $$data && this . value !== this . oldValue ) ; } get rowIndex ( ) : number { return ( this . row ) ? this . row . $$index : null ; } constructor ( public readonly row , public readonly column ) { this . _value = this . column . getValue ( this . row ) ; if ( this . row && this . row . $$data ) { this . oldValue = this . column . getValue ( this . row . $$data ) ; } this . updateViewValue ( ) ; } validate ( ) { const errors = this . column . validate ( this . value ) ; this . hasError = ( errors && errors . length > 0 ) ; } exist ( rowIndex , columnIndex ) { return this . row . $$index === rowIndex && this . column . index === columnIndex ; } updateViewValue ( ) { this . viewValue = this . column . getValueView ( this . row ) ; } getOptions ( ) { return this . column . getOptions ( this . row [ this . column . dependsColumn ] ) ; } }