UNPKG

@adaptabletools/adaptable-cjs

Version:

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

51 lines (50 loc) 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AlertScopeWizardSection = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const rebass_1 = require("rebass"); const NewScopeComponent_1 = require("../../Components/NewScopeComponent"); const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard"); const AlertScopeWizardSection = (props) => { const { data, api } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)(); let disableDataTypes = true; let disableColumns = true; if (props.alertType === 'DataChange' || props.alertType == 'Validation') { disableDataTypes = false; disableColumns = false; } return (React.createElement(rebass_1.Flex, { flexDirection: "column", style: { height: '100%' }, padding: 2 }, React.createElement(NewScopeComponent_1.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) { // when scope is changed, reset the rule to predicate of any // if it was set to a predicate before newData.Rule = { Predicates: [{ PredicateId: 'AnyChange' }], }; } if (newData.Rule.ObservableExpression !== undefined && !api.columnScopeApi.scopeIsAll(Scope)) { // if it had observable expression and the scope is changed to partial // we need to reset to not be an observable expression, as observable is not supported // for partial scope delete newData.Rule.ObservableExpression; newData.Rule.BooleanExpression = ''; } if (newData.Rule.AggregatedBooleanExpression !== undefined && !api.columnScopeApi.scopeIsAll(Scope)) { // if it had aggregation expression and the scope is changed to partial // we need to reset to not be an aggregation expression, as aggregation is not supported // for partial scope delete newData.Rule.AggregatedBooleanExpression; newData.Rule.BooleanExpression = ''; } props.onChange(newData); } }))); }; exports.AlertScopeWizardSection = AlertScopeWizardSection;