@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
77 lines (76 loc) • 4.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportColumnsWizardSection = exports.renderReportColumnsSummary = exports.isValidReportColumnsScope = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const Radio_1 = tslib_1.__importDefault(require("../../../components/Radio"));
const Tabs_1 = require("../../../components/Tabs");
const NewScopeComponent_1 = require("../../Components/NewScopeComponent");
const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
const isValidReportColumnsScope = (report) => {
if (report.ReportColumnScope === 'ScopeColumns') {
return report.Scope != null ? true : 'Column scope is not defined';
}
return true;
};
exports.isValidReportColumnsScope = isValidReportColumnsScope;
const renderReportColumnsSummary = (report) => {
return (React.createElement(rebass_1.Box, { fontSize: 2 },
report.ReportColumnScope === 'AllColumns' ? (React.createElement(React.Fragment, null,
"Include ",
React.createElement("b", null, "all Columns"),
" in the Report")) : null,
report.ReportColumnScope === 'VisibleColumns' ? (React.createElement(React.Fragment, null,
"Include ",
React.createElement("b", null, "only visible Columns"),
" in the Report")) : null,
report.ReportColumnScope === 'ScopeColumns' ? (React.createElement(React.Fragment, null, (0, NewScopeComponent_1.renderScopeSummary)(report.Scope, {
scopeColumns: 'Report Columns',
scopeWholeRow: 'not available',
scopeDataTypes: 'Report will include columns with the following types',
}))) : null));
};
exports.renderReportColumnsSummary = renderReportColumnsSummary;
const ReportColumnsWizardSection = (props) => {
const { api, data } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
return (React.createElement(rebass_1.Flex, { flexDirection: "column", style: { height: '100%' } },
React.createElement(Tabs_1.Tabs, { m: 2, value: data.ReportColumnScope, onValueChange: (ReportColumnScope) => {
const report = {
...data,
ReportColumnScope,
};
if (report.ReportColumnScope !== 'ScopeColumns') {
delete report.Scope;
}
else {
if (!report.Scope) {
report.Scope = {
ColumnIds: [],
};
}
}
props.onChange(report);
} },
React.createElement(Tabs_1.Tabs.Tab, { value: "AllColumns" },
React.createElement(Radio_1.default, { margin: 0, checked: data.ReportColumnScope == 'AllColumns', tabIndex: -1 }, "All Columns")),
React.createElement(Tabs_1.Tabs.Tab, { value: "VisibleColumns" },
React.createElement(Radio_1.default, { margin: 0, checked: data.ReportColumnScope == 'VisibleColumns', tabIndex: -1 }, "Visible Columns")),
React.createElement(Tabs_1.Tabs.Tab, { value: "ScopeColumns" },
React.createElement(Radio_1.default, { margin: 0, checked: data.ReportColumnScope == 'ScopeColumns', tabIndex: -1 }, "Bespoke Columns")),
React.createElement(Tabs_1.Tabs.Content, { value: "AllColumns" },
React.createElement(rebass_1.Text, { fontSize: 2, padding: 2 }, "All Columns in the datasource will be included in the Report, whether visible or not at time of export")),
React.createElement(Tabs_1.Tabs.Content, { value: "VisibleColumns" },
React.createElement(rebass_1.Text, { fontSize: 2, padding: 2 }, "Only Columns that are visible at the time the Report is exported will be included")),
React.createElement(Tabs_1.Tabs.Content, { value: "BespokeColumns" },
React.createElement(rebass_1.Text, { fontSize: 2, padding: 2 }, "Only selected Columns (which you will choose in the next step) will be exported - whether visible or not"))),
data.ReportColumnScope === 'ScopeColumns' ? (React.createElement(rebass_1.Box, { padding: 2, flex: 1, style: { overflow: 'auto' } },
React.createElement(NewScopeComponent_1.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) => {
const report = { ...data, Scope };
props.onChange(report);
} }))) : null));
};
exports.ReportColumnsWizardSection = ReportColumnsWizardSection;