UNPKG

@adaptabletools/adaptable

Version:

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

65 lines (64 loc) 2.56 kB
import { AdaptableModuleBase } from './AdaptableModuleBase'; import * as ModuleConstants from '../Utilities/Constants/ModuleConstants'; import { DataChangeHistoryStatusBarContent } from '../View/DataChangeHistory/DataChangeHistoryStatusBarContent'; export class DataChangeHistoryModule extends AdaptableModuleBase { isListeningToCellDataChanges; constructor(api) { super(ModuleConstants.DataChangeHistoryModuleId, ModuleConstants.DataChangeHistoryFriendlyName, 'target', 'DataChangeHistoryPopup', 'Provides an overview of all previous changes, giving the possibility to undo specific changes', api); this.isListeningToCellDataChanges = false; } onAdaptableReady() { this.api.internalApi.initializeDataChangeHistory(); this.checkListenToCellDataChanged(); } getAgGridModuleDependencies() { return ['ClientSideRowModelModule']; } shouldListenToDataChanges() { return this.api.dataChangeHistoryApi.getDataChangeHistoryMode() === 'ACTIVE'; } checkListenToCellDataChanged() { if (!this.isListeningToCellDataChanges) { if (this.shouldListenToDataChanges()) { this.setupCellDataChangeListener(); this.isListeningToCellDataChanges = true; } } } setupCellDataChangeListener() { this.api.internalApi .getDataService() .on('CellDataChanged', (cellDataChangedInfo) => { if (this.shouldListenToDataChanges() && this.isDataChangeLoggable(cellDataChangedInfo) && !cellDataChangedInfo.preventEdit) { this.api.dataChangeHistoryApi.addDataChangeHistoryEntry(cellDataChangedInfo); } }); } getPopupMaxWidth() { return 1000; } hasNamedQueryReferences() { return false; } isDataChangeLoggable(cellDataChangedInfo) { if (cellDataChangedInfo.trigger === 'undo' || cellDataChangedInfo.trigger === 'aggChange') { return false; } if (this.api.optionsApi.getDataChangeHistoryOptions().showDataChange) { return this.api.optionsApi.getDataChangeHistoryOptions().showDataChange(cellDataChangedInfo); } return true; } getViewProperties() { return { getStatusBarPanelProps: () => { return { triggerActionOnWrapperClick: false, content: DataChangeHistoryStatusBarContent, }; }, }; } }