import { IAggConfig } from '../agg_config' ; import { BaseParamType } from './base' ; export interface OptionedValueProp { value : string ; text : string ; disabled ? : boolean ; isCompatible : ( agg : IAggConfig ) => boolean ; } export class OptionedParamType extends BaseParamType { options : OptionedValueProp [ ] ; constructor ( config ) { super ( config ) ; if ( ! config . write ) { this . write = ( aggConfig , output ) => { output . params [ this . name ] = aggConfig . params [ this . name ] . value ; } ; } if ( ! config . serialize ) { this . serialize = ( selected ) => { return selected . value ; } ; } if ( ! config . deserialize ) { this . deserialize = ( value ) => { return this . options . find ( ( option ) => option . value === value ) ; } ; } this . options = config . options || [ ] ; } }