@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
35 lines (34 loc) • 1.42 kB
JavaScript
import { isRuleBasedAlertDefinition } from '../../../Utilities/Helpers/Scheduling/ScheduledAlertHelper';
export const mapAlertDefinition = (api, alertDefinition) => {
if (!isRuleBasedAlertDefinition(alertDefinition)) {
return 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;
}
};
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);
}
});
}
if (isRemovedRowChangeAlert) {
delete alertDefinition.AlertProperties.HighlightRow;
delete alertDefinition.AlertProperties.JumpToRow;
}
return alertDefinition;
};