import { ChangeDetectionStrategy , Component , Input , OnInit } from '@angular/core' ; import { DelayMacroAction } from 'uhk-common' ; import { MacroBaseComponent } from '../macro-base.component' ; const INITIAL_DELAY = 0.5 ; @ Component ( { selector : 'macro-delay-tab' , templateUrl : './macro-delay.component.html' , styleUrls : [ './macro-delay.component.scss' ] , host : { 'class' : 'macro__delay' } , changeDetection : ChangeDetectionStrategy . OnPush } ) export class MacroDelayTabComponent extends MacroBaseComponent implements OnInit { @ Input ( ) macroAction : DelayMacroAction ; presets : number [ ] = [ 0.1 , 0.5 , 1 , 5 , 10 ] ; get delay ( ) : number { return this . _delay ; } set delay ( value ) { this . _delay = value ; this . validate ( ) ; } private _delay : number ; constructor ( ) { super ( ) ; } ngOnInit ( ) { if ( ! this . macroAction ) { this . macroAction = new DelayMacroAction ( ) ; } this . delay = this . macroAction . delay > 0 ? this . macroAction . delay / 1000 : INITIAL_DELAY ; } setDelay ( value ) { this . _delay = value ; this . macroAction . delay = this . _delay * 1000 ; this . validate ( ) ; } isMacroValid = ( ) => this . macroAction . delay !== 0 ; }