@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
43 lines (42 loc) • 3.81 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useMemo } from 'react';
import { ExpressionEditor } from '../../../components/ExpressionEditor';
import { renderExportRowsView } from '../../../Strategy/Utilities/Export/getExportRowsViewItems';
import { useOnePageAdaptableWizardContext } from '../../Wizard/OnePageAdaptableWizard';
import { Box, Flex } from '../../../components/Flex';
import { Card } from '../../../components/Card';
import { TypeRadio } from '../../Wizard/TypeRadio';
export const isValidReportRowsQuery = (report) => {
if (report.ReportRowScope === 'ExpressionRows' && !report.Query?.BooleanExpression) {
return 'Rows query cannot be empty';
}
return true;
};
export const renderReportRowsSummary = (report, api) => renderExportRowsView(report, api);
export const ReportRowsWizardSection = (props) => {
const { api, data, moduleInfo } = useOnePageAdaptableWizardContext();
const initialData = useMemo(() => api.internalApi.getQueryPreviewData(), []);
const handleRowScopeChange = (ReportRowScope) => {
const report = {
...data,
ReportRowScope,
};
if (report.ReportRowScope !== 'ExpressionRows') {
delete report.Query;
}
else if (!report.Query) {
report.Query = {
BooleanExpression: '',
};
}
props.onChange(report);
};
return (_jsxs(Flex, { flexDirection: "column", className: "twa:h-full twa:gap-3 twa:p-3", children: [_jsxs(Card, { shadow: false, children: [_jsxs(Card.Title, { children: [_jsx(Box, { className: "twa:font-medium", children: "Rows" }), _jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:font-normal twa:max-w-[520px]", children: "Choose which rows to include in the Report" })] }), _jsx(Card.Body, { children: _jsxs(Flex, { flexDirection: "column", children: [_jsx(TypeRadio, { text: "All Rows", description: "All rows in the datasource will be included, whether visible or not at time of export", checked: data.ReportRowScope === 'AllRows', onClick: () => handleRowScopeChange('AllRows') }), _jsx(TypeRadio, { text: "Visible Rows", description: "Only rows that are visible at the time the Report is exported will be included", checked: data.ReportRowScope === 'VisibleRows', onClick: () => handleRowScopeChange('VisibleRows') }), _jsx(TypeRadio, { text: "By Query", description: "Only rows matching the query will be exported \u2014 whether visible or not", checked: data.ReportRowScope === 'ExpressionRows', onClick: () => handleRowScopeChange('ExpressionRows') })] }) })] }), data.ReportRowScope === 'ExpressionRows' ? (_jsxs(Card, { shadow: false, className: "twa:flex-1 twa:min-h-0", children: [_jsxs(Card.Title, { children: [_jsx(Box, { className: "twa:font-medium", children: "Query" }), _jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:font-normal twa:max-w-[520px]", children: "Build a boolean expression to filter which rows are included" })] }), _jsx(Card.Body, { className: "twa:flex-1 twa:min-h-0", children: _jsx(ExpressionEditor, { allowSaveNamedQuery: true, type: 'boolean', module: moduleInfo.ModuleName, className: "twa:pl-0", value: data.Query?.BooleanExpression ?? '', onChange: (BooleanExpression) => {
props.onChange({
...data,
Query: {
BooleanExpression,
},
});
}, initialData: initialData, columns: api.columnApi.internalApi.getQueryableColumnsForUIEditor(), fields: api.expressionApi.internalApi.getAvailableFields(), namedQueries: api.namedQueryApi.getNamedQueries(), api: api }) })] })) : null] }));
};