@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
66 lines (65 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAlertTypeText = exports.getAlertType = exports.AlertType = void 0;
const GeneralConstants_1 = require("./../../../Utilities/Constants/GeneralConstants");
var AlertType;
(function (AlertType) {
AlertType["DataChange"] = "DataChange";
AlertType["Validation"] = "Validation";
AlertType["RowChange"] = "RowChange";
AlertType["Aggregation"] = "Aggregation";
AlertType["Observable"] = "Observable";
})(AlertType || (exports.AlertType = AlertType = {}));
/**
* Based on alert shape the type is derived.
* In the future the alert will get a type property.
*
* @param alert
*/
const getAlertType = (alert) => {
if (alert.Rule.ObservableExpression) {
if (alert.Rule.ObservableExpression.includes(GeneralConstants_1.OBSERVABLE_EXPRESSION_ROW_ADDED) ||
alert.Rule.ObservableExpression.includes(GeneralConstants_1.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;
};
exports.getAlertType = getAlertType;
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;
};
exports.getAlertTypeText = getAlertTypeText;