@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
50 lines (49 loc) • 2.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormatColumnScopeWizardSection = exports.renderFormatColumnScopeSummary = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const NewScopeComponent_1 = require("../../Components/NewScopeComponent");
const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
const constants_1 = require("./constants");
const rebass_1 = require("rebass");
const renderFormatColumnScopeSummary = (data) => {
return (0, NewScopeComponent_1.renderScopeSummary)(data.Scope, {
scopeWholeRow: 'Matching rows will be formatted',
scopeColumns: 'Cells in selected columns will be formatted',
scopeDataTypes: 'Cells in columns with these Data Types will be formatted',
});
};
exports.renderFormatColumnScopeSummary = renderFormatColumnScopeSummary;
const FormatColumnScopeWizardSection = (props) => {
const { data, api } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
return (React.createElement(React.Fragment, null,
React.createElement(rebass_1.Box, { "data-name": 'scope-heading', style: {
borderRadius: `var(--ab__border-radius)`,
}, padding: 2, backgroundColor: `var(--ab-color-primarylight)` }, "Scope"),
React.createElement(NewScopeComponent_1.NewScopeComponent, { descriptions: {
rowScope: 'Format all columns in the row',
columnScope: 'Select columns to format',
}, scope: data.Scope, updateScope: (Scope) => {
const newData = { ...data, Scope };
const wholeRow = api.columnScopeApi.scopeIsAll(Scope);
if (newData.Rule?.Predicates?.length) {
if (wholeRow) {
// if scope is whole row, a predicate cannot be present, so we set the rule
// to be a boolean expression
delete newData.Rule.Predicates;
newData.Rule.BooleanExpression = '';
}
else {
// if scope is not whole row, if you have a predicate, reset it
newData.Rule.Predicates = [
{
PredicateId: constants_1.DEFAULT_PREDICATE_ID_FOR_FORMAT_COLUMN,
},
];
}
}
props.onChange(newData);
} })));
};
exports.FormatColumnScopeWizardSection = FormatColumnScopeWizardSection;