UNPKG

@adaptabletools/adaptable

Version:

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

49 lines (48 loc) 3.49 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { isRuleBasedAlertDefinition } from '../../../Utilities/Helpers/Scheduling/ScheduledAlertHelper'; import { NewScopeComponent } from '../../Components/NewScopeComponent'; import { useOnePageAdaptableWizardContext } from '../../Wizard/OnePageAdaptableWizard'; import { Box, Flex } from '../../../components/Flex'; import { isScopeColumnIds } from '../../../AdaptableState/Common/ColumnScope'; export const AlertScopeWizardSection = (props) => { const { data: alertData, api } = useOnePageAdaptableWizardContext(); if (!isRuleBasedAlertDefinition(alertData)) { return null; } const data = alertData; let disableDataTypes = true; let disableColumns = true; if (props.alertType === 'DataChange' || props.alertType == 'Validation') { disableDataTypes = false; disableColumns = false; } return (_jsxs(Flex, { flexDirection: "column", className: "twa:h-full", children: [_jsxs(Flex, { flexDirection: "row", alignItems: "center", className: "twa:p-2 twa:gap-3 twa:border-b twa:mb-2 twa:border-b-foreground/20", children: [_jsx(Box, { className: "twa:text-5 twa:font-medium", children: "Columns" }), _jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:max-w-[520px]", children: "Specify which columns should trigger the Alert" })] }), _jsx(Box, { className: "twa:flex-1 twa:min-h-0 twa:overflow-auto twa:p-2", children: _jsx(NewScopeComponent, { disableColumns: disableColumns, disableDataTypes: disableDataTypes, descriptions: { rowScope: 'Changes in any Column in the row will trigger an Alert', columnScope: 'Changes in selected Columns will trigger an Alert', dataTypeScope: 'Changes in any Column which is of the selected Data Type(s) will trigger an Alert', }, scope: data.Scope, updateScope: (Scope) => { const newData = { ...data, Scope }; if (newData.Rule.Predicates) { const validPredicateIds = new Set(api.alertApi.internalApi.getAlertPredicateDefsForScope(Scope).map((def) => def.id)); newData.Rule = { Predicates: newData.Rule.Predicates.filter((p) => validPredicateIds.has(p.PredicateId)).filter((predicate) => { if (isScopeColumnIds(Scope) && Scope.ColumnIds.length > 1) { return predicate.PredicateId !== 'In' && predicate.PredicateId !== 'NotIn'; } return true; }), }; } if (newData.Rule.ObservableExpression !== undefined && !api.columnScopeApi.scopeIsAll(Scope)) { delete newData.Rule.ObservableExpression; newData.Rule.BooleanExpression = ''; } if (newData.Rule.AggregatedBooleanExpression !== undefined && !api.columnScopeApi.scopeIsAll(Scope)) { delete newData.Rule.AggregatedBooleanExpression; newData.Rule.BooleanExpression = ''; } props.onChange(newData); } }) })] })); };