UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

58 lines (57 loc) 2.17 kB
import * as ShortcutRedux from '../../Redux/ActionsReducers/ShortcutRedux'; import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants'; import { ApiBase } from './ApiBase'; export class ShortcutApiImpl extends ApiBase { getShortcutState() { return this.getAdaptableState().Shortcut; } getShortcuts(config) { return (this.handleLayoutExtensionObjects(this.getShortcutState().Shortcuts, 'Shortcut', config) ?? []); } getShortcutById(id, config) { return this.getShortcuts(config).find((shortcut) => shortcut?.Uuid === id); } getShortcutByName(name) { return this.getShortcuts().find((shortcut) => shortcut.Name === name); } getActiveShortcuts(config) { return this.getShortcuts(config).filter((shortcut) => !shortcut.IsSuspended); } getSuspendedShortcuts(config) { return this.getShortcuts(config).filter((shortcut) => shortcut.IsSuspended); } addShortcut(shortcut) { this.addUidToAdaptableObject(shortcut); this.dispatchAction(ShortcutRedux.ShortcutAdd(shortcut)); return this.getShortcutById(shortcut.Uuid); } editShortcut(shortcut) { this.dispatchAction(ShortcutRedux.ShortcutEdit(shortcut)); return this.getShortcutById(shortcut.Uuid); } deleteShortcut(shortcut) { this.dispatchAction(ShortcutRedux.ShortcutDelete(shortcut)); } deleteAllShortcuts() { this.getShortcuts().forEach((s) => { this.deleteShortcut(s); }); } suspendShortcut(shortcut) { this.dispatchAction(ShortcutRedux.ShortcutSuspend(shortcut)); return this.getShortcutById(shortcut.Uuid); } unSuspendShortcut(shortcut) { this.dispatchAction(ShortcutRedux.ShortcutUnSuspend(shortcut)); return this.getShortcutById(shortcut.Uuid); } suspendAllShortcut() { this.dispatchAction(ShortcutRedux.ShortcutSuspendAll()); } unSuspendAllShortcut() { this.dispatchAction(ShortcutRedux.ShortcutUnSuspendAll()); } openShortcutSettingsPanel() { this.showModulePopup(ModuleConstants.ShortcutModuleId); } }