@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
147 lines (146 loc) • 5.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlertReducer = exports.AlertClearFlashingCells = exports.AlertReady = exports.AlertDefinitionUnSuspendAll = exports.AlertDefinitionSuspendAll = exports.AlertDefinitionUnSuspend = exports.AlertDefinitionSuspend = exports.AlertDefinitionDelete = exports.AlertDefinitionEdit = exports.AlertDefinitionAdd = exports.ALERT_READY = exports.ALERT_CLEAR_FLASHING_CELLS = exports.ALERT_DEFINITION_UNSUSPEND_ALL = exports.ALERT_DEFINITION_SUSPEND_ALL = exports.ALERT_DEFINITION_UNSUSPEND = exports.ALERT_DEFINITION_SUSPEND = exports.ALERT_DEFINITION_DELETE = exports.ALERT_DEFINITION_EDIT = exports.ALERT_DEFINITION_ADD = void 0;
const tslib_1 = require("tslib");
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
const AdaptableHelper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/AdaptableHelper"));
const utils_1 = require("./utils");
/**
* @ReduxAction An Alert Definition has been added
*/
exports.ALERT_DEFINITION_ADD = 'ALERT_DEFINITION_ADD';
/**
* @ReduxAction An Alert Definition has been edited
*/
exports.ALERT_DEFINITION_EDIT = 'ALERT_DEFINITION_EDIT';
/**
* @ReduxAction An Alert Definition has been deleted
*/
exports.ALERT_DEFINITION_DELETE = 'ALERT_DEFINITION_DELETE';
/**
* @ReduxAction Alert Definition is suspended
*/
exports.ALERT_DEFINITION_SUSPEND = 'ALERT_DEFINITION_SUSPEND';
/**
* @ReduxAction Alert Definition is unsuspended, or activated
*/
exports.ALERT_DEFINITION_UNSUSPEND = 'ALERT_DEFINITION_UNSUSPEND';
/**
* @ReduxAction All Alert Definitions are suspended
*/
exports.ALERT_DEFINITION_SUSPEND_ALL = 'ALERT_DEFINITION_SUSPEND_ALL';
/**
* @ReduxAction All Alert Definitions are unsuspended, or activated
*/
exports.ALERT_DEFINITION_UNSUSPEND_ALL = 'ALERT_DEFINITION_UNSUSPEND_ALL';
exports.ALERT_CLEAR_FLASHING_CELLS = 'ALERT_CLEAR_FLASHING_CELLS';
/**
* @ReduxAction Alert Module is ready
*/
exports.ALERT_READY = 'ALERT_READY';
const AlertDefinitionAdd = (alertDefinition) => ({
type: exports.ALERT_DEFINITION_ADD,
alertDefinition,
});
exports.AlertDefinitionAdd = AlertDefinitionAdd;
const AlertDefinitionEdit = (alertDefinition) => ({
type: exports.ALERT_DEFINITION_EDIT,
alertDefinition,
});
exports.AlertDefinitionEdit = AlertDefinitionEdit;
const AlertDefinitionDelete = (alertDefinition) => ({
type: exports.ALERT_DEFINITION_DELETE,
alertDefinition,
});
exports.AlertDefinitionDelete = AlertDefinitionDelete;
const AlertDefinitionSuspend = (alertDefinition) => ({
type: exports.ALERT_DEFINITION_SUSPEND,
alertDefinition,
});
exports.AlertDefinitionSuspend = AlertDefinitionSuspend;
const AlertDefinitionUnSuspend = (alertDefinition) => ({
type: exports.ALERT_DEFINITION_UNSUSPEND,
alertDefinition,
});
exports.AlertDefinitionUnSuspend = AlertDefinitionUnSuspend;
const AlertDefinitionSuspendAll = () => ({
type: exports.ALERT_DEFINITION_SUSPEND_ALL,
});
exports.AlertDefinitionSuspendAll = AlertDefinitionSuspendAll;
const AlertDefinitionUnSuspendAll = () => ({
type: exports.ALERT_DEFINITION_UNSUSPEND_ALL,
});
exports.AlertDefinitionUnSuspendAll = AlertDefinitionUnSuspendAll;
const AlertReady = (alertState) => ({
type: exports.ALERT_READY,
alertState,
});
exports.AlertReady = AlertReady;
const AlertClearFlashingCells = () => ({
type: exports.ALERT_CLEAR_FLASHING_CELLS,
});
exports.AlertClearFlashingCells = AlertClearFlashingCells;
const initialState = {
AlertDefinitions: GeneralConstants_1.EMPTY_ARRAY,
};
const AlertReducer = (state = initialState, action) => {
let alertDefinitions;
switch (action.type) {
case exports.ALERT_DEFINITION_ADD: {
const actionAlertDefinition = action
.alertDefinition;
AdaptableHelper_1.default.addAdaptableObjectPrimitives(actionAlertDefinition);
alertDefinitions = [].concat(state.AlertDefinitions);
alertDefinitions.push(actionAlertDefinition);
return { ...state, AlertDefinitions: alertDefinitions };
}
case exports.ALERT_DEFINITION_EDIT: {
const actionAlertDefinition = action
.alertDefinition;
return {
...state,
AlertDefinitions: state.AlertDefinitions.map((abObject) => abObject.Uuid === actionAlertDefinition.Uuid ? actionAlertDefinition : abObject),
};
}
case exports.ALERT_DEFINITION_DELETE: {
const actionAlertDefinition = action
.alertDefinition;
return {
...state,
AlertDefinitions: state.AlertDefinitions.filter((abObject) => abObject.Uuid !== actionAlertDefinition.Uuid),
};
}
case exports.ALERT_DEFINITION_SUSPEND: {
return {
...state,
AlertDefinitions: (0, utils_1.changeIsSuspendInList)(action.alertDefinition, state.AlertDefinitions, true),
};
}
case exports.ALERT_DEFINITION_UNSUSPEND: {
return {
...state,
AlertDefinitions: (0, utils_1.changeIsSuspendInList)(action.alertDefinition, state.AlertDefinitions, false),
};
}
case exports.ALERT_DEFINITION_SUSPEND_ALL: {
return {
...state,
AlertDefinitions: (0, utils_1.suspendAllInList)(state.AlertDefinitions),
};
}
case exports.ALERT_DEFINITION_UNSUSPEND_ALL: {
return {
...state,
AlertDefinitions: (0, utils_1.unsuspendAllInList)(state.AlertDefinitions),
};
}
case exports.ALERT_CLEAR_FLASHING_CELLS: {
return {
AlertDefinitions: state.AlertDefinitions,
};
}
default:
return state;
}
};
exports.AlertReducer = AlertReducer;