@genesislcap/grid-pro 14.141.3 → 14.142.1-alpha-a84f41b.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/dist/custom-elements.json +2311 -950
- package/dist/dts/datasource/base.datasource.d.ts +60 -2
- package/dist/dts/datasource/base.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.datasource.d.ts +19 -12
- package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
- package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts +6 -66
- package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts.map +1 -1
- package/dist/dts/grid-pro.d.ts +3 -21
- package/dist/dts/grid-pro.d.ts.map +1 -1
- package/dist/esm/datasource/base.datasource.js +193 -14
- package/dist/esm/datasource/server-side.datasource.js +69 -63
- package/dist/esm/grid-pro-genesis-datasource/grid-pro-genesis-datasource.js +16 -156
- package/dist/esm/grid-pro.js +8 -1
- package/dist/grid-pro.api.json +188 -61
- package/dist/grid-pro.d.ts +93 -111
- package/docs/api/grid-pro.gridprogenesisdatasource.applyasyncfuncname.md +11 -0
- package/docs/api/grid-pro.gridprogenesisdatasource.applyfuncname.md +11 -0
- package/docs/api/grid-pro.gridprogenesisdatasource.applytransaction.md +22 -0
- package/docs/api/grid-pro.gridprogenesisdatasource.applytransactionasync.md +23 -0
- package/docs/api/grid-pro.gridprogenesisdatasource.md +4 -2
- package/docs/api-report.md +30 -16
- package/package.json +8 -8
- package/docs/api/grid-pro.gridprogenesisdatasource.rowdatamapper.md +0 -13
- package/docs/api/grid-pro.gridprogenesisdatasource.rowidattr.md +0 -15
|
@@ -6,14 +6,15 @@ import { take } from 'rxjs/operators';
|
|
|
6
6
|
import { dateTimeValueFormatter, dateValueFormatter } from '../grid-pro.definitions';
|
|
7
7
|
import { GridProRendererTypes } from '../grid-pro.types';
|
|
8
8
|
import { logger } from '../utils';
|
|
9
|
-
import { GridProBaseDatasource } from './base.datasource';
|
|
9
|
+
import { GridProBaseDatasource, StreamBaseDatasource } from './base.datasource';
|
|
10
10
|
import { getColumnType, getFilterByFieldType, getFilterParamsByFieldType, } from './server-side.grid-definitions';
|
|
11
11
|
/**
|
|
12
12
|
* The IServerSideDatasource implementation, used for SSRM (Server-Side Row Model) in the grid.
|
|
13
13
|
* @alpha
|
|
14
14
|
*/
|
|
15
|
-
export class StreamDatasource {
|
|
15
|
+
export class StreamDatasource extends StreamBaseDatasource {
|
|
16
16
|
constructor(options) {
|
|
17
|
+
super();
|
|
17
18
|
/**
|
|
18
19
|
* The number of rows in the grid. THIS DO NOT CONSIDER CRITERIA_MATCH scenarios.
|
|
19
20
|
* @internal
|
|
@@ -27,7 +28,6 @@ export class StreamDatasource {
|
|
|
27
28
|
this.moreRows = false;
|
|
28
29
|
this.calculatedRowsCount = 0;
|
|
29
30
|
this.lastSequenceId = 0;
|
|
30
|
-
this.rowData = new Map();
|
|
31
31
|
this.dataserverStream = options.stream;
|
|
32
32
|
this.resourceName = options.resourceName;
|
|
33
33
|
this.resourceParams = options.resourceParams;
|
|
@@ -83,7 +83,6 @@ export class StreamDatasource {
|
|
|
83
83
|
if (this.moreRows && params.request.startRow >= Number(this.maxRows)) {
|
|
84
84
|
this.connect.getMoreRows(this.streamSourceRef);
|
|
85
85
|
}
|
|
86
|
-
// TODO: take(1) is temporary, won't have to do this once SSRM Transactions are implemented
|
|
87
86
|
this.dataserverStream.pipe(take(1)).subscribe((result) => {
|
|
88
87
|
var _a, _b;
|
|
89
88
|
const messageType = result.MESSAGE_TYPE;
|
|
@@ -95,39 +94,29 @@ export class StreamDatasource {
|
|
|
95
94
|
this.moreRows = result.MORE_ROWS;
|
|
96
95
|
if (result.ROW) {
|
|
97
96
|
const nextMessage = dataServerResultFilter(result);
|
|
98
|
-
this.
|
|
97
|
+
this.handleCurrentStreamLoad(nextMessage);
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
100
|
this.rowData = new Map();
|
|
102
|
-
const successRowData = { rowData:
|
|
101
|
+
const successRowData = { rowData: [] };
|
|
103
102
|
successRowData.rowCount = 0;
|
|
104
103
|
params.success(successRowData);
|
|
105
104
|
return;
|
|
106
105
|
}
|
|
107
|
-
// TODO: SSRM Transactions - https://www.ag-grid.com/javascript-data-grid/server-side-model-updating-transactions/
|
|
108
|
-
// if (messageType === MessageType.QUERY_UPDATE) {
|
|
109
|
-
// if (result.ROW) {
|
|
110
|
-
// const nextMessage = dataServerResultFilter(result);
|
|
111
|
-
// this.agTransaction = { add: [], remove: [], update: [] };
|
|
112
|
-
// this.handleStreamInserts(nextMessage.inserts);
|
|
113
|
-
// this.handleStreamDeletes(nextMessage.deletes);
|
|
114
|
-
// this.handleStreamUpdates(nextMessage.updates);
|
|
115
|
-
// params.api.applyServerSideTransactionAsync(this.agTransaction);
|
|
116
|
-
// }
|
|
117
|
-
// }
|
|
118
106
|
this.lastSequenceId = result.SEQUENCE_ID;
|
|
119
107
|
if (this.lastSequenceId === 1) {
|
|
120
108
|
this.streamSourceRef = result.SOURCE_REF;
|
|
121
109
|
this.server_ROWS_COUNT = (_a = result.ROWS_COUNT) !== null && _a !== void 0 ? _a : this.rowData.size;
|
|
122
110
|
}
|
|
123
|
-
// TODO: TEMPORARY - Due ROWS_COUNT not respecting CRITERIA_MATCH scenarios.
|
|
124
111
|
if (!this.moreRows && this.server_ROWS_COUNT >= this.client_ROWS_COUNT) {
|
|
125
112
|
this.calculatedRowsCount = this.client_ROWS_COUNT;
|
|
126
113
|
}
|
|
127
114
|
else {
|
|
128
115
|
this.calculatedRowsCount += (_b = this.rowData.size) !== null && _b !== void 0 ? _b : 0;
|
|
129
116
|
}
|
|
130
|
-
const successRowData = {
|
|
117
|
+
const successRowData = {
|
|
118
|
+
rowData: Array.from(this.sortMapByNumericKey(this.rowData).values()),
|
|
119
|
+
};
|
|
131
120
|
if (this.pagination) {
|
|
132
121
|
successRowData.rowCount = Math.min(this.server_ROWS_COUNT, this.maxView);
|
|
133
122
|
}
|
|
@@ -142,34 +131,13 @@ export class StreamDatasource {
|
|
|
142
131
|
});
|
|
143
132
|
});
|
|
144
133
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// } else {
|
|
153
|
-
// this.agTransaction.add.push(insertData);
|
|
154
|
-
// this.agTransaction.addIndex = 0;
|
|
155
|
-
// }
|
|
156
|
-
// this.rowData.set(insertData[this.rowId], insertData);
|
|
157
|
-
// });
|
|
158
|
-
// }
|
|
159
|
-
// private handleStreamDeletes(deletedRows: any[]) {
|
|
160
|
-
// deletedRows?.forEach((deleteData) => {
|
|
161
|
-
// this.agTransaction.remove.push({ [this.rowId]: deleteData[this.rowId] });
|
|
162
|
-
// this.rowData.delete(deleteData[this.rowId]);
|
|
163
|
-
// });
|
|
164
|
-
// }
|
|
165
|
-
// private handleStreamUpdates(updatedRows: any[]) {
|
|
166
|
-
// updatedRows?.forEach((updateData) => {
|
|
167
|
-
// const rowToBeUpdated = this.rowData.get(updateData[this.rowId]);
|
|
168
|
-
// const updatedRow = { ...rowToBeUpdated, ...updateData };
|
|
169
|
-
// this.agTransaction.update.push(updatedRow);
|
|
170
|
-
// this.rowData.set(updateData[this.rowId], updatedRow);
|
|
171
|
-
// });
|
|
172
|
-
// }
|
|
134
|
+
sortMapByNumericKey(inputMap) {
|
|
135
|
+
// Convert Map to array of key-value pairs
|
|
136
|
+
const sortedArray = Array.from(inputMap.entries()).sort(([key1], [key2]) => +key2 - +key1);
|
|
137
|
+
// Create a new Map from the sorted array
|
|
138
|
+
const sortedMap = new Map(sortedArray);
|
|
139
|
+
return sortedMap;
|
|
140
|
+
}
|
|
173
141
|
dataLogoff() {
|
|
174
142
|
const shouldPerformDataLogoff = this.streamSourceRef;
|
|
175
143
|
if (shouldPerformDataLogoff && this.auth.isLoggedIn) {
|
|
@@ -195,16 +163,14 @@ export class StreamDatasource {
|
|
|
195
163
|
}
|
|
196
164
|
}
|
|
197
165
|
}
|
|
198
|
-
|
|
166
|
+
handleCurrentStreamLoad(result) {
|
|
199
167
|
var _a;
|
|
200
168
|
if (!result)
|
|
201
169
|
return;
|
|
202
170
|
const rows = new Map();
|
|
203
171
|
(_a = result.inserts) === null || _a === void 0 ? void 0 : _a.forEach((insertData) => {
|
|
204
|
-
rows.set(insertData.
|
|
172
|
+
rows.set(insertData[this.rowId], insertData);
|
|
205
173
|
});
|
|
206
|
-
// TODO: TEMPORARY - Due ROWS_COUNT not being in sync with CRITERIA_MATCH scenarios.
|
|
207
|
-
this.client_ROWS_COUNT += rows.size;
|
|
208
174
|
this.rowData = rows;
|
|
209
175
|
}
|
|
210
176
|
buildCriteriaMatchFromFilters() {
|
|
@@ -295,8 +261,9 @@ const criteriaDelimiter = ';';
|
|
|
295
261
|
let GridProServerSideDatasource = class GridProServerSideDatasource extends LifecycleMixin(GridProBaseDatasource) {
|
|
296
262
|
constructor() {
|
|
297
263
|
super(...arguments);
|
|
264
|
+
this.applyFuncName = 'applyServerSideTransaction';
|
|
265
|
+
this.applyAsyncFuncName = 'applyServerSideTransactionAsync';
|
|
298
266
|
this.pagination = false;
|
|
299
|
-
this.rowId = 'ROW_REF';
|
|
300
267
|
}
|
|
301
268
|
criteriaChanged(oldCriteria, newCriteria) {
|
|
302
269
|
const startingCriteria = !oldCriteria && newCriteria;
|
|
@@ -343,6 +310,11 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
343
310
|
return null;
|
|
344
311
|
}
|
|
345
312
|
return params.data[this.rowId];
|
|
313
|
+
}, getRowStyle(params) {
|
|
314
|
+
var _a, _b;
|
|
315
|
+
if ((_b = (_a = params.data) === null || _a === void 0 ? void 0 : _a.ROW_REF) === null || _b === void 0 ? void 0 : _b.includes('_deleted')) {
|
|
316
|
+
return { color: 'grey' };
|
|
317
|
+
}
|
|
346
318
|
}, cacheBlockSize: this.maxRows, defaultColDef: {
|
|
347
319
|
filter: true,
|
|
348
320
|
resizable: true,
|
|
@@ -360,7 +332,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
360
332
|
const agColumnDefs = this.getAgColumnDefs(fieldMetadata);
|
|
361
333
|
this.agGrid.gridApi.setColumnDefs(agColumnDefs);
|
|
362
334
|
const dataserverStream = yield this.createDataserverStream();
|
|
363
|
-
this.
|
|
335
|
+
this.ssrmDatasource = new StreamDatasource({
|
|
364
336
|
stream: dataserverStream,
|
|
365
337
|
resourceName: this.resourceName,
|
|
366
338
|
resourceParams: this.params,
|
|
@@ -371,7 +343,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
371
343
|
rowId: this.rowId,
|
|
372
344
|
pagination: this.pagination,
|
|
373
345
|
});
|
|
374
|
-
this.agGrid.gridApi.setServerSideDatasource(this.
|
|
346
|
+
this.agGrid.gridApi.setServerSideDatasource(this.ssrmDatasource);
|
|
375
347
|
}), { once: true });
|
|
376
348
|
return;
|
|
377
349
|
}
|
|
@@ -380,17 +352,14 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
380
352
|
reset() {
|
|
381
353
|
var _a;
|
|
382
354
|
this.clearRowData();
|
|
383
|
-
this.
|
|
355
|
+
this.ssrmDatasource = undefined;
|
|
384
356
|
this.originalFieldDef = undefined;
|
|
385
|
-
(_a = this.agGrid.gridApi) === null || _a === void 0 ? void 0 : _a.
|
|
357
|
+
(_a = this.agGrid.gridApi) === null || _a === void 0 ? void 0 : _a.refreshServerSide({ purge: true });
|
|
386
358
|
}
|
|
387
359
|
restart() {
|
|
388
360
|
this.reset();
|
|
389
361
|
this.init();
|
|
390
362
|
}
|
|
391
|
-
get agGrid() {
|
|
392
|
-
return this.parentElement;
|
|
393
|
-
}
|
|
394
363
|
clearRowData() {
|
|
395
364
|
var _a, _b, _c, _d;
|
|
396
365
|
(_b = (_a = this.agGrid) === null || _a === void 0 ? void 0 : _a.gridApi) === null || _b === void 0 ? void 0 : _b.setColumnDefs([]);
|
|
@@ -429,13 +398,47 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
429
398
|
logger.debug('Getting configured params:', params);
|
|
430
399
|
return params;
|
|
431
400
|
}
|
|
401
|
+
get rowModel() {
|
|
402
|
+
return this.agGrid.gridApi.getModel();
|
|
403
|
+
}
|
|
432
404
|
createDataserverStream(existingParams = null) {
|
|
433
405
|
return __awaiter(this, void 0, void 0, function* () {
|
|
434
|
-
const streamOnMessage = (message) =>
|
|
406
|
+
const streamOnMessage = (message) => __awaiter(this, void 0, void 0, function* () {
|
|
407
|
+
var _a, _b;
|
|
408
|
+
const messageType = message.MESSAGE_TYPE;
|
|
409
|
+
if (messageType === MessageType.QUERY_UPDATE && message.ROW) {
|
|
410
|
+
const nextMessage = dataServerResultFilter(message);
|
|
411
|
+
this.agTransaction = { add: [], remove: [], update: [] };
|
|
412
|
+
this.handleStreamInserts(nextMessage.inserts);
|
|
413
|
+
// TODO: deletion flow not being handled yet.
|
|
414
|
+
// this.handleStreamDeletes(nextMessage.deletes);
|
|
415
|
+
this.handleStreamDeletesTemp(nextMessage.deletes);
|
|
416
|
+
this.handleStreamUpdates(nextMessage.updates);
|
|
417
|
+
this.ssrmDatasource.client_ROWS_COUNT = (_b = (_a = this.rowData) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 0;
|
|
418
|
+
if (message.SEQUENCE_ID > 1) {
|
|
419
|
+
const updatedInfo = yield this.connect.snapshot(this.resourceName, {
|
|
420
|
+
MAX_ROWS: 1,
|
|
421
|
+
MAX_VIEW: 1,
|
|
422
|
+
});
|
|
423
|
+
this.ssrmDatasource.server_ROWS_COUNT = updatedInfo.ROWS_COUNT;
|
|
424
|
+
}
|
|
425
|
+
this.applyAllAgTransactions();
|
|
426
|
+
}
|
|
427
|
+
});
|
|
435
428
|
const onError = (error) => logger.error(error);
|
|
436
429
|
return this.connect.stream(this.resourceName, streamOnMessage, onError, existingParams !== null && existingParams !== void 0 ? existingParams : this.params);
|
|
437
430
|
});
|
|
438
431
|
}
|
|
432
|
+
handleStreamDeletesTemp(deletes) {
|
|
433
|
+
if (!deletes)
|
|
434
|
+
return;
|
|
435
|
+
deletes.forEach((deleteData) => {
|
|
436
|
+
const rowNode = this.agGrid.gridApi.getRowNode(deleteData.ROW_REF);
|
|
437
|
+
if (rowNode) {
|
|
438
|
+
rowNode.setData(Object.assign(Object.assign({}, rowNode.data), { ROW_REF: deleteData.ROW_REF + '_deleted' }));
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
439
442
|
getAgColumnDefs(fieldsMetadata) {
|
|
440
443
|
const colDefsFromGenesisData = fieldsMetadata === null || fieldsMetadata === void 0 ? void 0 : fieldsMetadata.flatMap((field) => {
|
|
441
444
|
var _a;
|
|
@@ -477,13 +480,16 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
477
480
|
const colDefsMergedWithTemplateDefs = this.agGrid.mergeAllColumnDefsAndStates(colDefsFromGenesisData, true);
|
|
478
481
|
return colDefsMergedWithTemplateDefs;
|
|
479
482
|
}
|
|
483
|
+
applyTransaction(agTransaction) {
|
|
484
|
+
return this.agGrid.gridApi.applyServerSideTransaction(agTransaction);
|
|
485
|
+
}
|
|
486
|
+
applyTransactionAsync(agTransaction, callback) {
|
|
487
|
+
this.agGrid.gridApi.applyServerSideTransactionAsync(agTransaction, callback);
|
|
488
|
+
}
|
|
480
489
|
};
|
|
481
490
|
__decorate([
|
|
482
491
|
attr({ mode: 'boolean' })
|
|
483
492
|
], GridProServerSideDatasource.prototype, "pagination", void 0);
|
|
484
|
-
__decorate([
|
|
485
|
-
attr({ attribute: 'row-id' })
|
|
486
|
-
], GridProServerSideDatasource.prototype, "rowId", void 0);
|
|
487
493
|
GridProServerSideDatasource = __decorate([
|
|
488
494
|
customElement({
|
|
489
495
|
name: 'grid-pro-server-side-datasource',
|
|
@@ -12,16 +12,6 @@ const criteriaDelimiter = ';';
|
|
|
12
12
|
const criteriaJoin = ' && ';
|
|
13
13
|
const withoutFullInit = null;
|
|
14
14
|
const withoutColumnDefs = null;
|
|
15
|
-
/**
|
|
16
|
-
* The operation type for the {@link @genesislcap/grid-pro#GridProGenesisDatasource.mapTransaction} method.
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export var OperationType;
|
|
20
|
-
(function (OperationType) {
|
|
21
|
-
OperationType["Add"] = "add";
|
|
22
|
-
OperationType["Update"] = "update";
|
|
23
|
-
OperationType["Remove"] = "remove";
|
|
24
|
-
})(OperationType || (OperationType = {}));
|
|
25
15
|
/**
|
|
26
16
|
* The Genesis Datasource element, for CSRM-compatible data fetching and used exclusively by the GridPro element.
|
|
27
17
|
* @remarks Only supports Client-Side Row Model.
|
|
@@ -30,13 +20,12 @@ export var OperationType;
|
|
|
30
20
|
let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleMixin(GridProBaseDatasource) {
|
|
31
21
|
constructor() {
|
|
32
22
|
super(...arguments);
|
|
23
|
+
this.applyFuncName = 'applyTransaction';
|
|
24
|
+
this.applyAsyncFuncName = 'applyTransactionAsync';
|
|
33
25
|
this.pollingInterval = DatasourceDefaults.REQ_REP_POLLING_INTERVAL_MS;
|
|
34
26
|
this.disablePolling = false;
|
|
35
27
|
this.restartOnReconnection = false;
|
|
36
|
-
this.isRequestServer = false;
|
|
37
28
|
this.requiresFullRowDataAndColDefs = true;
|
|
38
|
-
this.dataSubWasLoggedOff = false;
|
|
39
|
-
this.rows = new Map();
|
|
40
29
|
this.criteriaFromFilters = new Map();
|
|
41
30
|
this.update = new BehaviorSubject(new Map());
|
|
42
31
|
}
|
|
@@ -89,36 +78,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
89
78
|
copy.request = structuredClone(this.request);
|
|
90
79
|
return copy;
|
|
91
80
|
}
|
|
92
|
-
get agGrid() {
|
|
93
|
-
return this.parentElement;
|
|
94
|
-
}
|
|
95
81
|
// Genesis Specific
|
|
96
|
-
/**
|
|
97
|
-
* Returns the `row-id` attribute, depending on the resource type.
|
|
98
|
-
* @remarks Will favour the `row-id` attribute if set.
|
|
99
|
-
* @internal
|
|
100
|
-
*/
|
|
101
|
-
get rowId() {
|
|
102
|
-
if (this.rowIdAttr)
|
|
103
|
-
return this.rowIdAttr;
|
|
104
|
-
if (this.isRequestServer)
|
|
105
|
-
return DatasourceDefaults.REQUEST_SERVER_ROW_ID;
|
|
106
|
-
return DatasourceDefaults.DATASERVER_ROW_ID;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Returns whether the `row-id` attribute is the default one, depending on the resource type.
|
|
110
|
-
* @internal
|
|
111
|
-
*/
|
|
112
|
-
get hasDefaultRowId() {
|
|
113
|
-
return (!this.rowIdAttr ||
|
|
114
|
-
this.rowIdAttr === DatasourceDefaults.REQUEST_SERVER_ROW_ID ||
|
|
115
|
-
this.rowIdAttr === DatasourceDefaults.DATASERVER_ROW_ID);
|
|
116
|
-
}
|
|
117
|
-
get defaultRowIdByResourceType() {
|
|
118
|
-
return this.isRequestServer
|
|
119
|
-
? DatasourceDefaults.REQUEST_SERVER_ROW_ID
|
|
120
|
-
: DatasourceDefaults.DATASERVER_ROW_ID;
|
|
121
|
-
}
|
|
122
82
|
/**
|
|
123
83
|
* Initializes the datasource.
|
|
124
84
|
* @public
|
|
@@ -201,7 +161,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
201
161
|
* Force the grid to redispatch the current rows
|
|
202
162
|
*/
|
|
203
163
|
refreshRows() {
|
|
204
|
-
this.setRowData(Array.from(this.
|
|
164
|
+
this.setRowData(Array.from(this.rowData.values()));
|
|
205
165
|
}
|
|
206
166
|
/**
|
|
207
167
|
* Sends a DATA_LOGOFF when the resource is an active stream
|
|
@@ -223,7 +183,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
223
183
|
*/
|
|
224
184
|
clearRowData(withColumnDefs = true) {
|
|
225
185
|
var _a, _b, _c, _d;
|
|
226
|
-
this.
|
|
186
|
+
this.rowData = new Map();
|
|
227
187
|
this.agTransaction = undefined;
|
|
228
188
|
if (withColumnDefs) {
|
|
229
189
|
(_b = (_a = this.agGrid) === null || _a === void 0 ? void 0 : _a.gridApi) === null || _b === void 0 ? void 0 : _b.setColumnDefs([]);
|
|
@@ -377,14 +337,14 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
377
337
|
}
|
|
378
338
|
if (this.requiresFullRowDataAndColDefs) {
|
|
379
339
|
requestServerData === null || requestServerData === void 0 ? void 0 : requestServerData.forEach((insertData) => {
|
|
380
|
-
this.
|
|
340
|
+
this.rowData.set(insertData[this.rowId], insertData);
|
|
381
341
|
});
|
|
382
|
-
const rowData = this.
|
|
342
|
+
const rowData = this.rowData.size > 0 ? Array.from(this.rowData.values()) : requestServerData;
|
|
383
343
|
this.setRowData(rowData);
|
|
384
344
|
return;
|
|
385
345
|
}
|
|
386
346
|
const rowsToUpdate = [];
|
|
387
|
-
const rowsToDelete = Array.from(this.
|
|
347
|
+
const rowsToDelete = Array.from(this.rowData.values()).filter((row) => {
|
|
388
348
|
const match = requestServerData.find((data) => data[this.rowId] === row[this.rowId]);
|
|
389
349
|
if (match) {
|
|
390
350
|
rowsToUpdate.push(match);
|
|
@@ -392,7 +352,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
392
352
|
}
|
|
393
353
|
return true; // delete rows that don't exist in requestServerData
|
|
394
354
|
});
|
|
395
|
-
const rowsToInsert = requestServerData.filter((data) => !this.
|
|
355
|
+
const rowsToInsert = requestServerData.filter((data) => !this.rowData.has(data[this.rowId]));
|
|
396
356
|
this.agTransaction = { add: [], remove: [], update: [] };
|
|
397
357
|
this.handleStreamInserts(rowsToInsert);
|
|
398
358
|
this.handleStreamDeletes(rowsToDelete);
|
|
@@ -403,9 +363,9 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
403
363
|
var _a;
|
|
404
364
|
if (this.requiresFullRowDataAndColDefs) {
|
|
405
365
|
(_a = dataServerResult.inserts) === null || _a === void 0 ? void 0 : _a.forEach((insertData) => {
|
|
406
|
-
this.
|
|
366
|
+
this.rowData.set(insertData[this.rowId], insertData);
|
|
407
367
|
});
|
|
408
|
-
const rowData = Array.from(this.
|
|
368
|
+
const rowData = Array.from(this.rowData.values());
|
|
409
369
|
this.setRowData(rowData);
|
|
410
370
|
return;
|
|
411
371
|
}
|
|
@@ -415,106 +375,6 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
415
375
|
this.handleStreamUpdates(dataServerResult.updates);
|
|
416
376
|
this.applyAllAgTransactions();
|
|
417
377
|
}
|
|
418
|
-
applyAllAgTransactions() {
|
|
419
|
-
if (!this.agTransaction.add.length &&
|
|
420
|
-
!this.agTransaction.update.length &&
|
|
421
|
-
!this.agTransaction.remove.length) {
|
|
422
|
-
this.agGrid.gridApi.hideOverlay();
|
|
423
|
-
if (this.rows.size === 0) {
|
|
424
|
-
this.agGrid.gridApi.showNoRowsOverlay();
|
|
425
|
-
}
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
if (this.agTransaction.add.length > 0) {
|
|
429
|
-
this.applyMappedAgTransaction({ add: this.agTransaction.add, addIndex: this.agGrid.addIndex }, OperationType.Add, this.agGrid.asyncAdd);
|
|
430
|
-
}
|
|
431
|
-
if (this.agTransaction.remove.length > 0) {
|
|
432
|
-
this.applyMappedAgTransaction({ remove: this.agTransaction.remove }, OperationType.Remove, this.agGrid.asyncRemove);
|
|
433
|
-
}
|
|
434
|
-
if (this.agTransaction.update.length > 0) {
|
|
435
|
-
this.applyMappedAgTransaction({ update: this.agTransaction.update }, OperationType.Update, this.agGrid.asyncUpdate);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
flashAddedCells(rowNodes) {
|
|
439
|
-
if (this.agGrid.enableRowFlashing && rowNodes.length) {
|
|
440
|
-
this.agGrid.gridApi.flashCells({ rowNodes });
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
applyMappedAgTransaction(agTransaction, operation, isAsync) {
|
|
444
|
-
if (isAsync) {
|
|
445
|
-
this.agGrid.gridApi.applyTransactionAsync(this.mapTransaction(agTransaction, [operation]), (changedNodes) => {
|
|
446
|
-
this.flashAddedCells(changedNodes.add);
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
else {
|
|
450
|
-
const changedNodes = this.agGrid.gridApi.applyTransaction(this.mapTransaction(agTransaction, [operation]));
|
|
451
|
-
this.flashAddedCells(changedNodes.add);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Maps the transaction data to the row data mapper function, if it exists.
|
|
456
|
-
* @param transaction - The transaction data to be mapped.
|
|
457
|
-
* @param operations - The operations to be mapped. Can be 'add', 'update' or 'remove'.
|
|
458
|
-
* @returns The mapped transaction (if the row data mapper function exists), or the original transaction.
|
|
459
|
-
*/
|
|
460
|
-
mapTransaction(transaction, operations = Object.values(OperationType)) {
|
|
461
|
-
if (!this.rowDataMapper) {
|
|
462
|
-
return transaction;
|
|
463
|
-
}
|
|
464
|
-
const mappedTransaction = {};
|
|
465
|
-
if (operations.includes(OperationType.Add)) {
|
|
466
|
-
mappedTransaction.add = this.rowDataMapper(transaction.add, this.rows);
|
|
467
|
-
}
|
|
468
|
-
if (operations.includes(OperationType.Remove)) {
|
|
469
|
-
mappedTransaction.remove = this.rowDataMapper(transaction.remove, this.rows);
|
|
470
|
-
}
|
|
471
|
-
if (operations.includes(OperationType.Update)) {
|
|
472
|
-
mappedTransaction.update = this.rowDataMapper(transaction.update, this.rows);
|
|
473
|
-
}
|
|
474
|
-
return mappedTransaction;
|
|
475
|
-
}
|
|
476
|
-
handleStreamInserts(insertedRows) {
|
|
477
|
-
insertedRows === null || insertedRows === void 0 ? void 0 : insertedRows.forEach((insertData) => {
|
|
478
|
-
if (this.rows.has(insertData[this.rowId]) || this.dataSubWasLoggedOff) {
|
|
479
|
-
const rowToBeUpdated = this.rows.get(insertData[this.rowId]);
|
|
480
|
-
const updatedRow = Object.assign(Object.assign({}, rowToBeUpdated), insertData);
|
|
481
|
-
this.agTransaction.update.push(updatedRow);
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
this.agTransaction.add.push(insertData);
|
|
485
|
-
this.agTransaction.addIndex = 0;
|
|
486
|
-
}
|
|
487
|
-
this.rows.set(insertData[this.rowId], insertData);
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
handleStreamDeletes(deletedRows) {
|
|
491
|
-
deletedRows === null || deletedRows === void 0 ? void 0 : deletedRows.forEach((deleteData) => {
|
|
492
|
-
if (this.hasDefaultRowId || this.isRequestServer) {
|
|
493
|
-
this.agTransaction.remove.push({ [this.rowId]: deleteData[this.rowId] });
|
|
494
|
-
}
|
|
495
|
-
else {
|
|
496
|
-
const rowToBeDeleted = Object.values(Object.fromEntries(this.rows)).find((obj) => obj[this.defaultRowIdByResourceType] === deleteData[this.defaultRowIdByResourceType]);
|
|
497
|
-
this.agTransaction.remove.push({ [this.rowId]: rowToBeDeleted[this.rowId] });
|
|
498
|
-
}
|
|
499
|
-
this.rows.delete(deleteData[this.rowId]);
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
handleStreamUpdates(updatedRows) {
|
|
503
|
-
updatedRows === null || updatedRows === void 0 ? void 0 : updatedRows.forEach((updateData) => {
|
|
504
|
-
let updatedRow;
|
|
505
|
-
if (this.hasDefaultRowId || this.isRequestServer) {
|
|
506
|
-
const rowToBeUpdated = this.rows.get(updateData[this.rowId]);
|
|
507
|
-
updatedRow = Object.assign(Object.assign({}, rowToBeUpdated), updateData);
|
|
508
|
-
this.agTransaction.update.push(updatedRow);
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
const rowToBeUpdated = Object.values(Object.fromEntries(this.rows)).find((obj) => obj[this.defaultRowIdByResourceType] === updateData[this.defaultRowIdByResourceType]);
|
|
512
|
-
updatedRow = Object.assign(Object.assign({}, rowToBeUpdated), updateData);
|
|
513
|
-
this.agTransaction.update.push(updatedRow);
|
|
514
|
-
}
|
|
515
|
-
this.rows.set(updateData[this.rowId], updatedRow);
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
378
|
// FUTURE: Work with the field types vs ag grid column def types!
|
|
519
379
|
getAgColumnDefs(fieldsMetadata) {
|
|
520
380
|
const colDefsFromGenesisData = fieldsMetadata === null || fieldsMetadata === void 0 ? void 0 : fieldsMetadata.flatMap((field) => {
|
|
@@ -587,6 +447,12 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
587
447
|
this.criteriaFromFilters.delete(fieldName);
|
|
588
448
|
this.update.next(this.criteriaFromFilters);
|
|
589
449
|
}
|
|
450
|
+
applyTransaction(agTransaction) {
|
|
451
|
+
return this.agGrid.gridApi.applyTransaction(agTransaction);
|
|
452
|
+
}
|
|
453
|
+
applyTransactionAsync(agTransaction, callback) {
|
|
454
|
+
this.agGrid.gridApi.applyTransactionAsync(agTransaction, callback);
|
|
455
|
+
}
|
|
590
456
|
};
|
|
591
457
|
__decorate([
|
|
592
458
|
Auth
|
|
@@ -603,15 +469,9 @@ __decorate([
|
|
|
603
469
|
__decorate([
|
|
604
470
|
observable
|
|
605
471
|
], GridProGenesisDatasource.prototype, "request", void 0);
|
|
606
|
-
__decorate([
|
|
607
|
-
attr({ attribute: 'row-id' })
|
|
608
|
-
], GridProGenesisDatasource.prototype, "rowIdAttr", void 0);
|
|
609
472
|
__decorate([
|
|
610
473
|
attr({ mode: 'boolean', attribute: 'restart-on-reconnection' })
|
|
611
474
|
], GridProGenesisDatasource.prototype, "restartOnReconnection", void 0);
|
|
612
|
-
__decorate([
|
|
613
|
-
observable
|
|
614
|
-
], GridProGenesisDatasource.prototype, "rowDataMapper", void 0);
|
|
615
475
|
GridProGenesisDatasource = __decorate([
|
|
616
476
|
customElement({
|
|
617
477
|
name: 'grid-pro-genesis-datasource',
|
package/dist/esm/grid-pro.js
CHANGED
|
@@ -274,7 +274,14 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
|
|
|
274
274
|
if (onFirstDataRendered) {
|
|
275
275
|
onFirstDataRendered(event);
|
|
276
276
|
}
|
|
277
|
-
}, onColumnPinned: gridOnChangeCallback, onColumnResized: gridOnChangeCallback, onColumnMoved: gridOnChangeCallback, onDisplayedColumnsChanged: gridOnChangeCallback, onFilterChanged: gridOnChangeCallback, onGridSizeChanged: gridOnChangeCallback, onSortChanged: gridOnChangeCallback
|
|
277
|
+
}, onColumnPinned: gridOnChangeCallback, onColumnResized: gridOnChangeCallback, onColumnMoved: gridOnChangeCallback, onDisplayedColumnsChanged: gridOnChangeCallback, onFilterChanged: gridOnChangeCallback, onGridSizeChanged: gridOnChangeCallback, onSortChanged: gridOnChangeCallback, onCellContextMenu: (event) => {
|
|
278
|
+
this.session.setSessionStorageItem('selectedRowId', event.node.id);
|
|
279
|
+
this.session.setSessionStorageItem('selectedColId', event.column['colId']);
|
|
280
|
+
this.addEventListener('click', (e) => {
|
|
281
|
+
this.session.removeSessionStorageItem('selectedRowId');
|
|
282
|
+
this.session.removeSessionStorageItem('selectedColId');
|
|
283
|
+
}, { once: true });
|
|
284
|
+
} }), rest);
|
|
278
285
|
if (this.gridProDatasource) {
|
|
279
286
|
derivedOptions.columnDefs = columnDefs;
|
|
280
287
|
}
|