@adaptabletools/adaptable 15.2.0-canary.1 → 15.2.0-canary.2

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": "15.2.0-canary.1",
3
+ "version": "15.2.0-canary.2",
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,2 +1,2 @@
1
- declare const _default: 1680766462195;
1
+ declare const _default: 1680846291184;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1680766462195;
3
+ exports.default = 1680846291184;
@@ -196,8 +196,14 @@ export interface IAdaptable {
196
196
  includeGroupRows?: boolean;
197
197
  filterFn?: (rowNode: IRowNode) => boolean;
198
198
  }): void;
199
- forAllVisibleRowNodesDo(func: (rowNode: IRowNode) => void): void;
200
- getVisibleRowNodes(): IRowNode[];
199
+ forAllVisibleRowNodesDo(func: (rowNode: IRowNode, rowIndex: number) => void, config?: {
200
+ includeGroupRows?: boolean;
201
+ filterFn?: (rowNode: IRowNode) => boolean;
202
+ }): void;
203
+ getVisibleRowNodes(config?: {
204
+ includeGroupRows?: boolean;
205
+ filterFn?: (rowNode: IRowNode) => boolean;
206
+ }): IRowNode[];
201
207
  getAllRowNodes(config?: {
202
208
  includeGroupRows?: boolean;
203
209
  filterFn?: (rowNode: IRowNode) => boolean;
@@ -57,6 +57,33 @@ export interface ExportOptions {
57
57
  * @defaultValue true
58
58
  */
59
59
  isColumnExportable?: (exportableColumnContext: ExportableColumnContext) => boolean;
60
+ /**
61
+ * Function invoked when a Report is run, enabling you to preload the data before it is exported.
62
+ * If the function returns a `ReportData` object, that will be used as the data for the Report;
63
+ * if it returns `TRUE`, the Report will be run as normal, using the data from the grid;
64
+ * if it returns `FALSE`, the Report will be cancelled.
65
+ */
66
+ preProcessExport?: (context: PreProcessExportContext) => boolean | Promise<ReportData | boolean>;
67
+ }
68
+ /**
69
+ * Context provided to `ExportOptions.processExport()` callback
70
+ */
71
+ export interface PreProcessExportContext extends BaseContext {
72
+ /**
73
+ * The report to be exported
74
+ */
75
+ report: Report;
76
+ /**
77
+ * Returns the columns which would be included in the report based on the `Report.ReportColumnScope`
78
+ * @param includePrimaryKey - whether to include the primary key column (defaults to `false`)
79
+ */
80
+ getReportColumns: (includePrimaryKey?: boolean) => AdaptableColumnBase[];
81
+ /**
82
+ * Returns the row data which would be included in the report based on the `Report.ReportRowScope`
83
+ * @param reportColumns - the columns to include in the report
84
+ * @param includePrimaryKey - whether to include the primary key column (defaults to `false`)
85
+ */
86
+ getReportRowData: (reportColumns: AdaptableColumnBase[], includePrimaryKey?: boolean) => Record<string, any>[];
60
87
  }
61
88
  /**
62
89
  * Format of exported Data - 'rawValue' or 'formattedValue'
@@ -211,8 +211,12 @@ export interface GridApi {
211
211
  getFirstDisplayedRowNode(): IRowNode | undefined;
212
212
  /**
213
213
  * Retrieves all filtered Row Nodes currently in the Grid (i.e. after applying the current filter)
214
+ * @param config - configuration
214
215
  */
215
- getVisibleRowNodes(): IRowNode[];
216
+ getVisibleRowNodes(config?: {
217
+ includeGroupRows?: boolean;
218
+ filterFn?: (rowNode: IRowNode) => boolean;
219
+ }): IRowNode[];
216
220
  /**
217
221
  * Retrieves all Row Nodes currently in the Grid (by default excluding the group rows)
218
222
  * @param config - configuration
@@ -101,4 +101,6 @@ export declare class AdaptableApiImpl implements AdaptableApi {
101
101
  logSuccess(message: string, ...optionalParams: any[]): void;
102
102
  logWarn(message: string, ...optionalParams: any[]): void;
103
103
  logError(message: string, ...optionalParams: any[]): void;
104
+ consoleError(message: string, ...optionalParams: any[]): void;
105
+ consoleWarn(message: string, ...optionalParams: any[]): void;
104
106
  }
@@ -161,5 +161,11 @@ class AdaptableApiImpl {
161
161
  logError(message, ...optionalParams) {
162
162
  this.adaptable.logger.error(message, optionalParams);
163
163
  }
164
+ consoleError(message, ...optionalParams) {
165
+ this.adaptable.logger.consoleError(message, optionalParams);
166
+ }
167
+ consoleWarn(message, ...optionalParams) {
168
+ this.adaptable.logger.consoleWarn(message, optionalParams);
169
+ }
164
170
  }
165
171
  exports.AdaptableApiImpl = AdaptableApiImpl;
@@ -70,7 +70,10 @@ export declare class GridApiImpl extends ApiBase implements GridApi {
70
70
  selectColumns(columnIds: string[]): void;
71
71
  getFirstRowNode(): IRowNode;
72
72
  getFirstDisplayedRowNode(): IRowNode;
73
- getVisibleRowNodes(): IRowNode[];
73
+ getVisibleRowNodes(config?: {
74
+ includeGroupRows?: boolean;
75
+ filterFn?: (rowNode: IRowNode) => boolean;
76
+ }): IRowNode[];
74
77
  getAllRowNodes(config?: {
75
78
  includeGroupRows?: boolean;
76
79
  filterFn?: (rowNode: IRowNode) => boolean;
@@ -262,7 +262,7 @@ class GridApiImpl extends ApiBase_1.ApiBase {
262
262
  getFirstDisplayedRowNode() {
263
263
  return this.adaptable.getFirstDisplayedRowNode();
264
264
  }
265
- getVisibleRowNodes() {
265
+ getVisibleRowNodes(config) {
266
266
  return this.adaptable.getVisibleRowNodes();
267
267
  }
268
268
  getAllRowNodes(config) {
@@ -77,8 +77,14 @@ export declare class AdaptableInternalApi extends ApiBase {
77
77
  getRowEditService(): IRowEditService;
78
78
  getModules(): IModuleCollection;
79
79
  getModuleFriendlyName(adaptableModule: AdaptableModule): string;
80
- forAllRowNodesDo(func: (rowNode: IRowNode) => void): void;
81
- forAllVisibleRowNodesDo(func: (rowNode: IRowNode) => void): void;
80
+ forAllRowNodesDo(func: (rowNode: IRowNode) => void, config?: {
81
+ includeGroupRows?: boolean;
82
+ filterFn?: (rowNode: IRowNode) => boolean;
83
+ }): void;
84
+ forAllVisibleRowNodesDo(func: (rowNode: IRowNode) => void, config?: {
85
+ includeGroupRows?: boolean;
86
+ filterFn?: (rowNode: IRowNode) => boolean;
87
+ }): void;
82
88
  getLabelForButton(button: AdaptableButton<BaseContext>, context: BaseContext): string | undefined;
83
89
  getTooltipForButton(button: AdaptableButton<BaseContext>, context: BaseContext): string | undefined;
84
90
  getStyleForButton(button: AdaptableButton<BaseContext>, context: BaseContext): ButtonStyle | undefined;
@@ -143,11 +143,11 @@ class AdaptableInternalApi extends ApiBase_1.ApiBase {
143
143
  var _a, _b;
144
144
  return ((_b = (_a = this.adaptable.ModuleService.getModuleInfoByModule(adaptableModule)) === null || _a === void 0 ? void 0 : _a.FriendlyName) !== null && _b !== void 0 ? _b : adaptableModule);
145
145
  }
146
- forAllRowNodesDo(func) {
147
- this.adaptable.forAllRowNodesDo(func);
146
+ forAllRowNodesDo(func, config) {
147
+ this.adaptable.forAllRowNodesDo(func, config);
148
148
  }
149
- forAllVisibleRowNodesDo(func) {
150
- this.adaptable.forAllVisibleRowNodesDo(func);
149
+ forAllVisibleRowNodesDo(func, config) {
150
+ this.adaptable.forAllVisibleRowNodesDo(func, config);
151
151
  }
152
152
  getLabelForButton(button, context) {
153
153
  if (!button.label) {
@@ -74,7 +74,7 @@ export interface ReportData {
74
74
  */
75
75
  columns: AdaptableColumnBase[];
76
76
  /**
77
- * Rows in the Report
77
+ * Row Data in the Report
78
78
  */
79
79
  rows: Record<string, any>[];
80
80
  }
@@ -13,7 +13,8 @@ export declare class ExportModule extends AdaptableModuleBase implements IExport
13
13
  getExplicitlyReferencedColumnIds(report: Report): string[];
14
14
  getReferencedNamedQueryNames(report: Report): string[];
15
15
  addContextMenuItems(menuContext: ContextMenuContext): AdaptableMenuItem[] | undefined;
16
- export(report: Report, exportDestination: ExportDestination | string): void;
16
+ export(report: Report, exportDestination: ExportDestination | string): Promise<void>;
17
+ private preProcessExport;
17
18
  private isCustomDestination;
18
19
  private convertReportToJSON;
19
20
  private openReportInTablePopup;
@@ -21,6 +21,7 @@ const ExportSelector_1 = require("../View/Export/ExportSelector");
21
21
  const SystemRedux_1 = require("../Redux/ActionsReducers/SystemRedux");
22
22
  const windowFactory_1 = require("../View/Components/Popups/WindowPopups/windowFactory");
23
23
  const Uuid_1 = require("../PredefinedConfig/Uuid");
24
+ const waitForTimeout_1 = require("../Utilities/waitForTimeout");
24
25
  class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
25
26
  constructor(api) {
26
27
  super(ModuleConstants.ExportModuleId, ModuleConstants.ExportFriendlyName, 'export-data', 'ExportPopup', 'Export data from the Grid to numerous locations in numerous formatso', api);
@@ -70,12 +71,46 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
70
71
  },
71
72
  ];
72
73
  }
73
- export(report, exportDestination) {
74
+ async export(report, exportDestination) {
75
+ var _a;
76
+ const cleanupExportProcess = () => {
77
+ this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemVisualExportEnd)());
78
+ this.api.internalApi.hideProgressIndicator();
79
+ };
74
80
  if (report.Name === GeneralConstants_1.VISUAL_DATA_REPORT) {
75
81
  this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemVisualExportBegin)());
76
82
  }
77
- this.api.internalApi.executeWithProgressIndicator(`${report.Name} Export in progress...`, () => {
78
- var _a;
83
+ this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemProgressIndicatorShow)(`${report.Name} Export in progress...`));
84
+ try {
85
+ // waitForTimeout required to give the ProgressIndicator rendering a head-start (see rAF in ProgressIndicator implementation)
86
+ await (0, waitForTimeout_1.waitForTimeout)(16);
87
+ if (report.Name === GeneralConstants_1.VISUAL_DATA_REPORT) {
88
+ this.api.logInfo(`Export ${report.Name} (${exportDestination})`);
89
+ this.api.exportApi.exportVisualDataToExcel();
90
+ // WYSIWYG is fully delegated to the AG Grid excel export, so we don't need to do anything else
91
+ cleanupExportProcess();
92
+ return;
93
+ }
94
+ const preProcessedExport = await this.preProcessExport(report);
95
+ let reportData;
96
+ if (preProcessedExport === false) {
97
+ this.api.logInfo(`Export ${report.Name} (${exportDestination}) cancelled by preProcessExport()`);
98
+ cleanupExportProcess();
99
+ return;
100
+ }
101
+ else if (preProcessedExport === true) {
102
+ this.api.logInfo(`Export ${report.Name} (${exportDestination}) using data from the grid`);
103
+ reportData = this.api.internalApi.getReportService().getReportData(report);
104
+ }
105
+ else if ((preProcessedExport === null || preProcessedExport === void 0 ? void 0 : preProcessedExport.rows) == undefined ||
106
+ (preProcessedExport === null || preProcessedExport === void 0 ? void 0 : preProcessedExport.columns) == undefined) {
107
+ this.api.logWarn(`Export ${report.Name} (${exportDestination}) : preProcessExport() returned an invalid ReportData object, fallback to data from the grid`);
108
+ reportData = this.api.internalApi.getReportService().getReportData(report);
109
+ }
110
+ else {
111
+ this.api.logInfo(`Export ${report.Name} (${exportDestination}) using data from preProcessExport()`);
112
+ reportData = preProcessedExport;
113
+ }
79
114
  if (this.isCustomDestination(exportDestination)) {
80
115
  const customDestination = (_a = this.api.optionsApi
81
116
  .getAdaptableOptions()
@@ -90,7 +125,8 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
90
125
  return new Promise((resolve) => {
91
126
  setTimeout(() => {
92
127
  const preparedContext = Object.assign(Object.assign({}, context), { report,
93
- customDestination, reportData: this.api.internalApi.getReportService().getReportData(report) });
128
+ customDestination,
129
+ reportData });
94
130
  resolve(preparedContext);
95
131
  }, 20);
96
132
  });
@@ -100,7 +136,7 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
100
136
  else if (customDestination) {
101
137
  const reportContext = {
102
138
  report: report,
103
- reportData: this.api.internalApi.getReportService().getReportData(report),
139
+ reportData,
104
140
  adaptableApi: this.api,
105
141
  };
106
142
  customDestination.onExport(reportContext);
@@ -109,33 +145,49 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
109
145
  else {
110
146
  switch (exportDestination) {
111
147
  case Enums_1.ExportDestination.Excel:
112
- if (report.Name === GeneralConstants_1.VISUAL_DATA_REPORT) {
113
- // WYSIWYG is fully delegated to the AG Grid excel export
114
- this.api.exportApi.exportVisualDataToExcel();
115
- }
116
- else {
117
- this.convertReportToExcel(report);
118
- }
148
+ this.convertReportToExcel(report, reportData);
119
149
  break;
120
150
  case Enums_1.ExportDestination.Clipboard:
121
- this.copyToClipboard(report);
151
+ this.copyToClipboard(report, reportData);
122
152
  break;
123
153
  case Enums_1.ExportDestination.CSV:
124
- this.convertReportToCsv(report);
154
+ this.convertReportToCsv(report, reportData);
125
155
  break;
126
156
  case Enums_1.ExportDestination.JSON:
127
- this.convertReportToJSON(report);
157
+ this.convertReportToJSON(report, reportData);
128
158
  break;
129
159
  case Enums_1.ExportDestination.Table:
130
- this.openReportInTablePopup(report);
160
+ this.openReportInTablePopup(report, reportData);
131
161
  break;
132
162
  }
133
163
  }
134
- this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemVisualExportEnd)());
135
- this.api.internalApi.hideProgressIndicator();
136
- }, () => {
137
- this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemVisualExportEnd)());
138
- });
164
+ cleanupExportProcess();
165
+ }
166
+ catch (e) {
167
+ this.api.consoleError(`Error while exporting ${report.Name}}`, e);
168
+ cleanupExportProcess();
169
+ }
170
+ }
171
+ async preProcessExport(report) {
172
+ const preProcessExportFn = this.api.optionsApi.getAdaptableOptions().exportOptions.preProcessExport;
173
+ if (preProcessExportFn) {
174
+ this.api.logInfo(`Export ${report.Name} : preProcessExport()`);
175
+ return preProcessExportFn({
176
+ report,
177
+ adaptableApi: this.api,
178
+ getReportColumns: (includePrimaryKey) => {
179
+ return this.api.internalApi
180
+ .getReportService()
181
+ .getReportDataColumns(report, includePrimaryKey);
182
+ },
183
+ getReportRowData: (reportColumns, includePrimaryKey) => {
184
+ return this.api.internalApi
185
+ .getReportService()
186
+ .getReportDataRows(report, reportColumns, includePrimaryKey);
187
+ },
188
+ });
189
+ }
190
+ return true;
139
191
  }
140
192
  isCustomDestination(exportDestination) {
141
193
  if (Object.values(Enums_1.ExportDestination).some((val) => val === exportDestination)) {
@@ -143,8 +195,7 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
143
195
  }
144
196
  return this.api.exportApi.isExportDestinationCustom(exportDestination);
145
197
  }
146
- convertReportToJSON(report) {
147
- const reportData = this.api.internalApi.getReportService().getReportData(report);
198
+ convertReportToJSON(report, reportData) {
148
199
  if (this.isEmptyReportData(reportData)) {
149
200
  this.showEmptyExportWarning();
150
201
  return;
@@ -153,8 +204,7 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
153
204
  const jsonFileName = this.api.internalApi.getReportService().getReportFileName(report.Name) + '.json';
154
205
  Helper_1.Helper.createDownloadedFile(jsonContent, jsonFileName, 'application/json');
155
206
  }
156
- openReportInTablePopup(report) {
157
- const reportData = this.api.internalApi.getReportService().getReportData(report, true);
207
+ openReportInTablePopup(report, reportData) {
158
208
  if (this.isEmptyReportData(reportData)) {
159
209
  this.showEmptyExportWarning();
160
210
  return;
@@ -191,7 +241,7 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
191
241
  popupProps,
192
242
  });
193
243
  }
194
- convertReportToCsv(report) {
244
+ convertReportToCsv(report, reportData) {
195
245
  const csvContent = this.createCSVContent(report);
196
246
  if (StringExtensions_1.default.IsNullOrEmpty(csvContent)) {
197
247
  this.showEmptyExportWarning();
@@ -200,15 +250,14 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
200
250
  const csvFileName = this.api.internalApi.getReportService().getReportFileName(report.Name) + '.csv';
201
251
  Helper_1.Helper.createDownloadedFile(csvContent, csvFileName, 'text/csv;encoding:utf-8');
202
252
  }
203
- convertReportToExcel(report) {
204
- const reportData = this.api.internalApi.getReportService().getReportData(report);
253
+ convertReportToExcel(report, reportData) {
205
254
  if (this.isEmptyReportData(reportData)) {
206
255
  this.showEmptyExportWarning();
207
256
  return;
208
257
  }
209
258
  this.api.exportApi.exportDataToExcel(reportData, this.api.internalApi.getReportService().getReportFileName(report.Name));
210
259
  }
211
- copyToClipboard(report) {
260
+ copyToClipboard(report, reportData) {
212
261
  const csvContent = this.createTabularContent(report);
213
262
  if (StringExtensions_1.default.IsNullOrEmpty(csvContent)) {
214
263
  this.showEmptyExportWarning();
@@ -1,5 +1,5 @@
1
1
  import { Report, ReportData, SystemReportName } from '../../../PredefinedConfig/ExportState';
2
- import { AdaptableColumn } from '../../../PredefinedConfig/Common/AdaptableColumn';
2
+ import { AdaptableColumn, AdaptableColumnBase } from '../../../PredefinedConfig/Common/AdaptableColumn';
3
3
  import { IAdaptableService } from './IAdaptableService';
4
4
  import { ExcelStyle, IRowNode } from '@ag-grid-community/core';
5
5
  import { SystemExportDestination } from '../../../types';
@@ -17,10 +17,12 @@ export interface IReportService extends IAdaptableService {
17
17
  GetReportColumnScopeShortDescription(report: Report): string[];
18
18
  GetReportColumnScopeLongDescription(report: Report): string;
19
19
  GetReportExpressionDescription(Report: Report, cols: AdaptableColumn[]): string;
20
- GetReportColumnsForReport(report: Report): AdaptableColumn[];
21
20
  PublishLiveLiveDataChangedEvent(reportDestination: 'OpenFin' | 'ipushpull' | 'Glue42', liveDataChangedTrigger: 'Connected' | 'Disconnected' | 'SnapshotSent' | 'LiveDataStarted' | 'LiveDataStopped' | 'LiveDataUpdated', liveReport?: any): void;
21
+ getReportDataColumns(report: Report, includePrimaryKey?: boolean): AdaptableColumnBase[];
22
+ getReportDataRows(report: Report, columns: AdaptableColumnBase[], includePrimaryKey?: boolean): Record<string, any>[];
22
23
  getReportData(report: Report, includePrimaryKey?: boolean): ReportData;
23
24
  getReportDataAsArray(report: Report, includePrimaryKey?: boolean): any[][];
25
+ getReportDataColumns(report: Report, includePrimaryKey?: boolean): AdaptableColumnBase[];
24
26
  convertReportDataToArray(reportData: ReportData): any[][];
25
27
  getCellExportValueFromRowNode(rowNode: IRowNode, columnId: string): any;
26
28
  getCellExportValueFromRawValue(rowNode: IRowNode, rawValue: any, columnId: string): any;
@@ -1,4 +1,4 @@
1
- import { AdaptableColumn } from '../../PredefinedConfig/Common/AdaptableColumn';
1
+ import { AdaptableColumn, AdaptableColumnBase } from '../../PredefinedConfig/Common/AdaptableColumn';
2
2
  import { Report, ReportData, SystemReportName } from '../../PredefinedConfig/ExportState';
3
3
  import { IReportService } from './Interface/IReportService';
4
4
  import { ExcelStyle, IRowNode } from '@ag-grid-community/core';
@@ -23,7 +23,8 @@ export declare class ReportService implements IReportService {
23
23
  GetReportColumnScopeShortDescription(report: Report): string[];
24
24
  GetReportColumnScopeLongDescription(report: Report): string;
25
25
  GetReportExpressionDescription(report: Report, cols: AdaptableColumn[]): string;
26
- GetReportColumnsForReport(report: Report, includePrimaryKey?: boolean): AdaptableColumn[];
26
+ getReportDataColumns(report: Report, includePrimaryKey?: boolean): AdaptableColumnBase[];
27
+ getReportDataRows(report: Report, columns: AdaptableColumnBase[], includePrimaryKey?: boolean): Record<string, any>[];
27
28
  getReportData(report: Report, includePrimaryKey?: boolean): ReportData;
28
29
  getReportDataAsArray(report: Report, includePrimaryKey?: boolean): any[][];
29
30
  convertReportDataToArray(reportData: ReportData): any[][];
@@ -186,7 +186,7 @@ class ReportService {
186
186
  }
187
187
  }
188
188
  }
189
- GetReportColumnsForReport(report, includePrimaryKey = false) {
189
+ getReportDataColumns(report, includePrimaryKey = false) {
190
190
  let reportColumns = [];
191
191
  let gridColumns = this.adaptableApi.columnApi.getExportableColumns();
192
192
  if (this.adaptableApi.exportApi.isServerReport(report)) {
@@ -224,38 +224,28 @@ class ReportService {
224
224
  reportColumns.push(this.adaptableApi.columnApi.getPrimaryKeyColumn());
225
225
  }
226
226
  }
227
- return reportColumns;
228
- }
229
- getReportData(report, includePrimaryKey = false) {
230
- var _a, _b;
231
- const columns = this.GetReportColumnsForReport(report, includePrimaryKey).map((column) => ({
227
+ return reportColumns.map((column) => ({
232
228
  columnId: column.columnId,
233
229
  friendlyName: column.friendlyName,
234
230
  dataType: column.dataType,
235
231
  }));
236
- if (this.adaptableApi.exportApi.isServerReport(report)) {
237
- return this.adaptableApi.exportApi.runServerReport(report.Name);
238
- }
232
+ }
233
+ getReportDataRows(report, columns, includePrimaryKey) {
234
+ var _a, _b;
239
235
  if (ArrayExtensions_1.default.IsNullOrEmpty(columns)) {
240
- return { columns: [], rows: [] };
236
+ return [];
241
237
  }
242
- const data = { columns, rows: [] };
243
238
  const columnIds = columns.map((column) => column.columnId);
239
+ const resultRowData = [];
244
240
  switch (report.ReportRowScope) {
245
241
  case 'AllRows':
246
242
  this.adaptableApi.internalApi.forAllRowNodesDo((rowNode) => {
247
- // skip row groups
248
- if (!rowNode.group) {
249
- data.rows.push(this.getRowObjectForColumnIds(rowNode, columnIds));
250
- }
243
+ resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds));
251
244
  });
252
245
  break;
253
246
  case 'VisibleRows':
254
247
  this.adaptableApi.internalApi.forAllVisibleRowNodesDo((rowNode) => {
255
- // skip row groups
256
- if (!rowNode.group) {
257
- data.rows.push(this.getRowObjectForColumnIds(rowNode, columnIds));
258
- }
248
+ resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds));
259
249
  });
260
250
  break;
261
251
  case 'ExpressionRows':
@@ -264,7 +254,7 @@ class ReportService {
264
254
  if (this.adaptableApi.internalApi
265
255
  .getQueryLanguageService()
266
256
  .evaluateBooleanExpression((_a = report.Query) === null || _a === void 0 ? void 0 : _a.BooleanExpression, ModuleConstants_1.ExportModuleId, rowNode)) {
267
- data.rows.push(this.getRowObjectForColumnIds(rowNode, columnIds));
257
+ resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds));
268
258
  }
269
259
  });
270
260
  break;
@@ -283,7 +273,7 @@ class ReportService {
283
273
  if (includePrimaryKey) {
284
274
  row[this.adaptableApi.optionsApi.getPrimaryKey()] = rowPrimaryKeyValue;
285
275
  }
286
- data.rows.push(row);
276
+ resultRowData.push(row);
287
277
  }
288
278
  });
289
279
  break;
@@ -294,13 +284,21 @@ class ReportService {
294
284
  this.adaptableApi.internalApi.forAllRowNodesDo((rowNode) => {
295
285
  const rowPrimaryKeyValue = this.adaptableApi.gridApi.getPrimaryKeyValueForRowNode(rowNode);
296
286
  if (selectedGridRowPrimaryKeys.includes(rowPrimaryKeyValue)) {
297
- data.rows.push(this.getRowObjectForColumnIds(rowNode, columnIds));
287
+ resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds));
298
288
  }
299
289
  });
300
290
  }
301
291
  break;
302
292
  }
303
- return data;
293
+ return resultRowData;
294
+ }
295
+ getReportData(report, includePrimaryKey = false) {
296
+ if (this.adaptableApi.exportApi.isServerReport(report)) {
297
+ return this.adaptableApi.exportApi.runServerReport(report.Name);
298
+ }
299
+ const columns = this.getReportDataColumns(report, includePrimaryKey);
300
+ const rows = this.getReportDataRows(report, columns, includePrimaryKey);
301
+ return { columns, rows };
304
302
  }
305
303
  getReportDataAsArray(report, includePrimaryKey = false) {
306
304
  const reportData = this.getReportData(report, includePrimaryKey);
@@ -0,0 +1 @@
1
+ export declare function waitForTimeout(ms: number): Promise<void>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitForTimeout = void 0;
4
+ // waits for the given ms milliseconds
5
+ function waitForTimeout(ms) {
6
+ return new Promise((resolve) => {
7
+ setTimeout(() => {
8
+ resolve();
9
+ }, ms);
10
+ });
11
+ }
12
+ exports.waitForTimeout = waitForTimeout;
@@ -15,18 +15,17 @@ const tableDOMProps = {
15
15
  const ExportTablePopup = (props) => {
16
16
  const adaptable = (0, AdaptableContext_1.useAdaptable)();
17
17
  const adaptableApi = adaptable.api;
18
- const primaryKey = adaptableApi.optionsApi.getPrimaryKey();
18
+ const primaryKey = '_rowIndex';
19
19
  const { reportData, } = props.popupProps;
20
- const data = reportData.rows;
20
+ const data = reportData.rows.map((row, index) => (Object.assign(Object.assign({}, row), { [primaryKey]: index + 1 })));
21
21
  const columns = React.useMemo(() => {
22
- const getFriendlyName = (columnId) => adaptableApi.columnApi.getFriendlyNameForColumnId(columnId);
23
22
  const columns = {
24
- [primaryKey]: { field: primaryKey, header: getFriendlyName(primaryKey) },
23
+ [primaryKey]: { field: primaryKey, header: 'Index' },
25
24
  };
26
25
  for (let column of reportData.columns) {
27
26
  columns[column.columnId] = {
28
27
  field: column.columnId,
29
- header: getFriendlyName(column.columnId),
28
+ header: column.friendlyName,
30
29
  dataType: column.dataType,
31
30
  };
32
31
  if (column.dataType === 'Date') {
@@ -49,6 +48,9 @@ const ExportTablePopup = (props) => {
49
48
  }
50
49
  return columns;
51
50
  }, [props.popupProps]);
51
+ const columnOrder = React.useMemo(() => {
52
+ return Object.keys(columns);
53
+ }, [columns]);
52
54
  return (React.createElement(InfiniteTable_1.DataSource, { data: data, primaryKey: primaryKey },
53
55
  React.createElement(InfiniteTable_1.InfiniteTable, { columnTypes: {
54
56
  default: {
@@ -223,8 +223,14 @@ export declare class Adaptable implements IAdaptable {
223
223
  includeGroupRows?: boolean;
224
224
  filterFn?: (rowNode: IRowNode) => boolean;
225
225
  }): void;
226
- forAllVisibleRowNodesDo(func: (rowNode: IRowNode, rowIndex: number) => void): void;
227
- getVisibleRowNodes(): IRowNode[];
226
+ forAllVisibleRowNodesDo(func: (rowNode: IRowNode, rowIndex: number) => void, config?: {
227
+ includeGroupRows?: boolean;
228
+ filterFn?: (rowNode: IRowNode) => boolean;
229
+ }): void;
230
+ getVisibleRowNodes(config?: {
231
+ includeGroupRows?: boolean;
232
+ filterFn?: (rowNode: IRowNode) => boolean;
233
+ }): IRowNode[];
228
234
  getAllRowNodes(config?: {
229
235
  includeGroupRows?: boolean;
230
236
  filterFn?: (rowNode: IRowNode) => boolean;
@@ -2112,16 +2112,18 @@ class Adaptable {
2112
2112
  }
2113
2113
  });
2114
2114
  }
2115
- forAllVisibleRowNodesDo(func) {
2115
+ forAllVisibleRowNodesDo(func, config) {
2116
2116
  this.gridOptions.api.forEachNodeAfterFilterAndSort((rowNode, rowIndex) => {
2117
- func(rowNode, rowIndex);
2117
+ const includeGroupRows = (config === null || config === void 0 ? void 0 : config.includeGroupRows) || !this.isGroupRowNode(rowNode);
2118
+ const filterFnFulfilled = !(config === null || config === void 0 ? void 0 : config.filterFn) || (config === null || config === void 0 ? void 0 : config.filterFn(rowNode));
2119
+ if (includeGroupRows && filterFnFulfilled) {
2120
+ func(rowNode, rowIndex);
2121
+ }
2118
2122
  });
2119
2123
  }
2120
- getVisibleRowNodes() {
2124
+ getVisibleRowNodes(config) {
2121
2125
  let rowNodes = [];
2122
- this.gridOptions.api.forEachNodeAfterFilterAndSort((rowNode, rowIndex) => {
2123
- rowNodes.push(rowNode);
2124
- });
2126
+ this.forAllVisibleRowNodesDo((rowNode) => rowNodes.push(rowNode), config);
2125
2127
  return rowNodes;
2126
2128
  }
2127
2129
  getAllRowNodes(config) {
@@ -4584,6 +4586,7 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4584
4586
  const colDefs = displayedColumns.map((column) => {
4585
4587
  return column.getColDef();
4586
4588
  });
4589
+ const forAllVisibleRowNodesDoConfig = { includeGroupRows: true };
4587
4590
  this.forAllVisibleRowNodesDo((node, rowIndex) => {
4588
4591
  const rowParams = {
4589
4592
  node,
@@ -4684,7 +4687,7 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4684
4687
  .getReportService()
4685
4688
  .registerExcelStyle(finalCellExcelStyle, cellClassId);
4686
4689
  });
4687
- });
4690
+ }, forAllVisibleRowNodesDoConfig);
4688
4691
  return this.api.internalApi.getReportService().getRegisteredExcelStyles();
4689
4692
  });
4690
4693
  }
@@ -40,7 +40,7 @@ const ProgressIndicator = () => {
40
40
  disableAdaptableGrid(adaptable.getAdaptableContainerElement(), active);
41
41
  disableAdaptableGrid(adaptable.getAgGridContainerElement(), active);
42
42
  updateGridContainerCoordinates(adaptable.getAdaptableContainerElement());
43
- // without RAF the progress indicator would be rendered instantly, without the 'transition-delay' defined via CSS
43
+ // without rAF the progress indicator would be rendered instantly, without the 'transition-delay' defined via CSS
44
44
  requestAnimationFrame(() => {
45
45
  setVisible(active);
46
46
  });