@genesislcap/grid-pro 14.482.1-alpha-c9fc44ab6.0 → 14.482.1
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 +7 -327
- package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-base.d.ts +2 -23
- package/dist/dts/datasource/server-side.resource-base.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-dataserver.d.ts +1 -32
- package/dist/dts/datasource/server-side.resource-dataserver.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-reqrep.d.ts +1 -1
- package/dist/dts/datasource/server-side.resource-reqrep.d.ts.map +1 -1
- package/dist/esm/datasource/server-side.datasource.js +2 -8
- package/dist/esm/datasource/server-side.resource-base.js +135 -191
- package/dist/esm/datasource/server-side.resource-dataserver.js +25 -262
- package/dist/esm/datasource/server-side.resource-reqrep.js +2 -3
- package/package.json +14 -14
|
@@ -24,12 +24,6 @@ export class BaseServerSideDatasource {
|
|
|
24
24
|
this.moreRows = false;
|
|
25
25
|
this.calculatedRowsCount = 0;
|
|
26
26
|
this.currentSequenceId = null;
|
|
27
|
-
/**
|
|
28
|
-
* Whether the corrective ROWS_COUNT snapshot() has resolved for the current CRITERIA_MATCH.
|
|
29
|
-
* Reset in destroy() so it re-resolves on filter/sort changes.
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
this.criteriaRowCountResolved = false;
|
|
33
27
|
this.reloadResourceDataFunc = options.reloadResourceDataFunc;
|
|
34
28
|
this.errorHandlerFunc = options.errorHandlerFunc;
|
|
35
29
|
this.onNoDataAvailableFunc = options.onNoDataAvailableFunc;
|
|
@@ -85,9 +79,6 @@ export class BaseServerSideDatasource {
|
|
|
85
79
|
/**
|
|
86
80
|
* Handles filtering setup for server-side datasources.
|
|
87
81
|
* Common logic used by both dataserver and req-rep implementations.
|
|
88
|
-
*
|
|
89
|
-
* @returns `true` when a filter change triggered {@link refreshDatasource} - the current
|
|
90
|
-
* getRows() request is then superseded and the caller must stop processing it.
|
|
91
82
|
*/
|
|
92
83
|
setupFiltering(params) {
|
|
93
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -100,18 +91,15 @@ export class BaseServerSideDatasource {
|
|
|
100
91
|
this.currentFilterModel = null;
|
|
101
92
|
this.setResourceParam('CRITERIA_MATCH', this.originalCriteriaMatch);
|
|
102
93
|
yield this.refreshDatasource(params);
|
|
103
|
-
|
|
104
|
-
// getRows() is re-invoked with fresh params - this invocation is superseded.
|
|
105
|
-
return true;
|
|
94
|
+
return;
|
|
106
95
|
}
|
|
107
96
|
else if (filterModelBeingAppliedDiffersFromCurrent && filtersAreBeingApplied) {
|
|
108
97
|
this.currentFilterModel = filterModelBeingApplied;
|
|
109
98
|
this.setResourceParam('CRITERIA_MATCH', this.buildCriteriaMatchFromFilters());
|
|
110
99
|
yield this.refreshDatasource(params);
|
|
111
|
-
return
|
|
100
|
+
return;
|
|
112
101
|
}
|
|
113
102
|
}
|
|
114
|
-
return false;
|
|
115
103
|
});
|
|
116
104
|
}
|
|
117
105
|
/**
|
|
@@ -134,7 +122,6 @@ export class BaseServerSideDatasource {
|
|
|
134
122
|
this.moreRows = false;
|
|
135
123
|
this.sourceRef = undefined;
|
|
136
124
|
this.lastSuccessRowData = undefined;
|
|
137
|
-
this.criteriaRowCountResolved = false;
|
|
138
125
|
}
|
|
139
126
|
refreshDatasource(params) {
|
|
140
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -186,182 +173,142 @@ export class BaseServerSideDatasource {
|
|
|
186
173
|
criteriaFromFilters() {
|
|
187
174
|
const filters = [];
|
|
188
175
|
this.getFiltersByType('text').forEach((k) => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
filters.push(
|
|
176
|
+
if (!this.currentFilterModel[k].filter &&
|
|
177
|
+
(this.currentFilterModel[k].type === 'false' || this.currentFilterModel[k].type === 'true')) {
|
|
178
|
+
filters.push(`${k} == ${this.currentFilterModel[k].type}`);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
switch (this.currentFilterModel[k].type) {
|
|
182
|
+
case 'blank':
|
|
183
|
+
filters.push(`(${k} == '' || ${k} == null)`);
|
|
184
|
+
break;
|
|
185
|
+
case 'contains':
|
|
186
|
+
filters.push(`Expr.containsIgnoreCase(${k}, '${this.currentFilterModel[k].filter}')`);
|
|
187
|
+
break;
|
|
188
|
+
case 'equals':
|
|
189
|
+
filters.push(`${k} == '${this.currentFilterModel[k].filter}'`);
|
|
190
|
+
break;
|
|
191
|
+
case 'notBlank':
|
|
192
|
+
filters.push(`(${k} != '' && ${k} != null)`);
|
|
193
|
+
break;
|
|
194
|
+
case 'notEqual':
|
|
195
|
+
filters.push(`${k} != '${this.currentFilterModel[k].filter}'`);
|
|
196
|
+
break;
|
|
197
|
+
case 'wordStartsWith':
|
|
198
|
+
filters.push(`Expr.containsWordsStartingWithIgnoreCase(${k}, '${this.currentFilterModel[k].filter}')`);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
192
201
|
}
|
|
193
202
|
});
|
|
203
|
+
// TODO: Handle multi filters if we decide we want to use them in SSRM
|
|
194
204
|
// Handle set filters (typically used for enum fields with ag-set-column-filter)
|
|
195
205
|
this.getFiltersByType('set').forEach((k) => {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
var _a, _b, _c;
|
|
207
|
+
const model = (_a = this.currentFilterModel) === null || _a === void 0 ? void 0 : _a[k];
|
|
208
|
+
const selectedValues = ((_b = model === null || model === void 0 ? void 0 : model.values) !== null && _b !== void 0 ? _b : []);
|
|
209
|
+
if (!selectedValues || selectedValues.length === 0) {
|
|
210
|
+
// Nothing selected means no additional criteria
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// Try to detect "all values selected" using VALID_VALUES from metadata.
|
|
214
|
+
// In that case we don't want to send any criteria, as it would be equivalent
|
|
215
|
+
// to no filter at all.
|
|
216
|
+
const colMeta = (_c = this.resourceColDefs) === null || _c === void 0 ? void 0 : _c.find((o) => o.NAME === k);
|
|
217
|
+
let allValues;
|
|
218
|
+
if (colMeta === null || colMeta === void 0 ? void 0 : colMeta.VALID_VALUES) {
|
|
219
|
+
try {
|
|
220
|
+
allValues = Array.isArray(colMeta.VALID_VALUES)
|
|
221
|
+
? colMeta.VALID_VALUES
|
|
222
|
+
: colMeta.VALID_VALUES.split('|');
|
|
223
|
+
}
|
|
224
|
+
catch (_d) {
|
|
225
|
+
allValues = undefined;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (allValues &&
|
|
229
|
+
allValues.length === selectedValues.length &&
|
|
230
|
+
allValues.every((v) => selectedValues.includes(v))) {
|
|
231
|
+
// All enum options are selected – skip adding criteria for this column
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const orConditions = selectedValues.map((val) => {
|
|
235
|
+
const safeVal = String(val).replace(/'/g, "\\'");
|
|
236
|
+
return `${k} == '${safeVal}'`;
|
|
237
|
+
});
|
|
238
|
+
if (orConditions.length > 0) {
|
|
239
|
+
filters.push(`(${orConditions.join(' || ')})`);
|
|
199
240
|
}
|
|
200
241
|
});
|
|
201
242
|
this.getFiltersByType('number').forEach((k) => {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
243
|
+
const value = this.currentFilterModel[k].filter;
|
|
244
|
+
const valueTwo = this.currentFilterModel[k].filterTo;
|
|
245
|
+
switch (this.currentFilterModel[k].type) {
|
|
246
|
+
case 'equals':
|
|
247
|
+
!isNaN(value) && filters.push(`${k} == ${value}`);
|
|
248
|
+
break;
|
|
249
|
+
case 'notEqual':
|
|
250
|
+
!isNaN(value) && filters.push(`${k} != ${value}`);
|
|
251
|
+
break;
|
|
252
|
+
case 'greaterThan':
|
|
253
|
+
!isNaN(value) && filters.push(`${k} > ${value}`);
|
|
254
|
+
break;
|
|
255
|
+
case 'greaterThanOrEqual':
|
|
256
|
+
!isNaN(value) && filters.push(`${k} >= ${value}`);
|
|
257
|
+
break;
|
|
258
|
+
case 'lessThan':
|
|
259
|
+
!isNaN(value) && filters.push(`${k} < ${value}`);
|
|
260
|
+
break;
|
|
261
|
+
case 'lessThanOrEqual':
|
|
262
|
+
!isNaN(value) && filters.push(`${k} <= ${value}`);
|
|
263
|
+
break;
|
|
264
|
+
case 'inRange':
|
|
265
|
+
!isNaN(value) &&
|
|
266
|
+
!isNaN(valueTwo) &&
|
|
267
|
+
filters.push(`${k} >= ${value} && ${k} <= ${valueTwo}`);
|
|
268
|
+
break;
|
|
269
|
+
case 'blank':
|
|
270
|
+
filters.push(`${k} == 0`);
|
|
271
|
+
break;
|
|
272
|
+
case 'notBlank':
|
|
273
|
+
filters.push(`${k} != 0`);
|
|
274
|
+
break;
|
|
205
275
|
}
|
|
206
276
|
});
|
|
207
277
|
this.getFiltersByType('date').forEach((k) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
278
|
+
var _a, _b;
|
|
279
|
+
const dateFrom = (_a = this.currentFilterModel[k].dateFrom) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '').replace('T', '-').split(' ')[0];
|
|
280
|
+
const dateTo = (_b = this.currentFilterModel[k].dateTo) === null || _b === void 0 ? void 0 : _b.replace(/-/g, '').replace('T', '-').split(' ')[0];
|
|
281
|
+
switch (this.currentFilterModel[k].type) {
|
|
282
|
+
case 'equals':
|
|
283
|
+
filters.push(`Expr.dateIsEqual(${k}, '${dateFrom}')`);
|
|
284
|
+
break;
|
|
285
|
+
case 'lessThan':
|
|
286
|
+
filters.push(`Expr.dateIsBefore(${k}, '${dateFrom}')`);
|
|
287
|
+
break;
|
|
288
|
+
case 'greaterThan':
|
|
289
|
+
filters.push(`Expr.dateIsAfter(${k}, '${dateFrom}')`);
|
|
290
|
+
break;
|
|
291
|
+
case 'inRange':
|
|
292
|
+
filters.push(`Expr.dateIsAfter(${k}, '${dateFrom}') && Expr.dateIsBefore(${k}, '${dateTo}')`);
|
|
293
|
+
break;
|
|
294
|
+
case 'isToday':
|
|
295
|
+
const now = new Date();
|
|
296
|
+
const year = now.getFullYear();
|
|
297
|
+
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
298
|
+
const day = now.getDate().toString().padStart(2, '0');
|
|
299
|
+
const todayStr = `${year}-${month}-${day} 00:00:00`;
|
|
300
|
+
filters.push(`Expr.dateIsEqual(${k}, '${todayStr}')`);
|
|
301
|
+
break;
|
|
302
|
+
case 'blank':
|
|
303
|
+
filters.push(`${k} == null`);
|
|
304
|
+
break;
|
|
305
|
+
case 'notBlank':
|
|
306
|
+
filters.push(`${k} != null`);
|
|
307
|
+
break;
|
|
229
308
|
}
|
|
230
309
|
});
|
|
231
310
|
return filters;
|
|
232
311
|
}
|
|
233
|
-
/**
|
|
234
|
-
* Builds a single criteria fragment for one filter model (flat per-column model or a
|
|
235
|
-
* multi-filter sub-model).
|
|
236
|
-
* @internal
|
|
237
|
-
*/
|
|
238
|
-
criteriaForSingleModel(k, model) {
|
|
239
|
-
if (!model)
|
|
240
|
-
return null;
|
|
241
|
-
switch (model.filterType) {
|
|
242
|
-
case 'text':
|
|
243
|
-
return this.criteriaForTextModel(k, model);
|
|
244
|
-
case 'set':
|
|
245
|
-
return this.criteriaForSetModel(k, model);
|
|
246
|
-
case 'number':
|
|
247
|
-
return this.criteriaForNumberModel(k, model);
|
|
248
|
-
case 'date':
|
|
249
|
-
return this.criteriaForDateModel(k, model);
|
|
250
|
-
default:
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
criteriaForTextModel(k, model) {
|
|
255
|
-
const type = model.type;
|
|
256
|
-
const val = model.filter;
|
|
257
|
-
if (!val && (type === 'false' || type === 'true')) {
|
|
258
|
-
return `${k} == ${type}`;
|
|
259
|
-
}
|
|
260
|
-
switch (type) {
|
|
261
|
-
case 'blank':
|
|
262
|
-
return `(${k} == '' || ${k} == null)`;
|
|
263
|
-
case 'contains':
|
|
264
|
-
return `Expr.containsIgnoreCase(${k}, '${val}')`;
|
|
265
|
-
case 'equals':
|
|
266
|
-
return `${k} == '${val}'`;
|
|
267
|
-
case 'notBlank':
|
|
268
|
-
return `(${k} != '' && ${k} != null)`;
|
|
269
|
-
case 'notEqual':
|
|
270
|
-
return `${k} != '${val}'`;
|
|
271
|
-
case 'wordStartsWith':
|
|
272
|
-
return `Expr.containsWordsStartingWithIgnoreCase(${k}, '${val}')`;
|
|
273
|
-
default:
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
criteriaForSetModel(k, model) {
|
|
278
|
-
var _a, _b;
|
|
279
|
-
const selectedValues = ((_a = model.values) !== null && _a !== void 0 ? _a : []);
|
|
280
|
-
if (!selectedValues.length) {
|
|
281
|
-
// Nothing selected means no additional criteria
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
// Try to detect "all values selected" using VALID_VALUES from metadata.
|
|
285
|
-
// In that case we don't want to send any criteria, as it would be equivalent
|
|
286
|
-
// to no filter at all.
|
|
287
|
-
const colMeta = (_b = this.resourceColDefs) === null || _b === void 0 ? void 0 : _b.find((o) => o.NAME === k);
|
|
288
|
-
let allValues;
|
|
289
|
-
if (colMeta === null || colMeta === void 0 ? void 0 : colMeta.VALID_VALUES) {
|
|
290
|
-
try {
|
|
291
|
-
allValues = Array.isArray(colMeta.VALID_VALUES)
|
|
292
|
-
? colMeta.VALID_VALUES
|
|
293
|
-
: colMeta.VALID_VALUES.split('|');
|
|
294
|
-
}
|
|
295
|
-
catch (_c) {
|
|
296
|
-
allValues = undefined;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (allValues &&
|
|
300
|
-
allValues.length === selectedValues.length &&
|
|
301
|
-
allValues.every((v) => selectedValues.includes(v))) {
|
|
302
|
-
// All enum options are selected – skip adding criteria for this column
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
const orConditions = selectedValues.map((val) => {
|
|
306
|
-
const safeVal = String(val).replace(/'/g, "\\'");
|
|
307
|
-
return `${k} == '${safeVal}'`;
|
|
308
|
-
});
|
|
309
|
-
return orConditions.length ? `(${orConditions.join(' || ')})` : null;
|
|
310
|
-
}
|
|
311
|
-
criteriaForNumberModel(k, model) {
|
|
312
|
-
const value = model.filter;
|
|
313
|
-
const valueTwo = model.filterTo;
|
|
314
|
-
switch (model.type) {
|
|
315
|
-
case 'equals':
|
|
316
|
-
return !isNaN(value) ? `${k} == ${value}` : null;
|
|
317
|
-
case 'notEqual':
|
|
318
|
-
return !isNaN(value) ? `${k} != ${value}` : null;
|
|
319
|
-
case 'greaterThan':
|
|
320
|
-
return !isNaN(value) ? `${k} > ${value}` : null;
|
|
321
|
-
case 'greaterThanOrEqual':
|
|
322
|
-
return !isNaN(value) ? `${k} >= ${value}` : null;
|
|
323
|
-
case 'lessThan':
|
|
324
|
-
return !isNaN(value) ? `${k} < ${value}` : null;
|
|
325
|
-
case 'lessThanOrEqual':
|
|
326
|
-
return !isNaN(value) ? `${k} <= ${value}` : null;
|
|
327
|
-
case 'inRange':
|
|
328
|
-
return !isNaN(value) && !isNaN(valueTwo) ? `${k} >= ${value} && ${k} <= ${valueTwo}` : null;
|
|
329
|
-
case 'blank':
|
|
330
|
-
return `${k} == 0`;
|
|
331
|
-
case 'notBlank':
|
|
332
|
-
return `${k} != 0`;
|
|
333
|
-
default:
|
|
334
|
-
return null;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
criteriaForDateModel(k, model) {
|
|
338
|
-
var _a, _b;
|
|
339
|
-
const dateFrom = (_a = model.dateFrom) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '').replace('T', '-').split(' ')[0];
|
|
340
|
-
const dateTo = (_b = model.dateTo) === null || _b === void 0 ? void 0 : _b.replace(/-/g, '').replace('T', '-').split(' ')[0];
|
|
341
|
-
switch (model.type) {
|
|
342
|
-
case 'equals':
|
|
343
|
-
return `Expr.dateIsEqual(${k}, '${dateFrom}')`;
|
|
344
|
-
case 'lessThan':
|
|
345
|
-
return `Expr.dateIsBefore(${k}, '${dateFrom}')`;
|
|
346
|
-
case 'greaterThan':
|
|
347
|
-
return `Expr.dateIsAfter(${k}, '${dateFrom}')`;
|
|
348
|
-
case 'inRange':
|
|
349
|
-
return `Expr.dateIsAfter(${k}, '${dateFrom}') && Expr.dateIsBefore(${k}, '${dateTo}')`;
|
|
350
|
-
case 'isToday': {
|
|
351
|
-
const now = new Date();
|
|
352
|
-
const year = now.getFullYear();
|
|
353
|
-
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
354
|
-
const day = now.getDate().toString().padStart(2, '0');
|
|
355
|
-
return `Expr.dateIsEqual(${k}, '${year}-${month}-${day} 00:00:00')`;
|
|
356
|
-
}
|
|
357
|
-
case 'blank':
|
|
358
|
-
return `${k} == null`;
|
|
359
|
-
case 'notBlank':
|
|
360
|
-
return `${k} != null`;
|
|
361
|
-
default:
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
312
|
getFiltersByType(filterType) {
|
|
366
313
|
var _a;
|
|
367
314
|
return Object.keys((_a = this.currentFilterModel) !== null && _a !== void 0 ? _a : {})
|
|
@@ -389,22 +336,19 @@ export class BaseServerSideDatasource {
|
|
|
389
336
|
}
|
|
390
337
|
return rowCount;
|
|
391
338
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (!this.moreRows) {
|
|
395
|
-
// Dataset ends here: rowData.size is the deduplicated loaded count. Deliberately not
|
|
396
|
-
// serverRowsCount (GSF's ROWS_COUNT ignores CRITERIA_MATCH) nor clientRowsCount
|
|
397
|
-
// (non-deduplicated running sum, overcounts on live streams).
|
|
398
|
-
rowCount = Math.min(this.rowData.size, this.maxView);
|
|
339
|
+
if (currentLastRowNumber === this.serverRowsCount && !this.moreRows) {
|
|
340
|
+
rowCount = this.serverRowsCount;
|
|
399
341
|
}
|
|
400
|
-
else if (
|
|
401
|
-
|
|
402
|
-
rowCount = this.maxView;
|
|
342
|
+
else if (currentLastRowNumber > this.maxView) {
|
|
343
|
+
rowCount = Math.min(defaultCount, this.calculatedRowsCount);
|
|
403
344
|
}
|
|
404
|
-
else {
|
|
405
|
-
//
|
|
406
|
-
//
|
|
407
|
-
rowCount =
|
|
345
|
+
else if (!this.moreRows && currentLastRowNumber > this.calculatedRowsCount) {
|
|
346
|
+
// No more data from server and request is beyond what has been counted.
|
|
347
|
+
// Return the actual loaded count so AG Grid knows the dataset ends here.
|
|
348
|
+
rowCount = this.clientRowsCount || this.calculatedRowsCount;
|
|
349
|
+
}
|
|
350
|
+
else if (!this.moreRows && this.serverRowsCount > this.calculatedRowsCount) {
|
|
351
|
+
rowCount = this.calculatedRowsCount;
|
|
408
352
|
}
|
|
409
353
|
return rowCount;
|
|
410
354
|
}
|