@sankhyalabs/sankhyablocks 8.8.0-rc.5 → 8.8.0-rc.6
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-45893a0c.js → SnkMultiSelectionListDataSource-4f7a031a.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-2454608a.js → dataunit-fetcher-a8bac9cc.js} +50 -24
- 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 +3 -2
- package/dist/cjs/{snk-guides-viewer-018c1c8e.js → snk-guides-viewer-00e028f1.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/collection/components/snk-grid/snk-grid.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +6 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +13 -14
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +28 -9
- package/dist/components/dataunit-fetcher.js +50 -24
- package/dist/components/snk-grid2.js +1 -0
- package/dist/esm/{SnkMultiSelectionListDataSource-a0b69ac4.js → SnkMultiSelectionListDataSource-2a4ec61c.js} +1 -1
- package/dist/esm/{dataunit-fetcher-493182bc.js → dataunit-fetcher-5e9245d7.js} +50 -24
- 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 +3 -2
- package/dist/esm/{snk-guides-viewer-7c120bc6.js → snk-guides-viewer-9efd5ce9.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/sankhyablocks/p-171b12d5.js +59 -0
- package/dist/sankhyablocks/{p-e33b308f.entry.js → p-3ad594b3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f34b9087.entry.js → p-3b28c4b3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9256574e.entry.js → p-3d0a0a36.entry.js} +1 -1
- package/dist/sankhyablocks/p-61513624.entry.js +1 -0
- package/dist/sankhyablocks/{p-53091bcd.js → p-7469e2ef.js} +1 -1
- package/dist/sankhyablocks/{p-21d01a8c.entry.js → p-880d08b8.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b9b7bfce.entry.js → p-ae6a90a1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e13c3fbc.entry.js → p-b4edd50c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8f7e0bbd.entry.js → p-bb1bdb17.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7650d823.js → p-c34cea23.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +2 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-bdfcc2e2.js +0 -59
- package/dist/sankhyablocks/p-db45a464.entry.js +0 -1
@@ -192,6 +192,9 @@ class ArrayRepository {
|
|
192
192
|
for (const item of this._list) {
|
193
193
|
const processedItem = itemProcessor(item);
|
194
194
|
if (processedItem == undefined) {
|
195
|
+
continue;
|
196
|
+
}
|
197
|
+
if (processedItem.value == undefined) {
|
195
198
|
hasEmpty = true;
|
196
199
|
continue;
|
197
200
|
}
|
@@ -287,26 +290,25 @@ class PreloadManager {
|
|
287
290
|
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
288
291
|
return Promise.resolve(undefined);
|
289
292
|
}
|
293
|
+
let filterFunction;
|
294
|
+
const request = dataUnit.getLastLoadRequest();
|
295
|
+
if (request != undefined) {
|
296
|
+
const columnFilters = PreloadManager.getColumnFilters(request.filters);
|
297
|
+
filterFunction = PreloadManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
298
|
+
}
|
290
299
|
return new Promise((accept, reject) => {
|
291
300
|
PreloadManager.getRepository(dataUnit).distict(record => {
|
301
|
+
if (filterFunction != undefined && !filterFunction(record)) {
|
302
|
+
return undefined;
|
303
|
+
}
|
292
304
|
const fieldValue = record[fieldName];
|
293
305
|
if (fieldValue == undefined) {
|
294
|
-
return
|
306
|
+
return { key: null, value: null };
|
295
307
|
}
|
296
308
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
297
309
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
298
310
|
})
|
299
|
-
.then(result =>
|
300
|
-
if (result != undefined && result.size > 0) {
|
301
|
-
const field = dataUnit.getField(fieldName);
|
302
|
-
const sortedMap = new Map(Array.from(result.entries())
|
303
|
-
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
304
|
-
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
305
|
-
accept(sortedMap);
|
306
|
-
return;
|
307
|
-
}
|
308
|
-
accept(result);
|
309
|
-
})
|
311
|
+
.then(result => accept(result))
|
310
312
|
.catch(reason => reject(reason));
|
311
313
|
});
|
312
314
|
}
|
@@ -320,7 +322,7 @@ class PreloadManager {
|
|
320
322
|
return PreloadManager.loadFromCache(dataUnit, request);
|
321
323
|
}
|
322
324
|
}
|
323
|
-
//Como não vamos aproveitar o cache, ele precisa ser
|
325
|
+
//Como não vamos aproveitar o cache, ele precisa ser limpo.
|
324
326
|
PreloadManager.getRepository(dataUnit).clear().catch(() => { });
|
325
327
|
}
|
326
328
|
return loadFromServer(dataUnit, request);
|
@@ -390,7 +392,7 @@ class PreloadManager {
|
|
390
392
|
.then(loadResult => {
|
391
393
|
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
392
394
|
const { count, result: records } = loadResult;
|
393
|
-
const firstRecord = count == 0 ?
|
395
|
+
const firstRecord = count == 0 ? 0 : offset + 1;
|
394
396
|
const lastRecord = offset + Math.min(records.length, limit);
|
395
397
|
const currentPage = offset / limit;
|
396
398
|
const paginationInfo = {
|
@@ -536,17 +538,36 @@ class DatasetStrategy {
|
|
536
538
|
return Promise.resolve({ records: [], loadingInfo });
|
537
539
|
}
|
538
540
|
try {
|
541
|
+
const localSorting = [];
|
542
|
+
const serverSorting = [];
|
543
|
+
if (request.sort != undefined) {
|
544
|
+
for (const sort of request.sort) {
|
545
|
+
const descriptor = dataUnit.getField(sort.field);
|
546
|
+
const local = descriptor != undefined
|
547
|
+
&& descriptor.properties != undefined
|
548
|
+
&& descriptor.properties.calculated === "true";
|
549
|
+
if (local) {
|
550
|
+
localSorting.push(sort);
|
551
|
+
}
|
552
|
+
else {
|
553
|
+
serverSorting.push(sort);
|
554
|
+
}
|
555
|
+
}
|
556
|
+
}
|
539
557
|
const fields = this.getFieldsList(dataUnit);
|
540
558
|
const serviceName = "DatasetSP.loadRecords";
|
541
|
-
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo);
|
542
|
-
const {
|
559
|
+
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
|
560
|
+
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
561
|
+
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
543
562
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
544
563
|
const loadingInProgress = pagerId != undefined;
|
545
564
|
const count = loadingInfo.count + records.length;
|
565
|
+
const needReload = !loadingInProgress && localSorting.length > 0;
|
546
566
|
return Promise.resolve({
|
547
567
|
records,
|
548
568
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
549
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count
|
569
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
570
|
+
needReload })
|
550
571
|
});
|
551
572
|
}
|
552
573
|
catch (error) {
|
@@ -556,9 +577,10 @@ class DatasetStrategy {
|
|
556
577
|
}
|
557
578
|
getFieldsList(dataUnit) {
|
558
579
|
let fields = ["__record__id__", "__record__label__"];
|
559
|
-
dataUnit.metadata.fields.forEach(descriptor => {
|
560
|
-
if (descriptor.standAlone)
|
580
|
+
dataUnit.metadata.fields.forEach((descriptor) => {
|
581
|
+
if (descriptor.standAlone) {
|
561
582
|
return;
|
583
|
+
}
|
562
584
|
fields = fields.concat(this.getFieldNames(descriptor));
|
563
585
|
});
|
564
586
|
return fields;
|
@@ -570,7 +592,7 @@ class DatasetStrategy {
|
|
570
592
|
}
|
571
593
|
return [descriptor.name, descriptionField];
|
572
594
|
}
|
573
|
-
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo) {
|
595
|
+
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
|
574
596
|
const dataSetID = dataUnit.dataUnitId;
|
575
597
|
const dataUnitName = dataUnit.name;
|
576
598
|
const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
|
@@ -591,13 +613,13 @@ class DatasetStrategy {
|
|
591
613
|
tryJoinedFields: true,
|
592
614
|
parallelLoader: true,
|
593
615
|
crudListener: "br.com.sankhya.modelcore.dataset.DataUnitDatasetAdapter",
|
594
|
-
txProperties: this.getTxProperties(dataUnitName, request),
|
616
|
+
txProperties: this.getTxProperties(dataUnitName, request, sorting),
|
595
617
|
useDefaultRowsLimit: false
|
596
618
|
}
|
597
619
|
};
|
598
620
|
return JSON.stringify(requestBody);
|
599
621
|
}
|
600
|
-
getTxProperties(dataUnitName, request) {
|
622
|
+
getTxProperties(dataUnitName, request, sorting) {
|
601
623
|
const txProperties = {
|
602
624
|
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
|
603
625
|
};
|
@@ -605,7 +627,6 @@ class DatasetStrategy {
|
|
605
627
|
if (serverSideFilters.length !== 0) {
|
606
628
|
txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
|
607
629
|
}
|
608
|
-
const sorting = request.sort;
|
609
630
|
if (sorting != undefined && sorting.length !== 0) {
|
610
631
|
txProperties["__DATA_UNIT_ADAPTER__[sorting]"] = JSON.stringify(sorting);
|
611
632
|
}
|
@@ -712,7 +733,7 @@ class DataUnitDataLoader {
|
|
712
733
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
713
734
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
714
735
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
715
|
-
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
736
|
+
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
716
737
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
717
738
|
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
718
739
|
.catch(reason => console.error(reason));
|
@@ -730,6 +751,11 @@ class DataUnitDataLoader {
|
|
730
751
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
731
752
|
return;
|
732
753
|
}
|
754
|
+
if (loadingInfo.needReload) {
|
755
|
+
//Ir para a primeira página, faz com que o loadData seja chamado novamente
|
756
|
+
dataUnit.gotoPage(0);
|
757
|
+
return;
|
758
|
+
}
|
733
759
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
734
760
|
}
|
735
761
|
static registryLoading(dataUnit, loadingInfo) {
|
@@ -116,6 +116,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
116
116
|
if (this._gridConfig && this._dataUnit) {
|
117
117
|
this._dataUnit.defaultSorting = this._gridConfig
|
118
118
|
.columns
|
119
|
+
.filter(col => col.ascending != undefined)
|
119
120
|
.sort((colA, colB) => colA.orderIndex - colB.orderIndex)
|
120
121
|
.map(({ name: field, ascending }) => {
|
121
122
|
const { dataType } = this._dataUnit.getField(field);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { UserInterface, DateUtils } from '@sankhyalabs/core';
|
2
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
2
|
+
import { P as PreloadManager } from './dataunit-fetcher-5e9245d7.js';
|
3
3
|
|
4
4
|
class SnkMultiSelectionListDataSource {
|
5
5
|
setDataUnit(dataUnit) {
|
@@ -31,6 +31,9 @@ class ArrayRepository {
|
|
31
31
|
for (const item of this._list) {
|
32
32
|
const processedItem = itemProcessor(item);
|
33
33
|
if (processedItem == undefined) {
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
if (processedItem.value == undefined) {
|
34
37
|
hasEmpty = true;
|
35
38
|
continue;
|
36
39
|
}
|
@@ -126,26 +129,25 @@ class PreloadManager {
|
|
126
129
|
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
127
130
|
return Promise.resolve(undefined);
|
128
131
|
}
|
132
|
+
let filterFunction;
|
133
|
+
const request = dataUnit.getLastLoadRequest();
|
134
|
+
if (request != undefined) {
|
135
|
+
const columnFilters = PreloadManager.getColumnFilters(request.filters);
|
136
|
+
filterFunction = PreloadManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
137
|
+
}
|
129
138
|
return new Promise((accept, reject) => {
|
130
139
|
PreloadManager.getRepository(dataUnit).distict(record => {
|
140
|
+
if (filterFunction != undefined && !filterFunction(record)) {
|
141
|
+
return undefined;
|
142
|
+
}
|
131
143
|
const fieldValue = record[fieldName];
|
132
144
|
if (fieldValue == undefined) {
|
133
|
-
return
|
145
|
+
return { key: null, value: null };
|
134
146
|
}
|
135
147
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
136
148
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
137
149
|
})
|
138
|
-
.then(result =>
|
139
|
-
if (result != undefined && result.size > 0) {
|
140
|
-
const field = dataUnit.getField(fieldName);
|
141
|
-
const sortedMap = new Map(Array.from(result.entries())
|
142
|
-
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
143
|
-
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
144
|
-
accept(sortedMap);
|
145
|
-
return;
|
146
|
-
}
|
147
|
-
accept(result);
|
148
|
-
})
|
150
|
+
.then(result => accept(result))
|
149
151
|
.catch(reason => reject(reason));
|
150
152
|
});
|
151
153
|
}
|
@@ -159,7 +161,7 @@ class PreloadManager {
|
|
159
161
|
return PreloadManager.loadFromCache(dataUnit, request);
|
160
162
|
}
|
161
163
|
}
|
162
|
-
//Como não vamos aproveitar o cache, ele precisa ser
|
164
|
+
//Como não vamos aproveitar o cache, ele precisa ser limpo.
|
163
165
|
PreloadManager.getRepository(dataUnit).clear().catch(() => { });
|
164
166
|
}
|
165
167
|
return loadFromServer(dataUnit, request);
|
@@ -229,7 +231,7 @@ class PreloadManager {
|
|
229
231
|
.then(loadResult => {
|
230
232
|
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
231
233
|
const { count, result: records } = loadResult;
|
232
|
-
const firstRecord = count == 0 ?
|
234
|
+
const firstRecord = count == 0 ? 0 : offset + 1;
|
233
235
|
const lastRecord = offset + Math.min(records.length, limit);
|
234
236
|
const currentPage = offset / limit;
|
235
237
|
const paginationInfo = {
|
@@ -375,17 +377,36 @@ class DatasetStrategy {
|
|
375
377
|
return Promise.resolve({ records: [], loadingInfo });
|
376
378
|
}
|
377
379
|
try {
|
380
|
+
const localSorting = [];
|
381
|
+
const serverSorting = [];
|
382
|
+
if (request.sort != undefined) {
|
383
|
+
for (const sort of request.sort) {
|
384
|
+
const descriptor = dataUnit.getField(sort.field);
|
385
|
+
const local = descriptor != undefined
|
386
|
+
&& descriptor.properties != undefined
|
387
|
+
&& descriptor.properties.calculated === "true";
|
388
|
+
if (local) {
|
389
|
+
localSorting.push(sort);
|
390
|
+
}
|
391
|
+
else {
|
392
|
+
serverSorting.push(sort);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
}
|
378
396
|
const fields = this.getFieldsList(dataUnit);
|
379
397
|
const serviceName = "DatasetSP.loadRecords";
|
380
|
-
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo);
|
381
|
-
const {
|
398
|
+
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
|
399
|
+
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
400
|
+
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
382
401
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
383
402
|
const loadingInProgress = pagerId != undefined;
|
384
403
|
const count = loadingInfo.count + records.length;
|
404
|
+
const needReload = !loadingInProgress && localSorting.length > 0;
|
385
405
|
return Promise.resolve({
|
386
406
|
records,
|
387
407
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
388
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count
|
408
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
409
|
+
needReload })
|
389
410
|
});
|
390
411
|
}
|
391
412
|
catch (error) {
|
@@ -395,9 +416,10 @@ class DatasetStrategy {
|
|
395
416
|
}
|
396
417
|
getFieldsList(dataUnit) {
|
397
418
|
let fields = ["__record__id__", "__record__label__"];
|
398
|
-
dataUnit.metadata.fields.forEach(descriptor => {
|
399
|
-
if (descriptor.standAlone)
|
419
|
+
dataUnit.metadata.fields.forEach((descriptor) => {
|
420
|
+
if (descriptor.standAlone) {
|
400
421
|
return;
|
422
|
+
}
|
401
423
|
fields = fields.concat(this.getFieldNames(descriptor));
|
402
424
|
});
|
403
425
|
return fields;
|
@@ -409,7 +431,7 @@ class DatasetStrategy {
|
|
409
431
|
}
|
410
432
|
return [descriptor.name, descriptionField];
|
411
433
|
}
|
412
|
-
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo) {
|
434
|
+
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
|
413
435
|
const dataSetID = dataUnit.dataUnitId;
|
414
436
|
const dataUnitName = dataUnit.name;
|
415
437
|
const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
|
@@ -430,13 +452,13 @@ class DatasetStrategy {
|
|
430
452
|
tryJoinedFields: true,
|
431
453
|
parallelLoader: true,
|
432
454
|
crudListener: "br.com.sankhya.modelcore.dataset.DataUnitDatasetAdapter",
|
433
|
-
txProperties: this.getTxProperties(dataUnitName, request),
|
455
|
+
txProperties: this.getTxProperties(dataUnitName, request, sorting),
|
434
456
|
useDefaultRowsLimit: false
|
435
457
|
}
|
436
458
|
};
|
437
459
|
return JSON.stringify(requestBody);
|
438
460
|
}
|
439
|
-
getTxProperties(dataUnitName, request) {
|
461
|
+
getTxProperties(dataUnitName, request, sorting) {
|
440
462
|
const txProperties = {
|
441
463
|
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
|
442
464
|
};
|
@@ -444,7 +466,6 @@ class DatasetStrategy {
|
|
444
466
|
if (serverSideFilters.length !== 0) {
|
445
467
|
txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
|
446
468
|
}
|
447
|
-
const sorting = request.sort;
|
448
469
|
if (sorting != undefined && sorting.length !== 0) {
|
449
470
|
txProperties["__DATA_UNIT_ADAPTER__[sorting]"] = JSON.stringify(sorting);
|
450
471
|
}
|
@@ -551,7 +572,7 @@ class DataUnitDataLoader {
|
|
551
572
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
552
573
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
553
574
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
554
|
-
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
575
|
+
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
555
576
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
556
577
|
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
557
578
|
.catch(reason => console.error(reason));
|
@@ -569,6 +590,11 @@ class DataUnitDataLoader {
|
|
569
590
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
570
591
|
return;
|
571
592
|
}
|
593
|
+
if (loadingInfo.needReload) {
|
594
|
+
//Ir para a primeira página, faz com que o loadData seja chamado novamente
|
595
|
+
dataUnit.gotoPage(0);
|
596
|
+
return;
|
597
|
+
}
|
572
598
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
573
599
|
}
|
574
600
|
static registryLoading(dataUnit, loadingInfo) {
|
@@ -7,7 +7,7 @@ import './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.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-5e9245d7.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-5b886892.js';
|
13
13
|
import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
|
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-9840d004.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-07935045.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-1afab780.js';
|
7
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-5e9245d7.js';
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-7c46996d.js';
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
10
10
|
import './form-config-fetcher-5b886892.js';
|
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
|
3
3
|
import { D as DataFetcher } from './DataFetcher-07935045.js';
|
4
4
|
import { S as SaveErrorsEnum } from './ISave-4412b20c.js';
|
5
5
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
6
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
6
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-5e9245d7.js';
|
7
7
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
8
8
|
import './_commonjsHelpers-9943807e.js';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
@@ -7,7 +7,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.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-5e9245d7.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-5b886892.js';
|
13
13
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
@@ -8,12 +8,12 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.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-5e9245d7.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-5b886892.js';
|
14
14
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
15
15
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
16
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
16
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-9efd5ce9.js';
|
17
17
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
18
18
|
import './ConfigStorage-9840d004.js';
|
19
19
|
import './_commonjsHelpers-9943807e.js';
|
@@ -6,14 +6,14 @@ import { C as ConfigStorage } from './ConfigStorage-9840d004.js';
|
|
6
6
|
import { P as PresentationMode } from './index-1564817d.js';
|
7
7
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
8
8
|
import { s as store } from './index-bdf75557.js';
|
9
|
-
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-
|
9
|
+
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-2a4ec61c.js';
|
10
10
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
11
11
|
import './form-config-fetcher-5b886892.js';
|
12
12
|
import './DataFetcher-07935045.js';
|
13
13
|
import './_commonjsHelpers-9943807e.js';
|
14
14
|
import './PrintUtils-3e4ff0f5.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
|
-
import './dataunit-fetcher-
|
16
|
+
import './dataunit-fetcher-5e9245d7.js';
|
17
17
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
18
18
|
import './ResourceIDUtils-a114189a.js';
|
19
19
|
|
@@ -108,6 +108,7 @@ const SnkGrid = class {
|
|
108
108
|
if (this._gridConfig && this._dataUnit) {
|
109
109
|
this._dataUnit.defaultSorting = this._gridConfig
|
110
110
|
.columns
|
111
|
+
.filter(col => col.ascending != undefined)
|
111
112
|
.sort((colA, colB) => colA.orderIndex - colB.orderIndex)
|
112
113
|
.map(({ name: field, ascending }) => {
|
113
114
|
const { dataType } = this._dataUnit.getField(field);
|
@@ -11,7 +11,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
11
11
|
import './ISave-4412b20c.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-5e9245d7.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
16
|
import './form-config-fetcher-5b886892.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-9efd5ce9.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-a7c4ac16.js';
|
@@ -18,6 +18,6 @@ import './constants-3644f1b6.js';
|
|
18
18
|
import './pesquisa-fetcher-7c46996d.js';
|
19
19
|
import './ISave-4412b20c.js';
|
20
20
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
21
|
-
import './dataunit-fetcher-
|
21
|
+
import './dataunit-fetcher-5e9245d7.js';
|
22
22
|
import './ResourceIDUtils-a114189a.js';
|
23
23
|
import '@sankhyalabs/core/dist/dataunit/DataUnit';
|
@@ -8,11 +8,11 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import { I as InMemoryLoader } from './dataunit-fetcher-
|
11
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-5e9245d7.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-5b886892.js';
|
14
14
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
15
|
-
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-
|
15
|
+
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-2a4ec61c.js';
|
16
16
|
import './index-bdf75557.js';
|
17
17
|
import './_commonjsHelpers-9943807e.js';
|
18
18
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import{FieldComparator as t,SortMode as e,DataUnit as r,defaultDataLoader as n,DataType as s,DateUtils as a,StringUtils as i,ChangeOperation as o,UserInterface as c,DataUnitStorage as l}from"@sankhyalabs/core";import{D as u,d}from"./p-4f7b9c50.js";import{DISTINCT_FILTER_NAME_PREFIX as h}from"@sankhyalabs/ezui/dist/collection/utils/constants";import{DataUnitTransient as f}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{R as m}from"./p-688dcb4c.js";class _{constructor(t){this._list=[],this._equalsFunction=t}async load(t,e,r,n){let s=[].concat(this._list);null!=t&&(s=this._list.filter((e=>t(e)))),null!=e&&(s=s.sort(e));const a=s.length;if(null!=n){const t=r||0;s=s.slice(t,n?t+n:s.length)}return Promise.resolve({result:s,count:a})}async distict(t){const e=[];let r=!1;for(const n of this._list){const s=t(n);null!=s&&(null!=s.value?e.push(s):r=!0)}return r&&e.push({key:"",value:null}),Promise.resolve(new Map(e.map((t=>[t.key,t.value]))))}async push(t){this._list.push(...t)}async clear(){this._list=[]}async delete(t){this._list=this._list.filter((e=>{for(const r of t)if(this._equalsFunction(e,r))return!1;return!0}))}async update(t){this._list=this._list.map((e=>{const r=t.find((t=>this._equalsFunction(e,t)));return null==r?e:r}))}async insert(t,e){const r=this._list.indexOf(t);-1!=r?this._list=this._list.slice(0,r).concat(e).concat(this._list.slice(r)):this._list.push(...e)}isOperating(){return!0}async isEmpty(){return Promise.resolve(0===this._list.length)}async count(){return Promise.resolve(this._list.length)}}const p=/FILTRO_COLUNA_(.+)/;class g{static setLoadingStatus(t,e){this._loadingStatus.set(t.name,e)}static isCacheEnabled(t){return g.getResourceId(t.name)===this.applicationResourceID&&this.getRepository(t).isOperating()}static getResourceId(t){const e=I.parseDataUnitName(t);return null==e?void 0:e.resourceID}static cacheRecords(t,e,r,n){g.setLoadingStatus(t,n),g.isCacheEnabled(t)?this.getRepository(t).push(e):r&&this._repositories.delete(t.name)}static getSortingFunction(r,n){if(null!=n&&0!=n.length)return(s,a)=>{for(const i of n){const n=t.compare(r.getField(i.field),s,a,i.mode===e.ASC);if(0!=n)return n}}}static async getDistinct(t,e){if(!g.isCacheEnabled(t))return Promise.resolve(void 0);let r;const n=t.getLastLoadRequest();if(null!=n){const e=g.getColumnFilters(n.filters);r=g.getFilterFunction(t,Array.from(e.values()))}return new Promise(((n,s)=>{g.getRepository(t).distict((n=>{if(null!=r&&!r(n))return;const s=n[e];if(null==s)return{key:null,value:null};const a=null!=s.value?s.value:s;return{key:t.getFormattedValue(e,s),value:a}})).then((t=>n(t))).catch((t=>s(t)))}))}static async loadData(t,e,n){try{if(g.isCacheEnabled(t)){if(("EZ_GRID_LOADING_SOURCE"===e.source||e.source===r.CHANGING_PAGE_LOADING_SOURCE)&&!await g.getRepository(t).isEmpty())return g.loadFromCache(t,e);g.getRepository(t).clear().catch((()=>{}))}return n(t,e)}catch(t){return console.error(t),Promise.reject(t)}}static insertRecords(t,e,r){g.isCacheEnabled(t)&&g.getRepository(t).insert(e,r)}static updateRecords(t,e){g.isCacheEnabled(t)&&g.getRepository(t).update(e)}static removeRecords(t,e){g.isCacheEnabled(t)&&g.getRepository(t).delete(e)}static async countRecords(t){return g.isCacheEnabled(t)?g.getRepository(t).count():Promise.resolve(0)}static getRepository(t){const e=t.name;return g._repositories.has(e)||g._repositories.set(e,new _(((t,e)=>t.__record__id__===e.__record__id__))),g._repositories.get(e)}static getFilterFunction(t,e){if(null!=e&&e.length>0)return r=>{for(const n of e)if(!g.recordMatchesFilter(t,r,n))return!1;return!0}}static recordMatchesFilter(e,r,n){const s=r[n.columnName];for(let r of n.params){const a=e.valueFromString(n.columnName,r.value);if(0===t.compareValues(e.getField(n.columnName),s,a))return!0}return!1}static async loadFromCache(t,e){return new Promise(((r,n)=>{const s=g.getColumnFilters(e.filters),{limit:a,offset:i,sort:o}=e;g.getRepository(t).load(g.getFilterFunction(t,Array.from(s.values())),g.getSortingFunction(t,o),i,a).then((e=>{const n=g._loadingStatus.get(t.name),{count:s,result:o}=e,c=0==s?0:i+1,l=i+Math.min(o.length,a);r({records:o,paginationInfo:{count:s,currentPage:i/a,firstRecord:c,lastRecord:l,hasMore:n||l<s,total:n?void 0:s}})})).catch((t=>n(t)))}))}static getColumnFilters(t){const e=new Map;return null==t||0==t.length||t.forEach((t=>{const r=p.exec(t.name);r&&e.set(t.name,Object.assign({columnName:r[1]},t))})),e}}g._repositories=new Map,g._loadingStatus=new Map;class y{constructor(t,e){this.metadata=t,this.records=e,this._dataUnit=new r(y.IN_MEMORY_DATA_UNIT_NAME),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,e)=>n(t,e,this.getRecordsToLoad()),this._dataUnit.saveLoader=(t,e)=>this.saveLoader(t,e),this._dataUnit.removeLoader=(t,e)=>this.removeLoader(t,e),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}getRecordsToLoad(){if(this._initialRecords)try{return this._initialRecords}finally{this._initialRecords=void 0}return this.dataUnit.records}get dataUnit(){return this._dataUnit}get records(){return this.dataUnit.records}static getConvertedValue(t,e){return t.dataType===s.BOOLEAN?"S"===e:t.dataType===s.NUMBER?Number(e):t.dataType===s.DATE?a.strToDate(e,!0):e}set records(t){const e=this._metadata?new Map(this._metadata.fields.map((t=>[t.name,t]))):void 0,r=null==t?void 0:t.map((t=>{if(t.__record__id__||(t.__record__id__=this.generateUniqueId()),null!=e)for(const r in t){const n=t[r];"string"==typeof n&&e.has(r)&&(t[r]=y.getConvertedValue(e.get(r),n))}return t}));this._dataUnit?this._dataUnit.records=r:this._initialRecords=r}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return i.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}saveLoader(t,e){return new Promise((t=>{let r=[];e.forEach((t=>{let{record:e,updatingFields:n,operation:s}=t;const a=Object.assign(Object.assign({},e),n);if(s===o.INSERT||s===o.COPY)a.__old__id__=e.__record__id__,a.__record__id__=this.generateUniqueId(),this.records.push(a);else{const t=this.records.findIndex((t=>t.__record__id__==a.__record__id__));this.records[t]=a}r.push(a)})),t(r)}))}removeLoader(t,e){return new Promise((t=>{t(e)}))}}y.IN_MEMORY_DATA_UNIT_NAME="InMemoryDataUnit";class b{canSlice(){return!1}async load(t,e,r){if(null==t.metadata)return Promise.resolve({records:[],loadingInfo:r});try{const n=[],s=[];if(null!=e.sort)for(const r of e.sort){const e=t.getField(r.field);null!=e&&null!=e.properties&&"true"===e.properties.calculated?n.push(r):s.push(r)}const a=this.getFieldsList(t),i="DatasetSP.loadRecords",o=this.buildRequestBody(i,a,t,e,r,s),c=r.quiet?{urlParams:{quietMode:"true"}}:void 0,{result:l,pagerID:d}=await u.get().callServiceBroker(i,o,c),h=this.processRecords(t,a,l),f=null!=d,m=r.count+h.length,_=!f&&n.length>0;return Promise.resolve({records:h,loadingInfo:Object.assign(Object.assign({},r),{pagerId:d,loadingInProgress:f,total:f?void 0:m,count:m,needReload:_})})}catch(t){return console.error(t),Promise.reject(t)}}getFieldsList(t){let e=["__record__id__","__record__label__"];return t.metadata.fields.forEach((t=>{t.standAlone||(e=e.concat(this.getFieldNames(t)))})),e}getFieldNames(t){const e=this.getSearchDescriptionField(t);return null==e?t.name:[t.name,e]}buildRequestBody(t,e,r,n,s,a){const i=r.name,o={serviceName:t,requestBody:{dataSetID:r.dataUnitId,fields:e,entityName:I.parseDataUnitName(i).entityName,pageNumber:s.pageNumber,totalRecordsCount:s.count,pagerID:s.pagerId,standAlone:!1,standAloneFieldsMD:{__record__id__:{fieldType:"S",userType:"P"},__record__label__:{fieldType:"S",userType:"P"}},tryJoinedFields:!0,parallelLoader:!0,crudListener:"br.com.sankhya.modelcore.dataset.DataUnitDatasetAdapter",txProperties:this.getTxProperties(i,n,a),useDefaultRowsLimit:!1}};return JSON.stringify(o)}getTxProperties(t,e,r){const n={"__DATA_UNIT_ADAPTER__[dataUnitName]":t},s=e.filters.filter((t=>!t.name.startsWith("FILTRO_COLUNA_")));return 0!==s.length&&(n["__DATA_UNIT_ADAPTER__[criteria]"]=JSON.stringify(s)),null!=r&&0!==r.length&&(n["__DATA_UNIT_ADAPTER__[sorting]"]=JSON.stringify(r)),n}processRecords(t,e,r){return r.map((r=>{const n={__record__id__:r[0],__record__label__:r[1]};return t.metadata.fields.forEach((t=>{n[t.name]=this.buildFieldValue(t,e,r)})),n}))}buildFieldValue(t,e,r){const n=e.indexOf(t.name);if(n<0)return null;const s=r[n];if(i.isEmpty(s))return null;const a=this.getSearchDescriptionField(t);if(null!=a){const t=e.indexOf(a);if(t>=0)return{value:s,label:r[t]}}return t.userInterface===c.SEARCH?isNaN(Number(s))?s:Number(s):y.getConvertedValue(t,s)}getSearchDescriptionField(t){if(t.userInterface===c.SEARCH){const{ENTITYNAME:e,mergedFrom:r,DESCRIPTIONFIELD:n}=t.properties;if(!i.isEmpty(n))return null!=r?`${r}.${e}.${n}`:`${e}.${n}`}}}class v{static async debounce(t,e){const r=t.name;v._debouncingTimeouts[r]&&(clearTimeout(v._debouncingTimeouts[r]),delete v._debouncingTimeouts[r]),v._debouncingTimeouts[r]=setTimeout((()=>{delete v._debouncingTimeouts[r],e()}),100)}static async loadData(t,e){return new Promise(((r,n)=>{v.debounce(t,(()=>{g.loadData(t,e,this.loadFromServer).then((t=>r(t))).catch((t=>n(t)))}))}))}static async loadFromServer(t,e,r){try{r=v.registryLoading(t,r);const n=await v.callLoader(t,e,r);if(null==n)return;const s=n.records,a=v.buildPaginationInfo(s.length,e,n.loadingInfo),i=null==a?s:s.slice(0,a.lastRecord);return Promise.resolve({records:i,paginationInfo:a})}catch(t){return console.error(t),Promise.reject(t)}}static async callLoader(t,e,r,n){null==n&&(n=new b);const s=await n.load(t,e,r),{records:a,loadingInfo:i}=s;if(v.isOldRequest(t,i))return Promise.resolve(void 0);const o=!n.canSlice()||0===i.count;if(g.cacheRecords(t,a,o,i.loadingInProgress),g.isCacheEnabled(t)&&i.loadingInProgress){const r=Object.assign(Object.assign({},e),{offset:i.count}),s=Object.assign(Object.assign({},i),{pageNumber:(i.pageNumber||0)+1,quiet:!0});this.callLoader(t,r,s,n).then((e=>v.afterLoadingPage(t,e.loadingInfo))).catch((t=>console.error(t)))}return Promise.resolve(s)}static afterLoadingPage(t,e){g.setLoadingStatus(t,e.loadingInProgress);const r=t.getPaginationInfo();if(null==r)return;const n=e.count;e.loadingInProgress?t.updatePagination(Object.assign(Object.assign({},r),{count:n})):e.needReload?t.gotoPage(0):t.updatePagination(Object.assign(Object.assign({},r),{total:n,count:n}))}static registryLoading(t,e){return null==e&&(e={requestTime:(new Date).getTime(),count:0}),v._requestTimeByDataUnit.set(t.name,e.requestTime),e}static isOldRequest(t,e){return v._requestTimeByDataUnit.get(t.name)>e.requestTime}static buildPaginationInfo(t,e,r){let{limit:n,offset:s}=e;if(!n)return;1===r.pageNumber&&(s=0);const{total:a,count:i,loadingInProgress:o}=r,c=0===i||0===t?0:s+1,l=s+Math.min(t,n);return{total:a,count:i,lastRecord:l,firstRecord:c,currentPage:s/n,hasMore:l<i||o}}}v._requestTimeByDataUnit=new Map,v._debouncingTimeouts={};const D=/dd:\/\/([^/]+)\/([^/?]+)/;class I{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",d.gql`query($name: String!) {
|
2
|
+
$queryAlias$: fetchDataUnit(name: $name){
|
3
|
+
name
|
4
|
+
fields{
|
5
|
+
name
|
6
|
+
defaultValue
|
7
|
+
label
|
8
|
+
visible
|
9
|
+
readOnly
|
10
|
+
required
|
11
|
+
dataType
|
12
|
+
userInterface
|
13
|
+
calculated
|
14
|
+
group
|
15
|
+
order
|
16
|
+
properties{
|
17
|
+
name
|
18
|
+
value
|
19
|
+
}
|
20
|
+
dependencies{
|
21
|
+
masterFields
|
22
|
+
type
|
23
|
+
expression
|
24
|
+
}
|
25
|
+
}
|
26
|
+
children{
|
27
|
+
name
|
28
|
+
label
|
29
|
+
links{
|
30
|
+
source
|
31
|
+
target
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}`),this.templateByQuery.set("saveData",d.gql`mutation($changes: [InputBatchChange!]!) {
|
36
|
+
$queryAlias$: batchOperationDataUnit(changes: $changes){
|
37
|
+
oldId
|
38
|
+
id
|
39
|
+
label
|
40
|
+
ownerDataUnitName
|
41
|
+
fields {
|
42
|
+
name
|
43
|
+
value
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}`),this.templateByQuery.set("fetchDataRecord",d.gql`query($dataunit: String! $recordID: [String!]) {
|
47
|
+
$queryAlias$: fetchDataUnit(name: $dataunit){
|
48
|
+
record(id: $recordID){
|
49
|
+
id
|
50
|
+
label
|
51
|
+
fields {
|
52
|
+
name
|
53
|
+
value
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}`),this.templateByQuery.set("fetchDistinctColumn",d.gql`query($dataUnit: String!, $fieldName: String!, $argument: String, $filters: [InputFilter], $parentRecordId: String) {
|
58
|
+
$queryAlias$: selectDistinct(dataUnit: $dataUnit, fieldName: $fieldName, argument: $argument, filters: $filters, parentRecordId: $parentRecordId)
|
59
|
+
}`)}static parseDataUnitName(t){if(null==t)return;const e=D.exec(t);return e?{entityName:e[1],resourceID:e[2]}:void 0}getDataUnit(t,e,n,s){null==g.applicationResourceID&&m.getResourceID().then((t=>g.applicationResourceID=t));const a=`dd://${t}/${e}${s?"/"+s:""}`,i=null!=n?n.getChildDataunit(a):new r(a);return i.metadataLoader=t=>this.loadMetadata(t),i.dataLoader=(t,e)=>v.loadData(t,e),i.saveLoader=(t,e)=>this.saveData(i,e),i.removeLoader=(t,e)=>this.removeRecords(t,e),i.recordLoader=(t,e)=>this.loadRecord(t,e),i}loadMetadata(t){return new Promise(((e,r)=>{u.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var r;const n={name:t.name,label:t.name,children:[...t.children],fields:[]};null===(r=t.fields)||void 0===r||r.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.calculated&&(e.gridHeaderTooltip="Campos calculados não podem ser ordenados"),t.properties.forEach((t=>e[t.name]=t.value))),n.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),n.fields.sort(((t,e)=>t.order-e.order)),e(n)})).catch((t=>{r(t)}))}))}loadSelectDistinct(t,e,r){const{parentRecordId:n,filters:s}=t.getLastLoadRequest()||{},a=s.filter((t=>t.name!==`${h}${e}`)),i={dataUnit:t.name,argument:r,fieldName:e,parentRecordId:n,filters:a};return new Promise(((t,e)=>{u.get().callGraphQL({values:i,query:this.templateByQuery.get("fetchDistinctColumn")}).then((e=>{t(e)})).catch((t=>{e(t)}))}))}saveData(t,e){const r=[],n=[],a=e.map((e=>{const{dataUnit:a,record:i,updatingFields:c,operation:u}=e,d=l.get(a);let h;c&&(h=Object.entries(c).map((([t,e])=>{const r=d.getField(t);return{fieldName:t,dataType:r?r.dataType:s.TEXT,value:d.valueToString(t,e)}}))),a===t.name&&(u===o.INSERT||u===o.COPY?n.push(i.__record__id__):r.push(i.__record__id__));const f={dataUnit:a,fields:h,operation:u,recordId:i.__record__id__};return e.sourceId&&(f.sourceId=e.sourceId),i.__parent__record__id__&&(f.parentRecordId=i.__parent__record__id__),f}));return new Promise(((e,s)=>{const i=a.map((t=>function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]])}return r}(t,[])));u.get().callGraphQL({values:{changes:i},query:this.templateByQuery.get("saveData")}).then((s=>{const a=[];null==s||s.forEach((e=>{const r={__record__id__:e.id,__record__label__:e.label,__owner__dataunit__name__:e.ownerDataUnitName},n=l.get(r.__owner__dataunit__name__)||t;e.oldId&&(r.__old__id__=e.oldId),e.fields.forEach((({name:t,value:e})=>{var s;r[t]=(null===(s=null==n?void 0:n.valueFromString)||void 0===s?void 0:s.call(n,t,e))||e})),a.push(r)})),this.updateCache(t,a,r,n),e(a)})).catch((t=>{s(t)}))}))}updateCache(t,e,r,n){const s=new Map(e.map((t=>[t.__old__id__||t.__record__id__,t]))),a=n.map((t=>{const e=Object.assign({},s.get(t));return delete e.__old__id__,e}));a.length>0&&g.insertRecords(t,t.records[0],a);const i=r.map((t=>Object.assign({},s.get(t))));g.updateRecords(t,i)}getTransientInfo(t,e){const{records:r}=t.getSelectionInfo();return Object.entries(r.filter((t=>t.__record__id__==e))[0]).filter((([t])=>t.startsWith(f.DATA_UNIT_TRANSIENT_PREFIX_NAME))).map((([t,e])=>({fieldName:t,value:e,dataType:s.TEXT})))}removeRecords(t,e){const r=e.map((e=>({dataUnit:t.name,operation:o.DELETE,recordId:e,fields:this.getTransientInfo(t,e)})));return new Promise(((n,s)=>{u.get().callGraphQL({values:{changes:r},query:this.templateByQuery.get("saveData")}).then((()=>{g.removeRecords(t,t.records.filter((t=>e.includes(t.__record__id__)))),n(e)})).catch((t=>{s(t)}))}))}loadRecord(t,e){return new Promise(((r,n)=>{u.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const n=[];e.record.forEach((e=>{const r={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:n})=>{r[e]=t.valueFromString(e,n)})),n.push(r)})),r(n)})).catch((t=>{n(t)}))}))}}export{I as D,y as I,g as P}
|
@@ -1 +1 @@
|
|
1
|
-
export{S as snk_guides_viewer}from"./p-
|
1
|
+
export{S as snk_guides_viewer}from"./p-c34cea23.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-96dd0c41.js";import"./p-b19c272c.js";import"./p-0f2b03e5.js";import"./p-4f7b9c50.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d884fab.js";import"./p-584d7212.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-c2beb95c.js";import"./p-c9841939.js";import"./p-5534e08c.js";import"./p-6dc031de.js";import"./p-4a78e118.js";import"./p-efb2e247.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-171b12d5.js";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,h as s,H as e,g as a}from"./p-d2d301a6.js";import{StringUtils as h,ElementIDUtils as o,ApplicationContext as n}from"@sankhyalabs/core";import{T as r}from"./p-c9841939.js";import"./p-4f7b9c50.js";import"./p-efb2e247.js";import{P as d}from"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-
|
1
|
+
import{r as t,c as i,h as s,H as e,g as a}from"./p-d2d301a6.js";import{StringUtils as h,ElementIDUtils as o,ApplicationContext as n}from"@sankhyalabs/core";import{T as r}from"./p-c9841939.js";import"./p-4f7b9c50.js";import"./p-efb2e247.js";import{P as d}from"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-171b12d5.js";import"./p-584d7212.js";import"./p-0f2b03e5.js";import{c}from"./p-4a78e118.js";import{A as l}from"./p-de1196c8.js";import"./p-6dc031de.js";import"./p-112455b1.js";import"./p-8d884fab.js";import"./p-688dcb4c.js";const m=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this._viewHistory=[],this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=c.GRID,this._canEdit=void 0,this._resourceID=void 0,this.configName=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=d.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${h.generateUUID()}`}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===c.GRID,this.setViewMode(c.FORM)}async executeAction(t){return t===r.GRID_MODE?this.setViewMode(c.GRID):t===r.FORM_MODE||t===r.UPDATE?this.gridToForm(t!==r.UPDATE):t===r.CONFIGURATOR?this._snkConfigurator.open():"ATTACH"===t?this.setViewMode(c.ATTACHMENT):void 0}backView(){const t=this._viewHistory.at(-2)||c.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t}openConfig(t){this._snkConfigurator.close(),t===c.GRID?this._snkGrid.showConfig():t===c.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(c.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}componentWillLoad(){const t=n.getContextValue("__SNK__APPLICATION__");t.hasAccess(l.UPDATE,this._resourceID).then((t=>this._canEdit=t));let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit(t):this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.initDataUnit(t)})),this._snkDataUnit.addEventListener("dataStateChange",(async({detail:t})=>{this._dataState=t,void 0!==t.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}));break}i=i.parentElement}this.configName||(this.configName=t.configName)}async initDataUnit(t){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),null==this._resourceID&&(this._resourceID=this._snkDataUnit.resourceID,null==this._resourceID&&(this._resourceID=await t.getResourceID()))}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}render(){if(null!=this._resourceID)return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===c.GRID,s(e,null,s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(c.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",null,s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId})),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return a(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};m.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{m as snk_crud}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{r as t,c as s,h as e,g as i}from"./p-d2d301a6.js";import{DateUtils as n,StringUtils as r,ObjectUtils as a,WaitingChangeException as o,WarningException as c,ErrorException as h,OnboardingUtils as u,DependencyType as l,ElementIDUtils as p,DataType as d,ApplicationContext as m,ErrorTracking as w}from"@sankhyalabs/core";import{ApplicationUtils as f}from"@sankhyalabs/ezui/dist/collection/utils";import{C as y}from"./p-b19c272c.js";import{d as P,D as g,U as v}from"./p-4f7b9c50.js";import{A as I,a as A}from"./p-de1196c8.js";import{D as _}from"./p-
|
1
|
+
import{r as t,c as s,h as e,g as i}from"./p-d2d301a6.js";import{DateUtils as n,StringUtils as r,ObjectUtils as a,WaitingChangeException as o,WarningException as c,ErrorException as h,OnboardingUtils as u,DependencyType as l,ElementIDUtils as p,DataType as d,ApplicationContext as m,ErrorTracking as w}from"@sankhyalabs/core";import{ApplicationUtils as f}from"@sankhyalabs/ezui/dist/collection/utils";import{C as y}from"./p-b19c272c.js";import{d as P,D as g,U as v}from"./p-4f7b9c50.js";import{A as I,a as A}from"./p-de1196c8.js";import{D as _}from"./p-171b12d5.js";import{P as S}from"./p-efb2e247.js";import{S as b}from"./p-f1f7b545.js";import"./p-0f2b03e5.js";import"./p-584d7212.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-688dcb4c.js";class E{static webConnectionCaller(t,s,e){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,s,e)}}const N=D;function D(t,s){const e=C();return(D=function(t){return e[t-=378]})(t,s)}function C(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(C=function(){return t})()}!function(){const t=D,s=C();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class T{[N(397)](t){const s=N;if(typeof(t=utxt(t[s(390)]))==s(392)&&(t=JSON[s(400)](t)),null==t)throw Error(s(395));const e=new L("S"===t[s(402)]||!0===t[s(402)]);return Array[s(394)](t[s(391)])&&t[s(391)][s(385)]((t=>e.putAccess(t[s(382)],String(t.status)==s(398)))),e}}class L{constructor(t){const s=N;this.isSup=t,this[s(384)]={}}[N(378)](t,s){this[N(384)][t]=s}[N(393)](t){const s=N;if(this[s(402)])return!0;let e=!0;return this[s(384)][s(380)](t)&&(e=this.actions[t]),e}isUserSup(){return this.isSup}}class O{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",P.gql`query($name: String!) {
|
2
2
|
$queryAlias$: fetchResource(name: $name){
|
3
3
|
name
|
4
4
|
resource
|