UNPKG

@adaptabletools/adaptable-cjs

Version:

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

38 lines (37 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mapAlertDefinition = void 0; 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; }; exports.mapAlertDefinition = mapAlertDefinition;