@sankhyalabs/core 5.20.0-dev.2 → 5.20.0-dev.21
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/.docs/README.md +3 -1
- package/.docs/classes/ApplicationContext.md +31 -32
- package/.docs/classes/ArrayUtils.md +95 -83
- package/.docs/classes/AuthorizedServiceCaller.md +25 -34
- package/.docs/classes/Change.md +59 -74
- package/.docs/classes/DataUnit.md +1031 -1078
- package/.docs/classes/DataUnitAction.md +25 -42
- package/.docs/classes/DataUnitStorage.md +40 -43
- package/.docs/classes/DateUtils.md +133 -126
- package/.docs/classes/ElementIDUtils.md +123 -122
- package/.docs/classes/ErrorException.md +67 -88
- package/.docs/classes/ErrorTracking.md +20 -23
- package/.docs/classes/FieldComparator.md +35 -39
- package/.docs/classes/FloatingManager.md +195 -198
- package/.docs/classes/HTMLBuilder.md +14 -20
- package/.docs/classes/HttpProvider.md +45 -41
- package/.docs/classes/IDBRepository.md +179 -196
- package/.docs/classes/JSUtils.md +65 -66
- package/.docs/classes/KeyboardManager.md +95 -87
- package/.docs/classes/{MaskFormatter-1.md → MaskFormatter.md} +81 -120
- package/.docs/classes/NumberUtils.md +163 -152
- package/.docs/classes/ObjectUtils.md +66 -71
- package/.docs/classes/OnboardingUtils.md +36 -51
- package/.docs/classes/OverflowWatcher.md +533 -0
- package/.docs/classes/PromiseSync.md +25 -42
- package/.docs/classes/ReadyUtil.md +31 -41
- package/.docs/classes/RequestMetadata.md +29 -30
- package/.docs/classes/SearchUtils.md +18 -20
- package/.docs/classes/SelectionInfo.md +59 -74
- package/.docs/classes/SkwHttpProvider.md +33 -45
- package/.docs/classes/StringUtils.md +297 -322
- package/.docs/classes/TimeFormatter.md +43 -44
- package/.docs/classes/UserAgentUtils.md +17 -20
- package/.docs/classes/VersionUtils.md +15 -18
- package/.docs/classes/WaitingChangeException.md +63 -84
- package/.docs/classes/WarningException.md +67 -88
- package/.docs/enumerations/Action.md +297 -0
- package/.docs/enumerations/ChangeOperation.md +47 -0
- package/.docs/enumerations/DataType.md +57 -0
- package/.docs/enumerations/DependencyType.md +37 -0
- package/.docs/enumerations/OverflowDirection.md +29 -0
- package/.docs/enumerations/SelectionMode.md +27 -0
- package/.docs/enumerations/SortMode.md +27 -0
- package/.docs/enumerations/UserInterface.md +177 -0
- package/.docs/functions/defaultDataLoader.md +25 -0
- package/.docs/{modules.md → globals.md} +26 -36
- package/.docs/interfaces/ChildDescriptor.md +12 -16
- package/.docs/interfaces/ChildLink.md +9 -12
- package/.docs/interfaces/DUActionInterceptor.md +10 -14
- package/.docs/interfaces/ExecutionContext.md +17 -32
- package/.docs/interfaces/FieldDescriptor.md +52 -66
- package/.docs/interfaces/Filter.md +13 -17
- package/.docs/interfaces/IElementIDInfo.md +11 -14
- package/.docs/interfaces/ILoadResult.md +11 -16
- package/.docs/interfaces/IRepository.md +88 -93
- package/.docs/interfaces/IRepositoryIndex.md +23 -30
- package/.docs/interfaces/LoadDataRequest.md +36 -45
- package/.docs/interfaces/LoadDataResponse.md +11 -14
- package/.docs/interfaces/OverFlowWatcherParams.md +67 -0
- package/.docs/interfaces/PageRequest.md +16 -20
- package/.docs/interfaces/PaginationInfo.md +24 -31
- package/.docs/interfaces/PromiseSyncCallback.md +13 -17
- package/.docs/interfaces/QuickFilter.md +17 -21
- package/.docs/interfaces/Record.md +26 -33
- package/.docs/interfaces/SavedRecord.md +33 -41
- package/.docs/interfaces/Sort.md +12 -16
- package/.docs/interfaces/SortingProvider.md +10 -13
- package/.docs/interfaces/UnitMetadata.md +16 -21
- package/.docs/interfaces/WaitingChange.md +16 -20
- package/.docs/namespaces/MaskFormatter/README.md +17 -0
- package/.docs/namespaces/MaskFormatter/type-aliases/MaskCharacter.md +13 -0
- package/.docs/namespaces/MaskFormatter/variables/MaskCharacter.md +13 -0
- package/.docs/type-aliases/DataUnitEventOptions.md +17 -0
- package/.docs/type-aliases/OnOverflowCallBack.md +25 -0
- package/.docs/variables/OVERFLOWED_CLASS_NAME.md +13 -0
- package/.releaserc +10 -10
- package/dist/dataunit/DataUnit.d.ts +28 -3
- package/dist/dataunit/DataUnit.js +55 -15
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/formatting/PrettyFormatter.js +9 -5
- package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
- package/dist/dataunit/metadata/DataType.js +13 -1
- package/dist/dataunit/metadata/DataType.js.map +1 -1
- package/dist/dataunit/state/action/DataUnitAction.d.ts +3 -1
- package/dist/dataunit/state/action/DataUnitAction.js +2 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/ChangesSlice.js +12 -11
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
- package/dist/dataunit/state/slice/InvalidFieldsSlice.js +2 -0
- package/dist/dataunit/state/slice/InvalidFieldsSlice.js.map +1 -1
- package/dist/dataunit/state/slice/LoadingProperties.d.ts +9 -0
- package/dist/dataunit/state/slice/LoadingProperties.js +31 -0
- package/dist/dataunit/state/slice/LoadingProperties.js.map +1 -0
- package/dist/dataunit/state/slice/SelectionSlice.js +3 -2
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/ElementUtils.d.ts +2 -0
- package/dist/utils/ElementUtils.js +9 -0
- package/dist/utils/ElementUtils.js.map +1 -0
- package/dist/utils/OverflowWatcher/index.d.ts +59 -0
- package/dist/utils/OverflowWatcher/index.js +188 -0
- package/dist/utils/OverflowWatcher/index.js.map +1 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.d.ts +6 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.js +2 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.js.map +1 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.d.ts +7 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.js +9 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.js.map +1 -0
- package/jest.config.ts +3 -1
- package/package.json +12 -4
- package/reports/test-report.xml +125 -0
- package/setupTests.js +1 -0
- package/sonar-project.properties +10 -0
- package/src/dataunit/DataUnit.ts +62 -17
- package/src/dataunit/formatting/PrettyFormatter.ts +8 -5
- package/src/dataunit/metadata/DataType.ts +13 -1
- package/src/dataunit/state/action/DataUnitAction.ts +3 -1
- package/src/dataunit/state/slice/ChangesSlice.ts +15 -14
- package/src/dataunit/state/slice/InvalidFieldsSlice.ts +2 -0
- package/src/dataunit/state/slice/LoadingProperties.ts +37 -0
- package/src/dataunit/state/slice/SelectionSlice.ts +3 -2
- package/src/index.ts +8 -1
- package/src/utils/ElementUtils.ts +10 -0
- package/src/utils/OverflowWatcher/index.ts +243 -0
- package/src/utils/OverflowWatcher/types/overflow-callback.ts +6 -0
- package/src/utils/OverflowWatcher/types/overflow-direction.ts +7 -0
- package/test/util/ElementUtils.spec.ts +34 -0
- package/test/util/OverflowWatcher.spec.ts +152 -0
- package/.docs/.nojekyll +0 -1
- package/.docs/enums/Action.md +0 -305
- package/.docs/enums/ChangeOperation.md +0 -52
- package/.docs/enums/DataType.md +0 -63
- package/.docs/enums/DependencyType.md +0 -41
- package/.docs/enums/SelectionMode.md +0 -30
- package/.docs/enums/SortMode.md +0 -30
- package/.docs/enums/UserInterface.md +0 -195
- package/.docs/modules/MaskFormatter.md +0 -37
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<unitTest version="1">
|
|
3
|
+
<file path="/builds/dti/design-system/sankhyacore/test/http/SkwHttpProvider.ts.spec.ts">
|
|
4
|
+
<testCase name="HttpProvider Metodo POST" duration="4"/>
|
|
5
|
+
</file>
|
|
6
|
+
<file path="/builds/dti/design-system/sankhyacore/test/http/HttpProvider.spec.ts">
|
|
7
|
+
<testCase name="HttpProvider Metodo GET" duration="80"/>
|
|
8
|
+
</file>
|
|
9
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/MaskFormatter.spec.ts">
|
|
10
|
+
<testCase name="Mask Formatter mask:CPF complete valid" duration="80"/>
|
|
11
|
+
<testCase name="Mask Formatter mask:CPF complete valid literals" duration="8"/>
|
|
12
|
+
<testCase name="Mask Formatter mask:CPF incomplete valid" duration="1"/>
|
|
13
|
+
<testCase name="Mask Formatter mask:CPF incomplete valid placeholder" duration="1"/>
|
|
14
|
+
<testCase name="Mask Formatter mask:CPF too long valid" duration="1"/>
|
|
15
|
+
<testCase name="Mask Formatter mask:CPF invalid for string" duration="91"/>
|
|
16
|
+
<testCase name="Mask Formatter mask:CPF invalid for being too long" duration="1"/>
|
|
17
|
+
<testCase name="Mask Formatter mask:Licence plate valid uppercase" duration="0"/>
|
|
18
|
+
<testCase name="Mask Formatter mask:Licence plate valid lowercase" duration="1"/>
|
|
19
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="2"/>
|
|
20
|
+
<testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="1"/>
|
|
21
|
+
<testCase name="Mask Formatter mask:Licence plate invalid for being too short with placeholder" duration="0"/>
|
|
22
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
|
|
23
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
|
|
24
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
|
|
25
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="0"/>
|
|
26
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="0"/>
|
|
27
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
|
|
28
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
|
|
29
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
|
|
30
|
+
<testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
|
|
31
|
+
<testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
|
|
32
|
+
</file>
|
|
33
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaParameter.spec.ts">
|
|
34
|
+
<testCase name="StringUtils it should return the correct values of "value" and "type" through the getters methods initial setted by the constructor" duration="67"/>
|
|
35
|
+
<testCase name="StringUtils it should return the correct values of "value" and "type" through the getters methods initial setted by the setters methods" duration="1"/>
|
|
36
|
+
<testCase name="StringUtils it should return the correct JSON/Object value through the buildParam method" duration="0"/>
|
|
37
|
+
</file>
|
|
38
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/TimeFormatter.spec.ts">
|
|
39
|
+
<testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="3"/>
|
|
40
|
+
<testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="1"/>
|
|
41
|
+
<testCase name="TimeFormatter Case: validateTime" duration="1"/>
|
|
42
|
+
</file>
|
|
43
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaModel.spec.ts">
|
|
44
|
+
<testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="21"/>
|
|
45
|
+
<testCase name="StringUtils it should modify "expressions" and "parameters" properties through Setters methods" duration="1"/>
|
|
46
|
+
<testCase name="StringUtils it should return "expression" and "parameters" setted through constructor method" duration="0"/>
|
|
47
|
+
<testCase name="StringUtils it should return a Criteria class with "expression" and "parameters" as needed setted through "append" method" duration="2"/>
|
|
48
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "append" method" duration="65"/>
|
|
49
|
+
<testCase name="StringUtils it should return undefined as "expression" and "[]" as parameters as we use an empty criteria as first entry in the constructor" duration="1"/>
|
|
50
|
+
<testCase name="StringUtils it should return a Criteria class with "Expression" and "parameters" concatenaded as needed setted through "OR" method" duration="1"/>
|
|
51
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "OR" method" duration="0"/>
|
|
52
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "OR" method" duration="1"/>
|
|
53
|
+
<testCase name="StringUtils it should return a Criteria class with "Expression" and "parameters" concatenaded as needed setted through "AND" method" duration="10"/>
|
|
54
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="1"/>
|
|
55
|
+
<testCase name="StringUtils it should return a Criteria class with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="0"/>
|
|
56
|
+
<testCase name="StringUtils it should return a toJSON object with "Criteria class" and "parameters" concatenaded as needed setted through "AND" method" duration="0"/>
|
|
57
|
+
<testCase name="StringUtils it should return a toJSON object with through empty constructor" duration="0"/>
|
|
58
|
+
</file>
|
|
59
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
|
|
60
|
+
<testCase name="StringUtils stringToNumber" duration="77"/>
|
|
61
|
+
<testCase name="StringUtils format" duration="108"/>
|
|
62
|
+
<testCase name="StringUtils format without formatnumber parameter" duration="1"/>
|
|
63
|
+
<testCase name="StringUtils format without formatnumber parameter" duration="1"/>
|
|
64
|
+
<testCase name="StringUtils format round number" duration="2"/>
|
|
65
|
+
</file>
|
|
66
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/StringUtils.spec.ts">
|
|
67
|
+
<testCase name="StringUtils valor vazio" duration="6"/>
|
|
68
|
+
<testCase name="StringUtils valor em branco" duration="1"/>
|
|
69
|
+
<testCase name="StringUtils valor null" duration="0"/>
|
|
70
|
+
<testCase name="StringUtils valor undefined" duration="0"/>
|
|
71
|
+
<testCase name="StringUtils valor 0" duration="1"/>
|
|
72
|
+
<testCase name="StringUtils com valor" duration="0"/>
|
|
73
|
+
<testCase name="StringUtils substitui vogais com acento por vogais sem acento" duration="1"/>
|
|
74
|
+
<testCase name="StringUtils should return the original value when called with an object without a toString method" duration="72"/>
|
|
75
|
+
<testCase name="StringUtils should return the original value when called with undefined" duration="1"/>
|
|
76
|
+
</file>
|
|
77
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/OverflowWatcher.spec.ts">
|
|
78
|
+
<testCase name="OverflowWatcher should initialize with provided parameters" duration="87"/>
|
|
79
|
+
<testCase name="OverflowWatcher should disconect ResizeObserver when destroy is called" duration="3"/>
|
|
80
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate" duration="110"/>
|
|
81
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="72"/>
|
|
82
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="13"/>
|
|
83
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="9"/>
|
|
84
|
+
<testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="5"/>
|
|
85
|
+
<testCase name="OverflowWatcher should ignore elements that can not overflow" duration="79"/>
|
|
86
|
+
<testCase name="OverflowWatcher Should not call callback on forceUpdate" duration="1"/>
|
|
87
|
+
</file>
|
|
88
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/DataUnitStorage.spec.ts">
|
|
89
|
+
<testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="7"/>
|
|
90
|
+
<testCase name="DataUnitStorage get should return the stored DataUnit instance from the DataUnitStorage" duration="1"/>
|
|
91
|
+
<testCase name="DataUnitStorage get should return undefined if the DataUnit instance is not found in the DataUnitStorage" duration="1"/>
|
|
92
|
+
<testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="0"/>
|
|
93
|
+
<testCase name="DataUnitStorage remove should remove the DataUnit instance with the specified name from the DataUnitStorage" duration="1"/>
|
|
94
|
+
<testCase name="DataUnitStorage remove should not remove any DataUnit instance if the specified DataUnit instance or name is not found in the DataUnitStorage" duration="0"/>
|
|
95
|
+
</file>
|
|
96
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/ElementIDUtils.spec.ts">
|
|
97
|
+
<testCase name="addIDInfo 1 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="14"/>
|
|
98
|
+
<testCase name="addIDInfo 2 - should add data-element-id with valid id "brComSankhyaFinCadMovimentacaofinanceira_snkApplication"" duration="1"/>
|
|
99
|
+
<testCase name="addIDInfo 3 - should add data-element-id with valid id "movFinanceira_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="2"/>
|
|
100
|
+
<testCase name="addIDInfo 4 - should add data-element-id with valid id "meuID2_snkApplication"" duration="4"/>
|
|
101
|
+
<testCase name="addIDInfo 5 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="1"/>
|
|
102
|
+
<testCase name="addIDInfo 6 - should add data-element-id with valid id "movFinanceira_snkApplication"" duration="1"/>
|
|
103
|
+
<testCase name="addIDInfo 7 - should add data-element-id with valid id "componenteNameTest_snkApplication"" duration="49"/>
|
|
104
|
+
<testCase name="addIDInfo 8 - should add data-element-id with valid id "componentLabel_snkApplication"" duration="1"/>
|
|
105
|
+
<testCase name="addIDInfo 9 - should add data-element-id with valid id "dataunitFinanceiro_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="2"/>
|
|
106
|
+
<testCase name="addIDInfo 10 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira"" duration="9"/>
|
|
107
|
+
<testCase name="addIDInfo 11 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira"" duration="1"/>
|
|
108
|
+
<testCase name="addIDInfo 12 - should add data-element-id with valid id "dataunitFinanceiro_movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
109
|
+
<testCase name="addIDInfo 13 - should add data-element-id with valid id "dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira"" duration="1"/>
|
|
110
|
+
<testCase name="addIDInfo 14 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira"" duration="1"/>
|
|
111
|
+
<testCase name="addIDInfo 15 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_snkApplication"" duration="1"/>
|
|
112
|
+
<testCase name="addIDInfo 16 - should add data-element-id with valid id "dataunitFinanceiro_meuIdTeste_snkApplication"" duration="1"/>
|
|
113
|
+
<testCase name="addIDInfo 17 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
114
|
+
<testCase name="addIDInfo 18 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
115
|
+
<testCase name="addIDInfo 19 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="0"/>
|
|
116
|
+
<testCase name="addIDInfo 20 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
117
|
+
<testCase name="addIDInfo 21 - should add data-element-id with valid id "movFinanceira_movimentacaoFinanceira"" duration="1"/>
|
|
118
|
+
<testCase name="addIDInfo 22 - should add data-element-id with valid id "bancoObrigatorio_movimentacaoFinanceira"" duration="1"/>
|
|
119
|
+
</file>
|
|
120
|
+
<file path="/builds/dti/design-system/sankhyacore/test/util/ElementUtils.spec.ts">
|
|
121
|
+
<testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="27"/>
|
|
122
|
+
<testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="1"/>
|
|
123
|
+
<testCase name="calcMarginSize should threat values defined as zero" duration="3"/>
|
|
124
|
+
</file>
|
|
125
|
+
</unitTest>
|
package/setupTests.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
global.ResizeObserver = require('resize-observer-polyfill');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
sonar.testExecutionReportPaths=./reports/test-report.xml
|
|
2
|
+
sonar.typescript.lcov.reportPaths=./coverage/lcov.info
|
|
3
|
+
sonar.test.inclusions=coverage/**,**/test/*.e2e.ts,**/test/*.spec.ts,**/test/*.spec.tsx,**/utils/*.spec.ts,**/test/**/*.ts
|
|
4
|
+
sonar.tests=test
|
|
5
|
+
sonar.sourceEncoding=UTF-8
|
|
6
|
+
sonar.c.file.suffixes=-
|
|
7
|
+
sonar.cpp.file.suffixes=-
|
|
8
|
+
sonar.objc.file.suffixes=-
|
|
9
|
+
sonar.qualitygate.wait=true
|
|
10
|
+
sonar.host.url=http://sonarqube.sankhya.com.br
|
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { getFormattedValue } from "./formatting/PrettyFormatter.js";
|
|
|
25
25
|
import { v4 as uuid } from "uuid";
|
|
26
26
|
import { DataUnitStorage } from "./DataUnitStorage.js";
|
|
27
27
|
import { getInvalidFieldMessage, InvalidFieldsReducer } from "./state/slice/InvalidFieldsSlice.js";
|
|
28
|
+
import { getLoadingProperties, LoadingPropertiesReducer } from "./state/slice/LoadingProperties.js";
|
|
28
29
|
|
|
29
30
|
/***
|
|
30
31
|
* `DataUnit`: Atua como uma camada de abstração entre o back-end e a interface do usuário.
|
|
@@ -36,7 +37,7 @@ export default class DataUnit {
|
|
|
36
37
|
|
|
37
38
|
private _uuid: string;
|
|
38
39
|
private _name: string;
|
|
39
|
-
private _observers: Array<(action: DataUnitAction) => void>;
|
|
40
|
+
private _observers: Array<(action: DataUnitAction, options?:DataUnitEventOptions) => void>;
|
|
40
41
|
private _sortingProvider?: SortingProvider;
|
|
41
42
|
private _filterProviders: Map<string, FilterProvider>;
|
|
42
43
|
private _stateManager: StateManager;
|
|
@@ -61,6 +62,7 @@ export default class DataUnit {
|
|
|
61
62
|
this._stateManager = new StateManager(
|
|
62
63
|
[
|
|
63
64
|
HistReducer,
|
|
65
|
+
LoadingPropertiesReducer,
|
|
64
66
|
UnitMetadataReducer,
|
|
65
67
|
LoadingControlReducer,
|
|
66
68
|
RecordsReducer,
|
|
@@ -114,6 +116,27 @@ export default class DataUnit {
|
|
|
114
116
|
this._interceptors = [];
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Adiciona uma propriedade transacional que será envida aos
|
|
121
|
+
* loaders (dataLoader, saveLoader, removeLoader e recordLoader) na chamada.
|
|
122
|
+
* Essas propriedades serão limpas ao final da execução de cada método.
|
|
123
|
+
*
|
|
124
|
+
* @param name - Nome da propriedade
|
|
125
|
+
* @param value - Valor da propriedade
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
public addGlobalLoaderProp(name: string, value: string):void{
|
|
129
|
+
this.dispatchAction(Action.LOADING_PROPERTY_ADDED, {[name]: value});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Retorna as propriedades transacionais adicionados anteriores à chamada.
|
|
134
|
+
*
|
|
135
|
+
* @returns - Todas as propriedades desde o final do último loader.
|
|
136
|
+
*/
|
|
137
|
+
public getGlobalLoaderProps(): Map<string, string>{
|
|
138
|
+
return getLoadingProperties(this._stateManager) || new Map();
|
|
139
|
+
}
|
|
117
140
|
|
|
118
141
|
public get dataUnitId(): string{
|
|
119
142
|
return this._uuid;
|
|
@@ -215,22 +238,24 @@ export default class DataUnit {
|
|
|
215
238
|
if (await this.dispatchAction(Action.LOADING_DATA, request, executionCtx)) {
|
|
216
239
|
if (this.dataLoader) {
|
|
217
240
|
this.dataLoader(this, request).then(
|
|
218
|
-
response => {
|
|
219
|
-
this.dispatchAction(
|
|
241
|
+
async response => {
|
|
242
|
+
await this.dispatchAction(
|
|
220
243
|
Action.DATA_LOADED,
|
|
221
244
|
{...response, keepSelection: request.keepSelection, filters: request.filters},
|
|
222
245
|
executionCtx
|
|
223
246
|
);
|
|
247
|
+
|
|
248
|
+
await this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
224
249
|
|
|
225
250
|
if(selectFirstRecord){
|
|
226
251
|
this.requestSelectFirst(executionCtx);
|
|
227
252
|
}
|
|
228
|
-
|
|
229
253
|
resolve(response);
|
|
230
254
|
}
|
|
231
255
|
).catch(error => {
|
|
232
256
|
console.error(error);
|
|
233
257
|
const {errorCode} = error;
|
|
258
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
234
259
|
fail(new ErrorException("Erro ao carregar registros", error, errorCode))
|
|
235
260
|
});
|
|
236
261
|
}
|
|
@@ -431,6 +456,7 @@ export default class DataUnit {
|
|
|
431
456
|
const changes: Array<Change> = this.getAllChangesToSave();
|
|
432
457
|
|
|
433
458
|
this.saveLoader(this, changes).then((records) => {
|
|
459
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
434
460
|
const recordsByDataUnit = this.getRecordsByDataUnit(records);
|
|
435
461
|
|
|
436
462
|
const dispatchPromisses = [];
|
|
@@ -445,9 +471,11 @@ export default class DataUnit {
|
|
|
445
471
|
Promise.all(dispatchPromisses).then(() => resolve());
|
|
446
472
|
}).catch(cause => {
|
|
447
473
|
const {errorCode} = cause;
|
|
474
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
448
475
|
fail(new ErrorException("Erro ao salvar alterações", cause, errorCode));
|
|
449
476
|
});
|
|
450
477
|
} else {
|
|
478
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
451
479
|
resolve();
|
|
452
480
|
}
|
|
453
481
|
});
|
|
@@ -536,6 +564,7 @@ export default class DataUnit {
|
|
|
536
564
|
public async removeRecords(recordIds: Array<string>, cachedRecords: Array<Record>, buffered: boolean = false, executionCtx?: ExecutionContext, silent: boolean = false): Promise<Array<string>> {
|
|
537
565
|
if (recordIds) {
|
|
538
566
|
if (buffered || !this.removeLoader) {
|
|
567
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
539
568
|
this.dispatchAction(Action.RECORDS_REMOVED, { records: recordIds, cachedRecords, buffered: true }, executionCtx);
|
|
540
569
|
} else {
|
|
541
570
|
if (await this.dispatchAction(Action.REMOVING_RECORDS, {silent}, executionCtx)) {
|
|
@@ -553,9 +582,11 @@ export default class DataUnit {
|
|
|
553
582
|
const selectionAfterRemove = [currentRecordsKeys[nextIndex]];
|
|
554
583
|
|
|
555
584
|
this.dispatchAction(Action.RECORDS_REMOVED, { records: removedIds, cachedRecords, removedIndex, buffered: false, selectionAfterRemove }, executionCtx);
|
|
585
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
556
586
|
resolve(removedIds);
|
|
557
587
|
}
|
|
558
588
|
).catch(error => {
|
|
589
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
559
590
|
const {errorCode} = error;
|
|
560
591
|
fail(new ErrorException("Erro ao remover registros", error, errorCode))
|
|
561
592
|
});
|
|
@@ -612,15 +643,14 @@ export default class DataUnit {
|
|
|
612
643
|
*
|
|
613
644
|
*/
|
|
614
645
|
public getFormattedValue(fieldName: string, value?: any): string {
|
|
615
|
-
|
|
616
646
|
const descriptor = this.getField(fieldName);
|
|
617
|
-
if (value
|
|
647
|
+
if (value === undefined) {
|
|
618
648
|
value = this.getFieldValue(fieldName);
|
|
619
649
|
} else if (typeof value === "string" && descriptor?.dataType != DataType.TEXT){
|
|
620
650
|
value = this.valueFromString(fieldName, value);
|
|
621
651
|
}
|
|
622
652
|
|
|
623
|
-
if(value
|
|
653
|
+
if(value === undefined){
|
|
624
654
|
return "";
|
|
625
655
|
}
|
|
626
656
|
|
|
@@ -918,7 +948,7 @@ export default class DataUnit {
|
|
|
918
948
|
* @returns - Promise que será resolvida quando o novo valor for persistido no state.
|
|
919
949
|
*
|
|
920
950
|
*/
|
|
921
|
-
public async setFieldValue(fieldName: string, newValue: any, records?: Array<string
|
|
951
|
+
public async setFieldValue(fieldName: string, newValue: any, records?: Array<string>, options?:DataUnitEventOptions): Promise<boolean> {
|
|
922
952
|
|
|
923
953
|
if(!this.hasNewRecord() && !this.getSelectedRecord()) await this.addRecord();
|
|
924
954
|
|
|
@@ -937,7 +967,7 @@ export default class DataUnit {
|
|
|
937
967
|
}
|
|
938
968
|
|
|
939
969
|
if (currentValue !== typedValue) {
|
|
940
|
-
const promise = this.dispatchAction(Action.DATA_CHANGED, { [fieldName]: typedValue, records }, undefined);
|
|
970
|
+
const promise = this.dispatchAction(Action.DATA_CHANGED, { [fieldName]: typedValue, records }, undefined, options);
|
|
941
971
|
this._savingLockers.push(promise);
|
|
942
972
|
return promise;
|
|
943
973
|
}
|
|
@@ -1404,7 +1434,7 @@ export default class DataUnit {
|
|
|
1404
1434
|
* @returns - Verdadeiro se ação iniciada.
|
|
1405
1435
|
*
|
|
1406
1436
|
*/
|
|
1407
|
-
private async dispatchAction(actionType: Action, payload?: any, executionCtx?: ExecutionContext): Promise<boolean> {
|
|
1437
|
+
private async dispatchAction(actionType: Action, payload?: any, executionCtx?: ExecutionContext, options?:DataUnitEventOptions): Promise<boolean> {
|
|
1408
1438
|
return new Promise(async resolve => {
|
|
1409
1439
|
let action = new DataUnitAction(actionType, payload);
|
|
1410
1440
|
if (executionCtx && executionCtx.before) {
|
|
@@ -1414,7 +1444,7 @@ export default class DataUnit {
|
|
|
1414
1444
|
action = await this.intercept(action, this._interceptors.values());
|
|
1415
1445
|
}
|
|
1416
1446
|
if (action) {
|
|
1417
|
-
this.doDispatchAction(action);
|
|
1447
|
+
this.doDispatchAction(action, options);
|
|
1418
1448
|
if (executionCtx && executionCtx.after) {
|
|
1419
1449
|
executionCtx.after(action)
|
|
1420
1450
|
}
|
|
@@ -1452,7 +1482,7 @@ export default class DataUnit {
|
|
|
1452
1482
|
* @param action - Ações em execução no DataUnit.
|
|
1453
1483
|
*
|
|
1454
1484
|
*/
|
|
1455
|
-
private doDispatchAction(action: DataUnitAction): void {
|
|
1485
|
+
private doDispatchAction(action: DataUnitAction, options:DataUnitEventOptions = {}): void {
|
|
1456
1486
|
this._stateManager.process(action);
|
|
1457
1487
|
this?._parentDataUnit?.dispatchAction(Action.CHILD_CHANGED, { srcAction: action, srcDataUnit: this });
|
|
1458
1488
|
this._observers.forEach(f => {
|
|
@@ -1461,7 +1491,7 @@ export default class DataUnit {
|
|
|
1461
1491
|
should be continued
|
|
1462
1492
|
*/
|
|
1463
1493
|
try {
|
|
1464
|
-
f(action);
|
|
1494
|
+
f(action, options);
|
|
1465
1495
|
} catch (e) {
|
|
1466
1496
|
console.warn("[DataUnit] error while call observer", e);
|
|
1467
1497
|
}
|
|
@@ -1500,7 +1530,7 @@ export default class DataUnit {
|
|
|
1500
1530
|
* @param observer - Função que recebe como parâmetro as ações que serão monitoradas.
|
|
1501
1531
|
*
|
|
1502
1532
|
*/
|
|
1503
|
-
public subscribe(observer: (action: DataUnitAction) => void) {
|
|
1533
|
+
public subscribe(observer: (action: DataUnitAction) => void | Promise<void>) {
|
|
1504
1534
|
this._observers.push(observer);
|
|
1505
1535
|
}
|
|
1506
1536
|
|
|
@@ -1527,12 +1557,16 @@ export default class DataUnit {
|
|
|
1527
1557
|
const selection = getSelection(this._stateManager);
|
|
1528
1558
|
this.dispatchAction(Action.LOADING_RECORD, selection);
|
|
1529
1559
|
|
|
1530
|
-
if(!this.dataLoader)
|
|
1531
|
-
|
|
1560
|
+
if(!this.recordLoader || !this.dataLoader) {
|
|
1561
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1532
1564
|
|
|
1533
1565
|
this.recordLoader(this, selection).then(response => {
|
|
1534
1566
|
this.dispatchAction(Action.RECORD_LOADED, response)
|
|
1567
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
1535
1568
|
}).catch(cause => {
|
|
1569
|
+
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
1536
1570
|
const {errorCode} = cause;
|
|
1537
1571
|
fail(new ErrorException("Erro ao recarregar registro", cause, errorCode));
|
|
1538
1572
|
});
|
|
@@ -1697,12 +1731,21 @@ export default class DataUnit {
|
|
|
1697
1731
|
return selection?.recordIds || [];
|
|
1698
1732
|
}
|
|
1699
1733
|
|
|
1734
|
+
/**
|
|
1735
|
+
* Adiciona um campo stand-alone ao dataUnit.
|
|
1736
|
+
*
|
|
1737
|
+
* @deprecated - metodo depreciado, utilizar o metodo addField
|
|
1738
|
+
*/
|
|
1739
|
+
public addStandAloneField() : void {
|
|
1740
|
+
console.warn("metodo depreciado, para adicionar um campo standAlone, utilizar o metodo addField")
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1700
1743
|
/**
|
|
1701
1744
|
* Adiciona um campo stand-alone ao dataUnit.
|
|
1702
1745
|
*
|
|
1703
1746
|
* @param field - Campo a ser adicionado.
|
|
1704
1747
|
*/
|
|
1705
|
-
public
|
|
1748
|
+
public addField(field: Omit<FieldDescriptor, 'standAlone'>) : void {
|
|
1706
1749
|
const standAloneField = {...field, standAlone: true};
|
|
1707
1750
|
this.metadata = {...this.metadata, fields: [...this.metadata.fields, standAloneField]};
|
|
1708
1751
|
}
|
|
@@ -1908,3 +1951,5 @@ export class SelectionInfo{
|
|
|
1908
1951
|
return this.length === 0;
|
|
1909
1952
|
}
|
|
1910
1953
|
}
|
|
1954
|
+
|
|
1955
|
+
export type DataUnitEventOptions = {[key:string]: any};
|
|
@@ -10,10 +10,10 @@ export const getFormattedValue = (value: any, descriptor?: FieldDescriptor) => {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
if(descriptor?.dataType === DataType.OBJECT){
|
|
13
|
-
if(Object.hasOwn(value, "value")){
|
|
13
|
+
if(value && Object.hasOwn(value, "value")){
|
|
14
14
|
return getSearchFormat(value, descriptor);
|
|
15
15
|
}
|
|
16
|
-
return value
|
|
16
|
+
return !value ? "" : value.toString();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if(descriptor?.userInterface === UserInterface.OPTIONSELECTOR){
|
|
@@ -53,6 +53,7 @@ export const getFormattedValue = (value: any, descriptor?: FieldDescriptor) => {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const getNumberFormat = (value: any, descriptor: FieldDescriptor) => {
|
|
56
|
+
if(!value) return "";
|
|
56
57
|
if(descriptor.userInterface === UserInterface.INTEGERNUMBER){
|
|
57
58
|
return value;
|
|
58
59
|
}
|
|
@@ -79,10 +80,12 @@ const getOptionFormat = (value: any, descriptor: FieldDescriptor) => {
|
|
|
79
80
|
options = JSON.parse(prop);
|
|
80
81
|
} else {
|
|
81
82
|
options = {};
|
|
82
|
-
prop
|
|
83
|
+
if(prop != undefined){
|
|
84
|
+
prop.forEach(opt => options[opt.label] = opt.value);
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
if(typeof value === "object"){
|
|
88
|
+
if(value && typeof value === "object" ){
|
|
86
89
|
value = value.value
|
|
87
90
|
}
|
|
88
91
|
|
|
@@ -90,7 +93,7 @@ const getOptionFormat = (value: any, descriptor: FieldDescriptor) => {
|
|
|
90
93
|
return options[value];
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
return value;
|
|
96
|
+
return value ?? "";
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
|
|
@@ -67,7 +67,16 @@ export const getConvertedValue = (dataType: DataType, value: any): any => {
|
|
|
67
67
|
case DataType.NUMBER:
|
|
68
68
|
return value === "" || isNaN(Number(value)) ? null : Number(value);
|
|
69
69
|
case DataType.OBJECT:
|
|
70
|
-
|
|
70
|
+
//Caso de uso campo DataType do tipo STRING e UserInterface do tipo TEXT, que tem relacionamento (TGFPRO.GRUPOPIS)
|
|
71
|
+
if(typeof value === "string") {
|
|
72
|
+
try{
|
|
73
|
+
return JSON.parse(value);
|
|
74
|
+
}catch(e){
|
|
75
|
+
console.warn(`Erro ao fazer parse do valor ${value} para objeto, dataType: ${dataType}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return value;
|
|
71
80
|
case DataType.BOOLEAN:
|
|
72
81
|
if (typeof value === "string") {
|
|
73
82
|
return Boolean(value === 'true');
|
|
@@ -110,6 +119,9 @@ export const toString = ( dataType: DataType|undefined, value: any): string => {
|
|
|
110
119
|
} else if (dataType === DataType.DATE) {
|
|
111
120
|
if (typeof value === "string") {
|
|
112
121
|
value = DateUtils.strToDate(value);
|
|
122
|
+
if (value == undefined) {
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
113
125
|
}
|
|
114
126
|
return DateUtils.formatRfc3339(value as Date);
|
|
115
127
|
} else {
|
|
@@ -63,6 +63,8 @@ export enum Action{
|
|
|
63
63
|
CHILD_CHANGED = "childChanged",
|
|
64
64
|
|
|
65
65
|
FIELD_INVALIDATED = "fieldInvalidated",
|
|
66
|
-
INVALIDATE_CLEAN = "invalidateClean"
|
|
66
|
+
INVALIDATE_CLEAN = "invalidateClean",
|
|
67
67
|
|
|
68
|
+
LOADING_PROPERTY_ADDED = "loadingPropertyAdded",
|
|
69
|
+
LOADING_PROPERTIES_CLEANED = "loadingPropertiesCleaned"
|
|
68
70
|
}
|
|
@@ -94,27 +94,28 @@ export const getChangedFieldValue = (fieldName: string, record: Record, stateMan
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export const getChangesToSave = (dataUnit: string, stateManager: StateManager): Array<Change> => {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
|
|
99
98
|
const changes = getChanges(stateManager);
|
|
100
99
|
const selectedRecords = getSelectionRecords(stateManager) || [];
|
|
101
|
-
const records:
|
|
100
|
+
const records: Map<string, Record> = new Map(
|
|
102
101
|
getRecords(stateManager)
|
|
103
102
|
.concat(
|
|
104
|
-
selectedRecords
|
|
105
|
-
.filter(record => !isAddedRecord(record.__record__id__, stateManager)
|
|
106
|
-
)
|
|
103
|
+
selectedRecords.filter(record => !isAddedRecord(record.__record__id__, stateManager))
|
|
107
104
|
)
|
|
105
|
+
.map(r => [r.__record__id__, r])
|
|
108
106
|
);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
|
|
108
|
+
const result: Array<Change> = [];
|
|
109
|
+
|
|
110
|
+
if(changes != undefined){
|
|
111
|
+
Array.from(changes.entries())
|
|
112
|
+
.forEach(([recordId, change]) =>{
|
|
113
|
+
const record = records.get(recordId);
|
|
114
|
+
if(record != undefined){
|
|
115
|
+
result.push(new Change(dataUnit, record, change, ChangeOperation.UPDATE, record.__record__source__id__));
|
|
115
116
|
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
118
119
|
|
|
119
120
|
const addedRecords = getAddedRecords(stateManager);
|
|
120
121
|
if (addedRecords) {
|
|
@@ -15,6 +15,8 @@ class InvalidFieldsReducerImpl implements ActionReducer{
|
|
|
15
15
|
return makeInvalid(currentState, action.payload);
|
|
16
16
|
case Action.INVALIDATE_CLEAN:
|
|
17
17
|
return clearRecord(currentState, action.payload);
|
|
18
|
+
case Action.EDITION_CANCELED:
|
|
19
|
+
return undefined;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
return currentState;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
3
|
+
import { Action } from "../action/DataUnitAction.js";
|
|
4
|
+
import StateManager from "../StateManager.js";
|
|
5
|
+
|
|
6
|
+
class LoadingPropertiesImpl implements ActionReducer{
|
|
7
|
+
|
|
8
|
+
public sliceName: string = "loadingProperties";
|
|
9
|
+
|
|
10
|
+
public reduce(_stateManager:StateManager, currentState: Map<string, string>, action: StateAction): Map<string, string>|undefined {
|
|
11
|
+
switch(action.type){
|
|
12
|
+
case Action.LOADING_PROPERTY_ADDED:
|
|
13
|
+
return buildNewState(currentState, action.payload);
|
|
14
|
+
case Action.LOADING_PROPERTIES_CLEANED:
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return currentState;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const LoadingPropertiesReducer = new LoadingPropertiesImpl();
|
|
22
|
+
|
|
23
|
+
export const getLoadingProperties = (stateManager: StateManager): Map<string, string>|undefined => {
|
|
24
|
+
return stateManager.select(LoadingPropertiesReducer.sliceName, (state: Map<string, string>) => state);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function buildNewState(currentState: Map<string, string>, payload: any): Map<string, string>{
|
|
28
|
+
const newState = new Map(currentState);
|
|
29
|
+
if(payload != undefined){
|
|
30
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
31
|
+
if(typeof key === "string" && typeof value === "string"){
|
|
32
|
+
newState.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return newState;
|
|
37
|
+
}
|
|
@@ -17,7 +17,8 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
17
17
|
return !action.payload?.keepSelection ? undefined : currentState;
|
|
18
18
|
case Action.RECORDS_ADDED:
|
|
19
19
|
case Action.RECORDS_COPIED:
|
|
20
|
-
|
|
20
|
+
const lastSelection = currentState?.currentSelection || [];
|
|
21
|
+
return {currentSelection: action.payload.map((r: Record)=>r.__record__id__), lastSelection};
|
|
21
22
|
case Action.DATA_SAVED:
|
|
22
23
|
return {currentSelection: updateSavedIds(stateManager, action.payload.records)};
|
|
23
24
|
case Action.RECORDS_REMOVED:
|
|
@@ -67,7 +68,7 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
67
68
|
if(currentState?.lastSelection){
|
|
68
69
|
return { currentSelection: currentState.lastSelection };
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
return { currentSelection: [] }
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
return currentState;
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { HttpProvider } from "./http/HttpProvider.js";
|
|
|
9
9
|
import { SkwHttpProvider } from "./http/SkwHttpProvider.js";
|
|
10
10
|
import { RequestMetadata } from "./http/RequestMetadata.js";
|
|
11
11
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller.js";
|
|
12
|
-
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo} from "./dataunit/DataUnit.js";
|
|
12
|
+
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo, DataUnitEventOptions} from "./dataunit/DataUnit.js";
|
|
13
13
|
import { DataType } from "./dataunit/metadata/DataType.js";
|
|
14
14
|
import { UnitMetadata, FieldDescriptor, UserInterface, Sort, SortMode, SortingProvider, Filter, DependencyType, ChildDescriptor, ChildLink } from "./dataunit/metadata/UnitMetadata.js";
|
|
15
15
|
import { DataUnitAction, Action, ExecutionContext } from "./dataunit/state/action/DataUnitAction.js";
|
|
@@ -39,6 +39,7 @@ import { IRepositoryIndex } from "./repository/indexeddb/IRepositoryIndex.js"
|
|
|
39
39
|
import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
|
|
40
40
|
import { KeyboardManager } from "./utils/KeyboardManager/index.js";
|
|
41
41
|
import { SearchUtils } from "./utils/SearchUtils.js";
|
|
42
|
+
import OverflowWatcher, { OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
|
|
42
43
|
|
|
43
44
|
/*Classes públicas no pacote*/
|
|
44
45
|
export {
|
|
@@ -106,4 +107,10 @@ export {
|
|
|
106
107
|
defaultDataLoader,
|
|
107
108
|
KeyboardManager,
|
|
108
109
|
SearchUtils,
|
|
110
|
+
OverflowWatcher,
|
|
111
|
+
OnOverflowCallBack,
|
|
112
|
+
OverflowDirection,
|
|
113
|
+
OverFlowWatcherParams,
|
|
114
|
+
OVERFLOWED_CLASS_NAME,
|
|
115
|
+
DataUnitEventOptions
|
|
109
116
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OverflowDirection } from './OverflowWatcher/types/overflow-direction.js';
|
|
2
|
+
|
|
3
|
+
export function calcMarginSize(el:Element, scrollDirection: OverflowDirection){
|
|
4
|
+
const computedStyle = getComputedStyle(el);
|
|
5
|
+
if(OverflowDirection.HORIZONTAL === scrollDirection){
|
|
6
|
+
return (parseInt(computedStyle.marginLeft || '0') + parseInt(computedStyle.marginRight || '0'));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return (parseInt(computedStyle.marginTop || '0') + parseInt(computedStyle.marginBottom || '0'));
|
|
10
|
+
}
|