UNPKG

@adaptabletools/adaptable

Version:

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

61 lines (60 loc) 1.99 kB
import { OBSERVABLE_EXPRESSION_ROW_ADDED, OBSERVABLE_EXPRESSION_ROW_REMOVED, } from './../../../Utilities/Constants/GeneralConstants'; export var AlertType; (function (AlertType) { AlertType["DataChange"] = "DataChange"; AlertType["Validation"] = "Validation"; AlertType["RowChange"] = "RowChange"; AlertType["Aggregation"] = "Aggregation"; AlertType["Observable"] = "Observable"; })(AlertType || (AlertType = {})); /** * Based on alert shape the type is derived. * In the future the alert will get a type property. * * @param alert */ export const getAlertType = (alert) => { 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 (alert.AlertProperties?.PreventEdit) { return AlertType.Validation; } return AlertType.DataChange; } const predicates = alert.Rule.Predicates; if (predicates) { return alert.AlertProperties?.PreventEdit ? AlertType.Validation : AlertType.DataChange; } // the object is not a valid alert 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; } return text; };