@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
52 lines (51 loc) • 1.88 kB
JavaScript
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.handleLayoutAssociatedObjects(this.getShortcutState().Shortcuts, 'Shortcut', config) ??
[]);
}
getShortcutById(id) {
return this.getShortcuts().find((shortcut) => shortcut?.Uuid === id);
}
getActiveShortcuts() {
return this.getShortcuts().filter((shortcut) => !shortcut.IsSuspended);
}
getSuspendedShortcuts() {
return this.getShortcuts().filter((shortcut) => shortcut.IsSuspended);
}
addShortcut(shortcut) {
this.addUidToAdaptableObject(shortcut);
this.dispatchAction(ShortcutRedux.ShortcutAdd(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);
}
}