@sankhyalabs/sankhyablocks 0.0.0-feat-dev-KB-14960.2 → 0.0.0-feat-dev-KB-14960.3
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/cjs/{SnkMultiSelectionListDataSource-8aae47a4.js → SnkMultiSelectionListDataSource-8711ff82.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-70d1c070.js → dataunit-fetcher-67ef8df2.js} +133 -99
- package/dist/cjs/snk-actions-button.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-20d219c5.js → snk-guides-viewer-daf6c7d8.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -90
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +23 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +6 -8
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +15 -15
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +5 -12
- package/dist/components/dataunit-fetcher.js +134 -101
- package/dist/components/snk-simple-crud2.js +2 -88
- package/dist/esm/{SnkMultiSelectionListDataSource-1871aa5f.js → SnkMultiSelectionListDataSource-04010e28.js} +1 -1
- package/dist/esm/{dataunit-fetcher-7d7726bb.js → dataunit-fetcher-57e6f9a2.js} +134 -101
- package/dist/esm/snk-actions-button.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-dcbfd2a6.js → snk-guides-viewer-bc8c3167.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +3 -89
- package/dist/sankhyablocks/{p-88ede1c0.js → p-0d039e62.js} +1 -1
- package/dist/sankhyablocks/{p-177fa5be.entry.js → p-16eb467b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6982fb80.entry.js → p-1f173bc2.entry.js} +2 -2
- package/dist/sankhyablocks/{p-505b29cb.entry.js → p-4606d486.entry.js} +1 -1
- package/dist/sankhyablocks/p-642953bd.js +59 -0
- package/dist/sankhyablocks/{p-d61c6a82.js → p-6e0891da.js} +1 -1
- package/dist/sankhyablocks/{p-75df7885.entry.js → p-89d5cbbc.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ddaf32de.entry.js → p-ae5a6fde.entry.js} +1 -1
- package/dist/sankhyablocks/{p-935f3865.entry.js → p-c40c1c4a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e66e2631.entry.js → p-c7a8b21e.entry.js} +1 -1
- package/dist/sankhyablocks/p-d670c445.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +1 -2
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +3 -1
- package/package.json +3 -3
- package/dist/sankhyablocks/p-6765e2a4.js +0 -76
- package/dist/sankhyablocks/p-ff712e39.entry.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const core = require('@sankhyalabs/core');
|
|
4
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
|
4
|
+
const dataunitFetcher = require('./dataunit-fetcher-67ef8df2.js');
|
|
5
5
|
|
|
6
6
|
class SnkMultiSelectionListDataSource {
|
|
7
7
|
setDataUnit(dataUnit) {
|
|
@@ -8,6 +8,7 @@ const ResourceIDUtils = require('./ResourceIDUtils-5ff86aa7.js');
|
|
|
8
8
|
|
|
9
9
|
class ArrayRepository {
|
|
10
10
|
constructor(equalsFunction) {
|
|
11
|
+
this._list = [];
|
|
11
12
|
this._equalsFunction = equalsFunction;
|
|
12
13
|
}
|
|
13
14
|
async load(filterFunction, sortingFunction, offset, limit) {
|
|
@@ -68,6 +69,9 @@ class ArrayRepository {
|
|
|
68
69
|
|
|
69
70
|
const COLUMN_FILTER_PATTERN = /FILTRO_COLUNA_(.+)/;
|
|
70
71
|
class PreloadManager {
|
|
72
|
+
static setLoadingStatus(dataUnit, loadingInProgress) {
|
|
73
|
+
this._loadingStatus.set(dataUnit.name, loadingInProgress);
|
|
74
|
+
}
|
|
71
75
|
static isCacheEnabled(dataUnit) {
|
|
72
76
|
const dataUnitResourceId = PreloadManager.getResourceId(dataUnit.name);
|
|
73
77
|
if (dataUnitResourceId !== this.applicationResourceID) {
|
|
@@ -79,7 +83,8 @@ class PreloadManager {
|
|
|
79
83
|
const dataUnitNameInfo = DataUnitFetcher.parseDataUnitName(dataUnitName);
|
|
80
84
|
return dataUnitNameInfo == undefined ? undefined : dataUnitNameInfo.resourceID;
|
|
81
85
|
}
|
|
82
|
-
static cacheRecords(dataUnit, records, resetDatabase) {
|
|
86
|
+
static cacheRecords(dataUnit, records, resetDatabase, loadingInProgress) {
|
|
87
|
+
PreloadManager.setLoadingStatus(dataUnit, loadingInProgress);
|
|
83
88
|
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
84
89
|
this.getRepository(dataUnit).push(records);
|
|
85
90
|
}
|
|
@@ -191,28 +196,23 @@ class PreloadManager {
|
|
|
191
196
|
return false;
|
|
192
197
|
}
|
|
193
198
|
static async loadFromCache(dataUnit, request) {
|
|
194
|
-
const start = new Date();
|
|
195
199
|
return new Promise((accept, reject) => {
|
|
196
200
|
const columnFilters = PreloadManager.getColumnFilters(request.filters);
|
|
197
201
|
const { limit, offset, sort } = request;
|
|
198
202
|
PreloadManager.getRepository(dataUnit)
|
|
199
203
|
.load(PreloadManager.getFilterFunction(dataUnit, Array.from(columnFilters.values())), PreloadManager.getSortingFunction(dataUnit, sort), offset, limit)
|
|
200
204
|
.then(loadResult => {
|
|
201
|
-
const
|
|
202
|
-
const
|
|
205
|
+
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
|
206
|
+
const { count, result: records } = loadResult;
|
|
207
|
+
const firstRecord = count == 0 ? 1 : offset + 1;
|
|
203
208
|
const lastRecord = offset + Math.min(records.length, limit);
|
|
204
209
|
const currentPage = offset / limit;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
lastRecord,
|
|
212
|
-
total,
|
|
213
|
-
hasMore: lastRecord < total
|
|
214
|
-
}
|
|
215
|
-
});
|
|
210
|
+
const paginationInfo = {
|
|
211
|
+
count, currentPage, firstRecord, lastRecord,
|
|
212
|
+
hasMore: stillLoading || (lastRecord < count),
|
|
213
|
+
total: stillLoading ? undefined : count
|
|
214
|
+
};
|
|
215
|
+
accept({ records, paginationInfo });
|
|
216
216
|
})
|
|
217
217
|
.catch(reason => reject(reason));
|
|
218
218
|
});
|
|
@@ -232,6 +232,114 @@ class PreloadManager {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
PreloadManager._repositories = new Map();
|
|
235
|
+
PreloadManager._loadingStatus = new Map();
|
|
236
|
+
|
|
237
|
+
class InMemoryLoader {
|
|
238
|
+
constructor(metadata, records) {
|
|
239
|
+
this.metadata = metadata;
|
|
240
|
+
this.records = records;
|
|
241
|
+
this._dataUnit = new core.DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
|
242
|
+
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
|
243
|
+
this._dataUnit.dataLoader = (dataUnit, request) => core.defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
|
244
|
+
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
|
245
|
+
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
|
246
|
+
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
|
247
|
+
}
|
|
248
|
+
getRecordsToLoad() {
|
|
249
|
+
if (this._initialRecords) {
|
|
250
|
+
try {
|
|
251
|
+
return this._initialRecords;
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
this._initialRecords = undefined;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return this.dataUnit.records;
|
|
258
|
+
}
|
|
259
|
+
get dataUnit() {
|
|
260
|
+
return this._dataUnit;
|
|
261
|
+
}
|
|
262
|
+
get records() {
|
|
263
|
+
return this.dataUnit.records;
|
|
264
|
+
}
|
|
265
|
+
static getConvertedValue(descriptor, strValue) {
|
|
266
|
+
if (descriptor.dataType === core.DataType.BOOLEAN) {
|
|
267
|
+
return strValue === "S";
|
|
268
|
+
}
|
|
269
|
+
if (descriptor.dataType === core.DataType.NUMBER) {
|
|
270
|
+
return Number(strValue);
|
|
271
|
+
}
|
|
272
|
+
if (descriptor.dataType === core.DataType.DATE) {
|
|
273
|
+
return core.DateUtils.strToDate(strValue, true);
|
|
274
|
+
}
|
|
275
|
+
return strValue;
|
|
276
|
+
}
|
|
277
|
+
set records(records) {
|
|
278
|
+
const columns = this._metadata ? new Map(this._metadata.fields.map(descriptor => [descriptor.name, descriptor])) : undefined;
|
|
279
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
|
280
|
+
if (!record["__record__id__"]) {
|
|
281
|
+
record["__record__id__"] = this.generateUniqueId();
|
|
282
|
+
}
|
|
283
|
+
if (columns != undefined) {
|
|
284
|
+
for (const name in record) {
|
|
285
|
+
const value = record[name];
|
|
286
|
+
if (typeof value === "string" && columns.has(name)) {
|
|
287
|
+
record[name] = InMemoryLoader.getConvertedValue(columns.get(name), value);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return record;
|
|
292
|
+
});
|
|
293
|
+
if (this._dataUnit) {
|
|
294
|
+
this._dataUnit.records = newRecords;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
this._initialRecords = newRecords;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
get metadata() {
|
|
301
|
+
return this._metadata;
|
|
302
|
+
}
|
|
303
|
+
set metadata(metadata) {
|
|
304
|
+
this._metadata = metadata;
|
|
305
|
+
if (this._dataUnit) {
|
|
306
|
+
this._dataUnit.metadata = this._metadata;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
generateUniqueId() {
|
|
310
|
+
return core.StringUtils.generateUUID();
|
|
311
|
+
}
|
|
312
|
+
metadaLoader() {
|
|
313
|
+
return Promise.resolve(this._metadata);
|
|
314
|
+
}
|
|
315
|
+
saveLoader(_dataUnit, changes) {
|
|
316
|
+
return new Promise((resolve) => {
|
|
317
|
+
let dataUnitRecords = [];
|
|
318
|
+
changes.forEach(change => {
|
|
319
|
+
let { record, updatingFields, operation } = change;
|
|
320
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
|
321
|
+
if (operation === core.ChangeOperation.INSERT ||
|
|
322
|
+
operation === core.ChangeOperation.COPY) {
|
|
323
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
|
324
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
|
325
|
+
this.records.push(changedRecord);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
|
329
|
+
this.records[recordIndex] = changedRecord;
|
|
330
|
+
}
|
|
331
|
+
dataUnitRecords.push(changedRecord);
|
|
332
|
+
});
|
|
333
|
+
resolve(dataUnitRecords);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
removeLoader(_dataUnit, recordIds) {
|
|
337
|
+
return new Promise((resolve) => {
|
|
338
|
+
resolve(recordIds);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
|
235
343
|
|
|
236
344
|
class DatasetStrategy {
|
|
237
345
|
canSlice() {
|
|
@@ -248,10 +356,11 @@ class DatasetStrategy {
|
|
|
248
356
|
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.DataFetcher.get().callServiceBroker(serviceName, requestBody);
|
|
249
357
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
|
250
358
|
const loadingInProgress = pagerId != undefined;
|
|
359
|
+
const count = loadingInfo.count + records.length;
|
|
251
360
|
return Promise.resolve({
|
|
252
361
|
records,
|
|
253
362
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
|
254
|
-
loadingInProgress,
|
|
363
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: !loadingInProgress })
|
|
255
364
|
});
|
|
256
365
|
}
|
|
257
366
|
catch (error) {
|
|
@@ -344,16 +453,7 @@ class DatasetStrategy {
|
|
|
344
453
|
//Mas é um search, tentamos parsear um numero...
|
|
345
454
|
return isNaN(Number(strValue)) ? strValue : Number(strValue);
|
|
346
455
|
}
|
|
347
|
-
|
|
348
|
-
return strValue === "S";
|
|
349
|
-
}
|
|
350
|
-
if (descriptor.dataType === core.DataType.NUMBER) {
|
|
351
|
-
return Number(strValue);
|
|
352
|
-
}
|
|
353
|
-
if (descriptor.dataType === core.DataType.DATE) {
|
|
354
|
-
return core.DateUtils.strToDate(strValue, true);
|
|
355
|
-
}
|
|
356
|
-
return strValue;
|
|
456
|
+
return InMemoryLoader.getConvertedValue(descriptor, strValue);
|
|
357
457
|
}
|
|
358
458
|
getSearchDescriptionField(descriptor) {
|
|
359
459
|
if (descriptor.userInterface === core.UserInterface.SEARCH) {
|
|
@@ -366,72 +466,6 @@ class DatasetStrategy {
|
|
|
366
466
|
}
|
|
367
467
|
}
|
|
368
468
|
|
|
369
|
-
const GQL_QUERY = DataFetcher.dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
|
|
370
|
-
$queryAlias$: fetchDataUnit(name: $dataunit) {
|
|
371
|
-
data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId) {
|
|
372
|
-
limit
|
|
373
|
-
offset
|
|
374
|
-
total
|
|
375
|
-
hasMore
|
|
376
|
-
records {
|
|
377
|
-
id
|
|
378
|
-
label
|
|
379
|
-
fields {
|
|
380
|
-
name
|
|
381
|
-
value
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}`;
|
|
387
|
-
class DataUnitStrategy {
|
|
388
|
-
canSlice() {
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
getVariables(dataunit, request) {
|
|
392
|
-
var _a;
|
|
393
|
-
let { sort, filters, limit, offset, quickFilter, parentRecordId } = request;
|
|
394
|
-
if (!core.StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
|
|
395
|
-
const quickFilterCriteria = {
|
|
396
|
-
name: "__QUICK_FILTER__",
|
|
397
|
-
expression: "__QUICK_FILTER__",
|
|
398
|
-
params: [{ name: "term", dataType: core.DataType.TEXT, value: quickFilter.term }]
|
|
399
|
-
};
|
|
400
|
-
if (((_a = quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
401
|
-
quickFilterCriteria.params.push({ name: "fields", dataType: core.DataType.OBJECT, value: quickFilter.fields });
|
|
402
|
-
}
|
|
403
|
-
if (filters === undefined) {
|
|
404
|
-
filters = [];
|
|
405
|
-
}
|
|
406
|
-
filters.push(quickFilterCriteria);
|
|
407
|
-
}
|
|
408
|
-
return { dataunit, sort, filters, limit, offset, parentRecordId };
|
|
409
|
-
}
|
|
410
|
-
async load(dataUnit, request, loadingInfo) {
|
|
411
|
-
return new Promise((accept, reject) => {
|
|
412
|
-
DataFetcher.DataFetcher.get().callGraphQL({
|
|
413
|
-
values: this.getVariables(dataUnit.name, request),
|
|
414
|
-
query: GQL_QUERY
|
|
415
|
-
}, false)
|
|
416
|
-
.then(resp => {
|
|
417
|
-
const { hasMore, records: responseRecords, total } = resp.data;
|
|
418
|
-
const records = responseRecords.map((record) => {
|
|
419
|
-
const duRecord = { __record__id__: record.id, __record__label__: record.label };
|
|
420
|
-
record.fields.forEach(({ name, value }) => {
|
|
421
|
-
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
422
|
-
});
|
|
423
|
-
return duRecord;
|
|
424
|
-
});
|
|
425
|
-
accept({
|
|
426
|
-
records,
|
|
427
|
-
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { loadingInProgress: hasMore, total, count: loadingInfo.count + records.length })
|
|
428
|
-
});
|
|
429
|
-
})
|
|
430
|
-
.catch(reason => reject(reason));
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
469
|
class DataUnitDataLoader {
|
|
436
470
|
static async debounce(dataUnit, callBack) {
|
|
437
471
|
const duName = dataUnit.name;
|
|
@@ -475,7 +509,8 @@ class DataUnitDataLoader {
|
|
|
475
509
|
}
|
|
476
510
|
static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
|
|
477
511
|
if (dataLoader == undefined) {
|
|
478
|
-
dataLoader =
|
|
512
|
+
//dataLoader = new DataUnitStrategy();
|
|
513
|
+
dataLoader = new DatasetStrategy();
|
|
479
514
|
}
|
|
480
515
|
const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
|
|
481
516
|
const { records, loadingInfo: responseLoadingInfo } = result;
|
|
@@ -483,17 +518,18 @@ class DataUnitDataLoader {
|
|
|
483
518
|
return Promise.resolve(undefined);
|
|
484
519
|
}
|
|
485
520
|
const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
|
|
486
|
-
PreloadManager.cacheRecords(dataUnit, records, recreateCache);
|
|
521
|
+
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
|
487
522
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
|
488
523
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
|
489
524
|
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
|
490
525
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
|
491
|
-
.then(result => DataUnitDataLoader.
|
|
526
|
+
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
|
492
527
|
.catch(reason => console.error(reason));
|
|
493
528
|
}
|
|
494
529
|
return Promise.resolve(result);
|
|
495
530
|
}
|
|
496
|
-
static
|
|
531
|
+
static afterLoadingPage(dataUnit, loadingInfo) {
|
|
532
|
+
PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
|
|
497
533
|
const dataUnitPagination = dataUnit.getPaginationInfo();
|
|
498
534
|
if (dataUnitPagination == undefined) {
|
|
499
535
|
return;
|
|
@@ -520,9 +556,6 @@ class DataUnitDataLoader {
|
|
|
520
556
|
static isOldRequest(dataUnit, loadingInfo) {
|
|
521
557
|
return DataUnitDataLoader._requestTimeByDataUnit.get(dataUnit.name) > loadingInfo.requestTime;
|
|
522
558
|
}
|
|
523
|
-
static getStrategy(legacy) {
|
|
524
|
-
return legacy ? new DatasetStrategy() : new DataUnitStrategy();
|
|
525
|
-
}
|
|
526
559
|
static buildPaginationInfo(pageSize, request, loadingInfo) {
|
|
527
560
|
let { limit, offset } = request;
|
|
528
561
|
if (!limit) {
|
|
@@ -843,4 +876,5 @@ class DataUnitFetcher {
|
|
|
843
876
|
}
|
|
844
877
|
|
|
845
878
|
exports.DataUnitFetcher = DataUnitFetcher;
|
|
879
|
+
exports.InMemoryLoader = InMemoryLoader;
|
|
846
880
|
exports.PreloadManager = PreloadManager;
|
|
@@ -11,7 +11,7 @@ require('./index-0e663819.js');
|
|
|
11
11
|
require('./ISave-d68ce3cd.js');
|
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
14
|
-
require('./dataunit-fetcher-
|
|
14
|
+
require('./dataunit-fetcher-67ef8df2.js');
|
|
15
15
|
require('./filter-item-type.enum-aa823a00.js');
|
|
16
16
|
require('./form-config-fetcher-ad090dd1.js');
|
|
17
17
|
const ResourceIDUtils = require('./ResourceIDUtils-5ff86aa7.js');
|
|
@@ -8,7 +8,7 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
|
8
8
|
const ConfigStorage = require('./ConfigStorage-2f4b9934.js');
|
|
9
9
|
const DataFetcher = require('./DataFetcher-adb2beb4.js');
|
|
10
10
|
const authFetcher = require('./auth-fetcher-e1d8c26b.js');
|
|
11
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
|
11
|
+
const dataunitFetcher = require('./dataunit-fetcher-67ef8df2.js');
|
|
12
12
|
const pesquisaFetcher = require('./pesquisa-fetcher-64473c9f.js');
|
|
13
13
|
const SnkMessageBuilder = require('./SnkMessageBuilder-d0abb63d.js');
|
|
14
14
|
require('./form-config-fetcher-ad090dd1.js');
|
|
@@ -7,7 +7,7 @@ const core = require('@sankhyalabs/core');
|
|
|
7
7
|
const DataFetcher = require('./DataFetcher-adb2beb4.js');
|
|
8
8
|
const ISave = require('./ISave-d68ce3cd.js');
|
|
9
9
|
const constants = require('./constants-d187e03e.js');
|
|
10
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
|
10
|
+
const dataunitFetcher = require('./dataunit-fetcher-67ef8df2.js');
|
|
11
11
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
|
12
12
|
require('./_commonjsHelpers-537d719a.js');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
@@ -11,7 +11,7 @@ const index$1 = require('./index-0e663819.js');
|
|
|
11
11
|
require('./ISave-d68ce3cd.js');
|
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
14
|
-
require('./dataunit-fetcher-
|
|
14
|
+
require('./dataunit-fetcher-67ef8df2.js');
|
|
15
15
|
require('./filter-item-type.enum-aa823a00.js');
|
|
16
16
|
require('./form-config-fetcher-ad090dd1.js');
|
|
17
17
|
const constants = require('./constants-d187e03e.js');
|
|
@@ -12,12 +12,12 @@ const index$1 = require('./index-0e663819.js');
|
|
|
12
12
|
require('./ISave-d68ce3cd.js');
|
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
15
|
-
require('./dataunit-fetcher-
|
|
15
|
+
require('./dataunit-fetcher-67ef8df2.js');
|
|
16
16
|
require('./filter-item-type.enum-aa823a00.js');
|
|
17
17
|
require('./form-config-fetcher-ad090dd1.js');
|
|
18
18
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
|
19
19
|
const constants = require('./constants-d187e03e.js');
|
|
20
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
|
20
|
+
const snkGuidesViewer = require('./snk-guides-viewer-daf6c7d8.js');
|
|
21
21
|
const SnkMessageBuilder = require('./SnkMessageBuilder-d0abb63d.js');
|
|
22
22
|
require('./ConfigStorage-2f4b9934.js');
|
|
23
23
|
require('./_commonjsHelpers-537d719a.js');
|
|
@@ -10,14 +10,14 @@ const ConfigStorage = require('./ConfigStorage-2f4b9934.js');
|
|
|
10
10
|
const index$1 = require('./index-0e663819.js');
|
|
11
11
|
const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
|
|
12
12
|
const index$2 = require('./index-102ba62d.js');
|
|
13
|
-
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-
|
|
13
|
+
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-8711ff82.js');
|
|
14
14
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
15
15
|
require('./form-config-fetcher-ad090dd1.js');
|
|
16
16
|
require('./DataFetcher-adb2beb4.js');
|
|
17
17
|
require('./_commonjsHelpers-537d719a.js');
|
|
18
18
|
require('./PrintUtils-bcaeb82f.js');
|
|
19
19
|
require('./filter-item-type.enum-aa823a00.js');
|
|
20
|
-
require('./dataunit-fetcher-
|
|
20
|
+
require('./dataunit-fetcher-67ef8df2.js');
|
|
21
21
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
22
22
|
require('./ResourceIDUtils-5ff86aa7.js');
|
|
23
23
|
|
|
@@ -13,7 +13,7 @@ const index$1 = require('./index-0e663819.js');
|
|
|
13
13
|
require('./ISave-d68ce3cd.js');
|
|
14
14
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
15
15
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
16
|
-
require('./dataunit-fetcher-
|
|
16
|
+
require('./dataunit-fetcher-67ef8df2.js');
|
|
17
17
|
require('./filter-item-type.enum-aa823a00.js');
|
|
18
18
|
require('./form-config-fetcher-ad090dd1.js');
|
|
19
19
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-daf6c7d8.js');
|
|
6
6
|
require('./index-f9e81701.js');
|
|
7
7
|
require('@sankhyalabs/core');
|
|
8
8
|
require('./SnkFormConfigManager-2c711d00.js');
|
|
@@ -22,7 +22,7 @@ require('./constants-d187e03e.js');
|
|
|
22
22
|
require('./pesquisa-fetcher-64473c9f.js');
|
|
23
23
|
require('./ISave-d68ce3cd.js');
|
|
24
24
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
25
|
-
require('./dataunit-fetcher-
|
|
25
|
+
require('./dataunit-fetcher-67ef8df2.js');
|
|
26
26
|
require('./ResourceIDUtils-5ff86aa7.js');
|
|
27
27
|
require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
28
28
|
|
|
@@ -12,102 +12,16 @@ const index$1 = require('./index-0e663819.js');
|
|
|
12
12
|
require('./ISave-d68ce3cd.js');
|
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
15
|
-
require('./dataunit-fetcher-
|
|
15
|
+
const dataunitFetcher = require('./dataunit-fetcher-67ef8df2.js');
|
|
16
16
|
require('./filter-item-type.enum-aa823a00.js');
|
|
17
17
|
require('./form-config-fetcher-ad090dd1.js');
|
|
18
18
|
const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
|
|
19
|
-
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-
|
|
19
|
+
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-8711ff82.js');
|
|
20
20
|
require('./index-102ba62d.js');
|
|
21
21
|
require('./_commonjsHelpers-537d719a.js');
|
|
22
22
|
require('./PrintUtils-bcaeb82f.js');
|
|
23
23
|
require('./ResourceIDUtils-5ff86aa7.js');
|
|
24
24
|
|
|
25
|
-
class InMemoryLoader {
|
|
26
|
-
constructor(metadata, records) {
|
|
27
|
-
this.records = records;
|
|
28
|
-
this.metadata = metadata;
|
|
29
|
-
this._dataUnit = new core.DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
|
30
|
-
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
|
31
|
-
this._dataUnit.dataLoader = (dataUnit, request) => core.defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
|
32
|
-
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
|
33
|
-
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
|
34
|
-
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
|
35
|
-
}
|
|
36
|
-
getRecordsToLoad() {
|
|
37
|
-
if (this._initialRecords) {
|
|
38
|
-
try {
|
|
39
|
-
return this._initialRecords;
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
this._initialRecords = undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return this.dataUnit.records;
|
|
46
|
-
}
|
|
47
|
-
get dataUnit() {
|
|
48
|
-
return this._dataUnit;
|
|
49
|
-
}
|
|
50
|
-
get records() {
|
|
51
|
-
return this.dataUnit.records;
|
|
52
|
-
}
|
|
53
|
-
set records(records) {
|
|
54
|
-
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
|
55
|
-
if (!record["__record__id__"]) {
|
|
56
|
-
record["__record__id__"] = this.generateUniqueId();
|
|
57
|
-
}
|
|
58
|
-
return record;
|
|
59
|
-
});
|
|
60
|
-
if (this._dataUnit) {
|
|
61
|
-
this._dataUnit.records = newRecords;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
this._initialRecords = newRecords;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
get metadata() {
|
|
68
|
-
return this._metadata;
|
|
69
|
-
}
|
|
70
|
-
set metadata(metadata) {
|
|
71
|
-
this._metadata = metadata;
|
|
72
|
-
if (this._dataUnit) {
|
|
73
|
-
this._dataUnit.metadata = this._metadata;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
generateUniqueId() {
|
|
77
|
-
return core.StringUtils.generateUUID();
|
|
78
|
-
}
|
|
79
|
-
metadaLoader() {
|
|
80
|
-
return Promise.resolve(this._metadata);
|
|
81
|
-
}
|
|
82
|
-
saveLoader(_dataUnit, changes) {
|
|
83
|
-
return new Promise((resolve) => {
|
|
84
|
-
let dataUnitRecords = [];
|
|
85
|
-
changes.forEach(change => {
|
|
86
|
-
let { record, updatingFields, operation } = change;
|
|
87
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
|
88
|
-
if (operation === core.ChangeOperation.INSERT ||
|
|
89
|
-
operation === core.ChangeOperation.COPY) {
|
|
90
|
-
changedRecord["__old__id__"] = record["__record__id__"];
|
|
91
|
-
changedRecord["__record__id__"] = this.generateUniqueId();
|
|
92
|
-
this.records.push(changedRecord);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
|
96
|
-
this.records[recordIndex] = changedRecord;
|
|
97
|
-
}
|
|
98
|
-
dataUnitRecords.push(changedRecord);
|
|
99
|
-
});
|
|
100
|
-
resolve(dataUnitRecords);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
removeLoader(_dataUnit, recordIds) {
|
|
104
|
-
return new Promise((resolve) => {
|
|
105
|
-
resolve(recordIds);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
|
110
|
-
|
|
111
25
|
const snkSimpleCrudCss = ".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";
|
|
112
26
|
|
|
113
27
|
const SnkSimpleCrud = class {
|
|
@@ -202,7 +116,7 @@ const SnkSimpleCrud = class {
|
|
|
202
116
|
return this._currentViewMode === constants.VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
|
203
117
|
}
|
|
204
118
|
initInMemoryDataUnit() {
|
|
205
|
-
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
|
119
|
+
this._inMemoryLoader = new dataunitFetcher.InMemoryLoader(this._metadata);
|
|
206
120
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
|
207
121
|
this.dataUnitReady.emit(this.dataUnit);
|
|
208
122
|
}
|
|
@@ -283,7 +197,7 @@ const SnkSimpleCrud = class {
|
|
|
283
197
|
}
|
|
284
198
|
render() {
|
|
285
199
|
var _a;
|
|
286
|
-
return (index.h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, index.h("header", null, index.h("slot", { name: "snkSimpleCrudHeader" })), index.h("section", { class: "ez-flex ez-box ez-box--shadow" }, index.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: index$1.PresentationMode.SECONDARY }, index.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index.h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index.h("stack-item", null, index.h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
|
200
|
+
return (index.h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, index.h("header", null, index.h("slot", { name: "snkSimpleCrudHeader" })), index.h("section", { class: "ez-flex ez-box ez-box--shadow" }, index.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: index$1.PresentationMode.SECONDARY }, index.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index.h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index.h("stack-item", null, index.h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
|
287
201
|
? undefined
|
|
288
202
|
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index.h("div", { slot: "footer" }, index.h("slot", { name: "snkSimpleCrudFooter" })))), index.h("stack-item", null, index.h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig }))))));
|
|
289
203
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChangeOperation, DataUnit, defaultDataLoader, StringUtils, } from '@sankhyalabs/core';
|
|
1
|
+
import { ChangeOperation, DataType, DataUnit, DateUtils, defaultDataLoader, StringUtils, } from '@sankhyalabs/core';
|
|
2
2
|
export default class InMemoryLoader {
|
|
3
3
|
constructor(metadata, records) {
|
|
4
|
-
this.records = records;
|
|
5
4
|
this.metadata = metadata;
|
|
5
|
+
this.records = records;
|
|
6
6
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
|
7
7
|
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
|
8
8
|
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
|
@@ -27,11 +27,32 @@ export default class InMemoryLoader {
|
|
|
27
27
|
get records() {
|
|
28
28
|
return this.dataUnit.records;
|
|
29
29
|
}
|
|
30
|
+
static getConvertedValue(descriptor, strValue) {
|
|
31
|
+
if (descriptor.dataType === DataType.BOOLEAN) {
|
|
32
|
+
return strValue === "S";
|
|
33
|
+
}
|
|
34
|
+
if (descriptor.dataType === DataType.NUMBER) {
|
|
35
|
+
return Number(strValue);
|
|
36
|
+
}
|
|
37
|
+
if (descriptor.dataType === DataType.DATE) {
|
|
38
|
+
return DateUtils.strToDate(strValue, true);
|
|
39
|
+
}
|
|
40
|
+
return strValue;
|
|
41
|
+
}
|
|
30
42
|
set records(records) {
|
|
43
|
+
const columns = this._metadata ? new Map(this._metadata.fields.map(descriptor => [descriptor.name, descriptor])) : undefined;
|
|
31
44
|
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
|
32
45
|
if (!record["__record__id__"]) {
|
|
33
46
|
record["__record__id__"] = this.generateUniqueId();
|
|
34
47
|
}
|
|
48
|
+
if (columns != undefined) {
|
|
49
|
+
for (const name in record) {
|
|
50
|
+
const value = record[name];
|
|
51
|
+
if (typeof value === "string" && columns.has(name)) {
|
|
52
|
+
record[name] = InMemoryLoader.getConvertedValue(columns.get(name), value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
35
56
|
return record;
|
|
36
57
|
});
|
|
37
58
|
if (this._dataUnit) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import PreloadManager from "./cache/PreloadManager";
|
|
2
2
|
import { DatasetStrategy } from "./loadstrategy/DatasetStrategy";
|
|
3
|
-
import { DataUnitStrategy } from "./loadstrategy/DataUnitStrategy";
|
|
4
3
|
export default class DataUnitDataLoader {
|
|
5
4
|
static async debounce(dataUnit, callBack) {
|
|
6
5
|
const duName = dataUnit.name;
|
|
@@ -44,7 +43,8 @@ export default class DataUnitDataLoader {
|
|
|
44
43
|
}
|
|
45
44
|
static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
|
|
46
45
|
if (dataLoader == undefined) {
|
|
47
|
-
dataLoader =
|
|
46
|
+
//dataLoader = new DataUnitStrategy();
|
|
47
|
+
dataLoader = new DatasetStrategy();
|
|
48
48
|
}
|
|
49
49
|
const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
|
|
50
50
|
const { records, loadingInfo: responseLoadingInfo } = result;
|
|
@@ -52,17 +52,18 @@ export default class DataUnitDataLoader {
|
|
|
52
52
|
return Promise.resolve(undefined);
|
|
53
53
|
}
|
|
54
54
|
const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
|
|
55
|
-
PreloadManager.cacheRecords(dataUnit, records, recreateCache);
|
|
55
|
+
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
|
56
56
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
|
57
57
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
|
58
58
|
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
|
59
59
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
|
60
|
-
.then(result => DataUnitDataLoader.
|
|
60
|
+
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
|
61
61
|
.catch(reason => console.error(reason));
|
|
62
62
|
}
|
|
63
63
|
return Promise.resolve(result);
|
|
64
64
|
}
|
|
65
|
-
static
|
|
65
|
+
static afterLoadingPage(dataUnit, loadingInfo) {
|
|
66
|
+
PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
|
|
66
67
|
const dataUnitPagination = dataUnit.getPaginationInfo();
|
|
67
68
|
if (dataUnitPagination == undefined) {
|
|
68
69
|
return;
|
|
@@ -89,9 +90,6 @@ export default class DataUnitDataLoader {
|
|
|
89
90
|
static isOldRequest(dataUnit, loadingInfo) {
|
|
90
91
|
return DataUnitDataLoader._requestTimeByDataUnit.get(dataUnit.name) > loadingInfo.requestTime;
|
|
91
92
|
}
|
|
92
|
-
static getStrategy(legacy) {
|
|
93
|
-
return legacy ? new DatasetStrategy() : new DataUnitStrategy();
|
|
94
|
-
}
|
|
95
93
|
static buildPaginationInfo(pageSize, request, loadingInfo) {
|
|
96
94
|
let { limit, offset } = request;
|
|
97
95
|
if (!limit) {
|