import { Component, Input } from '@angular/core'; import { Store } from '@ngrx/store'; import { ConfigActions, ConfigSelectors, WidgetDefaultSize } from '@onepoint-yap/dashboard'; @Component({ selector: 'yap-default-size', templateUrl: './select-default-size.component.html' }) export class SelectDefaultSizeComponent { @Input() label = true; availableSizes: { translation: any; value: any }[] = []; currentSize: WidgetDefaultSize = WidgetDefaultSize.QUARTER; private canDispatch = false; constructor(private store: Store) { this.availableSizes = Object.keys(WidgetDefaultSize).map((key) => ({ // @ts-ignore value: WidgetDefaultSize[key], translation: '@yap.search.params.size.' + key })); this.store .select(ConfigSelectors.widgetDefault) .subscribe((widgetDefault) => (this.currentSize = widgetDefault.size)); setTimeout(() => { this.canDispatch = true; }, 100); } changeSize($event: any) { if (this.canDispatch) { this.store.dispatch(ConfigActions.changeWidgetDefaults({ size: $event })); } } }