UNPKG

@adaptabletools/adaptable-cjs

Version:

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

114 lines (113 loc) 6.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FlashingCellWizard = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_1 = require("react"); const rebass_1 = require("rebass"); const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard"); const FlashingCellSettingsWizardSection_1 = require("./FlashingCellSettingsWizardSection"); const Helper_1 = require("../../../Utilities/Helpers/Helper"); const FlashingCellRulesWizardSection_1 = require("./FlashingCellRulesWizardSection"); const FlashingCellStyleWizardSection_1 = require("./FlashingCellStyleWizardSection"); const FlashingCellScopeWizardSection_1 = require("./FlashingCellScopeWizardSection"); const BaseAlertScopeWizardSection_1 = require("../../Alert/Wizard/BaseAlertScopeWizardSection"); const AdaptableContext_1 = require("../../AdaptableContext"); const NewScopeComponent_1 = require("../../Components/NewScopeComponent"); const ObjectFactory_1 = tslib_1.__importDefault(require("../../../Utilities/ObjectFactory")); const react_redux_1 = require("react-redux"); const isValidFlashingCellRules_1 = require("./isValidFlashingCellRules"); const FlashingCellRedux = tslib_1.__importStar(require("../../../Redux/ActionsReducers/FlashingCellRedux")); const ObjectTagsWizardSection_1 = require("../../Wizard/ObjectTagsWizardSection"); const FlashingCellWizard = (props) => { const { api } = (0, AdaptableContext_1.useAdaptable)(); const [flashingCell, setFlashingCell] = (0, react_1.useState)(() => { let flashingCell = props.data ? (0, Helper_1.cloneObject)(props.data) : ObjectFactory_1.default.CreateEmptyFlashingCellDefinition(); flashingCell = api.flashingCellApi.internalApi.mergeFlashingCellDefinitionWithDefaults(flashingCell); if (!flashingCell.Rule.BooleanExpression && !flashingCell.Rule?.Predicates?.length) { flashingCell.Rule.BooleanExpression = ''; } if (props.popupParams?.column && props.popupParams?.action === 'New') { flashingCell.Scope = { ColumnIds: [props.popupParams.column.columnId], }; } return flashingCell; }); const updateProperty = (propName) => { return (value) => { setFlashingCell((flashingCell) => { flashingCell = { ...flashingCell, [propName]: value }; return flashingCell; }); }; }; const updateStyles = { DownChangeStyle: (0, react_1.useCallback)(updateProperty('DownChangeStyle'), []), UpChangeStyle: (0, react_1.useCallback)(updateProperty('UpChangeStyle'), []), NeutralChangeStyle: (0, react_1.useCallback)(updateProperty('NeutralChangeStyle'), []), }; const dispatch = (0, react_redux_1.useDispatch)(); const handleFinish = () => { if (props.data) { dispatch(FlashingCellRedux.FlashingCellDefinitionEdit(flashingCell)); } else { dispatch(FlashingCellRedux.FlashingCellDefinitionAdd(flashingCell)); } props.onFinishWizard(flashingCell); }; return (React.createElement(OnePageAdaptableWizard_1.OnePageAdaptableWizard, { defaultCurrentSectionName: props.defaultCurrentSectionName, moduleInfo: props.moduleInfo, data: flashingCell, onHide: props.onCloseWizard, onFinish: handleFinish, sections: [ { details: 'Specify which data changes should trigger Cell Flashing', isValid: NewScopeComponent_1.isScopeValid, render: () => React.createElement(FlashingCellScopeWizardSection_1.FlashingAlertScopeWizardSection, { onChange: setFlashingCell }), renderSummary: BaseAlertScopeWizardSection_1.renderScopeSummary, title: 'Scope', }, { details: 'Build the Rules for when Cells should Flash', isValid: isValidFlashingCellRules_1.isValidFlashingCellRules, render: () => React.createElement(FlashingCellRulesWizardSection_1.FlashingAlertRulesWizardSection, { onChange: setFlashingCell }), renderSummary: FlashingCellRulesWizardSection_1.renderFlashingAlertRulesSummary, title: 'Rule', }, { details: 'Choose Flash Styles for Up, Down and Neutral Changes', render: () => (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(FlashingCellStyleWizardSection_1.FlashingAlertStyleWizardSection, { onStyleChange: (styleName, style) => { updateStyles[styleName](style); } }))), renderSummary: FlashingCellStyleWizardSection_1.renderFlashingAlertStyleSummary, title: 'Flash Styles', }, { details: 'Set Duration and Target Properties', render: () => (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(FlashingCellSettingsWizardSection_1.FlashingAlertSettingsWizardSection, { onChange: setFlashingCell }))), renderSummary: FlashingCellSettingsWizardSection_1.renderFlashingAlertSettingsSummary, title: 'Settings', }, { details: 'Select Flashing Cell Tags', title: 'Tags', isVisible: (_, api) => api.internalApi.shouldDisplayTagSections(), render: () => (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(ObjectTagsWizardSection_1.ObjectTagsWizardSection, { onChange: setFlashingCell }))), renderSummary: ObjectTagsWizardSection_1.renderObjectTagsSummary, }, '-', { details: 'Review the Flashing Cell Rule', render: () => { return (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(OnePageAdaptableWizard_1.OnePageWizardSummary, null))); }, title: 'Summary', }, ] })); }; exports.FlashingCellWizard = FlashingCellWizard;