@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
74 lines (73 loc) • 3.59 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useState } from 'react';
import { OnePageAdaptableWizard, OnePageWizardSummary } from '../../Wizard/OnePageAdaptableWizard';
import { cloneObject } from '../../../Utilities/Helpers/Helper';
import { renderReportColumnsSummary, ReportColumnsWizardSection, } from './ReportColumnsWizardSection';
import { isValidReportRowsQuery, renderReportRowsSummary, ReportRowsWizardSection, } from './ReportRowsWizardSection';
import { isValidReportName, renderReportNameSummary, ReportNameWizardSection, } from './ReportNameWizardSection';
import ObjectFactory from '../../../Utilities/ObjectFactory';
import { useDispatch, useSelector } from 'react-redux';
import * as ExportRedux from '../../../Redux/ActionsReducers/ExportRedux';
import { ObjectTagsWizardSection, renderObjectTagsSummary, } from '../../Wizard/ObjectTagsWizardSection';
import { Box } from '../../../components/Flex';
export const NewReportWizard = (props) => {
const isEdit = props.popupParams?.action
? props.popupParams.action === 'Edit'
: Boolean(props.data);
const currentReport = useSelector((state) => {
if (!isEdit) {
return;
}
return state.Export.Reports.find((report) => report.Name === state.Export.CurrentReport);
});
const data = props.data ?? currentReport;
const [report, setReport] = useState(() => {
return data ? cloneObject(data) : ObjectFactory.CreateEmptyReport();
});
const dispatch = useDispatch();
const handleFinish = () => {
if (isEdit) {
dispatch(ExportRedux.ReportEdit(report));
}
else {
dispatch(ExportRedux.ReportAdd(report));
}
props.onFinishWizard(report);
};
return (_jsx(OnePageAdaptableWizard, { defaultCurrentSectionName: props.defaultCurrentSectionName, moduleInfo: props.moduleInfo, data: report, onHide: props.onCloseWizard, onFinish: handleFinish, sections: [
{
title: 'Name',
details: 'Enter the name of the Report',
isValid: isValidReportName,
renderSummary: renderReportNameSummary,
render: () => (_jsx(Box, { className: "twa:p-2", children: _jsx(ReportNameWizardSection, { onChange: setReport }) })),
},
{
title: 'Columns',
details: 'Choose the Columns you want to include in the Report',
renderSummary: renderReportColumnsSummary,
render: () => _jsx(ReportColumnsWizardSection, { onChange: setReport }),
},
{
title: 'Rows',
details: 'Choose the Rows you want to include in the Report',
isValid: isValidReportRowsQuery,
renderSummary: renderReportRowsSummary,
render: () => _jsx(ReportRowsWizardSection, { onChange: setReport }),
},
{
details: 'Select Report Tags',
title: 'Tags',
isVisible: (_, api) => api.internalApi.shouldDisplayTagSections(),
render: () => (_jsx(Box, { className: "twa:p-2", children: _jsx(ObjectTagsWizardSection, { onChange: setReport }) })),
renderSummary: renderObjectTagsSummary,
},
'-',
{
title: 'Summary',
render: () => {
return (_jsx(Box, { className: "twa:p-2", children: _jsx(OnePageWizardSummary, {}) }));
},
},
] }));
};