import { Record } from './record' ; import { BaseModel } from '../models/base-model' ; import { DataItem , DataItemDirector } from './data-item' ; import { Observable } from 'rxjs' ; import { BaseField } from '../fields/base' ; export type ListRowRawData = { [ name ] : string | number | Date | Object ; } ; export type ListRowFieldValue = string | number | Date | Object | Record ; export type ListRowProcessedData = { [ name ] : ListRowFieldValue ; } ; export class ListRowDirector extends DataItemDirector { host : ListRow ; constructor ( data , public model ? ) { super ( data , ( model && model . fields ) ? model . fields . map ( ( field ) => field . name ) : undefined , false ) ; } init ( data ) { var d = { } ; for ( let fieldName of this . trackFields ) { var value = data [ fieldName ] ; var field = this . getField ( fieldName ) ; if ( field ) value = field . fromRAWtoInternal ( value ) ; d [ fieldName ] = value ; } super . init ( data ) ; } getField ( fieldName ) { if ( this . model ) { return this . model . getField ( fieldName ) ; } return null ; } getData ( ) { return Observable . of ( this . host ) ; } } export class ListRow extends DataItem { __director__ : ListRowDirector ; constructor ( data , model ? ) { super ( data instanceof ListRowDirector ? data : new ListRowDirector ( data , model ) ) ; if ( ! ( data instanceof ListRowDirector ) ) this . __director__ . init ( data ) ; } toString ( ) { return 'ListRow' ; } }