UNPKG

@adaptabletools/adaptable

Version:

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

34 lines (33 loc) 1.34 kB
export const mapAlertDefinition = (api, alertDefinition) => { const isRemovedRowChangeAlert = api.alertApi.internalApi.isAlertDefinitionForRemovedRowChangeEvent(alertDefinition); const mapValidButtonActions = (alertCommand) => { if (isRemovedRowChangeAlert) { if (alertCommand === 'highlight-row' || alertCommand === 'jump-to-row') { return null; } return alertCommand; } }; // the only case needed is when changing from AddedRow to RemovedRow // map FormButton Actions if (alertDefinition.AlertForm && typeof alertDefinition.AlertForm !== 'string') { const alertButtons = alertDefinition.AlertForm?.Buttons; alertButtons?.forEach((alertButton) => { const alertCommand = alertButton.Command; if (Array.isArray(alertCommand)) { alertButton.Command = alertCommand .map(mapValidButtonActions) .filter(Boolean); } else { alertButton.Command = mapValidButtonActions(alertCommand); } }); } // behaviours if (isRemovedRowChangeAlert) { delete alertDefinition.AlertProperties.HighlightRow; delete alertDefinition.AlertProperties.JumpToRow; } return alertDefinition; };