UNPKG

@adaptabletools/adaptable

Version:

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

62 lines (61 loc) 2.18 kB
import { OBSERVABLE_EXPRESSION_ROW_ADDED, OBSERVABLE_EXPRESSION_ROW_REMOVED, } from './../../../Utilities/Constants/GeneralConstants'; import { getRuleAlertProperties, isScheduledAlertDefinition, } from '../../../Utilities/Helpers/Scheduling/ScheduledAlertHelper'; export var AlertType; (function (AlertType) { AlertType["DataChange"] = "DataChange"; AlertType["Validation"] = "Validation"; AlertType["RowChange"] = "RowChange"; AlertType["Aggregation"] = "Aggregation"; AlertType["Observable"] = "Observable"; AlertType["Scheduled"] = "Scheduled"; })(AlertType || (AlertType = {})); export const getAlertType = (alert) => { if (isScheduledAlertDefinition(alert)) { return AlertType.Scheduled; } if (alert.Rule.ObservableExpression) { if (alert.Rule.ObservableExpression.includes(OBSERVABLE_EXPRESSION_ROW_ADDED) || alert.Rule.ObservableExpression.includes(OBSERVABLE_EXPRESSION_ROW_REMOVED)) { return AlertType.RowChange; } return AlertType.Observable; } if (alert.Rule.AggregatedBooleanExpression) { return AlertType.Aggregation; } if (alert.Rule.BooleanExpression) { if (getRuleAlertProperties(alert)?.PreventEdit) { return AlertType.Validation; } return AlertType.DataChange; } const predicates = alert.Rule.Predicates; if (predicates) { return getRuleAlertProperties(alert)?.PreventEdit ? AlertType.Validation : AlertType.DataChange; } return null; }; export const getAlertTypeText = (alertType) => { let text = ''; switch (alertType) { case AlertType.DataChange: text = 'Data Change'; break; case AlertType.Validation: text = 'Data Validation'; break; case AlertType.RowChange: text = 'Row Change'; break; case AlertType.Aggregation: text = 'Aggregation'; break; case AlertType.Observable: text = 'Observable'; break; case AlertType.Scheduled: text = 'Scheduled'; break; } return text; };