@sankhyalabs/sankhyablocks 8.16.0-dev.73 → 8.16.0-dev.75
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ContinuousInsertUtils-6e536e37.js → ContinuousInsertUtils-b5de47db.js} +2 -2
- package/dist/cjs/{dataunit-fetcher-8ea97d88.js → dataunit-fetcher-c32fdff7.js} +171 -17
- package/dist/cjs/{pesquisa-fetcher-3b86b6c4.js → pesquisa-fetcher-36d039c4.js} +4 -0
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-actions-button_5.cjs.entry.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +2 -2
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-72ef8777.js → snk-data-unit-2c7c1964.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +3 -3
- package/dist/cjs/{snk-guides-viewer-84cb012b.js → snk-guides-viewer-a651b9b8.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-pesquisa.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -3
- package/dist/collection/components/snk-pesquisa/pesquisaHelper.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +57 -12
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.js +108 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -8
- package/dist/components/ISave.js +4 -0
- package/dist/components/dataunit-fetcher.js +171 -17
- package/dist/esm/{ContinuousInsertUtils-91011e01.js → ContinuousInsertUtils-213385f5.js} +2 -2
- package/dist/esm/{dataunit-fetcher-8dd93d8b.js → dataunit-fetcher-26c2bed4.js} +171 -17
- package/dist/esm/{pesquisa-fetcher-767abffa.js → pesquisa-fetcher-aab1fe14.js} +4 -0
- package/dist/esm/pesquisa-grid_2.entry.js +2 -2
- package/dist/esm/snk-actions-button_5.entry.js +2 -2
- package/dist/esm/snk-application.entry.js +2 -2
- package/dist/esm/snk-attach.entry.js +2 -2
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-11a49fc3.js → snk-data-unit-a36df23f.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +3 -3
- package/dist/esm/{snk-guides-viewer-45ee10ff.js → snk-guides-viewer-cbd8511f.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-pesquisa.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +3 -3
- package/dist/sankhyablocks/{p-1a91d1f3.entry.js → p-045398fb.entry.js} +1 -1
- package/dist/sankhyablocks/{p-853074f4.entry.js → p-167ac365.entry.js} +3 -3
- package/dist/sankhyablocks/{p-cfd229f4.entry.js → p-2098a093.entry.js} +1 -1
- package/dist/sankhyablocks/{p-1bab295e.entry.js → p-3b2e5822.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6cfa8913.js → p-4ec70a7b.js} +1 -1
- package/dist/sankhyablocks/{p-035c63df.entry.js → p-70a546e9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-60e4db34.js → p-70ae0779.js} +1 -1
- package/dist/sankhyablocks/{p-0e6874ca.entry.js → p-76041b30.entry.js} +1 -1
- package/dist/sankhyablocks/p-78d49c74.js +60 -0
- package/dist/sankhyablocks/{p-6e0adddc.entry.js → p-7a95cbc7.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e74eb86d.entry.js → p-92dd432c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-1c2d8a9a.entry.js → p-9f9128d3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-dd7fb984.entry.js → p-b5ebc20a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-03e37897.entry.js → p-b738af3a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-935aa4fa.entry.js → p-bfdc08f2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-4fe8bb73.js → p-c9f22653.js} +1 -1
- package/dist/sankhyablocks/{p-ee759111.js → p-dd37be7e.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +9 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +4 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +3 -3
- package/package.json +1 -1
- package/dist/sankhyablocks/p-ddefbbc7.js +0 -60
@@ -1,13 +1,13 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
const DataFetcher = require('./DataFetcher-65879b2c.js');
|
4
|
-
require('./pesquisa-fetcher-
|
4
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
5
5
|
const core = require('@sankhyalabs/core');
|
6
6
|
require('./index-1dfc7a6e.js');
|
7
7
|
require('./ISave-e91b70a7.js');
|
8
8
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
9
9
|
const UnitMetadata = require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
10
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
10
|
+
const dataunitFetcher = require('./dataunit-fetcher-c32fdff7.js');
|
11
11
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
12
12
|
require('./form-config-fetcher-90126e4c.js');
|
13
13
|
const InMemoryFilterColumnDataSource = require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource');
|
@@ -449,12 +449,13 @@ class DatasetStrategy {
|
|
449
449
|
const serviceName = "DatasetSP.loadRecords";
|
450
450
|
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting, serverSideFilters);
|
451
451
|
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
452
|
-
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
452
|
+
const { result: responseRecords, pagerID: pagerId, askRowsLimit } = await DataFetcher.DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
453
453
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
454
454
|
const loadingInProgress = pagerId != undefined;
|
455
455
|
const count = loadingInfo.count + records.length;
|
456
456
|
const isInsertingNewRecord = dataUnit.hasNewRecord();
|
457
|
-
const
|
457
|
+
const hasLocalSorting = localSorting.length > 0;
|
458
|
+
const needReload = !loadingInProgress && hasLocalSorting;
|
458
459
|
/**
|
459
460
|
* Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
|
460
461
|
* Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
|
@@ -465,7 +466,8 @@ class DatasetStrategy {
|
|
465
466
|
return Promise.resolve({
|
466
467
|
records,
|
467
468
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
468
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord
|
469
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord, askRowsLimit,
|
470
|
+
hasLocalSorting })
|
469
471
|
});
|
470
472
|
}
|
471
473
|
catch (error) {
|
@@ -517,8 +519,7 @@ class DatasetStrategy {
|
|
517
519
|
},
|
518
520
|
}
|
519
521
|
};
|
520
|
-
|
521
|
-
return parsedRequestBody;
|
522
|
+
return JSON.stringify(requestBody);
|
522
523
|
}
|
523
524
|
getFieldsList(dataUnit) {
|
524
525
|
let fields = ["__record__id__", "__record__label__"];
|
@@ -645,7 +646,117 @@ class DatasetStrategy {
|
|
645
646
|
}
|
646
647
|
}
|
647
648
|
|
649
|
+
async function showAskCancelPaginationPopup() {
|
650
|
+
return new Promise((resolve) => {
|
651
|
+
const { checkboxContainer, checkbox } = buildCheckboxContainer();
|
652
|
+
const popup = builPopup(resolve, checkbox);
|
653
|
+
const contentContainer = buildContentContainer();
|
654
|
+
contentContainer.appendChild(buildMessage());
|
655
|
+
contentContainer.appendChild(checkboxContainer);
|
656
|
+
const actionsContainer = buildActionsContainer();
|
657
|
+
actionsContainer.appendChild(buildContinuePaginationBtn(popup, checkbox, resolve));
|
658
|
+
actionsContainer.appendChild(buildCancelPaginationBtn(popup, resolve));
|
659
|
+
contentContainer.appendChild(actionsContainer);
|
660
|
+
popup.appendChild(contentContainer);
|
661
|
+
document.body.appendChild(popup);
|
662
|
+
});
|
663
|
+
}
|
664
|
+
function buildCheckboxContainer() {
|
665
|
+
const checkboxContainer = document.createElement('div');
|
666
|
+
checkboxContainer.style.marginBottom = '14px';
|
667
|
+
checkboxContainer.style.display = 'flex';
|
668
|
+
checkboxContainer.style.alignItems = 'center';
|
669
|
+
const { checkbox, checkboxLabel } = buildCheckbox();
|
670
|
+
checkboxContainer.appendChild(checkbox);
|
671
|
+
checkboxContainer.appendChild(checkboxLabel);
|
672
|
+
return { checkboxContainer, checkbox };
|
673
|
+
}
|
674
|
+
function buildCheckbox() {
|
675
|
+
const checkbox = document.createElement('input');
|
676
|
+
checkbox.type = 'checkbox';
|
677
|
+
checkbox.id = 'loadAll';
|
678
|
+
const checkboxLabel = document.createElement('label');
|
679
|
+
checkboxLabel.htmlFor = 'loadAll';
|
680
|
+
checkboxLabel.textContent = 'Carregar tudo';
|
681
|
+
checkboxLabel.style.marginLeft = '5px';
|
682
|
+
return { checkbox, checkboxLabel };
|
683
|
+
}
|
684
|
+
function buildActionsContainer() {
|
685
|
+
const actionsContainer = document.createElement('div');
|
686
|
+
actionsContainer.style.display = 'flex';
|
687
|
+
actionsContainer.style.flexDirection = 'row';
|
688
|
+
actionsContainer.style.justifyContent = 'end';
|
689
|
+
actionsContainer.style.gap = '5px';
|
690
|
+
return actionsContainer;
|
691
|
+
}
|
692
|
+
function buildContentContainer() {
|
693
|
+
const contentContainer = document.createElement('div');
|
694
|
+
contentContainer.style.display = 'flex';
|
695
|
+
contentContainer.style.flexDirection = 'column';
|
696
|
+
contentContainer.style.fontFamily = 'var(--font-pattern, Roboto)';
|
697
|
+
contentContainer.style.fontSize = 'var(--text--medium)';
|
698
|
+
return contentContainer;
|
699
|
+
}
|
700
|
+
function buildMessage() {
|
701
|
+
const message = document.createElement('div');
|
702
|
+
const line1 = document.createElement('p');
|
703
|
+
const line2 = document.createElement('p');
|
704
|
+
const line3 = document.createElement('p');
|
705
|
+
line3.style.fontWeight = 'var(--text-weight--large, 600)';
|
706
|
+
line1.textContent = 'Uma quantidade de registros muito grande está sendo carregada.';
|
707
|
+
line2.textContent = 'Recomendamos que a paginação seja cancelada e que seja criado um filtro para os registros.';
|
708
|
+
line3.textContent = 'Deseja cancelar o carregamento?';
|
709
|
+
message.appendChild(line1);
|
710
|
+
message.appendChild(line2);
|
711
|
+
message.appendChild(line3);
|
712
|
+
return message;
|
713
|
+
}
|
714
|
+
function buildCancelPaginationBtn(popup, resolve) {
|
715
|
+
const cancelPaginationBtn = document.createElement('ez-button');
|
716
|
+
cancelPaginationBtn.label = 'Cancelar paginação';
|
717
|
+
cancelPaginationBtn.size = 'medium';
|
718
|
+
cancelPaginationBtn.classList.add('ez-button--primary');
|
719
|
+
cancelPaginationBtn.onclick = () => {
|
720
|
+
document.body.removeChild(popup);
|
721
|
+
resolve(CancelPaginationResponse.CANCEL);
|
722
|
+
};
|
723
|
+
return cancelPaginationBtn;
|
724
|
+
}
|
725
|
+
function buildContinuePaginationBtn(popup, checkBox, resolve) {
|
726
|
+
const continuePaginationBtn = document.createElement('ez-button');
|
727
|
+
continuePaginationBtn.label = 'Continuar';
|
728
|
+
continuePaginationBtn.size = 'medium';
|
729
|
+
continuePaginationBtn.onclick = () => {
|
730
|
+
document.body.removeChild(popup);
|
731
|
+
resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
|
732
|
+
};
|
733
|
+
return continuePaginationBtn;
|
734
|
+
}
|
735
|
+
function builPopup(resolve, checkBox) {
|
736
|
+
const popup = document.createElement('ez-popup');
|
737
|
+
popup.opened = true;
|
738
|
+
popup.size = 'x-small';
|
739
|
+
popup.ezTitle = 'Aviso';
|
740
|
+
popup.heightMode = "auto";
|
741
|
+
popup.addEventListener('ezClosePopup', () => {
|
742
|
+
document.body.removeChild(popup);
|
743
|
+
resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
|
744
|
+
}, { once: true });
|
745
|
+
popup.addEventListener('ezPopupAction', () => {
|
746
|
+
document.body.removeChild(popup);
|
747
|
+
resolve(CancelPaginationResponse.CANCEL);
|
748
|
+
}, { once: true });
|
749
|
+
return popup;
|
750
|
+
}
|
751
|
+
var CancelPaginationResponse;
|
752
|
+
(function (CancelPaginationResponse) {
|
753
|
+
CancelPaginationResponse["CANCEL"] = "CANCEL";
|
754
|
+
CancelPaginationResponse["CONTINUE"] = "CONTINUE";
|
755
|
+
CancelPaginationResponse["LOAD_ALL"] = "LOAD_ALL";
|
756
|
+
})(CancelPaginationResponse || (CancelPaginationResponse = {}));
|
757
|
+
|
648
758
|
class DataUnitDataLoader {
|
759
|
+
constructor() { }
|
649
760
|
static async debounce(dataUnit, callBack) {
|
650
761
|
const duName = dataUnit.name;
|
651
762
|
if (DataUnitDataLoader._debouncingTimeouts[duName]) {
|
@@ -691,25 +802,67 @@ class DataUnitDataLoader {
|
|
691
802
|
}
|
692
803
|
static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
|
693
804
|
if (dataLoader == undefined) {
|
694
|
-
//dataLoader = new DataUnitStrategy();
|
695
805
|
dataLoader = new DatasetStrategy();
|
696
806
|
}
|
697
807
|
const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
|
698
|
-
const
|
699
|
-
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
|
808
|
+
const responseLoadingInfo = result.loadingInfo;
|
809
|
+
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
|
700
810
|
return Promise.resolve(undefined);
|
811
|
+
this.handleCache(dataLoader, responseLoadingInfo, dataUnit, result.records);
|
812
|
+
if (dataUnit.cancelPagination)
|
813
|
+
return this.handlePaginationCanceled(dataUnit, result);
|
814
|
+
//Não existem mais páginas a serem carregadas
|
815
|
+
if (this.canFinishPagination(dataUnit, responseLoadingInfo))
|
816
|
+
return Promise.resolve(result);
|
817
|
+
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
818
|
+
let newLoadingInfo = this.buildNewLoadingInfo(responseLoadingInfo);
|
819
|
+
if (this.canProceedPagination(responseLoadingInfo))
|
820
|
+
return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
|
821
|
+
const confirm = await showAskCancelPaginationPopup();
|
822
|
+
if (confirm === CancelPaginationResponse.CANCEL)
|
823
|
+
return this.handlePaginationCanceled(dataUnit, result);
|
824
|
+
if (confirm === CancelPaginationResponse.LOAD_ALL) {
|
825
|
+
newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { loadAllRecords: true });
|
701
826
|
}
|
827
|
+
newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { lastRowLimitAsked: newLoadingInfo.count });
|
828
|
+
return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
|
829
|
+
}
|
830
|
+
static buildNewLoadingInfo(responseLoadingInfo) {
|
831
|
+
let newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
832
|
+
return newLoadingInfo;
|
833
|
+
}
|
834
|
+
static handleCache(dataLoader, responseLoadingInfo, dataUnit, records) {
|
702
835
|
const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
|
703
836
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
.catch(reason => console.error(reason));
|
710
|
-
}
|
837
|
+
}
|
838
|
+
static recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result) {
|
839
|
+
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
840
|
+
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
841
|
+
.catch(reason => console.error(reason));
|
711
842
|
return Promise.resolve(result);
|
712
843
|
}
|
844
|
+
static canFinishPagination(dataUnit, responseLoadingInfo) {
|
845
|
+
return !PreloadManager.isCacheEnabled(dataUnit) || !responseLoadingInfo.loadingInProgress;
|
846
|
+
}
|
847
|
+
static canProceedPagination(info) {
|
848
|
+
const { count, askRowsLimit, loadAllRecords, lastRowLimitAsked } = info;
|
849
|
+
if (loadAllRecords)
|
850
|
+
return true;
|
851
|
+
if (!count || !askRowsLimit)
|
852
|
+
return true;
|
853
|
+
const askRowLimitNumber = Number(askRowsLimit);
|
854
|
+
if (count < askRowLimitNumber)
|
855
|
+
return true;
|
856
|
+
const nextLimitToAsk = askRowLimitNumber + (lastRowLimitAsked ? lastRowLimitAsked : 0);
|
857
|
+
return count < nextLimitToAsk;
|
858
|
+
}
|
859
|
+
static handlePaginationCanceled(dataUnit, result) {
|
860
|
+
dataUnit.cancelPagination = false;
|
861
|
+
let loadingInfo = result.loadingInfo;
|
862
|
+
loadingInfo = Object.assign(Object.assign({}, loadingInfo), { total: loadingInfo.count, loadingInProgress: false, pagerId: undefined, needReload: loadingInfo.hasLocalSorting });
|
863
|
+
const loadDataResult = { records: result.records, loadingInfo };
|
864
|
+
return Promise.resolve(loadDataResult);
|
865
|
+
}
|
713
866
|
static afterLoadingPage(dataUnit, loadingInfo) {
|
714
867
|
PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
|
715
868
|
const dataUnitPagination = dataUnit.getPaginationInfo();
|
@@ -749,7 +902,7 @@ class DataUnitDataLoader {
|
|
749
902
|
// controle de paginação voltar pra primeira página.
|
750
903
|
offset = 0;
|
751
904
|
}
|
752
|
-
const { total, count, loadingInProgress } = loadingInfo;
|
905
|
+
const { total, count, loadingInProgress, askRowsLimit } = loadingInfo;
|
753
906
|
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
754
907
|
const lastRecord = offset + Math.min(pageSize, limit);
|
755
908
|
return {
|
@@ -758,7 +911,8 @@ class DataUnitDataLoader {
|
|
758
911
|
lastRecord,
|
759
912
|
firstRecord,
|
760
913
|
currentPage: offset / limit,
|
761
|
-
hasMore: lastRecord < count || loadingInProgress
|
914
|
+
hasMore: lastRecord < count || loadingInProgress,
|
915
|
+
askRowsLimit
|
762
916
|
};
|
763
917
|
}
|
764
918
|
}
|
@@ -59,6 +59,8 @@ function buildUserInterface(field) {
|
|
59
59
|
return core.UserInterface.DATETIME;
|
60
60
|
if (field['type'] === 'T')
|
61
61
|
return core.UserInterface.TIME;
|
62
|
+
if (field['type'] === 'I')
|
63
|
+
return core.UserInterface.INTEGERNUMBER;
|
62
64
|
return undefined;
|
63
65
|
}
|
64
66
|
function buildDataType(rawType) {
|
@@ -70,6 +72,8 @@ function buildDataType(rawType) {
|
|
70
72
|
return core.DataType.DATE;
|
71
73
|
case 'B':
|
72
74
|
return core.DataType.OBJECT;
|
75
|
+
case 'I':
|
76
|
+
return core.DataType.NUMBER;
|
73
77
|
default:
|
74
78
|
return core.DataType.TEXT;
|
75
79
|
}
|
@@ -3,9 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
5
|
const index = require('./index-f9e81701.js');
|
6
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
6
|
+
const dataunitFetcher = require('./dataunit-fetcher-c32fdff7.js');
|
7
7
|
require('./DataFetcher-65879b2c.js');
|
8
|
-
const pesquisaFetcher = require('./pesquisa-fetcher-
|
8
|
+
const pesquisaFetcher = require('./pesquisa-fetcher-36d039c4.js');
|
9
9
|
require('@sankhyalabs/core');
|
10
10
|
require('./index-1dfc7a6e.js');
|
11
11
|
require('./ISave-e91b70a7.js');
|
@@ -6,12 +6,12 @@ const index = require('./index-f9e81701.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
7
7
|
const DataFetcher = require('./DataFetcher-65879b2c.js');
|
8
8
|
const ParamType = require('./ParamType-90b440a0.js');
|
9
|
-
require('./pesquisa-fetcher-
|
9
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
10
10
|
require('./index-1dfc7a6e.js');
|
11
11
|
require('./ISave-e91b70a7.js');
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
|
-
require('./dataunit-fetcher-
|
14
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
15
15
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
16
16
|
const formConfigFetcher = require('./form-config-fetcher-90126e4c.js');
|
17
17
|
const GetSelectedRecordsIDsInfo = require('./GetSelectedRecordsIDsInfo-bd50caf1.js');
|
@@ -8,8 +8,8 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
8
|
const ConfigStorage = require('./ConfigStorage-d024aec8.js');
|
9
9
|
const DataFetcher = require('./DataFetcher-65879b2c.js');
|
10
10
|
const authFetcher = require('./auth-fetcher-8480751c.js');
|
11
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
12
|
-
const pesquisaFetcher = require('./pesquisa-fetcher-
|
11
|
+
const dataunitFetcher = require('./dataunit-fetcher-c32fdff7.js');
|
12
|
+
const pesquisaFetcher = require('./pesquisa-fetcher-36d039c4.js');
|
13
13
|
const SnkMessageBuilder = require('./SnkMessageBuilder-bae64d0d.js');
|
14
14
|
require('./form-config-fetcher-90126e4c.js');
|
15
15
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
const index = require('./index-f9e81701.js');
|
6
6
|
const core = require('@sankhyalabs/core');
|
7
7
|
const DataFetcher = require('./DataFetcher-65879b2c.js');
|
8
|
-
require('./pesquisa-fetcher-
|
8
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
9
9
|
require('./index-1dfc7a6e.js');
|
10
10
|
const ISave = require('./ISave-e91b70a7.js');
|
11
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
11
|
+
const dataunitFetcher = require('./dataunit-fetcher-c32fdff7.js');
|
12
12
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
13
13
|
require('./form-config-fetcher-90126e4c.js');
|
14
14
|
const constants = require('./constants-35ddd366.js');
|
@@ -6,12 +6,12 @@ const index = require('./index-f9e81701.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
7
7
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
8
8
|
require('./DataFetcher-65879b2c.js');
|
9
|
-
require('./pesquisa-fetcher-
|
9
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
10
10
|
const index$1 = require('./index-1dfc7a6e.js');
|
11
11
|
require('./ISave-e91b70a7.js');
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
|
-
require('./dataunit-fetcher-
|
14
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
15
15
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
16
16
|
require('./form-config-fetcher-90126e4c.js');
|
17
17
|
const constants = require('./constants-35ddd366.js');
|
@@ -8,12 +8,12 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
8
|
const index = require('./index-1dfc7a6e.js');
|
9
9
|
const constants = require('./constants-35ddd366.js');
|
10
10
|
const DataFetcher = require('./DataFetcher-65879b2c.js');
|
11
|
-
const snkDataUnit = require('./snk-data-unit-
|
12
|
-
require('./pesquisa-fetcher-
|
11
|
+
const snkDataUnit = require('./snk-data-unit-2c7c1964.js');
|
12
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
13
13
|
require('./ISave-e91b70a7.js');
|
14
14
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
15
15
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
16
|
-
require('./dataunit-fetcher-
|
16
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
17
17
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
18
18
|
require('./form-config-fetcher-90126e4c.js');
|
19
19
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -4,7 +4,7 @@ const index = require('./index-f9e81701.js');
|
|
4
4
|
const core = require('@sankhyalabs/core');
|
5
5
|
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
6
6
|
const SnkMessageBuilder = require('./SnkMessageBuilder-bae64d0d.js');
|
7
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
7
|
+
const dataunitFetcher = require('./dataunit-fetcher-c32fdff7.js');
|
8
8
|
const DataType = require('@sankhyalabs/core/dist/dataunit/metadata/DataType');
|
9
9
|
const GetSelectedRecordsIDsInfo = require('./GetSelectedRecordsIDsInfo-bd50caf1.js');
|
10
10
|
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkDataUnit = require('./snk-data-unit-
|
5
|
+
const snkDataUnit = require('./snk-data-unit-2c7c1964.js');
|
6
6
|
require('./index-f9e81701.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
8
|
require('@sankhyalabs/ezui/dist/collection/utils');
|
9
9
|
require('./SnkMessageBuilder-bae64d0d.js');
|
10
|
-
require('./dataunit-fetcher-
|
10
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
11
11
|
require('./DataFetcher-65879b2c.js');
|
12
12
|
require('./PrintUtils-bcaeb82f.js');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
@@ -7,17 +7,17 @@ const core = require('@sankhyalabs/core');
|
|
7
7
|
const SnkFormConfigManager = require('./SnkFormConfigManager-07f747be.js');
|
8
8
|
const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
|
9
9
|
require('./DataFetcher-65879b2c.js');
|
10
|
-
require('./pesquisa-fetcher-
|
10
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
11
11
|
const index$1 = require('./index-1dfc7a6e.js');
|
12
12
|
require('./ISave-e91b70a7.js');
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
15
|
-
require('./dataunit-fetcher-
|
15
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
16
16
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
17
17
|
require('./form-config-fetcher-90126e4c.js');
|
18
18
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
19
19
|
const constants = require('./constants-35ddd366.js');
|
20
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
20
|
+
const snkGuidesViewer = require('./snk-guides-viewer-a651b9b8.js');
|
21
21
|
const SnkMessageBuilder = require('./SnkMessageBuilder-bae64d0d.js');
|
22
22
|
require('./ConfigStorage-d024aec8.js');
|
23
23
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -9,14 +9,14 @@ const ConfigStorage = require('./ConfigStorage-d024aec8.js');
|
|
9
9
|
const index$1 = require('./index-1dfc7a6e.js');
|
10
10
|
const fieldSearch = require('./field-search-68e34bf4.js');
|
11
11
|
const index$2 = require('./index-102ba62d.js');
|
12
|
-
const ContinuousInsertUtils = require('./ContinuousInsertUtils-
|
12
|
+
const ContinuousInsertUtils = require('./ContinuousInsertUtils-b5de47db.js');
|
13
13
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
14
14
|
require('./DataFetcher-65879b2c.js');
|
15
|
-
require('./pesquisa-fetcher-
|
15
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
16
16
|
require('./ISave-e91b70a7.js');
|
17
17
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
18
18
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
19
|
-
require('./dataunit-fetcher-
|
19
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
20
20
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
21
21
|
require('./form-config-fetcher-90126e4c.js');
|
22
22
|
const GetSelectedRecordsIDsInfo = require('./GetSelectedRecordsIDsInfo-bd50caf1.js');
|
@@ -8,12 +8,12 @@ const fieldSearch = require('./field-search-68e34bf4.js');
|
|
8
8
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
9
9
|
const constants = require('./constants-35ddd366.js');
|
10
10
|
require('./DataFetcher-65879b2c.js');
|
11
|
-
require('./pesquisa-fetcher-
|
11
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
12
12
|
const index$1 = require('./index-1dfc7a6e.js');
|
13
13
|
require('./ISave-e91b70a7.js');
|
14
14
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
15
15
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
16
|
-
require('./dataunit-fetcher-
|
16
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
17
17
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
18
18
|
require('./form-config-fetcher-90126e4c.js');
|
19
19
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-a651b9b8.js');
|
6
6
|
require('./index-f9e81701.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
8
|
require('./SnkFormConfigManager-07f747be.js');
|
@@ -18,10 +18,10 @@ require('./field-search-68e34bf4.js');
|
|
18
18
|
require('./taskbar-elements-9ad1f9c0.js');
|
19
19
|
require('./index-1dfc7a6e.js');
|
20
20
|
require('./index-102ba62d.js');
|
21
|
-
require('./pesquisa-fetcher-
|
21
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
22
22
|
require('./ISave-e91b70a7.js');
|
23
23
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
24
|
-
require('./dataunit-fetcher-
|
24
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
25
25
|
require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils');
|
26
26
|
require('@sankhyalabs/core/dist/utils/SortingUtils');
|
27
27
|
require('./ResourceIDUtils-5ff86aa7.js');
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
5
5
|
const index = require('./index-f9e81701.js');
|
6
6
|
const core = require('@sankhyalabs/core');
|
7
|
-
const pesquisaFetcher = require('./pesquisa-fetcher-
|
7
|
+
const pesquisaFetcher = require('./pesquisa-fetcher-36d039c4.js');
|
8
8
|
require('./DataFetcher-65879b2c.js');
|
9
9
|
require('./index-1dfc7a6e.js');
|
10
10
|
require('./ISave-e91b70a7.js');
|
11
11
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
12
12
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
13
|
-
require('./dataunit-fetcher-
|
13
|
+
require('./dataunit-fetcher-c32fdff7.js');
|
14
14
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
15
15
|
require('./form-config-fetcher-90126e4c.js');
|
16
16
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -8,13 +8,13 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
8
|
const constants = require('./constants-35ddd366.js');
|
9
9
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
10
10
|
require('./DataFetcher-65879b2c.js');
|
11
|
-
require('./pesquisa-fetcher-
|
12
|
-
const ContinuousInsertUtils = require('./ContinuousInsertUtils-
|
11
|
+
require('./pesquisa-fetcher-36d039c4.js');
|
12
|
+
const ContinuousInsertUtils = require('./ContinuousInsertUtils-b5de47db.js');
|
13
13
|
const index = require('./index-1dfc7a6e.js');
|
14
14
|
require('./ISave-e91b70a7.js');
|
15
15
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
16
16
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
17
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
17
|
+
const dataunitFetcher = require('./dataunit-fetcher-c32fdff7.js');
|
18
18
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
19
19
|
const formConfigFetcher = require('./form-config-fetcher-90126e4c.js');
|
20
20
|
const fieldSearch = require('./field-search-68e34bf4.js');
|
@@ -55,6 +55,8 @@ function buildUserInterface(field) {
|
|
55
55
|
return UserInterface.DATETIME;
|
56
56
|
if (field['type'] === 'T')
|
57
57
|
return UserInterface.TIME;
|
58
|
+
if (field['type'] === 'I')
|
59
|
+
return UserInterface.INTEGERNUMBER;
|
58
60
|
return undefined;
|
59
61
|
}
|
60
62
|
function buildDataType(rawType) {
|
@@ -66,6 +68,8 @@ function buildDataType(rawType) {
|
|
66
68
|
return DataType.DATE;
|
67
69
|
case 'B':
|
68
70
|
return DataType.OBJECT;
|
71
|
+
case 'I':
|
72
|
+
return DataType.NUMBER;
|
69
73
|
default:
|
70
74
|
return DataType.TEXT;
|
71
75
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import PreloadManager from "./cache/PreloadManager";
|
2
2
|
import { DatasetStrategy } from "./loadstrategy/DatasetStrategy";
|
3
|
+
import { CancelPaginationResponse, showAskCancelPaginationPopup } from './helpers/DataUnitDataLoaderHelper';
|
3
4
|
export default class DataUnitDataLoader {
|
5
|
+
constructor() { }
|
4
6
|
static async debounce(dataUnit, callBack) {
|
5
7
|
const duName = dataUnit.name;
|
6
8
|
if (DataUnitDataLoader._debouncingTimeouts[duName]) {
|
@@ -46,25 +48,67 @@ export default class DataUnitDataLoader {
|
|
46
48
|
}
|
47
49
|
static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
|
48
50
|
if (dataLoader == undefined) {
|
49
|
-
//dataLoader = new DataUnitStrategy();
|
50
51
|
dataLoader = new DatasetStrategy();
|
51
52
|
}
|
52
53
|
const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
|
53
|
-
const
|
54
|
-
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
|
54
|
+
const responseLoadingInfo = result.loadingInfo;
|
55
|
+
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
|
55
56
|
return Promise.resolve(undefined);
|
57
|
+
this.handleCache(dataLoader, responseLoadingInfo, dataUnit, result.records);
|
58
|
+
if (dataUnit.cancelPagination)
|
59
|
+
return this.handlePaginationCanceled(dataUnit, result);
|
60
|
+
//Não existem mais páginas a serem carregadas
|
61
|
+
if (this.canFinishPagination(dataUnit, responseLoadingInfo))
|
62
|
+
return Promise.resolve(result);
|
63
|
+
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
64
|
+
let newLoadingInfo = this.buildNewLoadingInfo(responseLoadingInfo);
|
65
|
+
if (this.canProceedPagination(responseLoadingInfo))
|
66
|
+
return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
|
67
|
+
const confirm = await showAskCancelPaginationPopup();
|
68
|
+
if (confirm === CancelPaginationResponse.CANCEL)
|
69
|
+
return this.handlePaginationCanceled(dataUnit, result);
|
70
|
+
if (confirm === CancelPaginationResponse.LOAD_ALL) {
|
71
|
+
newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { loadAllRecords: true });
|
56
72
|
}
|
73
|
+
newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { lastRowLimitAsked: newLoadingInfo.count });
|
74
|
+
return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
|
75
|
+
}
|
76
|
+
static buildNewLoadingInfo(responseLoadingInfo) {
|
77
|
+
let newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
78
|
+
return newLoadingInfo;
|
79
|
+
}
|
80
|
+
static handleCache(dataLoader, responseLoadingInfo, dataUnit, records) {
|
57
81
|
const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
|
58
82
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
.catch(reason => console.error(reason));
|
65
|
-
}
|
83
|
+
}
|
84
|
+
static recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result) {
|
85
|
+
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
86
|
+
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
87
|
+
.catch(reason => console.error(reason));
|
66
88
|
return Promise.resolve(result);
|
67
89
|
}
|
90
|
+
static canFinishPagination(dataUnit, responseLoadingInfo) {
|
91
|
+
return !PreloadManager.isCacheEnabled(dataUnit) || !responseLoadingInfo.loadingInProgress;
|
92
|
+
}
|
93
|
+
static canProceedPagination(info) {
|
94
|
+
const { count, askRowsLimit, loadAllRecords, lastRowLimitAsked } = info;
|
95
|
+
if (loadAllRecords)
|
96
|
+
return true;
|
97
|
+
if (!count || !askRowsLimit)
|
98
|
+
return true;
|
99
|
+
const askRowLimitNumber = Number(askRowsLimit);
|
100
|
+
if (count < askRowLimitNumber)
|
101
|
+
return true;
|
102
|
+
const nextLimitToAsk = askRowLimitNumber + (lastRowLimitAsked ? lastRowLimitAsked : 0);
|
103
|
+
return count < nextLimitToAsk;
|
104
|
+
}
|
105
|
+
static handlePaginationCanceled(dataUnit, result) {
|
106
|
+
dataUnit.cancelPagination = false;
|
107
|
+
let loadingInfo = result.loadingInfo;
|
108
|
+
loadingInfo = Object.assign(Object.assign({}, loadingInfo), { total: loadingInfo.count, loadingInProgress: false, pagerId: undefined, needReload: loadingInfo.hasLocalSorting });
|
109
|
+
const loadDataResult = { records: result.records, loadingInfo };
|
110
|
+
return Promise.resolve(loadDataResult);
|
111
|
+
}
|
68
112
|
static afterLoadingPage(dataUnit, loadingInfo) {
|
69
113
|
PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
|
70
114
|
const dataUnitPagination = dataUnit.getPaginationInfo();
|
@@ -104,7 +148,7 @@ export default class DataUnitDataLoader {
|
|
104
148
|
// controle de paginação voltar pra primeira página.
|
105
149
|
offset = 0;
|
106
150
|
}
|
107
|
-
const { total, count, loadingInProgress } = loadingInfo;
|
151
|
+
const { total, count, loadingInProgress, askRowsLimit } = loadingInfo;
|
108
152
|
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
109
153
|
const lastRecord = offset + Math.min(pageSize, limit);
|
110
154
|
return {
|
@@ -113,7 +157,8 @@ export default class DataUnitDataLoader {
|
|
113
157
|
lastRecord,
|
114
158
|
firstRecord,
|
115
159
|
currentPage: offset / limit,
|
116
|
-
hasMore: lastRecord < count || loadingInProgress
|
160
|
+
hasMore: lastRecord < count || loadingInProgress,
|
161
|
+
askRowsLimit
|
117
162
|
};
|
118
163
|
}
|
119
164
|
}
|