@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
39 lines (38 loc) • 3.74 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { NewScopeComponent } from '../../Components/NewScopeComponent';
import { renderExportColumnsView } from '../../../Strategy/Utilities/Export/getExportColumnsViewItems';
import { useOnePageAdaptableWizardContext } from '../../Wizard/OnePageAdaptableWizard';
import { Box, Flex } from '../../../components/Flex';
import { Card } from '../../../components/Card';
import { TypeRadio } from '../../Wizard/TypeRadio';
export const isValidReportColumnsScope = (report) => {
if (report.ReportColumnScope === 'ScopeColumns') {
return report.Scope != null ? true : 'Column scope is not defined';
}
return true;
};
export const renderReportColumnsSummary = (report, api) => renderExportColumnsView(report, api);
export const ReportColumnsWizardSection = (props) => {
const { data } = useOnePageAdaptableWizardContext();
const handleColumnScopeChange = (ReportColumnScope) => {
const report = {
...data,
ReportColumnScope,
};
if (report.ReportColumnScope !== 'ScopeColumns') {
delete report.Scope;
}
else if (!report.Scope) {
report.Scope = {
ColumnIds: [],
};
}
props.onChange(report);
};
return (_jsxs(Flex, { flexDirection: "column", className: "twa:h-full", children: [_jsx(Flex, { flexDirection: "column", className: "twa:gap-3 twa:p-3 twa:shrink-0", children: _jsxs(Card, { shadow: false, children: [_jsxs(Card.Title, { children: [_jsx(Box, { className: "twa:font-medium", children: "Columns" }), _jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:font-normal twa:max-w-[520px]", children: "Choose which columns to include in the Report" })] }), _jsx(Card.Body, { children: _jsxs(Flex, { flexDirection: "column", children: [_jsx(TypeRadio, { text: "All Columns", description: "All columns in the datasource will be included, whether visible or not at time of export", checked: data.ReportColumnScope === 'AllColumns', onClick: () => handleColumnScopeChange('AllColumns') }), _jsx(TypeRadio, { text: "Visible Columns", description: "Only columns that are visible at the time the Report is exported will be included", checked: data.ReportColumnScope === 'VisibleColumns', onClick: () => handleColumnScopeChange('VisibleColumns') }), _jsx(TypeRadio, { text: "Bespoke Columns", description: "Only selected columns will be exported \u2014 whether visible or not", checked: data.ReportColumnScope === 'ScopeColumns', onClick: () => handleColumnScopeChange('ScopeColumns') })] }) })] }) }), data.ReportColumnScope === 'ScopeColumns' ? (_jsxs(Flex, { flexDirection: "column", className: "twa:flex-1 twa:min-h-0", children: [_jsxs(Flex, { flexDirection: "row", alignItems: "center", className: "twa:p-2 twa:gap-3 twa:border-b twa:mb-2 twa:border-b-foreground/20", children: [_jsx(Box, { className: "twa:text-5 twa:font-medium", children: "Column Selection" }), _jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:max-w-[520px]", children: "Select the columns to include in the Report" })] }), _jsx(Box, { className: "twa:flex-1 twa:min-h-0 twa:overflow-auto twa:p-2", children: _jsx(NewScopeComponent, { hideWholeRow: true, isColumnAvailable: (column) => Boolean(column.exportable), descriptions: {
rowScope: 'Apply Scope for: Row, or one or more Columns, or one or more Data Types',
columnScope: 'Selected columns will be included in the report',
}, scope: data.Scope, updateScope: (Scope) => {
props.onChange({ ...data, Scope });
} }) })] })) : null] }));
};