@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
99 lines (98 loc) • 4.88 kB
JavaScript
import * as FlashingCellRedux from '../../Redux/ActionsReducers/FlashingCellRedux';
import { ApiBase } from './ApiBase';
import { FlashingCellInternalApi } from '../Internal/FlashingCellInternalApi';
export class FlashingCellApiImpl extends ApiBase {
constructor(_adaptable) {
super(_adaptable);
this.internalApi = new FlashingCellInternalApi(_adaptable);
}
getFlashingCellState() {
return this.getAdaptableState().FlashingCell;
}
getFlashingCellDefinitions(config) {
const flashingCellDefinitions = this.handleLayoutAssociatedObjects(this.getFlashingCellState().FlashingCellDefinitions, 'FlashingCell', config) ?? [];
return flashingCellDefinitions.map((flashingCellDefinition) => {
return this.internalApi.mergeFlashingCellDefinitionWithDefaults(flashingCellDefinition);
});
}
getFlashingCellDefinitionById(id) {
return this.getFlashingCellDefinitions()?.find((fc) => fc?.Uuid === id);
}
getActiveFlashingCellDefinitions() {
return this.getFlashingCellDefinitions().filter((fc) => !fc.IsSuspended);
}
getSuspendedFlashingCellDefinitions() {
return this.getFlashingCellDefinitions().filter((fc) => fc.IsSuspended);
}
getFlashingCellFlashTarget(flashingCellDefinition) {
return flashingCellDefinition.FlashTarget ?? 'cell';
}
showFlashingCell(flashingCellToShow) {
this.addUidToAdaptableObject(flashingCellToShow);
this.getAdaptableApi()
.internalApi.getFlashingCellService()
.addGridCellFlash(flashingCellToShow);
const { FlashDuration: FlashDuration } = flashingCellToShow.flashingCellDefinition;
if (FlashDuration && FlashDuration !== 'always') {
setTimeout(() => {
this.getAdaptableApi()
.internalApi.getFlashingCellService()
.clearGridCellFlash(flashingCellToShow);
}, FlashDuration);
}
this.getEventApi().internalApi.fireFlashingCellDisplayedEvent(flashingCellToShow);
}
addFlashingCellDefinition(flashingCellDefinition) {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionAdd(flashingCellDefinition));
return this.getFlashingCellDefinitionById(flashingCellDefinition.Uuid);
}
setFlashingCellDefinitions(flashingCellDefinitions) {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionSet(flashingCellDefinitions));
}
editFlashingCellDefinition(flashingCellDefinition) {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionEdit(flashingCellDefinition));
return this.getFlashingCellDefinitionById(flashingCellDefinition.Uuid);
}
suspendFlashingCellDefinition(flashingCellDefinition) {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionSuspend(flashingCellDefinition));
return this.getFlashingCellDefinitionById(flashingCellDefinition.Uuid);
}
unSuspendFlashingCellDefinition(flashingCellDefinition) {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionUnSuspend(flashingCellDefinition));
return this.getFlashingCellDefinitionById(flashingCellDefinition.Uuid);
}
suspendAllFlashingCellDefinition() {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionSuspendAll());
}
unSuspendAllFlashingCellDefinition() {
this.dispatchAction(FlashingCellRedux.FlashingCellDefinitionUnSuspendAll());
}
addFlashingCellDefinitions(flashingCellDefinitions) {
flashingCellDefinitions.forEach((fad) => {
this.addFlashingCellDefinition(fad);
});
return flashingCellDefinitions?.map((flashingCell) => this.getFlashingCellDefinitionById(flashingCell?.Uuid));
}
editFlashingCellDefinitions(flashingCellDefinitions) {
flashingCellDefinitions.forEach((fad) => {
this.editFlashingCellDefinition(fad);
});
return flashingCellDefinitions?.map((flashingCell) => this.getFlashingCellDefinitionById(flashingCell?.Uuid));
}
getFlashingCellPredicateDefsForScope(scope) {
return this.getAdaptableApi()
.predicateApi.internalApi.getFlashingCellPredicateDefs(scope)
.filter((predicateDef) => this.getColumnScopeApi().isScopeInScope(scope, predicateDef.columnScope));
}
clearAllFlashingCells() {
this.getAdaptableInternalApi().getFlashingCellService().clearAllGridCellFlashes();
}
isAnyFlashingCellActive() {
return this.getAdaptableInternalApi().getFlashingCellService().isAnyFlashingCellActive();
}
findFlashingCellDefinitions(criteria) {
return this.getAdaptableInternalApi().findAdaptableObjectsByLookupCriteria(criteria, this.getFlashingCellDefinitions({
includeLayoutNotAssociatedObjects: true,
}));
}
}