@sankhyalabs/sankhyablocks 8.16.0-dev.90 → 8.16.0-dev.91
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ClientSideExporterProvider-6b781452.js → ClientSideExporterProvider-2f5f350c.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-8291ac21.js → dataunit-fetcher-449d51a3.js} +11 -161
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-actions-button_5.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-c8096724.js → snk-data-unit-bbd384bf.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- 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-a029ff50.js → snk-guides-viewer-5396062f.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -3
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +12 -101
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +7 -53
- package/dist/components/dataunit-fetcher.js +30 -179
- package/dist/components/snk-attach2.js +3 -3
- package/dist/esm/{ClientSideExporterProvider-ff89c7e9.js → ClientSideExporterProvider-3537805a.js} +1 -1
- package/dist/esm/{dataunit-fetcher-5247a708.js → dataunit-fetcher-91b094f2.js} +13 -162
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/snk-actions-button_5.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +3 -3
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-51659955.js → snk-data-unit-b03bb5cf.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- 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-fa45714d.js → snk-guides-viewer-749d027c.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/sankhyablocks/{p-b0ff53b7.entry.js → p-13391b3d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-82839c9f.js → p-23b47a92.js} +1 -1
- package/dist/sankhyablocks/p-3653374d.js +60 -0
- package/dist/sankhyablocks/{p-c82deea7.entry.js → p-389ba782.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e0a6d819.entry.js → p-44efbeed.entry.js} +1 -1
- package/dist/sankhyablocks/{p-0b00d69c.entry.js → p-4be6e0e7.entry.js} +1 -1
- package/dist/sankhyablocks/p-4d87cd45.entry.js +1 -0
- package/dist/sankhyablocks/{p-bee2a6d3.entry.js → p-4fa79d68.entry.js} +1 -1
- package/dist/sankhyablocks/{p-40e323f9.js → p-5dd7f4c7.js} +1 -1
- package/dist/sankhyablocks/{p-aa1a0f3e.entry.js → p-6234bda8.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e10faff0.entry.js → p-647f9830.entry.js} +1 -1
- package/dist/sankhyablocks/{p-de9da2f2.js → p-7b87d1a8.js} +1 -1
- package/dist/sankhyablocks/{p-d2d0535f.entry.js → p-ad5e4f9d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-172848d4.entry.js → p-b2de1bcc.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e718fb81.entry.js → p-ca316523.entry.js} +1 -1
- package/dist/sankhyablocks/{p-700a4cc3.entry.js → p-ee53b000.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +4 -11
- package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +3 -6
- package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +2 -2
- package/package.json +1 -1
- package/dist/sankhyablocks/p-38179225.js +0 -60
- package/dist/sankhyablocks/p-b02e58fd.entry.js +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ObjectUtils, DataUnit,
|
1
|
+
import { DataUnitInMemoryLoader, ObjectUtils, DataUnit, ApplicationContext, StringUtils, UserInterface, DataUnitStorage, DataType, ChangeOperation } from '@sankhyalabs/core';
|
2
2
|
import { D as DataFetcher, d as dist } from './DataFetcher.js';
|
3
3
|
import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
|
4
4
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
@@ -6,6 +6,34 @@ import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/component
|
|
6
6
|
import SortingUtils from '@sankhyalabs/core/dist/utils/SortingUtils';
|
7
7
|
import { R as ResourceIDUtils } from './ResourceIDUtils.js';
|
8
8
|
|
9
|
+
class InMemoryLoader {
|
10
|
+
constructor(metadata, records, config) {
|
11
|
+
this._dataUnitInMemoryLoader = new DataUnitInMemoryLoader(metadata, records, config);
|
12
|
+
}
|
13
|
+
get dataUnit() {
|
14
|
+
return this._dataUnitInMemoryLoader.dataUnit;
|
15
|
+
}
|
16
|
+
get records() {
|
17
|
+
return this._dataUnitInMemoryLoader.records;
|
18
|
+
}
|
19
|
+
set records(records) {
|
20
|
+
this._dataUnitInMemoryLoader.records = records;
|
21
|
+
}
|
22
|
+
get metadata() {
|
23
|
+
return this._dataUnitInMemoryLoader.metadata;
|
24
|
+
}
|
25
|
+
set metadata(metadata) {
|
26
|
+
this._dataUnitInMemoryLoader.metadata = metadata;
|
27
|
+
}
|
28
|
+
removeLoader(_dataUnit, recordIds) {
|
29
|
+
return this._dataUnitInMemoryLoader.removeLoader(_dataUnit, recordIds);
|
30
|
+
}
|
31
|
+
static getConvertedValue(descriptor, strValue, dateFormat) {
|
32
|
+
return DataUnitInMemoryLoader.getConvertedValue(descriptor, strValue, dateFormat);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = DataUnitInMemoryLoader.IN_MEMORY_DATA_UNIT_NAME;
|
36
|
+
|
9
37
|
class ArrayRepository {
|
10
38
|
constructor(equalsFunction) {
|
11
39
|
this._list = [];
|
@@ -238,183 +266,6 @@ class PreloadManager {
|
|
238
266
|
PreloadManager._repositories = new Map();
|
239
267
|
PreloadManager._loadingStatus = new Map();
|
240
268
|
|
241
|
-
function applyFilter(records, dataUnit, filters) {
|
242
|
-
const columnFilters = ColumnFilterManager.getColumnFilters(filters, "");
|
243
|
-
if (!(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.size)) {
|
244
|
-
return records;
|
245
|
-
}
|
246
|
-
const filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
247
|
-
if (filterFunction == undefined) {
|
248
|
-
return records;
|
249
|
-
}
|
250
|
-
return records.filter(filterFunction);
|
251
|
-
}
|
252
|
-
function buildLoadDataResponse(recordsIn, dataUnit, request) {
|
253
|
-
let records = recordsIn ? [...recordsIn] : [];
|
254
|
-
records = applyFilter(records, dataUnit, request.filters);
|
255
|
-
records = applySorting(records, dataUnit, request.sort);
|
256
|
-
const { offset, limit } = request;
|
257
|
-
const paginationInfoBuilderParams = {
|
258
|
-
recordsLength: records.length,
|
259
|
-
offset,
|
260
|
-
recordsPerPage: limit,
|
261
|
-
};
|
262
|
-
return Promise.resolve({
|
263
|
-
records: getPagesByRecords(records, offset, limit),
|
264
|
-
paginationInfo: dataUnit.pageSize ? buildPaginationInfo(paginationInfoBuilderParams) : undefined,
|
265
|
-
});
|
266
|
-
}
|
267
|
-
function applySorting(records, dataUnit, sorting) {
|
268
|
-
if (sorting == undefined || sorting.length == 0) {
|
269
|
-
return records;
|
270
|
-
}
|
271
|
-
const sortingFunction = PreloadManager.getSortingFunction(dataUnit, sorting);
|
272
|
-
if (sortingFunction == undefined) {
|
273
|
-
return records;
|
274
|
-
}
|
275
|
-
return records.sort(sortingFunction);
|
276
|
-
}
|
277
|
-
function hasValidLimitAndOffset(offset, limit) {
|
278
|
-
return offset >= 0 && limit >= 0;
|
279
|
-
}
|
280
|
-
function getPagesByRecords(records, offset = 0, limit = 0) {
|
281
|
-
if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
|
282
|
-
return [];
|
283
|
-
if (limit === 0 && offset === 0)
|
284
|
-
return records;
|
285
|
-
return records.slice(offset, offset + limit);
|
286
|
-
}
|
287
|
-
function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
288
|
-
if (!recordsLength) {
|
289
|
-
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
290
|
-
}
|
291
|
-
const lastRecordIndex = offset + recordsPerPage;
|
292
|
-
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
293
|
-
return {
|
294
|
-
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
295
|
-
firstRecord: offset + 1,
|
296
|
-
lastRecord: lastRecord,
|
297
|
-
total: recordsLength,
|
298
|
-
hasMore: lastRecord < recordsLength,
|
299
|
-
};
|
300
|
-
}
|
301
|
-
|
302
|
-
class InMemoryLoader {
|
303
|
-
constructor(metadata, records, config) {
|
304
|
-
this.metadata = metadata;
|
305
|
-
this.records = records;
|
306
|
-
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
307
|
-
this._dataUnit.pageSize = 150;
|
308
|
-
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
309
|
-
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
310
|
-
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
311
|
-
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
312
|
-
this.dataUnit.loadMetadata().then(() => {
|
313
|
-
if ((config === null || config === void 0 ? void 0 : config.autoLoad) !== false) {
|
314
|
-
this.dataUnit.loadData();
|
315
|
-
}
|
316
|
-
});
|
317
|
-
}
|
318
|
-
getRecordsToLoad() {
|
319
|
-
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
320
|
-
this._initialRecords = this.dataUnit.records;
|
321
|
-
}
|
322
|
-
const addedRecords = this.dataUnit.getAddedRecords();
|
323
|
-
if (addedRecords) {
|
324
|
-
return [...this._initialRecords, ...addedRecords];
|
325
|
-
}
|
326
|
-
return this._initialRecords;
|
327
|
-
}
|
328
|
-
get dataUnit() {
|
329
|
-
return this._dataUnit;
|
330
|
-
}
|
331
|
-
get records() {
|
332
|
-
return this.dataUnit.records;
|
333
|
-
}
|
334
|
-
static getConvertedValue(descriptor, strValue) {
|
335
|
-
if (descriptor.dataType === DataType.BOOLEAN) {
|
336
|
-
return strValue === "S";
|
337
|
-
}
|
338
|
-
if (descriptor.dataType === DataType.NUMBER) {
|
339
|
-
return Number(strValue);
|
340
|
-
}
|
341
|
-
if (descriptor.dataType === DataType.DATE) {
|
342
|
-
return DateUtils.strToDate(strValue, true);
|
343
|
-
}
|
344
|
-
if (descriptor.dataType === DataType.OBJECT) {
|
345
|
-
return JSON.parse(strValue);
|
346
|
-
}
|
347
|
-
return strValue;
|
348
|
-
}
|
349
|
-
set records(records) {
|
350
|
-
const columns = this._metadata ? new Map(this._metadata.fields.map(descriptor => [descriptor.name, descriptor])) : undefined;
|
351
|
-
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
352
|
-
if (!record["__record__id__"]) {
|
353
|
-
record["__record__id__"] = this.generateUniqueId();
|
354
|
-
}
|
355
|
-
if (columns != undefined) {
|
356
|
-
for (const name in record) {
|
357
|
-
const value = record[name];
|
358
|
-
if (typeof value === "string" && columns.has(name)) {
|
359
|
-
record[name] = InMemoryLoader.getConvertedValue(columns.get(name), value);
|
360
|
-
}
|
361
|
-
}
|
362
|
-
}
|
363
|
-
return record;
|
364
|
-
});
|
365
|
-
this._initialRecords = newRecords;
|
366
|
-
if (this._dataUnit) {
|
367
|
-
//Isso força o refresh internamente no datunit
|
368
|
-
this._dataUnit.loadData();
|
369
|
-
}
|
370
|
-
}
|
371
|
-
get metadata() {
|
372
|
-
return this._metadata;
|
373
|
-
}
|
374
|
-
set metadata(metadata) {
|
375
|
-
this._metadata = metadata;
|
376
|
-
if (this._dataUnit) {
|
377
|
-
this._dataUnit.metadata = this._metadata;
|
378
|
-
}
|
379
|
-
}
|
380
|
-
generateUniqueId() {
|
381
|
-
return StringUtils.generateUUID();
|
382
|
-
}
|
383
|
-
inMemoryLoader(dataUnit, request, recordsIn) {
|
384
|
-
return buildLoadDataResponse(recordsIn, dataUnit, request);
|
385
|
-
}
|
386
|
-
metadaLoader() {
|
387
|
-
return Promise.resolve(this._metadata);
|
388
|
-
}
|
389
|
-
saveLoader(_dataUnit, changes) {
|
390
|
-
return new Promise((resolve) => {
|
391
|
-
let dataUnitRecords = [];
|
392
|
-
changes.forEach(change => {
|
393
|
-
let { record, updatingFields, operation } = change;
|
394
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
395
|
-
if (operation === ChangeOperation.INSERT ||
|
396
|
-
operation === ChangeOperation.COPY) {
|
397
|
-
changedRecord["__old__id__"] = record["__record__id__"];
|
398
|
-
changedRecord["__record__id__"] = this.generateUniqueId();
|
399
|
-
this.records.push(changedRecord);
|
400
|
-
}
|
401
|
-
else {
|
402
|
-
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
403
|
-
this.records[recordIndex] = changedRecord;
|
404
|
-
}
|
405
|
-
dataUnitRecords.push(changedRecord);
|
406
|
-
});
|
407
|
-
resolve(dataUnitRecords);
|
408
|
-
});
|
409
|
-
}
|
410
|
-
removeLoader(_dataUnit, recordIds) {
|
411
|
-
return new Promise((resolve) => {
|
412
|
-
resolve(recordIds);
|
413
|
-
});
|
414
|
-
}
|
415
|
-
}
|
416
|
-
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
417
|
-
|
418
269
|
function getRecordValue(record, fieldName) {
|
419
270
|
var _a, _b;
|
420
271
|
return ((_a = record[fieldName]) === null || _a === void 0 ? void 0 : _a.value) !== undefined ? (_b = record[fieldName]) === null || _b === void 0 ? void 0 : _b.value : record[fieldName];
|
@@ -1250,4 +1101,4 @@ class DataUnitFetcher {
|
|
1250
1101
|
}
|
1251
1102
|
}
|
1252
1103
|
|
1253
|
-
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a,
|
1104
|
+
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a, getRecordValue as g };
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
2
|
-
import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnit } from '@sankhyalabs/core';
|
2
|
+
import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnitLoaderUtils, DataUnit } from '@sankhyalabs/core';
|
3
3
|
import { D as DataFetcher } from './DataFetcher.js';
|
4
4
|
import { S as SaveErrorsEnum } from './ISave.js';
|
5
|
-
import { P as PreloadManager,
|
5
|
+
import { P as PreloadManager, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
|
6
6
|
import './filter-item-type.enum.js';
|
7
7
|
import './form-config-fetcher.js';
|
8
8
|
import { V as VIEW_MODE } from './constants.js';
|
@@ -462,7 +462,7 @@ class AttachFetcherDataUnitFactory {
|
|
462
462
|
});
|
463
463
|
this._records = records;
|
464
464
|
}
|
465
|
-
return buildLoadDataResponse(this._records, dataUnit, request);
|
465
|
+
return DataUnitLoaderUtils.buildLoadDataResponse(this._records, dataUnit, request);
|
466
466
|
}
|
467
467
|
saveLoader(changes, fetcher) {
|
468
468
|
return new Promise((resolve) => {
|
package/dist/esm/{ClientSideExporterProvider-ff89c7e9.js → ClientSideExporterProvider-3537805a.js}
RENAMED
@@ -5,7 +5,7 @@ import { D as DataExporterOption } from './index-b40568ff.js';
|
|
5
5
|
import './ISave-d8c8bc59.js';
|
6
6
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
7
7
|
import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
8
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
8
|
+
import { P as PreloadManager } from './dataunit-fetcher-91b094f2.js';
|
9
9
|
import './filter-item-type.enum-d45e026f.js';
|
10
10
|
import './form-config-fetcher-126e2471.js';
|
11
11
|
import './constants-75abb876.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ObjectUtils, DataUnit,
|
1
|
+
import { ObjectUtils, DataUnit, DataUnitInMemoryLoader, ApplicationContext, StringUtils, UserInterface, DataUnitStorage, DataType, ChangeOperation } from '@sankhyalabs/core';
|
2
2
|
import { D as DataFetcher, d as dist } from './DataFetcher-5221b992.js';
|
3
3
|
import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
|
4
4
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
@@ -238,182 +238,33 @@ class PreloadManager {
|
|
238
238
|
PreloadManager._repositories = new Map();
|
239
239
|
PreloadManager._loadingStatus = new Map();
|
240
240
|
|
241
|
-
function applyFilter(records, dataUnit, filters) {
|
242
|
-
const columnFilters = ColumnFilterManager.getColumnFilters(filters, "");
|
243
|
-
if (!(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.size)) {
|
244
|
-
return records;
|
245
|
-
}
|
246
|
-
const filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
247
|
-
if (filterFunction == undefined) {
|
248
|
-
return records;
|
249
|
-
}
|
250
|
-
return records.filter(filterFunction);
|
251
|
-
}
|
252
|
-
function buildLoadDataResponse(recordsIn, dataUnit, request) {
|
253
|
-
let records = recordsIn ? [...recordsIn] : [];
|
254
|
-
records = applyFilter(records, dataUnit, request.filters);
|
255
|
-
records = applySorting(records, dataUnit, request.sort);
|
256
|
-
const { offset, limit } = request;
|
257
|
-
const paginationInfoBuilderParams = {
|
258
|
-
recordsLength: records.length,
|
259
|
-
offset,
|
260
|
-
recordsPerPage: limit,
|
261
|
-
};
|
262
|
-
return Promise.resolve({
|
263
|
-
records: getPagesByRecords(records, offset, limit),
|
264
|
-
paginationInfo: dataUnit.pageSize ? buildPaginationInfo(paginationInfoBuilderParams) : undefined,
|
265
|
-
});
|
266
|
-
}
|
267
|
-
function applySorting(records, dataUnit, sorting) {
|
268
|
-
if (sorting == undefined || sorting.length == 0) {
|
269
|
-
return records;
|
270
|
-
}
|
271
|
-
const sortingFunction = PreloadManager.getSortingFunction(dataUnit, sorting);
|
272
|
-
if (sortingFunction == undefined) {
|
273
|
-
return records;
|
274
|
-
}
|
275
|
-
return records.sort(sortingFunction);
|
276
|
-
}
|
277
|
-
function hasValidLimitAndOffset(offset, limit) {
|
278
|
-
return offset >= 0 && limit >= 0;
|
279
|
-
}
|
280
|
-
function getPagesByRecords(records, offset = 0, limit = 0) {
|
281
|
-
if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
|
282
|
-
return [];
|
283
|
-
if (limit === 0 && offset === 0)
|
284
|
-
return records;
|
285
|
-
return records.slice(offset, offset + limit);
|
286
|
-
}
|
287
|
-
function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
288
|
-
if (!recordsLength) {
|
289
|
-
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
290
|
-
}
|
291
|
-
const lastRecordIndex = offset + recordsPerPage;
|
292
|
-
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
293
|
-
return {
|
294
|
-
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
295
|
-
firstRecord: offset + 1,
|
296
|
-
lastRecord: lastRecord,
|
297
|
-
total: recordsLength,
|
298
|
-
hasMore: lastRecord < recordsLength,
|
299
|
-
};
|
300
|
-
}
|
301
|
-
|
302
241
|
class InMemoryLoader {
|
303
242
|
constructor(metadata, records, config) {
|
304
|
-
this.
|
305
|
-
this.records = records;
|
306
|
-
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
307
|
-
this._dataUnit.pageSize = 150;
|
308
|
-
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
309
|
-
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
310
|
-
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
311
|
-
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
312
|
-
this.dataUnit.loadMetadata().then(() => {
|
313
|
-
if ((config === null || config === void 0 ? void 0 : config.autoLoad) !== false) {
|
314
|
-
this.dataUnit.loadData();
|
315
|
-
}
|
316
|
-
});
|
317
|
-
}
|
318
|
-
getRecordsToLoad() {
|
319
|
-
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
320
|
-
this._initialRecords = this.dataUnit.records;
|
321
|
-
}
|
322
|
-
const addedRecords = this.dataUnit.getAddedRecords();
|
323
|
-
if (addedRecords) {
|
324
|
-
return [...this._initialRecords, ...addedRecords];
|
325
|
-
}
|
326
|
-
return this._initialRecords;
|
243
|
+
this._dataUnitInMemoryLoader = new DataUnitInMemoryLoader(metadata, records, config);
|
327
244
|
}
|
328
245
|
get dataUnit() {
|
329
|
-
return this.
|
246
|
+
return this._dataUnitInMemoryLoader.dataUnit;
|
330
247
|
}
|
331
248
|
get records() {
|
332
|
-
return this.
|
333
|
-
}
|
334
|
-
static getConvertedValue(descriptor, strValue) {
|
335
|
-
if (descriptor.dataType === DataType.BOOLEAN) {
|
336
|
-
return strValue === "S";
|
337
|
-
}
|
338
|
-
if (descriptor.dataType === DataType.NUMBER) {
|
339
|
-
return Number(strValue);
|
340
|
-
}
|
341
|
-
if (descriptor.dataType === DataType.DATE) {
|
342
|
-
return DateUtils.strToDate(strValue, true);
|
343
|
-
}
|
344
|
-
if (descriptor.dataType === DataType.OBJECT) {
|
345
|
-
return JSON.parse(strValue);
|
346
|
-
}
|
347
|
-
return strValue;
|
249
|
+
return this._dataUnitInMemoryLoader.records;
|
348
250
|
}
|
349
251
|
set records(records) {
|
350
|
-
|
351
|
-
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
352
|
-
if (!record["__record__id__"]) {
|
353
|
-
record["__record__id__"] = this.generateUniqueId();
|
354
|
-
}
|
355
|
-
if (columns != undefined) {
|
356
|
-
for (const name in record) {
|
357
|
-
const value = record[name];
|
358
|
-
if (typeof value === "string" && columns.has(name)) {
|
359
|
-
record[name] = InMemoryLoader.getConvertedValue(columns.get(name), value);
|
360
|
-
}
|
361
|
-
}
|
362
|
-
}
|
363
|
-
return record;
|
364
|
-
});
|
365
|
-
this._initialRecords = newRecords;
|
366
|
-
if (this._dataUnit) {
|
367
|
-
//Isso força o refresh internamente no datunit
|
368
|
-
this._dataUnit.loadData();
|
369
|
-
}
|
252
|
+
this._dataUnitInMemoryLoader.records = records;
|
370
253
|
}
|
371
254
|
get metadata() {
|
372
|
-
return this.
|
255
|
+
return this._dataUnitInMemoryLoader.metadata;
|
373
256
|
}
|
374
257
|
set metadata(metadata) {
|
375
|
-
this.
|
376
|
-
if (this._dataUnit) {
|
377
|
-
this._dataUnit.metadata = this._metadata;
|
378
|
-
}
|
379
|
-
}
|
380
|
-
generateUniqueId() {
|
381
|
-
return StringUtils.generateUUID();
|
382
|
-
}
|
383
|
-
inMemoryLoader(dataUnit, request, recordsIn) {
|
384
|
-
return buildLoadDataResponse(recordsIn, dataUnit, request);
|
385
|
-
}
|
386
|
-
metadaLoader() {
|
387
|
-
return Promise.resolve(this._metadata);
|
388
|
-
}
|
389
|
-
saveLoader(_dataUnit, changes) {
|
390
|
-
return new Promise((resolve) => {
|
391
|
-
let dataUnitRecords = [];
|
392
|
-
changes.forEach(change => {
|
393
|
-
let { record, updatingFields, operation } = change;
|
394
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
395
|
-
if (operation === ChangeOperation.INSERT ||
|
396
|
-
operation === ChangeOperation.COPY) {
|
397
|
-
changedRecord["__old__id__"] = record["__record__id__"];
|
398
|
-
changedRecord["__record__id__"] = this.generateUniqueId();
|
399
|
-
this.records.push(changedRecord);
|
400
|
-
}
|
401
|
-
else {
|
402
|
-
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
403
|
-
this.records[recordIndex] = changedRecord;
|
404
|
-
}
|
405
|
-
dataUnitRecords.push(changedRecord);
|
406
|
-
});
|
407
|
-
resolve(dataUnitRecords);
|
408
|
-
});
|
258
|
+
this._dataUnitInMemoryLoader.metadata = metadata;
|
409
259
|
}
|
410
260
|
removeLoader(_dataUnit, recordIds) {
|
411
|
-
return
|
412
|
-
|
413
|
-
|
261
|
+
return this._dataUnitInMemoryLoader.removeLoader(_dataUnit, recordIds);
|
262
|
+
}
|
263
|
+
static getConvertedValue(descriptor, strValue, dateFormat) {
|
264
|
+
return DataUnitInMemoryLoader.getConvertedValue(descriptor, strValue, dateFormat);
|
414
265
|
}
|
415
266
|
}
|
416
|
-
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME =
|
267
|
+
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = DataUnitInMemoryLoader.IN_MEMORY_DATA_UNIT_NAME;
|
417
268
|
|
418
269
|
function getRecordValue(record, fieldName) {
|
419
270
|
var _a, _b;
|
@@ -1250,4 +1101,4 @@ class DataUnitFetcher {
|
|
1250
1101
|
}
|
1251
1102
|
}
|
1252
1103
|
|
1253
|
-
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a,
|
1104
|
+
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a, getRecordValue as g };
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, F as Fragment } from './index-a7d3d3f1.js';
|
2
|
-
import { I as InMemoryLoader } from './dataunit-fetcher-
|
2
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-91b094f2.js';
|
3
3
|
import './DataFetcher-5221b992.js';
|
4
4
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-4284f2a3.js';
|
5
5
|
import '@sankhyalabs/core';
|
@@ -7,7 +7,7 @@ import './index-b40568ff.js';
|
|
7
7
|
import './ISave-d8c8bc59.js';
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
-
import './dataunit-fetcher-
|
10
|
+
import './dataunit-fetcher-91b094f2.js';
|
11
11
|
import './filter-item-type.enum-d45e026f.js';
|
12
12
|
import { F as FormConfigFetcher } from './form-config-fetcher-126e2471.js';
|
13
13
|
import { O as ORDER_VALUES } from './constants-75abb876.js';
|
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-373bb440.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-5221b992.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-e32fe8a4.js';
|
7
|
-
import { P as PreloadManager, D as DataUnitFetcher } from './dataunit-fetcher-
|
7
|
+
import { P as PreloadManager, D as DataUnitFetcher } from './dataunit-fetcher-91b094f2.js';
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-4284f2a3.js';
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-6fff4a4c.js';
|
10
10
|
import { T as TEMPLATES_SKELETON } from './constants-75abb876.js';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { r as registerInstance, c as createEvent, h } from './index-a7d3d3f1.js';
|
2
|
-
import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnit } from '@sankhyalabs/core';
|
2
|
+
import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnitLoaderUtils, DataUnit } from '@sankhyalabs/core';
|
3
3
|
import { D as DataFetcher } from './DataFetcher-5221b992.js';
|
4
4
|
import './pesquisa-fetcher-4284f2a3.js';
|
5
5
|
import './index-b40568ff.js';
|
6
6
|
import { S as SaveErrorsEnum } from './ISave-d8c8bc59.js';
|
7
|
-
import { P as PreloadManager,
|
7
|
+
import { P as PreloadManager, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-91b094f2.js';
|
8
8
|
import './filter-item-type.enum-d45e026f.js';
|
9
9
|
import './form-config-fetcher-126e2471.js';
|
10
10
|
import { V as VIEW_MODE } from './constants-75abb876.js';
|
@@ -460,7 +460,7 @@ class AttachFetcherDataUnitFactory {
|
|
460
460
|
});
|
461
461
|
this._records = records;
|
462
462
|
}
|
463
|
-
return buildLoadDataResponse(this._records, dataUnit, request);
|
463
|
+
return DataUnitLoaderUtils.buildLoadDataResponse(this._records, dataUnit, request);
|
464
464
|
}
|
465
465
|
saveLoader(changes, fetcher) {
|
466
466
|
return new Promise((resolve) => {
|
@@ -7,7 +7,7 @@ import { P as PresentationMode, E as ExporterStrategy } from './index-b40568ff.j
|
|
7
7
|
import './ISave-d8c8bc59.js';
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
-
import './dataunit-fetcher-
|
10
|
+
import './dataunit-fetcher-91b094f2.js';
|
11
11
|
import './filter-item-type.enum-d45e026f.js';
|
12
12
|
import './form-config-fetcher-126e2471.js';
|
13
13
|
import { V as VIEW_MODE } from './constants-75abb876.js';
|
@@ -5,12 +5,12 @@ import { I as IExportType } from './IFetchDataExporterParams-d73bed3d.js';
|
|
5
5
|
import { D as DataExporterOption, a as DataExporterType, b as DataExporterFormat } from './index-b40568ff.js';
|
6
6
|
import { R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-75abb876.js';
|
7
7
|
import { D as DataFetcher } from './DataFetcher-5221b992.js';
|
8
|
-
import { S as SnkDataUnit } from './snk-data-unit-
|
8
|
+
import { S as SnkDataUnit } from './snk-data-unit-b03bb5cf.js';
|
9
9
|
import './pesquisa-fetcher-4284f2a3.js';
|
10
10
|
import './ISave-d8c8bc59.js';
|
11
11
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
12
12
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
13
|
-
import './dataunit-fetcher-
|
13
|
+
import './dataunit-fetcher-91b094f2.js';
|
14
14
|
import './filter-item-type.enum-d45e026f.js';
|
15
15
|
import './form-config-fetcher-126e2471.js';
|
16
16
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -2,7 +2,7 @@ import { r as registerInstance, c as createEvent, h, g as getElement, H as Host
|
|
2
2
|
import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
4
|
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-6fff4a4c.js';
|
5
|
-
import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher-
|
5
|
+
import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher-91b094f2.js';
|
6
6
|
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
7
7
|
import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo-9fa41508.js';
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export { S as snk_data_unit } from './snk-data-unit-
|
1
|
+
export { S as snk_data_unit } from './snk-data-unit-b03bb5cf.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import '@sankhyalabs/ezui/dist/collection/utils';
|
5
5
|
import './SnkMessageBuilder-6fff4a4c.js';
|
6
|
-
import './dataunit-fetcher-
|
6
|
+
import './dataunit-fetcher-91b094f2.js';
|
7
7
|
import './DataFetcher-5221b992.js';
|
8
8
|
import './PrintUtils-3e4ff0f5.js';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
@@ -8,12 +8,12 @@ import { P as PresentationMode } from './index-b40568ff.js';
|
|
8
8
|
import './ISave-d8c8bc59.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import './dataunit-fetcher-
|
11
|
+
import './dataunit-fetcher-91b094f2.js';
|
12
12
|
import './filter-item-type.enum-d45e026f.js';
|
13
13
|
import './form-config-fetcher-126e2471.js';
|
14
14
|
import { V as VIEW_MODE } from './constants-75abb876.js';
|
15
15
|
import { T as TaskbarElement } from './taskbar-elements-d2353c64.js';
|
16
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
16
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-749d027c.js';
|
17
17
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-6fff4a4c.js';
|
18
18
|
import './ConfigStorage-373bb440.js';
|
19
19
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -5,14 +5,14 @@ import { C as ConfigStorage } from './ConfigStorage-373bb440.js';
|
|
5
5
|
import { P as PresentationMode, E as ExporterStrategy } from './index-b40568ff.js';
|
6
6
|
import { T as TaskbarProcessor, o as openFieldSearch, b as buildFieldSearch } from './field-search-f8b1d91e.js';
|
7
7
|
import { s as store } from './index-bdf75557.js';
|
8
|
-
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, a as CrudUtils, R as RmPrecisionCustomValueFormatter, b as ContinuousInsertUtils, c as ClientSideExporterProvider } from './ClientSideExporterProvider-
|
8
|
+
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, a as CrudUtils, R as RmPrecisionCustomValueFormatter, b as ContinuousInsertUtils, c as ClientSideExporterProvider } from './ClientSideExporterProvider-3537805a.js';
|
9
9
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
10
10
|
import './DataFetcher-5221b992.js';
|
11
11
|
import './pesquisa-fetcher-4284f2a3.js';
|
12
12
|
import './ISave-d8c8bc59.js';
|
13
13
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
14
14
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
15
|
-
import './dataunit-fetcher-
|
15
|
+
import './dataunit-fetcher-91b094f2.js';
|
16
16
|
import './filter-item-type.enum-d45e026f.js';
|
17
17
|
import './form-config-fetcher-126e2471.js';
|
18
18
|
import './constants-75abb876.js';
|
@@ -11,7 +11,7 @@ import { P as PresentationMode } from './index-b40568ff.js';
|
|
11
11
|
import './ISave-d8c8bc59.js';
|
12
12
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
13
13
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
14
|
-
import './dataunit-fetcher-
|
14
|
+
import './dataunit-fetcher-91b094f2.js';
|
15
15
|
import './filter-item-type.enum-d45e026f.js';
|
16
16
|
import './form-config-fetcher-126e2471.js';
|
17
17
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { S as snk_guides_viewer } from './snk-guides-viewer-
|
1
|
+
export { S as snk_guides_viewer } from './snk-guides-viewer-749d027c.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-5022f87f.js';
|
@@ -17,7 +17,7 @@ import './index-bdf75557.js';
|
|
17
17
|
import './pesquisa-fetcher-4284f2a3.js';
|
18
18
|
import './ISave-d8c8bc59.js';
|
19
19
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
20
|
-
import './dataunit-fetcher-
|
20
|
+
import './dataunit-fetcher-91b094f2.js';
|
21
21
|
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
22
22
|
import '@sankhyalabs/core/dist/utils/SortingUtils';
|
23
23
|
import './ResourceIDUtils-a114189a.js';
|
@@ -6,7 +6,7 @@ import './index-b40568ff.js';
|
|
6
6
|
import './ISave-d8c8bc59.js';
|
7
7
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
8
8
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
9
|
-
import './dataunit-fetcher-
|
9
|
+
import './dataunit-fetcher-91b094f2.js';
|
10
10
|
import './filter-item-type.enum-d45e026f.js';
|
11
11
|
import './form-config-fetcher-126e2471.js';
|
12
12
|
import './constants-75abb876.js';
|
@@ -5,12 +5,12 @@ import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants-75abb876.js';
|
|
5
5
|
import { T as TaskbarElement } from './taskbar-elements-d2353c64.js';
|
6
6
|
import './DataFetcher-5221b992.js';
|
7
7
|
import './pesquisa-fetcher-4284f2a3.js';
|
8
|
-
import { S as SnkMultiSelectionListDataSource, R as RmPrecisionCustomValueFormatter, b as ContinuousInsertUtils, a as CrudUtils, c as ClientSideExporterProvider } from './ClientSideExporterProvider-
|
8
|
+
import { S as SnkMultiSelectionListDataSource, R as RmPrecisionCustomValueFormatter, b as ContinuousInsertUtils, a as CrudUtils, c as ClientSideExporterProvider } from './ClientSideExporterProvider-3537805a.js';
|
9
9
|
import { P as PresentationMode } from './index-b40568ff.js';
|
10
10
|
import './ISave-d8c8bc59.js';
|
11
11
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
12
12
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
13
|
-
import { I as InMemoryLoader } from './dataunit-fetcher-
|
13
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-91b094f2.js';
|
14
14
|
import './filter-item-type.enum-d45e026f.js';
|
15
15
|
import { F as FormConfigFetcher } from './form-config-fetcher-126e2471.js';
|
16
16
|
import { T as TaskbarProcessor, b as buildFieldSearch, o as openFieldSearch } from './field-search-f8b1d91e.js';
|