@adaptabletools/adaptable-cjs 20.0.0-canary.6 → 20.0.0-canary.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/AdaptableOptions/ExportOptions.d.ts +8 -3
- package/src/Api/ExportApi.d.ts +1 -6
- package/src/Api/Implementation/ExportApiImpl.d.ts +1 -2
- package/src/Api/Implementation/ExportApiImpl.js +14 -8
- package/src/Api/Internal/ActionColumnInternalApi.js +16 -19
- package/src/Api/Internal/AdaptableInternalApi.js +1 -1
- package/src/Api/Internal/ExportInternalApi.d.ts +10 -6
- package/src/Api/Internal/ExportInternalApi.js +104 -135
- package/src/PredefinedConfig/ExportState.d.ts +7 -14
- package/src/Redux/Store/AdaptableStore.js +1 -1
- package/src/agGrid/AgGridExportAdapter.d.ts +24 -1
- package/src/agGrid/AgGridExportAdapter.js +24 -25
- package/src/agGrid/cellRenderers/BadgeRenderer.js +2 -1
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/types.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable-cjs",
|
|
3
|
-
"version": "20.0.0-canary.
|
|
3
|
+
"version": "20.0.0-canary.8",
|
|
4
4
|
"description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdaptableForm } from '../PredefinedConfig/Common/AdaptableForm';
|
|
2
2
|
import { FormContext } from '../PredefinedConfig/Common/FormContext';
|
|
3
|
-
import { Report, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
|
|
3
|
+
import { Report, ReportColumn, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
|
|
4
4
|
import { AdaptableColumn, BaseContext, AdaptableColumnContext } from '../types';
|
|
5
5
|
import { TypeHint } from '../PredefinedConfig/Common/Types';
|
|
6
6
|
import { CsvCell, ExcelCell, ExcelDataType, ExcelRow, IRowNode } from 'ag-grid-enterprise';
|
|
@@ -162,9 +162,9 @@ export interface ExternalReport {
|
|
|
162
162
|
*/
|
|
163
163
|
name: string;
|
|
164
164
|
/**
|
|
165
|
-
* Function invoked to return the data (in the form of a `
|
|
165
|
+
* Function invoked to return the data (in the form of a `ExportResultData` object)
|
|
166
166
|
*/
|
|
167
|
-
|
|
167
|
+
onExport: (context: ExternalReportContext) => Promise<ExportResultData>;
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Defines a custom Export destination
|
|
@@ -257,6 +257,11 @@ export interface ReportContext extends BaseExportContext {
|
|
|
257
257
|
*/
|
|
258
258
|
reportData: ExportResultData;
|
|
259
259
|
}
|
|
260
|
+
export interface ExternalReportContext extends BaseExportContext {
|
|
261
|
+
getGridReportColumns: () => ReportColumn[];
|
|
262
|
+
convertToExcel: (reportData: ReportData) => Blob;
|
|
263
|
+
convertToCsv: (reportData: ReportData) => string;
|
|
264
|
+
}
|
|
260
265
|
/**
|
|
261
266
|
* Context used for providing a custom filename for a Report
|
|
262
267
|
*/
|
package/src/Api/ExportApi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdaptableForm } from '../PredefinedConfig/Common/AdaptableForm';
|
|
2
|
-
import { ExportState, Report,
|
|
2
|
+
import { ExportState, Report, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
|
|
3
3
|
import { CustomDestination, ExportDestinationType, ExportFormContext, ExportResultData, ExternalReport, SystemExportDestination } from '../AdaptableOptions/ExportOptions';
|
|
4
4
|
import { AdaptableColumn } from '../types';
|
|
5
5
|
/**
|
|
@@ -139,11 +139,6 @@ export interface ExportApi {
|
|
|
139
139
|
* @param report Report to Check
|
|
140
140
|
*/
|
|
141
141
|
isExternalReport(report: Report): boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Runs the report function of the ExternalReport with the given reportName
|
|
144
|
-
* @param reportName external report name
|
|
145
|
-
*/
|
|
146
|
-
runExternalReport(reportName: string): ReportData | undefined;
|
|
147
142
|
/**
|
|
148
143
|
* Returns whether the given column is exportable
|
|
149
144
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExportApi } from '../ExportApi';
|
|
2
|
-
import { ExportState, Report,
|
|
2
|
+
import { ExportState, Report, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../../PredefinedConfig/ExportState';
|
|
3
3
|
import { ApiBase } from './ApiBase';
|
|
4
4
|
import { AdaptableForm } from '../../PredefinedConfig/Common/AdaptableForm';
|
|
5
5
|
import { CustomDestination, ExportDestinationType, ExportFormContext, ExportResultData, ExternalReport, SystemExportDestination } from '../../AdaptableOptions/ExportOptions';
|
|
@@ -36,7 +36,6 @@ export declare class ExportApiImpl extends ApiBase implements ExportApi {
|
|
|
36
36
|
getCustomReports(): Report[];
|
|
37
37
|
getExternalReports(): ExternalReport[];
|
|
38
38
|
isExternalReport(report: Report): boolean;
|
|
39
|
-
runExternalReport(externalReportName: string): ReportData | undefined;
|
|
40
39
|
isColumnExportable(adaptableColumn: AdaptableColumn): boolean;
|
|
41
40
|
getSupportedExportDestinations(reportFormat: ReportFormatType): ExportDestinationType[];
|
|
42
41
|
exportReport(reportName: ReportNameType, format: ReportFormatType, destination?: ExportDestinationType): void;
|
|
@@ -136,14 +136,6 @@ class ExportApiImpl extends ApiBase_1.ApiBase {
|
|
|
136
136
|
isExternalReport(report) {
|
|
137
137
|
return this.getExternalReports()?.find((cr) => cr.name == report.Name) != null;
|
|
138
138
|
}
|
|
139
|
-
runExternalReport(externalReportName) {
|
|
140
|
-
const externalReport = this.getExternalReports()?.find((cr) => cr.name == externalReportName);
|
|
141
|
-
if (!externalReport) {
|
|
142
|
-
this.logWarn(`External Report '${externalReportName}' not found!`);
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
return externalReport.onRunReport();
|
|
146
|
-
}
|
|
147
139
|
isColumnExportable(adaptableColumn) {
|
|
148
140
|
const isExportableFn = this.getExportOptions().isColumnExportable;
|
|
149
141
|
if (typeof isExportableFn === 'function') {
|
|
@@ -172,6 +164,20 @@ class ExportApiImpl extends ApiBase_1.ApiBase {
|
|
|
172
164
|
exportReport(reportName, format, destination = 'Download') {
|
|
173
165
|
let report = this.getReportByName(reportName);
|
|
174
166
|
if (this.checkItemExists(report, reportName, 'Report')) {
|
|
167
|
+
if (this.isExternalReport(report)) {
|
|
168
|
+
// Handle external report
|
|
169
|
+
this.internalApi
|
|
170
|
+
.getExternalReportData(reportName, format, destination)
|
|
171
|
+
.then((reportData) => {
|
|
172
|
+
if (reportData) {
|
|
173
|
+
this.internalApi.sendReportToDestination(reportData, report, format, destination);
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
.catch((error) => {
|
|
177
|
+
this.logWarn(`Failed to get external report data for '${reportName}': ${error}`);
|
|
178
|
+
});
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
175
181
|
this._adaptable.agGridExportAdapter
|
|
176
182
|
.exportData({
|
|
177
183
|
report,
|
|
@@ -81,13 +81,14 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
|
|
|
81
81
|
return { actionButtons, actionColumn };
|
|
82
82
|
}
|
|
83
83
|
updateAllActionColumnButtons(actionButtons) {
|
|
84
|
-
return actionButtons.map((actionButton) =>
|
|
85
|
-
...actionButton
|
|
86
|
-
Uuid
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
return actionButtons.map((actionButton) => {
|
|
85
|
+
actionButton = { ...actionButton };
|
|
86
|
+
actionButton.Uuid = (0, Uuid_1.createUuid)();
|
|
87
|
+
if (actionButton.command) {
|
|
88
|
+
this.updateActionButtonCommand(actionButton);
|
|
89
|
+
}
|
|
90
|
+
return actionButton;
|
|
91
|
+
});
|
|
91
92
|
}
|
|
92
93
|
updateActionButtonCommand(button) {
|
|
93
94
|
switch (button.command) {
|
|
@@ -96,7 +97,7 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
|
|
|
96
97
|
this.getRowFormApi().displayCreateRowForm();
|
|
97
98
|
};
|
|
98
99
|
button.tooltip = button.tooltip ? button.tooltip : 'Create Row';
|
|
99
|
-
button.icon = {
|
|
100
|
+
button.icon = button.icon ?? {
|
|
100
101
|
name: 'add',
|
|
101
102
|
};
|
|
102
103
|
break;
|
|
@@ -105,7 +106,7 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
|
|
|
105
106
|
this.getRowFormApi().displayCloneRowForm(context.primaryKeyValue);
|
|
106
107
|
};
|
|
107
108
|
button.tooltip = button.tooltip ? button.tooltip : 'Clone Row';
|
|
108
|
-
button.icon = {
|
|
109
|
+
button.icon = button.icon ?? {
|
|
109
110
|
name: 'clone',
|
|
110
111
|
};
|
|
111
112
|
break;
|
|
@@ -120,22 +121,18 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
|
|
|
120
121
|
this.getRowFormOptions().onRowFormSubmit?.(eventInfo);
|
|
121
122
|
};
|
|
122
123
|
button.tooltip = button.tooltip ? button.tooltip : 'Delete Row';
|
|
123
|
-
button.icon = button.icon
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
name: 'delete',
|
|
127
|
-
};
|
|
124
|
+
button.icon = button.icon ?? {
|
|
125
|
+
name: 'delete',
|
|
126
|
+
};
|
|
128
127
|
break;
|
|
129
128
|
case 'edit':
|
|
130
129
|
button.onClick = (button, context) => {
|
|
131
130
|
this.getRowFormApi().displayEditRowForm(context.primaryKeyValue);
|
|
132
131
|
};
|
|
133
132
|
button.tooltip = button.tooltip ? button.tooltip : 'Edit Row';
|
|
134
|
-
button.icon = button.icon
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
name: 'edit',
|
|
138
|
-
};
|
|
133
|
+
button.icon = button.icon ?? {
|
|
134
|
+
name: 'edit',
|
|
135
|
+
};
|
|
139
136
|
break;
|
|
140
137
|
}
|
|
141
138
|
}
|
|
@@ -191,7 +191,7 @@ class AdaptableInternalApi extends ApiBase_1.ApiBase {
|
|
|
191
191
|
if (firstRowNode == undefined) {
|
|
192
192
|
return {};
|
|
193
193
|
}
|
|
194
|
-
const firstRowData = { ...firstRowNode?.data }
|
|
194
|
+
const firstRowData = firstRowNode?.data ? { ...firstRowNode?.data } : {};
|
|
195
195
|
// handle CalcCols which are not persisted in the rowModel
|
|
196
196
|
this.getCalculatedColumnApi()
|
|
197
197
|
.getCalculatedColumns()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiBase } from '../Implementation/ApiBase';
|
|
2
2
|
import { CellDataChangedInfo } from '../../PredefinedConfig/Common/CellDataChangedInfo';
|
|
3
3
|
import { Report, ReportData, ReportFormatType, ReportNameType, SystemReportName } from '../../PredefinedConfig/ExportState';
|
|
4
|
-
import { IRowNode } from 'ag-grid-enterprise';
|
|
4
|
+
import { CsvCell, ExcelCell, ExcelDataType, IRowNode } from 'ag-grid-enterprise';
|
|
5
5
|
import { AdaptableColumn, AdaptableColumnDataType } from '../../PredefinedConfig/Common/AdaptableColumn';
|
|
6
6
|
import { BaseExportContext, DataFormatType, ExportDestinationType, ExportResultData } from '../../AdaptableOptions/ExportOptions';
|
|
7
7
|
export declare class ExportInternalApi extends ApiBase {
|
|
@@ -21,12 +21,7 @@ export declare class ExportInternalApi extends ApiBase {
|
|
|
21
21
|
getReportColumnScopeShortDescription(report: Report): string[];
|
|
22
22
|
getReportColumnScopeLongDescription(report: Report): string;
|
|
23
23
|
getReportExpressionDescription(report: Report, cols: AdaptableColumn[]): string;
|
|
24
|
-
getReportDataColumns(report: Report, includePrimaryKey?: boolean): AdaptableColumn[];
|
|
25
|
-
getReportDataRows(report: Report, columns: AdaptableColumn[], includePrimaryKey?: boolean): Record<string, any>[];
|
|
26
|
-
getReportData(report: Report, includePrimaryKey?: boolean): ReportData;
|
|
27
|
-
getReportDataAsArray(report: Report, includePrimaryKey?: boolean): any[][];
|
|
28
24
|
convertReportDataToArray(reportData: ReportData): any[][];
|
|
29
|
-
getRowObjectForColumnIds(rowNode: IRowNode, columnIds: string[], reportName: string): Record<string, any>;
|
|
30
25
|
publishLiveLiveDataChangedEvent(reportDestination: 'ipushpull' | 'OpenFin', liveDataTrigger: 'Connected' | 'Disconnected' | 'SnapshotSent' | 'LiveDataStarted' | 'LiveDataStopped' | 'LiveDataUpdated', liveReport?: any): void;
|
|
31
26
|
getCellExportValueFromRowNode(rowNode: IRowNode, columnId: string, isVisualReport?: boolean): any;
|
|
32
27
|
getCellExportValueFromRawValue(rowNode: IRowNode, cellRawValue: any, columnId: string, isVisualReport?: boolean): any;
|
|
@@ -36,4 +31,13 @@ export declare class ExportInternalApi extends ApiBase {
|
|
|
36
31
|
sendReportToDestination(reportResult: ExportResultData, report: Report, format: ReportFormatType, destination: ExportDestinationType): void;
|
|
37
32
|
private sendReportToCustomDestination;
|
|
38
33
|
buildBaseExportContext(reportName: ReportNameType, reportFormat: ReportFormatType, exportDestination?: ExportDestinationType): BaseExportContext;
|
|
34
|
+
createCellCsv(cellContent: any): CsvCell;
|
|
35
|
+
createCellExcel(cellContent: any, cellType: ExcelDataType): ExcelCell;
|
|
36
|
+
createCellHeader(cellContent: any): ExcelCell;
|
|
37
|
+
getExternalReportData(externalReportName: ReportNameType, reportFormat: ReportFormatType, exportDestination: ExportDestinationType): Promise<ExportResultData | undefined>;
|
|
38
|
+
private buildGridReportColumns;
|
|
39
|
+
private buildExcelConverter;
|
|
40
|
+
private buildCsvConverter;
|
|
41
|
+
private executeGridExport;
|
|
42
|
+
private buildCsvExportParams;
|
|
39
43
|
}
|
|
@@ -2,18 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExportInternalApi = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const groupBy_1 = tslib_1.__importDefault(require("lodash/groupBy"));
|
|
6
5
|
const ApiBase_1 = require("../Implementation/ApiBase");
|
|
6
|
+
const ag_grid_enterprise_1 = require("ag-grid-enterprise");
|
|
7
7
|
const Uuid_1 = require("../../PredefinedConfig/Uuid");
|
|
8
8
|
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
|
|
9
|
-
const ModuleConstants_1 = require("../../Utilities/Constants/ModuleConstants");
|
|
10
|
-
const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
|
|
11
9
|
const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
|
|
12
10
|
const FormatHelper_1 = tslib_1.__importStar(require("../../Utilities/Helpers/FormatHelper"));
|
|
13
11
|
const Helper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/Helper"));
|
|
14
12
|
const PopupRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/PopupRedux"));
|
|
15
13
|
const InternalRedux_1 = require("../../Redux/ActionsReducers/InternalRedux");
|
|
16
|
-
const AdaptableLogger_1 = require("../../agGrid/AdaptableLogger");
|
|
17
14
|
class ExportInternalApi extends ApiBase_1.ApiBase {
|
|
18
15
|
/**
|
|
19
16
|
* Value Items for Report Name Selection
|
|
@@ -215,7 +212,6 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
|
|
|
215
212
|
return `[${report.Name}]`;
|
|
216
213
|
}
|
|
217
214
|
else {
|
|
218
|
-
// FIXME AFL: maybe fihnd a better description?
|
|
219
215
|
switch (report.ReportRowScope) {
|
|
220
216
|
case 'AllRows':
|
|
221
217
|
return '[All Rows]';
|
|
@@ -228,138 +224,12 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
|
|
|
228
224
|
}
|
|
229
225
|
}
|
|
230
226
|
}
|
|
231
|
-
getReportDataColumns(report, includePrimaryKey = false) {
|
|
232
|
-
let reportColumns = [];
|
|
233
|
-
let gridColumns = this.getAdaptableApi().columnApi.getExportableColumns();
|
|
234
|
-
if (this.getAdaptableApi().exportApi.isExternalReport(report)) {
|
|
235
|
-
return reportColumns;
|
|
236
|
-
}
|
|
237
|
-
// first get the cols depending on the Column Scope
|
|
238
|
-
switch (report.ReportColumnScope) {
|
|
239
|
-
case 'AllColumns':
|
|
240
|
-
reportColumns = gridColumns;
|
|
241
|
-
break;
|
|
242
|
-
case 'VisibleColumns':
|
|
243
|
-
reportColumns = gridColumns.filter((c) => c.visible);
|
|
244
|
-
break;
|
|
245
|
-
case 'SelectedColumns':
|
|
246
|
-
// we extract the selected columns from the grid columns to preserve the grid column order
|
|
247
|
-
const selectedColumnIds = this.getAdaptableApi()
|
|
248
|
-
.gridApi.getSelectedCellInfo()
|
|
249
|
-
.columns.map((column) => column.columnId);
|
|
250
|
-
reportColumns = gridColumns.filter((gridColumn) => selectedColumnIds.includes(gridColumn.columnId));
|
|
251
|
-
break;
|
|
252
|
-
case 'ScopeColumns':
|
|
253
|
-
if ('ColumnIds' in report.Scope) {
|
|
254
|
-
reportColumns = report.Scope.ColumnIds.map((columnId) => this.getAdaptableApi().columnApi.getColumnWithColumnId(columnId)).filter((c) => c);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
reportColumns = this.getAdaptableApi().columnScopeApi.getColumnsInScope(report.Scope);
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
if (includePrimaryKey) {
|
|
262
|
-
const pkColumn = reportColumns.find((column) => column.columnId === this.getAdaptableApi().optionsApi.getPrimaryKey());
|
|
263
|
-
// TODO simplify after we fix the IsPrimaryKey bug
|
|
264
|
-
// const pkColumn = reportColumns.find(column => column.IsPrimaryKey);
|
|
265
|
-
if (!pkColumn && !!this.getAdaptableApi().columnApi.getPrimaryKeyColumn()) {
|
|
266
|
-
reportColumns.push(this.getAdaptableApi().columnApi.getPrimaryKeyColumn());
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return reportColumns;
|
|
270
|
-
}
|
|
271
|
-
getReportDataRows(report, columns, includePrimaryKey) {
|
|
272
|
-
if (ArrayExtensions_1.default.IsNullOrEmpty(columns)) {
|
|
273
|
-
return [];
|
|
274
|
-
}
|
|
275
|
-
const columnIds = columns.map((column) => column.columnId);
|
|
276
|
-
const resultRowData = [];
|
|
277
|
-
switch (report.ReportRowScope) {
|
|
278
|
-
case 'AllRows':
|
|
279
|
-
this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
|
|
280
|
-
resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
|
|
281
|
-
});
|
|
282
|
-
break;
|
|
283
|
-
case 'VisibleRows':
|
|
284
|
-
this.getAdaptableInternalApi().forAllVisibleRowNodesDo((rowNode) => {
|
|
285
|
-
resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
|
|
286
|
-
});
|
|
287
|
-
break;
|
|
288
|
-
case 'ExpressionRows':
|
|
289
|
-
this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
|
|
290
|
-
try {
|
|
291
|
-
if (this.getAdaptableApi()
|
|
292
|
-
.internalApi.getQueryLanguageService()
|
|
293
|
-
.evaluateBooleanExpression(report.Query?.BooleanExpression, ModuleConstants_1.ExportModuleId, rowNode)) {
|
|
294
|
-
resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
(0, AdaptableLogger_1.errorOnce)(error.message);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
break;
|
|
302
|
-
case 'SelectedRows':
|
|
303
|
-
// CellSelection
|
|
304
|
-
const selectedCellInfo = this.getAdaptableApi().gridApi.getSelectedCellInfo();
|
|
305
|
-
const { gridCells: GridCells } = selectedCellInfo;
|
|
306
|
-
let selectedCellsByPrimaryKey = (0, groupBy_1.default)(GridCells, 'primaryKeyValue');
|
|
307
|
-
// we iterate over all visibleRowNodes to preserve the current order
|
|
308
|
-
this.getAdaptableInternalApi().forAllVisibleRowNodesDo((rowNode) => {
|
|
309
|
-
const rowPrimaryKeyValue = this.getAdaptableApi().gridApi.getPrimaryKeyValueForRowNode(rowNode);
|
|
310
|
-
const selectedRowCells = selectedCellsByPrimaryKey[rowPrimaryKeyValue];
|
|
311
|
-
if (selectedRowCells) {
|
|
312
|
-
const selectedRowColumnIds = selectedRowCells.map((rowCell) => rowCell.column.columnId);
|
|
313
|
-
const selectedColumnIds = columnIds.filter((columnId) => selectedRowColumnIds.includes(columnId));
|
|
314
|
-
const row = this.getRowObjectForColumnIds(rowNode, selectedColumnIds, report.Name);
|
|
315
|
-
if (includePrimaryKey) {
|
|
316
|
-
row[this.getAdaptableApi().optionsApi.getPrimaryKey()] = rowPrimaryKeyValue;
|
|
317
|
-
}
|
|
318
|
-
resultRowData.push(row);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
// Row Selection
|
|
322
|
-
const selectedRowInfo = this.getAdaptableApi().gridApi.getSelectedRowInfo();
|
|
323
|
-
const selectedGridRowPrimaryKeys = selectedRowInfo?.gridRows
|
|
324
|
-
?.filter((gr) => gr.rowInfo.isGroup == false)
|
|
325
|
-
.map((gridRow) => gridRow.primaryKeyValue) ?? [];
|
|
326
|
-
if (selectedGridRowPrimaryKeys.length) {
|
|
327
|
-
this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
|
|
328
|
-
const rowPrimaryKeyValue = this.getAdaptableApi().gridApi.getPrimaryKeyValueForRowNode(rowNode);
|
|
329
|
-
if (selectedGridRowPrimaryKeys.includes(rowPrimaryKeyValue)) {
|
|
330
|
-
resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
return resultRowData;
|
|
337
|
-
}
|
|
338
|
-
getReportData(report, includePrimaryKey = false) {
|
|
339
|
-
if (this.getAdaptableApi().exportApi.isExternalReport(report)) {
|
|
340
|
-
return this.getAdaptableApi().exportApi.runExternalReport(report.Name);
|
|
341
|
-
}
|
|
342
|
-
const columns = this.getReportDataColumns(report, includePrimaryKey);
|
|
343
|
-
const rows = this.getReportDataRows(report, columns, includePrimaryKey);
|
|
344
|
-
return { columns, rows };
|
|
345
|
-
}
|
|
346
|
-
getReportDataAsArray(report, includePrimaryKey = false) {
|
|
347
|
-
const reportData = this.getReportData(report, includePrimaryKey);
|
|
348
|
-
return this.convertReportDataToArray(reportData);
|
|
349
|
-
}
|
|
350
227
|
convertReportDataToArray(reportData) {
|
|
351
228
|
return [
|
|
352
229
|
reportData.columns.map((column) => column.friendlyName),
|
|
353
|
-
...reportData.rows.map((row) => reportData.columns.map((column) => row[column.columnId])),
|
|
230
|
+
...reportData.rows.map((row) => reportData.columns.map((column) => row[column.field ?? column.columnId])),
|
|
354
231
|
];
|
|
355
232
|
}
|
|
356
|
-
getRowObjectForColumnIds(rowNode, columnIds, reportName) {
|
|
357
|
-
return columnIds.reduce((result, columnId) => {
|
|
358
|
-
// FIXME AFL if this method remains, 'false' should be replaced with dynamic value
|
|
359
|
-
result[columnId] = this.getCellExportValueFromRowNode(rowNode, columnId, false);
|
|
360
|
-
return result;
|
|
361
|
-
}, {});
|
|
362
|
-
}
|
|
363
233
|
publishLiveLiveDataChangedEvent(reportDestination, liveDataTrigger, liveReport) {
|
|
364
234
|
const liveDataChangedInfo = {
|
|
365
235
|
...this.getAdaptableInternalApi().buildBaseContext(),
|
|
@@ -433,9 +303,8 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
|
|
|
433
303
|
this.sendReportToCustomDestination(reportResult, report, format, destination);
|
|
434
304
|
}
|
|
435
305
|
if (destination === 'Download') {
|
|
436
|
-
if (
|
|
437
|
-
this.
|
|
438
|
-
return;
|
|
306
|
+
if (reportResult.type === 'excel') {
|
|
307
|
+
Helper_1.default.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
439
308
|
}
|
|
440
309
|
if (reportResult.type === 'csv') {
|
|
441
310
|
Helper_1.default.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'text/csv;encoding:utf-8');
|
|
@@ -494,5 +363,105 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
|
|
|
494
363
|
exportDestination,
|
|
495
364
|
};
|
|
496
365
|
}
|
|
366
|
+
createCellCsv(cellContent) {
|
|
367
|
+
return {
|
|
368
|
+
data: {
|
|
369
|
+
value: cellContent != undefined ? String(cellContent) : null,
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
createCellExcel(cellContent, cellType) {
|
|
374
|
+
return {
|
|
375
|
+
data: {
|
|
376
|
+
value: cellContent != undefined ? String(cellContent) : null,
|
|
377
|
+
type: cellType,
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
createCellHeader(cellContent) {
|
|
382
|
+
return {
|
|
383
|
+
data: {
|
|
384
|
+
value: cellContent != undefined ? String(cellContent) : null,
|
|
385
|
+
type: 'String',
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
getExternalReportData(externalReportName, reportFormat, exportDestination) {
|
|
390
|
+
const externalReport = this.getExportApi()
|
|
391
|
+
.getExternalReports()
|
|
392
|
+
?.find((cr) => cr.name == externalReportName);
|
|
393
|
+
if (!externalReport) {
|
|
394
|
+
this.logWarn(`External Report '${externalReportName}' not found!`);
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
return externalReport.onExport({
|
|
398
|
+
...this.buildBaseExportContext(externalReportName, reportFormat, exportDestination),
|
|
399
|
+
convertToExcel: this.buildExcelConverter(externalReportName, reportFormat, exportDestination),
|
|
400
|
+
convertToCsv: this.buildCsvConverter(externalReportName, reportFormat, exportDestination),
|
|
401
|
+
getGridReportColumns: this.buildGridReportColumns(),
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
buildGridReportColumns() {
|
|
405
|
+
return () => this.getAdaptableApi().columnApi.getColumns();
|
|
406
|
+
}
|
|
407
|
+
buildExcelConverter(externalReportName, reportFormat, exportDestination) {
|
|
408
|
+
return (reportData) => {
|
|
409
|
+
return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsExcel({ ...exportParams }));
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
buildCsvConverter(externalReportName, reportFormat, exportDestination) {
|
|
413
|
+
return (reportData) => {
|
|
414
|
+
const csvParams = this.buildCsvExportParams(externalReportName, reportFormat, exportDestination);
|
|
415
|
+
return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsCsv({ ...exportParams, ...csvParams }));
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
executeGridExport(reportData, externalReportName, reportFormat, exportDestination, exportFn) {
|
|
419
|
+
const htmlDivElement = document.createElement('div');
|
|
420
|
+
let ephemeralGridApi = null;
|
|
421
|
+
try {
|
|
422
|
+
const columnDefs = reportData.columns.map((col) => ({
|
|
423
|
+
colId: col.columnId,
|
|
424
|
+
field: col.field ?? col.columnId,
|
|
425
|
+
headerName: col.friendlyName ?? col.columnId,
|
|
426
|
+
type: col.dataType ?? 'text',
|
|
427
|
+
}));
|
|
428
|
+
const gridOptions = { columnDefs, rowData: reportData.rows };
|
|
429
|
+
const gridParams = {
|
|
430
|
+
modules: this.getAdaptableApi()
|
|
431
|
+
.internalApi.getAdaptableInstance()
|
|
432
|
+
.getAgGridRegisteredModules(),
|
|
433
|
+
};
|
|
434
|
+
htmlDivElement.style.display = 'none';
|
|
435
|
+
document.body.appendChild(htmlDivElement);
|
|
436
|
+
ephemeralGridApi = (0, ag_grid_enterprise_1.createGrid)(htmlDivElement, gridOptions, gridParams);
|
|
437
|
+
const exportParams = {
|
|
438
|
+
fileName: this.getReportFileName(externalReportName, reportFormat, exportDestination),
|
|
439
|
+
allColumns: true,
|
|
440
|
+
exportedRows: 'all',
|
|
441
|
+
};
|
|
442
|
+
return exportFn(ephemeralGridApi, exportParams);
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
this.logWarn('Failed to export data:', error);
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
finally {
|
|
449
|
+
if (ephemeralGridApi) {
|
|
450
|
+
ephemeralGridApi.destroy();
|
|
451
|
+
}
|
|
452
|
+
if (htmlDivElement?.parentNode) {
|
|
453
|
+
document.body.removeChild(htmlDivElement);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
buildCsvExportParams(externalReportName, reportFormat, exportDestination) {
|
|
458
|
+
const exportOptions = this.getAdaptableApi().optionsApi.getExportOptions();
|
|
459
|
+
const csvSeparator = typeof exportOptions.csvSeparator === 'function'
|
|
460
|
+
? exportOptions.csvSeparator(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination))
|
|
461
|
+
: exportOptions.csvSeparator;
|
|
462
|
+
return {
|
|
463
|
+
columnSeparator: csvSeparator,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
497
466
|
}
|
|
498
467
|
exports.ExportInternalApi = ExportInternalApi;
|
|
@@ -65,6 +65,12 @@ export interface ReportSchedule extends BaseSchedule {
|
|
|
65
65
|
*/
|
|
66
66
|
ExportDestination?: ExportDestinationType;
|
|
67
67
|
}
|
|
68
|
+
export interface ReportColumn extends AdaptableColumnBase {
|
|
69
|
+
/**
|
|
70
|
+
* Field in the row to get cell data from; defaults to `columnId`
|
|
71
|
+
*/
|
|
72
|
+
field?: string;
|
|
73
|
+
}
|
|
68
74
|
/**
|
|
69
75
|
* Defines the data in a Report run by AdapTable
|
|
70
76
|
*/
|
|
@@ -76,7 +82,7 @@ export interface ReportData {
|
|
|
76
82
|
/**
|
|
77
83
|
* Columns in the Report
|
|
78
84
|
*/
|
|
79
|
-
columns:
|
|
85
|
+
columns: ReportColumn[];
|
|
80
86
|
/**
|
|
81
87
|
* Group columns IDs in the Report
|
|
82
88
|
*/
|
|
@@ -86,19 +92,6 @@ export interface ReportData {
|
|
|
86
92
|
*/
|
|
87
93
|
pivotColumnIds?: string[];
|
|
88
94
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Row Data in the Report
|
|
91
|
-
*/
|
|
92
|
-
export interface ReportRow {
|
|
93
|
-
/**
|
|
94
|
-
* Data for the row
|
|
95
|
-
*/
|
|
96
|
-
data: Record<string, any>;
|
|
97
|
-
/**
|
|
98
|
-
* Optional children rows for grouped data
|
|
99
|
-
*/
|
|
100
|
-
children?: ReportRow[];
|
|
101
|
-
}
|
|
102
95
|
/**
|
|
103
96
|
* System report names provided by AdapTable
|
|
104
97
|
*/
|
|
@@ -667,7 +667,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
|
|
|
667
667
|
}
|
|
668
668
|
return ret;
|
|
669
669
|
}
|
|
670
|
-
case InternalRedux.
|
|
670
|
+
case InternalRedux.HIGHLIGHT_ROW_DELETE_ALL: {
|
|
671
671
|
const rowHighlightInfos = middlewareAPI.getState().Internal.RowHighlightInfo;
|
|
672
672
|
const ret = next(action);
|
|
673
673
|
rowHighlightInfos.forEach((rowHighlightInfo) => {
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { AdaptableAgGrid } from './AdaptableAgGrid';
|
|
2
2
|
import { Report, ReportFormatType } from '../PredefinedConfig/ExportState';
|
|
3
|
-
import { ExcelStyle } from 'ag-grid-enterprise';
|
|
3
|
+
import { CsvExportParams, ExcelExportParams, ExcelStyle } from 'ag-grid-enterprise';
|
|
4
4
|
import { ExportDestinationType, ExportResultData } from '../AdaptableOptions/ExportOptions';
|
|
5
|
+
import { Layout } from '../PredefinedConfig/LayoutState';
|
|
5
6
|
export interface ExportConfig {
|
|
6
7
|
report: Report;
|
|
7
8
|
format: ReportFormatType;
|
|
8
9
|
destination: ExportDestinationType;
|
|
9
10
|
showProgressIndicator: boolean;
|
|
10
11
|
}
|
|
12
|
+
interface ExportProcessContext extends ExportConfig {
|
|
13
|
+
exportedColumnIds: string[];
|
|
14
|
+
isExcelReport: boolean;
|
|
15
|
+
isVisualExcelReport: boolean;
|
|
16
|
+
isExportingVisibleColumnToJSON: boolean;
|
|
17
|
+
getCurrent: () => {
|
|
18
|
+
layout: Layout;
|
|
19
|
+
groupColumnIds: string[];
|
|
20
|
+
pivotColumnIds: string[];
|
|
21
|
+
};
|
|
22
|
+
isCellPartOfSelection: (rowId: string, columnId: string) => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ExportProcessData {
|
|
25
|
+
exportContext: ExportProcessContext;
|
|
26
|
+
exportParams: ExcelExportParams | CsvExportParams;
|
|
27
|
+
}
|
|
11
28
|
export declare class AgGridExportAdapter {
|
|
12
29
|
private _adaptableInstance;
|
|
13
30
|
/**
|
|
@@ -23,9 +40,14 @@ export declare class AgGridExportAdapter {
|
|
|
23
40
|
private get agGridApi();
|
|
24
41
|
private get adaptableApi();
|
|
25
42
|
private get exportOptions();
|
|
43
|
+
private get logger();
|
|
26
44
|
static getExcelClassNameForCell(colId: string, primaryKeyValue: any, userDefinedCellClass?: string | string[]): string;
|
|
27
45
|
destroy(): void;
|
|
28
46
|
exportData(config: ExportConfig): Promise<null | ExportResultData>;
|
|
47
|
+
/**
|
|
48
|
+
* Creates export context and parameters for a given export configuration
|
|
49
|
+
*/
|
|
50
|
+
buildExportProcessData(config: ExportConfig): ExportProcessData;
|
|
29
51
|
private buildExportParams;
|
|
30
52
|
private buildBaseExportParams;
|
|
31
53
|
private computeProcessRowGroupCallback;
|
|
@@ -50,3 +72,4 @@ export declare class AgGridExportAdapter {
|
|
|
50
72
|
private computeSkipColumnHeaders;
|
|
51
73
|
private computeGetCustomContentBelowRow;
|
|
52
74
|
}
|
|
75
|
+
export {};
|