UNPKG

@adaptabletools/adaptable-cjs

Version:

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

82 lines (81 loc) 4.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NewReportWizard = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_1 = require("react"); const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard"); const Helper_1 = require("../../../Utilities/Helpers/Helper"); const rebass_1 = require("rebass"); const ReportColumnsWizardSection_1 = require("./ReportColumnsWizardSection"); const ReportRowsWizardSection_1 = require("./ReportRowsWizardSection"); const ReportNameWizardSection_1 = require("./ReportNameWizardSection"); const ObjectFactory_1 = tslib_1.__importDefault(require("../../../Utilities/ObjectFactory")); const react_redux_1 = require("react-redux"); const ExportRedux = tslib_1.__importStar(require("../../../Redux/ActionsReducers/ExportRedux")); const ObjectTagsWizardSection_1 = require("../../Wizard/ObjectTagsWizardSection"); const NewReportWizard = (props) => { const isEdit = props.popupParams?.action ? props.popupParams.action === 'Edit' : Boolean(props.data); const currentReport = (0, react_redux_1.useSelector)((state) => { if (!isEdit) { return; } return state.Export.Reports.find((report) => report.Name === state.Export.CurrentReport); }); const data = props.data ?? currentReport; const [report, setReport] = (0, react_1.useState)(() => { return data ? (0, Helper_1.cloneObject)(data) : ObjectFactory_1.default.CreateEmptyReport(); }); const dispatch = (0, react_redux_1.useDispatch)(); const handleFinish = () => { if (isEdit) { dispatch(ExportRedux.ReportEdit(report)); } else { dispatch(ExportRedux.ReportAdd(report)); } props.onFinishWizard(report); }; return (React.createElement(OnePageAdaptableWizard_1.OnePageAdaptableWizard, { defaultCurrentSectionName: props.defaultCurrentSectionName, moduleInfo: props.moduleInfo, data: report, onHide: props.onCloseWizard, onFinish: handleFinish, sections: [ { title: 'Columns', details: 'Choose the Columns you want to include in the Report', renderSummary: ReportColumnsWizardSection_1.renderReportColumnsSummary, render: () => React.createElement(ReportColumnsWizardSection_1.ReportColumnsWizardSection, { onChange: setReport }), }, { title: 'Rows', details: 'Choose the Rows you want to include in the Report', isValid: ReportRowsWizardSection_1.isValidReportRowsQuery, renderSummary: ReportRowsWizardSection_1.renderReportRowsSummary, render: () => React.createElement(ReportRowsWizardSection_1.ReportRowsWizardSection, { onChange: setReport }), }, { title: 'Name', details: 'Enter the name of the Report', isValid: ReportNameWizardSection_1.isValidReportName, renderSummary: ReportNameWizardSection_1.renderReportNameSummary, render: () => (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(ReportNameWizardSection_1.ReportNameWizardSection, { onChange: setReport }))), }, { details: 'Select Report Tags', title: 'Tags', isVisible: (_, api) => api.internalApi.shouldDisplayTagSections(), render: () => (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(ObjectTagsWizardSection_1.ObjectTagsWizardSection, { onChange: setReport }))), renderSummary: ObjectTagsWizardSection_1.renderObjectTagsSummary, }, '-', { title: 'Summary', render: () => { return (React.createElement(rebass_1.Box, { padding: 2 }, React.createElement(OnePageAdaptableWizard_1.OnePageWizardSummary, null))); }, }, ] })); }; exports.NewReportWizard = NewReportWizard;