@adaptabletools/adaptable 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "20.0.0-canary.6",
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 `ReportData` object)
165
+ * Function invoked to return the data (in the form of a `ExportResultData` object)
166
166
  */
167
- onRunReport: () => ReportData;
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
  */
@@ -1,5 +1,5 @@
1
1
  import { AdaptableForm } from '../PredefinedConfig/Common/AdaptableForm';
2
- import { ExportState, Report, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
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, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../../PredefinedConfig/ExportState';
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;
@@ -132,14 +132,6 @@ export class ExportApiImpl extends ApiBase {
132
132
  isExternalReport(report) {
133
133
  return this.getExternalReports()?.find((cr) => cr.name == report.Name) != null;
134
134
  }
135
- runExternalReport(externalReportName) {
136
- const externalReport = this.getExternalReports()?.find((cr) => cr.name == externalReportName);
137
- if (!externalReport) {
138
- this.logWarn(`External Report '${externalReportName}' not found!`);
139
- return undefined;
140
- }
141
- return externalReport.onRunReport();
142
- }
143
135
  isColumnExportable(adaptableColumn) {
144
136
  const isExportableFn = this.getExportOptions().isColumnExportable;
145
137
  if (typeof isExportableFn === 'function') {
@@ -168,6 +160,20 @@ export class ExportApiImpl extends ApiBase {
168
160
  exportReport(reportName, format, destination = 'Download') {
169
161
  let report = this.getReportByName(reportName);
170
162
  if (this.checkItemExists(report, reportName, 'Report')) {
163
+ if (this.isExternalReport(report)) {
164
+ // Handle external report
165
+ this.internalApi
166
+ .getExternalReportData(reportName, format, destination)
167
+ .then((reportData) => {
168
+ if (reportData) {
169
+ this.internalApi.sendReportToDestination(reportData, report, format, destination);
170
+ }
171
+ })
172
+ .catch((error) => {
173
+ this.logWarn(`Failed to get external report data for '${reportName}': ${error}`);
174
+ });
175
+ return;
176
+ }
171
177
  this._adaptable.agGridExportAdapter
172
178
  .exportData({
173
179
  report,
@@ -78,13 +78,14 @@ export class ActionColumnInternalApi extends ApiBase {
78
78
  return { actionButtons, actionColumn };
79
79
  }
80
80
  updateAllActionColumnButtons(actionButtons) {
81
- return actionButtons.map((actionButton) => ({
82
- ...actionButton,
83
- Uuid: createUuid(),
84
- command: actionButton.command == undefined
85
- ? undefined
86
- : this.updateActionButtonCommand(actionButton),
87
- }));
81
+ return actionButtons.map((actionButton) => {
82
+ actionButton = { ...actionButton };
83
+ actionButton.Uuid = createUuid();
84
+ if (actionButton.command) {
85
+ this.updateActionButtonCommand(actionButton);
86
+ }
87
+ return actionButton;
88
+ });
88
89
  }
89
90
  updateActionButtonCommand(button) {
90
91
  switch (button.command) {
@@ -93,7 +94,7 @@ export class ActionColumnInternalApi extends ApiBase {
93
94
  this.getRowFormApi().displayCreateRowForm();
94
95
  };
95
96
  button.tooltip = button.tooltip ? button.tooltip : 'Create Row';
96
- button.icon = {
97
+ button.icon = button.icon ?? {
97
98
  name: 'add',
98
99
  };
99
100
  break;
@@ -102,7 +103,7 @@ export class ActionColumnInternalApi extends ApiBase {
102
103
  this.getRowFormApi().displayCloneRowForm(context.primaryKeyValue);
103
104
  };
104
105
  button.tooltip = button.tooltip ? button.tooltip : 'Clone Row';
105
- button.icon = {
106
+ button.icon = button.icon ?? {
106
107
  name: 'clone',
107
108
  };
108
109
  break;
@@ -117,22 +118,18 @@ export class ActionColumnInternalApi extends ApiBase {
117
118
  this.getRowFormOptions().onRowFormSubmit?.(eventInfo);
118
119
  };
119
120
  button.tooltip = button.tooltip ? button.tooltip : 'Delete Row';
120
- button.icon = button.icon
121
- ? button.icon
122
- : {
123
- name: 'delete',
124
- };
121
+ button.icon = button.icon ?? {
122
+ name: 'delete',
123
+ };
125
124
  break;
126
125
  case 'edit':
127
126
  button.onClick = (button, context) => {
128
127
  this.getRowFormApi().displayEditRowForm(context.primaryKeyValue);
129
128
  };
130
129
  button.tooltip = button.tooltip ? button.tooltip : 'Edit Row';
131
- button.icon = button.icon
132
- ? button.icon
133
- : {
134
- name: 'edit',
135
- };
130
+ button.icon = button.icon ?? {
131
+ name: 'edit',
132
+ };
136
133
  break;
137
134
  }
138
135
  }
@@ -187,7 +187,7 @@ export class AdaptableInternalApi extends ApiBase {
187
187
  if (firstRowNode == undefined) {
188
188
  return {};
189
189
  }
190
- const firstRowData = { ...firstRowNode?.data } ?? {};
190
+ const firstRowData = firstRowNode?.data ? { ...firstRowNode?.data } : {};
191
191
  // handle CalcCols which are not persisted in the rowModel
192
192
  this.getCalculatedColumnApi()
193
193
  .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
  }
@@ -1,15 +1,12 @@
1
- import groupBy from 'lodash/groupBy';
2
1
  import { ApiBase } from '../Implementation/ApiBase';
2
+ import { createGrid, } from 'ag-grid-enterprise';
3
3
  import { createUuid } from '../../PredefinedConfig/Uuid';
4
4
  import { ALL_DATA_REPORT, CURRENT_LAYOUT_REPORT, SELECTED_DATA_REPORT, SYSTEM_EXPORT_DESTINATIONS, SYSTEM_REPORT_NAMES, } from '../../Utilities/Constants/GeneralConstants';
5
- import { ExportModuleId } from '../../Utilities/Constants/ModuleConstants';
6
- import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
7
5
  import StringExtensions from '../../Utilities/Extensions/StringExtensions';
8
6
  import FormatHelper, { DateFormatter } from '../../Utilities/Helpers/FormatHelper';
9
7
  import Helper from '../../Utilities/Helpers/Helper';
10
8
  import * as PopupRedux from '../../Redux/ActionsReducers/PopupRedux';
11
9
  import { SystemExportBegin, SystemExportEnd } from '../../Redux/ActionsReducers/InternalRedux';
12
- import { errorOnce } from '../../agGrid/AdaptableLogger';
13
10
  export class ExportInternalApi extends ApiBase {
14
11
  /**
15
12
  * Value Items for Report Name Selection
@@ -211,7 +208,6 @@ export class ExportInternalApi extends ApiBase {
211
208
  return `[${report.Name}]`;
212
209
  }
213
210
  else {
214
- // FIXME AFL: maybe fihnd a better description?
215
211
  switch (report.ReportRowScope) {
216
212
  case 'AllRows':
217
213
  return '[All Rows]';
@@ -224,138 +220,12 @@ export class ExportInternalApi extends ApiBase {
224
220
  }
225
221
  }
226
222
  }
227
- getReportDataColumns(report, includePrimaryKey = false) {
228
- let reportColumns = [];
229
- let gridColumns = this.getAdaptableApi().columnApi.getExportableColumns();
230
- if (this.getAdaptableApi().exportApi.isExternalReport(report)) {
231
- return reportColumns;
232
- }
233
- // first get the cols depending on the Column Scope
234
- switch (report.ReportColumnScope) {
235
- case 'AllColumns':
236
- reportColumns = gridColumns;
237
- break;
238
- case 'VisibleColumns':
239
- reportColumns = gridColumns.filter((c) => c.visible);
240
- break;
241
- case 'SelectedColumns':
242
- // we extract the selected columns from the grid columns to preserve the grid column order
243
- const selectedColumnIds = this.getAdaptableApi()
244
- .gridApi.getSelectedCellInfo()
245
- .columns.map((column) => column.columnId);
246
- reportColumns = gridColumns.filter((gridColumn) => selectedColumnIds.includes(gridColumn.columnId));
247
- break;
248
- case 'ScopeColumns':
249
- if ('ColumnIds' in report.Scope) {
250
- reportColumns = report.Scope.ColumnIds.map((columnId) => this.getAdaptableApi().columnApi.getColumnWithColumnId(columnId)).filter((c) => c);
251
- }
252
- else {
253
- reportColumns = this.getAdaptableApi().columnScopeApi.getColumnsInScope(report.Scope);
254
- }
255
- break;
256
- }
257
- if (includePrimaryKey) {
258
- const pkColumn = reportColumns.find((column) => column.columnId === this.getAdaptableApi().optionsApi.getPrimaryKey());
259
- // TODO simplify after we fix the IsPrimaryKey bug
260
- // const pkColumn = reportColumns.find(column => column.IsPrimaryKey);
261
- if (!pkColumn && !!this.getAdaptableApi().columnApi.getPrimaryKeyColumn()) {
262
- reportColumns.push(this.getAdaptableApi().columnApi.getPrimaryKeyColumn());
263
- }
264
- }
265
- return reportColumns;
266
- }
267
- getReportDataRows(report, columns, includePrimaryKey) {
268
- if (ArrayExtensions.IsNullOrEmpty(columns)) {
269
- return [];
270
- }
271
- const columnIds = columns.map((column) => column.columnId);
272
- const resultRowData = [];
273
- switch (report.ReportRowScope) {
274
- case 'AllRows':
275
- this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
276
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
277
- });
278
- break;
279
- case 'VisibleRows':
280
- this.getAdaptableInternalApi().forAllVisibleRowNodesDo((rowNode) => {
281
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
282
- });
283
- break;
284
- case 'ExpressionRows':
285
- this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
286
- try {
287
- if (this.getAdaptableApi()
288
- .internalApi.getQueryLanguageService()
289
- .evaluateBooleanExpression(report.Query?.BooleanExpression, ExportModuleId, rowNode)) {
290
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
291
- }
292
- }
293
- catch (error) {
294
- errorOnce(error.message);
295
- }
296
- });
297
- break;
298
- case 'SelectedRows':
299
- // CellSelection
300
- const selectedCellInfo = this.getAdaptableApi().gridApi.getSelectedCellInfo();
301
- const { gridCells: GridCells } = selectedCellInfo;
302
- let selectedCellsByPrimaryKey = groupBy(GridCells, 'primaryKeyValue');
303
- // we iterate over all visibleRowNodes to preserve the current order
304
- this.getAdaptableInternalApi().forAllVisibleRowNodesDo((rowNode) => {
305
- const rowPrimaryKeyValue = this.getAdaptableApi().gridApi.getPrimaryKeyValueForRowNode(rowNode);
306
- const selectedRowCells = selectedCellsByPrimaryKey[rowPrimaryKeyValue];
307
- if (selectedRowCells) {
308
- const selectedRowColumnIds = selectedRowCells.map((rowCell) => rowCell.column.columnId);
309
- const selectedColumnIds = columnIds.filter((columnId) => selectedRowColumnIds.includes(columnId));
310
- const row = this.getRowObjectForColumnIds(rowNode, selectedColumnIds, report.Name);
311
- if (includePrimaryKey) {
312
- row[this.getAdaptableApi().optionsApi.getPrimaryKey()] = rowPrimaryKeyValue;
313
- }
314
- resultRowData.push(row);
315
- }
316
- });
317
- // Row Selection
318
- const selectedRowInfo = this.getAdaptableApi().gridApi.getSelectedRowInfo();
319
- const selectedGridRowPrimaryKeys = selectedRowInfo?.gridRows
320
- ?.filter((gr) => gr.rowInfo.isGroup == false)
321
- .map((gridRow) => gridRow.primaryKeyValue) ?? [];
322
- if (selectedGridRowPrimaryKeys.length) {
323
- this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
324
- const rowPrimaryKeyValue = this.getAdaptableApi().gridApi.getPrimaryKeyValueForRowNode(rowNode);
325
- if (selectedGridRowPrimaryKeys.includes(rowPrimaryKeyValue)) {
326
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
327
- }
328
- });
329
- }
330
- break;
331
- }
332
- return resultRowData;
333
- }
334
- getReportData(report, includePrimaryKey = false) {
335
- if (this.getAdaptableApi().exportApi.isExternalReport(report)) {
336
- return this.getAdaptableApi().exportApi.runExternalReport(report.Name);
337
- }
338
- const columns = this.getReportDataColumns(report, includePrimaryKey);
339
- const rows = this.getReportDataRows(report, columns, includePrimaryKey);
340
- return { columns, rows };
341
- }
342
- getReportDataAsArray(report, includePrimaryKey = false) {
343
- const reportData = this.getReportData(report, includePrimaryKey);
344
- return this.convertReportDataToArray(reportData);
345
- }
346
223
  convertReportDataToArray(reportData) {
347
224
  return [
348
225
  reportData.columns.map((column) => column.friendlyName),
349
- ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.columnId])),
226
+ ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.field ?? column.columnId])),
350
227
  ];
351
228
  }
352
- getRowObjectForColumnIds(rowNode, columnIds, reportName) {
353
- return columnIds.reduce((result, columnId) => {
354
- // FIXME AFL if this method remains, 'false' should be replaced with dynamic value
355
- result[columnId] = this.getCellExportValueFromRowNode(rowNode, columnId, false);
356
- return result;
357
- }, {});
358
- }
359
229
  publishLiveLiveDataChangedEvent(reportDestination, liveDataTrigger, liveReport) {
360
230
  const liveDataChangedInfo = {
361
231
  ...this.getAdaptableInternalApi().buildBaseContext(),
@@ -429,9 +299,8 @@ export class ExportInternalApi extends ApiBase {
429
299
  this.sendReportToCustomDestination(reportResult, report, format, destination);
430
300
  }
431
301
  if (destination === 'Download') {
432
- if (format === 'Excel' || format === 'VisualExcel') {
433
- this.logWarn(`Download of Excel files should already be handed by internal APIs, something went wrong`);
434
- return;
302
+ if (reportResult.type === 'excel') {
303
+ Helper.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
435
304
  }
436
305
  if (reportResult.type === 'csv') {
437
306
  Helper.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'text/csv;encoding:utf-8');
@@ -490,4 +359,104 @@ export class ExportInternalApi extends ApiBase {
490
359
  exportDestination,
491
360
  };
492
361
  }
362
+ createCellCsv(cellContent) {
363
+ return {
364
+ data: {
365
+ value: cellContent != undefined ? String(cellContent) : null,
366
+ },
367
+ };
368
+ }
369
+ createCellExcel(cellContent, cellType) {
370
+ return {
371
+ data: {
372
+ value: cellContent != undefined ? String(cellContent) : null,
373
+ type: cellType,
374
+ },
375
+ };
376
+ }
377
+ createCellHeader(cellContent) {
378
+ return {
379
+ data: {
380
+ value: cellContent != undefined ? String(cellContent) : null,
381
+ type: 'String',
382
+ },
383
+ };
384
+ }
385
+ getExternalReportData(externalReportName, reportFormat, exportDestination) {
386
+ const externalReport = this.getExportApi()
387
+ .getExternalReports()
388
+ ?.find((cr) => cr.name == externalReportName);
389
+ if (!externalReport) {
390
+ this.logWarn(`External Report '${externalReportName}' not found!`);
391
+ return undefined;
392
+ }
393
+ return externalReport.onExport({
394
+ ...this.buildBaseExportContext(externalReportName, reportFormat, exportDestination),
395
+ convertToExcel: this.buildExcelConverter(externalReportName, reportFormat, exportDestination),
396
+ convertToCsv: this.buildCsvConverter(externalReportName, reportFormat, exportDestination),
397
+ getGridReportColumns: this.buildGridReportColumns(),
398
+ });
399
+ }
400
+ buildGridReportColumns() {
401
+ return () => this.getAdaptableApi().columnApi.getColumns();
402
+ }
403
+ buildExcelConverter(externalReportName, reportFormat, exportDestination) {
404
+ return (reportData) => {
405
+ return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsExcel({ ...exportParams }));
406
+ };
407
+ }
408
+ buildCsvConverter(externalReportName, reportFormat, exportDestination) {
409
+ return (reportData) => {
410
+ const csvParams = this.buildCsvExportParams(externalReportName, reportFormat, exportDestination);
411
+ return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsCsv({ ...exportParams, ...csvParams }));
412
+ };
413
+ }
414
+ executeGridExport(reportData, externalReportName, reportFormat, exportDestination, exportFn) {
415
+ const htmlDivElement = document.createElement('div');
416
+ let ephemeralGridApi = null;
417
+ try {
418
+ const columnDefs = reportData.columns.map((col) => ({
419
+ colId: col.columnId,
420
+ field: col.field ?? col.columnId,
421
+ headerName: col.friendlyName ?? col.columnId,
422
+ type: col.dataType ?? 'text',
423
+ }));
424
+ const gridOptions = { columnDefs, rowData: reportData.rows };
425
+ const gridParams = {
426
+ modules: this.getAdaptableApi()
427
+ .internalApi.getAdaptableInstance()
428
+ .getAgGridRegisteredModules(),
429
+ };
430
+ htmlDivElement.style.display = 'none';
431
+ document.body.appendChild(htmlDivElement);
432
+ ephemeralGridApi = createGrid(htmlDivElement, gridOptions, gridParams);
433
+ const exportParams = {
434
+ fileName: this.getReportFileName(externalReportName, reportFormat, exportDestination),
435
+ allColumns: true,
436
+ exportedRows: 'all',
437
+ };
438
+ return exportFn(ephemeralGridApi, exportParams);
439
+ }
440
+ catch (error) {
441
+ this.logWarn('Failed to export data:', error);
442
+ return null;
443
+ }
444
+ finally {
445
+ if (ephemeralGridApi) {
446
+ ephemeralGridApi.destroy();
447
+ }
448
+ if (htmlDivElement?.parentNode) {
449
+ document.body.removeChild(htmlDivElement);
450
+ }
451
+ }
452
+ }
453
+ buildCsvExportParams(externalReportName, reportFormat, exportDestination) {
454
+ const exportOptions = this.getAdaptableApi().optionsApi.getExportOptions();
455
+ const csvSeparator = typeof exportOptions.csvSeparator === 'function'
456
+ ? exportOptions.csvSeparator(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination))
457
+ : exportOptions.csvSeparator;
458
+ return {
459
+ columnSeparator: csvSeparator,
460
+ };
461
+ }
493
462
  }
@@ -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: AdaptableColumnBase[];
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
  */
@@ -660,7 +660,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
660
660
  }
661
661
  return ret;
662
662
  }
663
- case InternalRedux.HIGHLIGHT_CELL_DELETE_ALL: {
663
+ case InternalRedux.HIGHLIGHT_ROW_DELETE_ALL: {
664
664
  const rowHighlightInfos = middlewareAPI.getState().Internal.RowHighlightInfo;
665
665
  const ret = next(action);
666
666
  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 {};