@adaptabletools/adaptable 16.1.0-canary.2 → 16.1.0

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": "16.1.0-canary.2",
3
+ "version": "16.1.0",
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",
@@ -64,6 +64,6 @@
64
64
  "uuid": "^3.3.2"
65
65
  },
66
66
  "peerDependencies": {
67
- "@ag-grid-community/core": ">=30.0.0"
67
+ "@ag-grid-community/core": ">=30.1.0"
68
68
  }
69
69
  }
@@ -1,2 +1,2 @@
1
- declare const _default: 1697637650202;
1
+ declare const _default: 1698160309123;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1697637650202;
3
+ exports.default = 1698160309123;
@@ -161,6 +161,10 @@ export interface IAdaptable {
161
161
  getFilteredData(): any[];
162
162
  updateRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
163
163
  addRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
164
+ addOrUpdateRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<{
165
+ added: IRowNode[];
166
+ updated: IRowNode[];
167
+ }>;
164
168
  deleteRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
165
169
  selectColumn(columnId: string, config?: {
166
170
  keepExistingSelection?: boolean;
@@ -47,7 +47,10 @@ export interface GridApi {
47
47
  * @param dataRows rows to add or update
48
48
  * @param config batch option and callback function to run post change
49
49
  */
50
- addOrUpdateGridData(dataRows: any[], config?: DataUpdateConfig): Promise<IRowNode[]>;
50
+ addOrUpdateGridData(dataRows: any[], config?: DataUpdateConfig): Promise<{
51
+ addedRows: IRowNode[];
52
+ updatedRows: IRowNode[];
53
+ }>;
51
54
  /**
52
55
  * Adds rows to AdapTable (and AG Grid)
53
56
  * @param dataRows rows to add; ensure all 'mandatory' fields are included and Primary Key is unique
@@ -23,7 +23,10 @@ export declare class GridApiImpl extends ApiBase implements GridApi {
23
23
  getGridData(): any[];
24
24
  getFilteredData(): any[];
25
25
  updateGridData(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
26
- addOrUpdateGridData(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
26
+ addOrUpdateGridData(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<{
27
+ addedRows: IRowNode[];
28
+ updatedRows: IRowNode[];
29
+ }>;
27
30
  addGridData(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
28
31
  undoCellEdit(cellDataChangedInfo: CellDataChangedInfo): boolean;
29
32
  deleteGridData(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
@@ -36,30 +36,17 @@ class GridApiImpl extends ApiBase_1.ApiBase {
36
36
  return rowNodes;
37
37
  }
38
38
  async addOrUpdateGridData(dataRows, dataUpdateConfig) {
39
- let addRows = [];
40
- let updateRows = [];
41
- const primaryKey = this.getOptions().primaryKey;
42
- dataRows.forEach((dataRow) => {
43
- const node = this.getRowNodeForPrimaryKey(dataRow[primaryKey]);
44
- if (node) {
45
- updateRows.push(dataRow);
46
- }
47
- else {
48
- addRows.push(dataRow);
49
- }
50
- });
51
- let returnNodes = [];
52
- if (ArrayExtensions_1.default.IsNotNullOrEmpty(updateRows)) {
53
- const updatedNodes = await this.adaptable.updateRows(updateRows, dataUpdateConfig);
54
- this.internalApi.fireGridDataChangedEvent(dataRows, updatedNodes, 'Edit');
55
- (await returnNodes).push(...updatedNodes);
39
+ const { added, updated } = await this.adaptable.addOrUpdateRows(dataRows, dataUpdateConfig);
40
+ if (ArrayExtensions_1.default.IsNotNullOrEmpty(updated)) {
41
+ this.internalApi.fireGridDataChangedEvent(dataRows, updated, 'Edit');
56
42
  }
57
- if (ArrayExtensions_1.default.IsNotNullOrEmpty(addRows)) {
58
- const addedNodes = await this.adaptable.addRows(addRows, dataUpdateConfig);
59
- this.internalApi.fireGridDataChangedEvent(dataRows, addedNodes, 'Add');
60
- (await returnNodes).push(...addedNodes);
43
+ if (ArrayExtensions_1.default.IsNotNullOrEmpty(added)) {
44
+ this.internalApi.fireGridDataChangedEvent(dataRows, added, 'Add');
61
45
  }
62
- return returnNodes;
46
+ return {
47
+ addedRows: added,
48
+ updatedRows: updated,
49
+ };
63
50
  }
64
51
  async addGridData(dataRows, dataUpdateConfig) {
65
52
  const rowNodes = await this.adaptable.addRows(dataRows, dataUpdateConfig);
@@ -382,6 +382,10 @@ export declare class Adaptable implements IAdaptable {
382
382
  getFilteredData(): any[];
383
383
  updateRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
384
384
  addRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
385
+ addOrUpdateRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<{
386
+ added: IRowNode[];
387
+ updated: IRowNode[];
388
+ }>;
385
389
  deleteRows(dataRows: any[], dataUpdateConfig?: DataUpdateConfig): Promise<IRowNode[]>;
386
390
  getFirstGroupedColumn(): AdaptableColumn | undefined;
387
391
  private checkColumnsDataTypeSet;
@@ -4370,6 +4370,48 @@ class Adaptable {
4370
4370
  return Promise.resolve(transaction === null || transaction === void 0 ? void 0 : transaction.add);
4371
4371
  }
4372
4372
  }
4373
+ addOrUpdateRows(dataRows, dataUpdateConfig) {
4374
+ const addDataRows = [];
4375
+ const updateDataRows = [];
4376
+ const primaryKey = this.adaptableOptions.primaryKey;
4377
+ dataRows.forEach((dataRow) => {
4378
+ const node = this.getRowNodeForPrimaryKey(dataRow[primaryKey]);
4379
+ if (node) {
4380
+ updateDataRows.push(dataRow);
4381
+ }
4382
+ else {
4383
+ addDataRows.push(dataRow);
4384
+ }
4385
+ });
4386
+ if (this.hasAutogeneratedPrimaryKey()) {
4387
+ this.addSyntheticPrimaryKeyIfMissing(addDataRows);
4388
+ }
4389
+ dataUpdateConfig = dataUpdateConfig || {};
4390
+ if (dataUpdateConfig.runAsync) {
4391
+ return new Promise((resolve) => {
4392
+ this.gridOptions.api.applyTransactionAsync({ update: updateDataRows, add: addDataRows, addIndex: dataUpdateConfig.addIndex }, (transaction) => {
4393
+ if (typeof dataUpdateConfig.callback === 'function') {
4394
+ dataUpdateConfig.callback(transaction);
4395
+ }
4396
+ resolve({
4397
+ added: transaction === null || transaction === void 0 ? void 0 : transaction.add,
4398
+ updated: transaction === null || transaction === void 0 ? void 0 : transaction.update,
4399
+ });
4400
+ });
4401
+ });
4402
+ }
4403
+ else {
4404
+ const transaction = this.gridOptions.api.applyTransaction({
4405
+ update: updateDataRows,
4406
+ add: addDataRows,
4407
+ addIndex: dataUpdateConfig.addIndex,
4408
+ });
4409
+ return Promise.resolve({
4410
+ added: transaction === null || transaction === void 0 ? void 0 : transaction.add,
4411
+ updated: transaction === null || transaction === void 0 ? void 0 : transaction.update,
4412
+ });
4413
+ }
4414
+ }
4373
4415
  deleteRows(dataRows, dataUpdateConfig) {
4374
4416
  dataUpdateConfig = dataUpdateConfig || {};
4375
4417
  if (dataUpdateConfig.runAsync) {
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "16.1.0-canary.2";
1
+ declare const _default: "16.1.0";
2
2
  export default _default;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '16.1.0-canary.2'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version
3
+ exports.default = '16.1.0'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version