@sankhyalabs/sankhyablocks 8.16.0-dev.72 → 8.16.0-dev.74
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ContinuousInsertUtils-6e536e37.js → ContinuousInsertUtils-2718aaaa.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-8ea97d88.js → dataunit-fetcher-c32fdff7.js} +171 -17
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-actions-button_5.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-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 +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-84cb012b.js → snk-guides-viewer-266339d2.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-taskbar.cjs.entry.js +8 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +9 -3
- 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/dataunit-fetcher.js +171 -17
- package/dist/components/snk-taskbar2.js +9 -3
- package/dist/esm/{ContinuousInsertUtils-91011e01.js → ContinuousInsertUtils-deb7767f.js} +1 -1
- package/dist/esm/{dataunit-fetcher-8dd93d8b.js → dataunit-fetcher-26c2bed4.js} +171 -17
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/snk-actions-button_5.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-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 +2 -2
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-45ee10ff.js → snk-guides-viewer-9f03a9a0.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/esm/snk-taskbar.entry.js +9 -3
- package/dist/sankhyablocks/{p-1a91d1f3.entry.js → p-045398fb.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cfd229f4.entry.js → p-07583bae.entry.js} +1 -1
- package/dist/sankhyablocks/{p-935aa4fa.entry.js → p-09b4a36b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-035c63df.entry.js → p-0d2c8bc8.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6cfa8913.js → p-18f58d73.js} +1 -1
- package/dist/sankhyablocks/{p-6e0adddc.entry.js → p-1f17a44e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-619aeac8.entry.js → p-28ca3908.entry.js} +1 -1
- package/dist/sankhyablocks/{p-1bab295e.entry.js → p-5dbed7b4.entry.js} +1 -1
- package/dist/sankhyablocks/{p-60e4db34.js → p-70ae0779.js} +1 -1
- package/dist/sankhyablocks/p-78d49c74.js +60 -0
- package/dist/sankhyablocks/{p-e74eb86d.entry.js → p-800a8209.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ee759111.js → p-86fc5865.js} +1 -1
- package/dist/sankhyablocks/{p-03e37897.entry.js → p-9070bfe3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-853074f4.entry.js → p-9cec99d8.entry.js} +3 -3
- package/dist/sankhyablocks/{p-1c2d8a9a.entry.js → p-aa3ead06.entry.js} +1 -1
- package/dist/sankhyablocks/{p-dd7fb984.entry.js → p-b896f0df.entry.js} +1 -1
- package/dist/sankhyablocks/{p-0e6874ca.entry.js → p-d3a44f8f.entry.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
package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.js
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
export async function showAskCancelPaginationPopup() {
|
2
|
+
return new Promise((resolve) => {
|
3
|
+
const { checkboxContainer, checkbox } = buildCheckboxContainer();
|
4
|
+
const popup = builPopup(resolve, checkbox);
|
5
|
+
const contentContainer = buildContentContainer();
|
6
|
+
contentContainer.appendChild(buildMessage());
|
7
|
+
contentContainer.appendChild(checkboxContainer);
|
8
|
+
const actionsContainer = buildActionsContainer();
|
9
|
+
actionsContainer.appendChild(buildContinuePaginationBtn(popup, checkbox, resolve));
|
10
|
+
actionsContainer.appendChild(buildCancelPaginationBtn(popup, resolve));
|
11
|
+
contentContainer.appendChild(actionsContainer);
|
12
|
+
popup.appendChild(contentContainer);
|
13
|
+
document.body.appendChild(popup);
|
14
|
+
});
|
15
|
+
}
|
16
|
+
function buildCheckboxContainer() {
|
17
|
+
const checkboxContainer = document.createElement('div');
|
18
|
+
checkboxContainer.style.marginBottom = '14px';
|
19
|
+
checkboxContainer.style.display = 'flex';
|
20
|
+
checkboxContainer.style.alignItems = 'center';
|
21
|
+
const { checkbox, checkboxLabel } = buildCheckbox();
|
22
|
+
checkboxContainer.appendChild(checkbox);
|
23
|
+
checkboxContainer.appendChild(checkboxLabel);
|
24
|
+
return { checkboxContainer, checkbox };
|
25
|
+
}
|
26
|
+
function buildCheckbox() {
|
27
|
+
const checkbox = document.createElement('input');
|
28
|
+
checkbox.type = 'checkbox';
|
29
|
+
checkbox.id = 'loadAll';
|
30
|
+
const checkboxLabel = document.createElement('label');
|
31
|
+
checkboxLabel.htmlFor = 'loadAll';
|
32
|
+
checkboxLabel.textContent = 'Carregar tudo';
|
33
|
+
checkboxLabel.style.marginLeft = '5px';
|
34
|
+
return { checkbox, checkboxLabel };
|
35
|
+
}
|
36
|
+
function buildActionsContainer() {
|
37
|
+
const actionsContainer = document.createElement('div');
|
38
|
+
actionsContainer.style.display = 'flex';
|
39
|
+
actionsContainer.style.flexDirection = 'row';
|
40
|
+
actionsContainer.style.justifyContent = 'end';
|
41
|
+
actionsContainer.style.gap = '5px';
|
42
|
+
return actionsContainer;
|
43
|
+
}
|
44
|
+
function buildContentContainer() {
|
45
|
+
const contentContainer = document.createElement('div');
|
46
|
+
contentContainer.style.display = 'flex';
|
47
|
+
contentContainer.style.flexDirection = 'column';
|
48
|
+
contentContainer.style.fontFamily = 'var(--font-pattern, Roboto)';
|
49
|
+
contentContainer.style.fontSize = 'var(--text--medium)';
|
50
|
+
return contentContainer;
|
51
|
+
}
|
52
|
+
function buildMessage() {
|
53
|
+
const message = document.createElement('div');
|
54
|
+
const line1 = document.createElement('p');
|
55
|
+
const line2 = document.createElement('p');
|
56
|
+
const line3 = document.createElement('p');
|
57
|
+
line3.style.fontWeight = 'var(--text-weight--large, 600)';
|
58
|
+
line1.textContent = 'Uma quantidade de registros muito grande está sendo carregada.';
|
59
|
+
line2.textContent = 'Recomendamos que a paginação seja cancelada e que seja criado um filtro para os registros.';
|
60
|
+
line3.textContent = 'Deseja cancelar o carregamento?';
|
61
|
+
message.appendChild(line1);
|
62
|
+
message.appendChild(line2);
|
63
|
+
message.appendChild(line3);
|
64
|
+
return message;
|
65
|
+
}
|
66
|
+
function buildCancelPaginationBtn(popup, resolve) {
|
67
|
+
const cancelPaginationBtn = document.createElement('ez-button');
|
68
|
+
cancelPaginationBtn.label = 'Cancelar paginação';
|
69
|
+
cancelPaginationBtn.size = 'medium';
|
70
|
+
cancelPaginationBtn.classList.add('ez-button--primary');
|
71
|
+
cancelPaginationBtn.onclick = () => {
|
72
|
+
document.body.removeChild(popup);
|
73
|
+
resolve(CancelPaginationResponse.CANCEL);
|
74
|
+
};
|
75
|
+
return cancelPaginationBtn;
|
76
|
+
}
|
77
|
+
function buildContinuePaginationBtn(popup, checkBox, resolve) {
|
78
|
+
const continuePaginationBtn = document.createElement('ez-button');
|
79
|
+
continuePaginationBtn.label = 'Continuar';
|
80
|
+
continuePaginationBtn.size = 'medium';
|
81
|
+
continuePaginationBtn.onclick = () => {
|
82
|
+
document.body.removeChild(popup);
|
83
|
+
resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
|
84
|
+
};
|
85
|
+
return continuePaginationBtn;
|
86
|
+
}
|
87
|
+
function builPopup(resolve, checkBox) {
|
88
|
+
const popup = document.createElement('ez-popup');
|
89
|
+
popup.opened = true;
|
90
|
+
popup.size = 'x-small';
|
91
|
+
popup.ezTitle = 'Aviso';
|
92
|
+
popup.heightMode = "auto";
|
93
|
+
popup.addEventListener('ezClosePopup', () => {
|
94
|
+
document.body.removeChild(popup);
|
95
|
+
resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
|
96
|
+
}, { once: true });
|
97
|
+
popup.addEventListener('ezPopupAction', () => {
|
98
|
+
document.body.removeChild(popup);
|
99
|
+
resolve(CancelPaginationResponse.CANCEL);
|
100
|
+
}, { once: true });
|
101
|
+
return popup;
|
102
|
+
}
|
103
|
+
export var CancelPaginationResponse;
|
104
|
+
(function (CancelPaginationResponse) {
|
105
|
+
CancelPaginationResponse["CANCEL"] = "CANCEL";
|
106
|
+
CancelPaginationResponse["CONTINUE"] = "CONTINUE";
|
107
|
+
CancelPaginationResponse["LOAD_ALL"] = "LOAD_ALL";
|
108
|
+
})(CancelPaginationResponse || (CancelPaginationResponse = {}));
|
package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ApplicationContext, StringUtils, UserInterface, } from '@sankhyalabs/core';
|
2
|
-
import { DataFetcher } from
|
3
|
-
import DataUnitFetcher from
|
4
|
-
import InMemoryLoader from
|
2
|
+
import { DataFetcher } from '../../../DataFetcher';
|
3
|
+
import DataUnitFetcher from '../dataunit-fetcher';
|
4
|
+
import InMemoryLoader from '../../../../../dataUnit/InMemoryLoader';
|
5
5
|
import { getRecordValue } from '../../../../../dataUnit/ValueFormatter';
|
6
6
|
export class DatasetStrategy {
|
7
7
|
canSlice() {
|
@@ -40,12 +40,13 @@ export class DatasetStrategy {
|
|
40
40
|
const serviceName = "DatasetSP.loadRecords";
|
41
41
|
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting, serverSideFilters);
|
42
42
|
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
43
|
-
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
43
|
+
const { result: responseRecords, pagerID: pagerId, askRowsLimit } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
44
44
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
45
45
|
const loadingInProgress = pagerId != undefined;
|
46
46
|
const count = loadingInfo.count + records.length;
|
47
47
|
const isInsertingNewRecord = dataUnit.hasNewRecord();
|
48
|
-
const
|
48
|
+
const hasLocalSorting = localSorting.length > 0;
|
49
|
+
const needReload = !loadingInProgress && hasLocalSorting;
|
49
50
|
/**
|
50
51
|
* Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
|
51
52
|
* Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
|
@@ -56,7 +57,8 @@ export class DatasetStrategy {
|
|
56
57
|
return Promise.resolve({
|
57
58
|
records,
|
58
59
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
59
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord
|
60
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord, askRowsLimit,
|
61
|
+
hasLocalSorting })
|
60
62
|
});
|
61
63
|
}
|
62
64
|
catch (error) {
|
@@ -108,8 +110,7 @@ export class DatasetStrategy {
|
|
108
110
|
},
|
109
111
|
}
|
110
112
|
};
|
111
|
-
|
112
|
-
return parsedRequestBody;
|
113
|
+
return JSON.stringify(requestBody);
|
113
114
|
}
|
114
115
|
getFieldsList(dataUnit) {
|
115
116
|
let fields = ["__record__id__", "__record__label__"];
|
@@ -443,12 +443,13 @@ class DatasetStrategy {
|
|
443
443
|
const serviceName = "DatasetSP.loadRecords";
|
444
444
|
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting, serverSideFilters);
|
445
445
|
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
446
|
-
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
446
|
+
const { result: responseRecords, pagerID: pagerId, askRowsLimit } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
447
447
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
448
448
|
const loadingInProgress = pagerId != undefined;
|
449
449
|
const count = loadingInfo.count + records.length;
|
450
450
|
const isInsertingNewRecord = dataUnit.hasNewRecord();
|
451
|
-
const
|
451
|
+
const hasLocalSorting = localSorting.length > 0;
|
452
|
+
const needReload = !loadingInProgress && hasLocalSorting;
|
452
453
|
/**
|
453
454
|
* Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
|
454
455
|
* Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
|
@@ -459,7 +460,8 @@ class DatasetStrategy {
|
|
459
460
|
return Promise.resolve({
|
460
461
|
records,
|
461
462
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
462
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord
|
463
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord, askRowsLimit,
|
464
|
+
hasLocalSorting })
|
463
465
|
});
|
464
466
|
}
|
465
467
|
catch (error) {
|
@@ -511,8 +513,7 @@ class DatasetStrategy {
|
|
511
513
|
},
|
512
514
|
}
|
513
515
|
};
|
514
|
-
|
515
|
-
return parsedRequestBody;
|
516
|
+
return JSON.stringify(requestBody);
|
516
517
|
}
|
517
518
|
getFieldsList(dataUnit) {
|
518
519
|
let fields = ["__record__id__", "__record__label__"];
|
@@ -639,7 +640,117 @@ class DatasetStrategy {
|
|
639
640
|
}
|
640
641
|
}
|
641
642
|
|
643
|
+
async function showAskCancelPaginationPopup() {
|
644
|
+
return new Promise((resolve) => {
|
645
|
+
const { checkboxContainer, checkbox } = buildCheckboxContainer();
|
646
|
+
const popup = builPopup(resolve, checkbox);
|
647
|
+
const contentContainer = buildContentContainer();
|
648
|
+
contentContainer.appendChild(buildMessage());
|
649
|
+
contentContainer.appendChild(checkboxContainer);
|
650
|
+
const actionsContainer = buildActionsContainer();
|
651
|
+
actionsContainer.appendChild(buildContinuePaginationBtn(popup, checkbox, resolve));
|
652
|
+
actionsContainer.appendChild(buildCancelPaginationBtn(popup, resolve));
|
653
|
+
contentContainer.appendChild(actionsContainer);
|
654
|
+
popup.appendChild(contentContainer);
|
655
|
+
document.body.appendChild(popup);
|
656
|
+
});
|
657
|
+
}
|
658
|
+
function buildCheckboxContainer() {
|
659
|
+
const checkboxContainer = document.createElement('div');
|
660
|
+
checkboxContainer.style.marginBottom = '14px';
|
661
|
+
checkboxContainer.style.display = 'flex';
|
662
|
+
checkboxContainer.style.alignItems = 'center';
|
663
|
+
const { checkbox, checkboxLabel } = buildCheckbox();
|
664
|
+
checkboxContainer.appendChild(checkbox);
|
665
|
+
checkboxContainer.appendChild(checkboxLabel);
|
666
|
+
return { checkboxContainer, checkbox };
|
667
|
+
}
|
668
|
+
function buildCheckbox() {
|
669
|
+
const checkbox = document.createElement('input');
|
670
|
+
checkbox.type = 'checkbox';
|
671
|
+
checkbox.id = 'loadAll';
|
672
|
+
const checkboxLabel = document.createElement('label');
|
673
|
+
checkboxLabel.htmlFor = 'loadAll';
|
674
|
+
checkboxLabel.textContent = 'Carregar tudo';
|
675
|
+
checkboxLabel.style.marginLeft = '5px';
|
676
|
+
return { checkbox, checkboxLabel };
|
677
|
+
}
|
678
|
+
function buildActionsContainer() {
|
679
|
+
const actionsContainer = document.createElement('div');
|
680
|
+
actionsContainer.style.display = 'flex';
|
681
|
+
actionsContainer.style.flexDirection = 'row';
|
682
|
+
actionsContainer.style.justifyContent = 'end';
|
683
|
+
actionsContainer.style.gap = '5px';
|
684
|
+
return actionsContainer;
|
685
|
+
}
|
686
|
+
function buildContentContainer() {
|
687
|
+
const contentContainer = document.createElement('div');
|
688
|
+
contentContainer.style.display = 'flex';
|
689
|
+
contentContainer.style.flexDirection = 'column';
|
690
|
+
contentContainer.style.fontFamily = 'var(--font-pattern, Roboto)';
|
691
|
+
contentContainer.style.fontSize = 'var(--text--medium)';
|
692
|
+
return contentContainer;
|
693
|
+
}
|
694
|
+
function buildMessage() {
|
695
|
+
const message = document.createElement('div');
|
696
|
+
const line1 = document.createElement('p');
|
697
|
+
const line2 = document.createElement('p');
|
698
|
+
const line3 = document.createElement('p');
|
699
|
+
line3.style.fontWeight = 'var(--text-weight--large, 600)';
|
700
|
+
line1.textContent = 'Uma quantidade de registros muito grande está sendo carregada.';
|
701
|
+
line2.textContent = 'Recomendamos que a paginação seja cancelada e que seja criado um filtro para os registros.';
|
702
|
+
line3.textContent = 'Deseja cancelar o carregamento?';
|
703
|
+
message.appendChild(line1);
|
704
|
+
message.appendChild(line2);
|
705
|
+
message.appendChild(line3);
|
706
|
+
return message;
|
707
|
+
}
|
708
|
+
function buildCancelPaginationBtn(popup, resolve) {
|
709
|
+
const cancelPaginationBtn = document.createElement('ez-button');
|
710
|
+
cancelPaginationBtn.label = 'Cancelar paginação';
|
711
|
+
cancelPaginationBtn.size = 'medium';
|
712
|
+
cancelPaginationBtn.classList.add('ez-button--primary');
|
713
|
+
cancelPaginationBtn.onclick = () => {
|
714
|
+
document.body.removeChild(popup);
|
715
|
+
resolve(CancelPaginationResponse.CANCEL);
|
716
|
+
};
|
717
|
+
return cancelPaginationBtn;
|
718
|
+
}
|
719
|
+
function buildContinuePaginationBtn(popup, checkBox, resolve) {
|
720
|
+
const continuePaginationBtn = document.createElement('ez-button');
|
721
|
+
continuePaginationBtn.label = 'Continuar';
|
722
|
+
continuePaginationBtn.size = 'medium';
|
723
|
+
continuePaginationBtn.onclick = () => {
|
724
|
+
document.body.removeChild(popup);
|
725
|
+
resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
|
726
|
+
};
|
727
|
+
return continuePaginationBtn;
|
728
|
+
}
|
729
|
+
function builPopup(resolve, checkBox) {
|
730
|
+
const popup = document.createElement('ez-popup');
|
731
|
+
popup.opened = true;
|
732
|
+
popup.size = 'x-small';
|
733
|
+
popup.ezTitle = 'Aviso';
|
734
|
+
popup.heightMode = "auto";
|
735
|
+
popup.addEventListener('ezClosePopup', () => {
|
736
|
+
document.body.removeChild(popup);
|
737
|
+
resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
|
738
|
+
}, { once: true });
|
739
|
+
popup.addEventListener('ezPopupAction', () => {
|
740
|
+
document.body.removeChild(popup);
|
741
|
+
resolve(CancelPaginationResponse.CANCEL);
|
742
|
+
}, { once: true });
|
743
|
+
return popup;
|
744
|
+
}
|
745
|
+
var CancelPaginationResponse;
|
746
|
+
(function (CancelPaginationResponse) {
|
747
|
+
CancelPaginationResponse["CANCEL"] = "CANCEL";
|
748
|
+
CancelPaginationResponse["CONTINUE"] = "CONTINUE";
|
749
|
+
CancelPaginationResponse["LOAD_ALL"] = "LOAD_ALL";
|
750
|
+
})(CancelPaginationResponse || (CancelPaginationResponse = {}));
|
751
|
+
|
642
752
|
class DataUnitDataLoader {
|
753
|
+
constructor() { }
|
643
754
|
static async debounce(dataUnit, callBack) {
|
644
755
|
const duName = dataUnit.name;
|
645
756
|
if (DataUnitDataLoader._debouncingTimeouts[duName]) {
|
@@ -685,25 +796,67 @@ class DataUnitDataLoader {
|
|
685
796
|
}
|
686
797
|
static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
|
687
798
|
if (dataLoader == undefined) {
|
688
|
-
//dataLoader = new DataUnitStrategy();
|
689
799
|
dataLoader = new DatasetStrategy();
|
690
800
|
}
|
691
801
|
const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
|
692
|
-
const
|
693
|
-
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
|
802
|
+
const responseLoadingInfo = result.loadingInfo;
|
803
|
+
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
|
694
804
|
return Promise.resolve(undefined);
|
805
|
+
this.handleCache(dataLoader, responseLoadingInfo, dataUnit, result.records);
|
806
|
+
if (dataUnit.cancelPagination)
|
807
|
+
return this.handlePaginationCanceled(dataUnit, result);
|
808
|
+
//Não existem mais páginas a serem carregadas
|
809
|
+
if (this.canFinishPagination(dataUnit, responseLoadingInfo))
|
810
|
+
return Promise.resolve(result);
|
811
|
+
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
812
|
+
let newLoadingInfo = this.buildNewLoadingInfo(responseLoadingInfo);
|
813
|
+
if (this.canProceedPagination(responseLoadingInfo))
|
814
|
+
return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
|
815
|
+
const confirm = await showAskCancelPaginationPopup();
|
816
|
+
if (confirm === CancelPaginationResponse.CANCEL)
|
817
|
+
return this.handlePaginationCanceled(dataUnit, result);
|
818
|
+
if (confirm === CancelPaginationResponse.LOAD_ALL) {
|
819
|
+
newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { loadAllRecords: true });
|
695
820
|
}
|
821
|
+
newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { lastRowLimitAsked: newLoadingInfo.count });
|
822
|
+
return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
|
823
|
+
}
|
824
|
+
static buildNewLoadingInfo(responseLoadingInfo) {
|
825
|
+
let newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
826
|
+
return newLoadingInfo;
|
827
|
+
}
|
828
|
+
static handleCache(dataLoader, responseLoadingInfo, dataUnit, records) {
|
696
829
|
const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
|
697
830
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
.catch(reason => console.error(reason));
|
704
|
-
}
|
831
|
+
}
|
832
|
+
static recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result) {
|
833
|
+
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
834
|
+
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
835
|
+
.catch(reason => console.error(reason));
|
705
836
|
return Promise.resolve(result);
|
706
837
|
}
|
838
|
+
static canFinishPagination(dataUnit, responseLoadingInfo) {
|
839
|
+
return !PreloadManager.isCacheEnabled(dataUnit) || !responseLoadingInfo.loadingInProgress;
|
840
|
+
}
|
841
|
+
static canProceedPagination(info) {
|
842
|
+
const { count, askRowsLimit, loadAllRecords, lastRowLimitAsked } = info;
|
843
|
+
if (loadAllRecords)
|
844
|
+
return true;
|
845
|
+
if (!count || !askRowsLimit)
|
846
|
+
return true;
|
847
|
+
const askRowLimitNumber = Number(askRowsLimit);
|
848
|
+
if (count < askRowLimitNumber)
|
849
|
+
return true;
|
850
|
+
const nextLimitToAsk = askRowLimitNumber + (lastRowLimitAsked ? lastRowLimitAsked : 0);
|
851
|
+
return count < nextLimitToAsk;
|
852
|
+
}
|
853
|
+
static handlePaginationCanceled(dataUnit, result) {
|
854
|
+
dataUnit.cancelPagination = false;
|
855
|
+
let loadingInfo = result.loadingInfo;
|
856
|
+
loadingInfo = Object.assign(Object.assign({}, loadingInfo), { total: loadingInfo.count, loadingInProgress: false, pagerId: undefined, needReload: loadingInfo.hasLocalSorting });
|
857
|
+
const loadDataResult = { records: result.records, loadingInfo };
|
858
|
+
return Promise.resolve(loadDataResult);
|
859
|
+
}
|
707
860
|
static afterLoadingPage(dataUnit, loadingInfo) {
|
708
861
|
PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
|
709
862
|
const dataUnitPagination = dataUnit.getPaginationInfo();
|
@@ -743,7 +896,7 @@ class DataUnitDataLoader {
|
|
743
896
|
// controle de paginação voltar pra primeira página.
|
744
897
|
offset = 0;
|
745
898
|
}
|
746
|
-
const { total, count, loadingInProgress } = loadingInfo;
|
899
|
+
const { total, count, loadingInProgress, askRowsLimit } = loadingInfo;
|
747
900
|
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
748
901
|
const lastRecord = offset + Math.min(pageSize, limit);
|
749
902
|
return {
|
@@ -752,7 +905,8 @@ class DataUnitDataLoader {
|
|
752
905
|
lastRecord,
|
753
906
|
firstRecord,
|
754
907
|
currentPage: offset / limit,
|
755
|
-
hasMore: lastRecord < count || loadingInProgress
|
908
|
+
hasMore: lastRecord < count || loadingInProgress,
|
909
|
+
askRowsLimit
|
756
910
|
};
|
757
911
|
}
|
758
912
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
|
2
|
-
import { Action, LockManager, LockManagerOperation, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
|
2
|
+
import { Action, LockManager, LockManagerOperation, SilentException, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
|
3
3
|
import { A as AuthorizationConfig } from './AuthorizationConfig.js';
|
4
4
|
import { P as PresentationMode } from './ISave.js';
|
5
5
|
import { s as store } from './index2.js';
|
@@ -300,8 +300,14 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
300
300
|
case TaskbarElement.SAVE:
|
301
301
|
if (!this._isWaitingForSave) {
|
302
302
|
this._isWaitingForSave = true;
|
303
|
-
this.dataUnit.saveData()
|
304
|
-
|
303
|
+
this.dataUnit.saveData().catch((err) => {
|
304
|
+
if (err instanceof SilentException) {
|
305
|
+
return;
|
306
|
+
}
|
307
|
+
else {
|
308
|
+
throw err;
|
309
|
+
}
|
310
|
+
}).finally(() => {
|
305
311
|
this._isWaitingForSave = false;
|
306
312
|
});
|
307
313
|
}
|
@@ -5,7 +5,7 @@ import './index-3aa4977a.js';
|
|
5
5
|
import './ISave-d8c8bc59.js';
|
6
6
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
7
7
|
import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
8
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
8
|
+
import { P as PreloadManager } from './dataunit-fetcher-26c2bed4.js';
|
9
9
|
import './filter-item-type.enum-d45e026f.js';
|
10
10
|
import './form-config-fetcher-126e2471.js';
|
11
11
|
import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|