@sankhyalabs/ezui 1.1.8 → 1.1.12
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/README.md +72 -72
- package/dist/cjs/{DataUnit-28b290cb.js → DataUnit-79f69df9.js} +421 -371
- package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
- package/dist/cjs/ez-button_14.cjs.entry.js +1943 -1911
- package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
- package/dist/cjs/ez-modal.cjs.entry.js +102 -104
- package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
- package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
- package/dist/cjs/form-metadata.cjs.entry.js +65 -65
- package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
- package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
- package/dist/collection/components/ez-button/ez-button.css +94 -94
- package/dist/collection/components/ez-button/ez-button.js +125 -125
- package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
- package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
- package/dist/collection/components/ez-check/ez-check.css +265 -265
- package/dist/collection/components/ez-check/ez-check.js +168 -168
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
- package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
- package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
- package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
- package/dist/collection/components/ez-form/ez-form.css +19 -19
- package/dist/collection/components/ez-form/ez-form.js +400 -368
- package/dist/collection/components/ez-form/store/Form.actions.js +132 -132
- package/dist/collection/components/ez-form/store/Form.reducer.js +194 -194
- package/dist/collection/components/ez-form/store/Form.selectors.js +44 -44
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +257 -207
- package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
- package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
- package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
- package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
- package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -40
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -27
- package/dist/collection/components/ez-icon/ez-icon.css +36 -36
- package/dist/collection/components/ez-icon/ez-icon.js +56 -56
- package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
- package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
- package/dist/collection/components/ez-modal/ez-modal.css +86 -86
- package/dist/collection/components/ez-modal/ez-modal.js +222 -224
- package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
- package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
- package/dist/collection/components/ez-popover/ez-popover.css +38 -38
- package/dist/collection/components/ez-popover/ez-popover.js +323 -323
- package/dist/collection/components/ez-search/ez-search.css +295 -295
- package/dist/collection/components/ez-search/ez-search.js +527 -527
- package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
- package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
- package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
- package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
- package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
- package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
- package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
- package/dist/collection/index.js +1 -1
- package/dist/collection/servidor.js +100 -100
- package/dist/collection/utils/FloatingManager.js +15 -15
- package/dist/collection/utils/utils.js +6 -6
- package/dist/custom-elements/index.js +3161 -3081
- package/dist/esm/{DataUnit-69e518fa.js → DataUnit-bce6b190.js} +421 -371
- package/dist/esm/ez-action-chip.entry.js +41 -41
- package/dist/esm/ez-button_14.entry.js +1943 -1911
- package/dist/esm/ez-label-chip.entry.js +120 -120
- package/dist/esm/ez-modal.entry.js +102 -104
- package/dist/esm/ez-number-input.entry.js +236 -236
- package/dist/esm/ez-time-input.entry.js +168 -168
- package/dist/esm/form-metadata.entry.js +65 -65
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-db11c600.entry.js → p-039054b7.entry.js} +1 -1
- package/dist/ezui/p-10ac6d78.js +1 -0
- package/dist/ezui/{p-b0974f4f.entry.js → p-419c9a35.entry.js} +1 -1
- package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
- package/dist/types/components/ez-button/ez-button.d.ts +20 -20
- package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
- package/dist/types/components/ez-check/ez-check.d.ts +32 -32
- package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
- package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
- package/dist/types/components/ez-form/ez-form.d.ts +27 -31
- package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -111
- package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -20
- package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -14
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +61 -55
- package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
- package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
- package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
- package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
- package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
- package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
- package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -17
- package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
- package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
- package/dist/types/components/ez-modal/ez-modal.d.ts +32 -32
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
- package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
- package/dist/types/components/ez-search/ez-search.d.ts +95 -95
- package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +2 -2
- package/package.json +114 -114
- package/dist/ezui/p-10ef58b3.js +0 -1
- package/react/components.d.ts +0 -22
- package/react/components.js +0 -25
- package/react/components.js.map +0 -1
- package/react/react-component-lib/createComponent.d.ts +0 -10
- package/react/react-component-lib/createComponent.js +0 -59
- package/react/react-component-lib/createComponent.js.map +0 -1
- package/react/react-component-lib/createOverlayComponent.d.ts +0 -20
- package/react/react-component-lib/createOverlayComponent.js +0 -89
- package/react/react-component-lib/createOverlayComponent.js.map +0 -1
- package/react/react-component-lib/index.d.ts +0 -2
- package/react/react-component-lib/index.js +0 -3
- package/react/react-component-lib/index.js.map +0 -1
- package/react/react-component-lib/interfaces.d.ts +0 -29
- package/react/react-component-lib/interfaces.js +0 -1
- package/react/react-component-lib/interfaces.js.map +0 -1
- package/react/react-component-lib/utils/attachProps.d.ts +0 -12
- package/react/react-component-lib/utils/attachProps.js +0 -96
- package/react/react-component-lib/utils/attachProps.js.map +0 -1
- package/react/react-component-lib/utils/case.d.ts +0 -2
- package/react/react-component-lib/utils/case.js +0 -7
- package/react/react-component-lib/utils/case.js.map +0 -1
- package/react/react-component-lib/utils/dev.d.ts +0 -2
- package/react/react-component-lib/utils/dev.js +0 -13
- package/react/react-component-lib/utils/dev.js.map +0 -1
- package/react/react-component-lib/utils/index.d.ts +0 -7
- package/react/react-component-lib/utils/index.js +0 -21
- package/react/react-component-lib/utils/index.js.map +0 -1
|
@@ -1,380 +1,430 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function changeFieldValue(dataUnit, recordId, fieldName, value) {
|
|
4
|
-
return {
|
|
5
|
-
type: 'FORM/CHANGEFIELD',
|
|
6
|
-
payload: { dataUnit, recordId, fieldName, value }
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function changeTab(formId, index) {
|
|
10
|
-
return {
|
|
11
|
-
type: 'FORM/CHANGETAB',
|
|
12
|
-
payload: { formId, index }
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function clearEdition(dataUnit, recordsLimit) {
|
|
16
|
-
return {
|
|
17
|
-
type: 'FORM/CLEAREDITION',
|
|
18
|
-
payload: {
|
|
19
|
-
dataUnit,
|
|
20
|
-
recordsLimit
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function collapseExpandGroup(collapseId, collapsed) {
|
|
25
|
-
return {
|
|
26
|
-
type: 'FORM/COLLAPSEGROUP',
|
|
27
|
-
payload: { collapseId, collapsed }
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function previousRecord(dataUnit) {
|
|
31
|
-
return {
|
|
32
|
-
type: 'FORM/NAVIGATE',
|
|
33
|
-
payload: {
|
|
34
|
-
dataUnit,
|
|
35
|
-
limit: 0,
|
|
36
|
-
backward: true
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function nextRecord(dataUnit, limit) {
|
|
41
|
-
return {
|
|
42
|
-
type: 'FORM/NAVIGATE',
|
|
43
|
-
payload: {
|
|
44
|
-
dataUnit,
|
|
45
|
-
limit,
|
|
46
|
-
backward: false
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function insertRecord(dataUnit, insertionIndex) {
|
|
51
|
-
return {
|
|
52
|
-
type: 'FORM/INSERT',
|
|
53
|
-
payload: {
|
|
54
|
-
dataUnit,
|
|
55
|
-
insertionIndex
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function formLoad() {
|
|
60
|
-
return {
|
|
61
|
-
type: 'FORM/LOAD'
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function dataLoading(dataUnit) {
|
|
65
|
-
return {
|
|
66
|
-
type: 'FORM/DATALOADING',
|
|
67
|
-
payload: {
|
|
68
|
-
dataUnit
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function savingChanges(dataUnit) {
|
|
73
|
-
return {
|
|
74
|
-
type: 'FORM/SAVINGCHANGES',
|
|
75
|
-
payload: {
|
|
76
|
-
dataUnit
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function dataLoaded(dataUnit) {
|
|
81
|
-
return {
|
|
82
|
-
type: 'FORM/DATALOADED',
|
|
83
|
-
payload: {
|
|
84
|
-
dataUnit
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function changesSaved(dataUnit) {
|
|
89
|
-
return {
|
|
90
|
-
type: 'FORM/CHANGESSAVED',
|
|
91
|
-
payload: {
|
|
92
|
-
dataUnit
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function removingRecord(dataUnit) {
|
|
97
|
-
return {
|
|
98
|
-
type: 'FORM/REMOVINGRECORD',
|
|
99
|
-
payload: {
|
|
100
|
-
dataUnit
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function recordRemoved(dataUnit) {
|
|
105
|
-
return {
|
|
106
|
-
type: 'FORM/RECORDREMOVED',
|
|
107
|
-
payload: {
|
|
108
|
-
dataUnit
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function invalidField(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
|
|
113
|
-
return {
|
|
114
|
-
type: 'FORM/INVALIDFIELD',
|
|
115
|
-
payload: {
|
|
116
|
-
tabController,
|
|
117
|
-
tabIndex,
|
|
118
|
-
dataUnit,
|
|
119
|
-
recordId,
|
|
120
|
-
recordIndex,
|
|
121
|
-
fieldName,
|
|
122
|
-
errorMessage
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function showHideNavigationButtons(buttonName, status) {
|
|
127
|
-
return {
|
|
128
|
-
type: 'FORM/SHOWHIDENAVBTN',
|
|
129
|
-
payload: {
|
|
130
|
-
buttonName,
|
|
131
|
-
status
|
|
132
|
-
}
|
|
133
|
-
};
|
|
3
|
+
function changeFieldValue(dataUnit, recordId, fieldName, value) {
|
|
4
|
+
return {
|
|
5
|
+
type: 'FORM/CHANGEFIELD',
|
|
6
|
+
payload: { dataUnit, recordId, fieldName, value }
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function changeTab(formId, index) {
|
|
10
|
+
return {
|
|
11
|
+
type: 'FORM/CHANGETAB',
|
|
12
|
+
payload: { formId, index }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function clearEdition(dataUnit, recordsLimit) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'FORM/CLEAREDITION',
|
|
18
|
+
payload: {
|
|
19
|
+
dataUnit,
|
|
20
|
+
recordsLimit
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function collapseExpandGroup(collapseId, collapsed) {
|
|
25
|
+
return {
|
|
26
|
+
type: 'FORM/COLLAPSEGROUP',
|
|
27
|
+
payload: { collapseId, collapsed }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function previousRecord(dataUnit) {
|
|
31
|
+
return {
|
|
32
|
+
type: 'FORM/NAVIGATE',
|
|
33
|
+
payload: {
|
|
34
|
+
dataUnit,
|
|
35
|
+
limit: 0,
|
|
36
|
+
backward: true
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function nextRecord(dataUnit, limit) {
|
|
41
|
+
return {
|
|
42
|
+
type: 'FORM/NAVIGATE',
|
|
43
|
+
payload: {
|
|
44
|
+
dataUnit,
|
|
45
|
+
limit,
|
|
46
|
+
backward: false
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function insertRecord(dataUnit, insertionIndex) {
|
|
51
|
+
return {
|
|
52
|
+
type: 'FORM/INSERT',
|
|
53
|
+
payload: {
|
|
54
|
+
dataUnit,
|
|
55
|
+
insertionIndex
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function formLoad() {
|
|
60
|
+
return {
|
|
61
|
+
type: 'FORM/LOAD'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function dataLoading(dataUnit) {
|
|
65
|
+
return {
|
|
66
|
+
type: 'FORM/DATALOADING',
|
|
67
|
+
payload: {
|
|
68
|
+
dataUnit
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function savingChanges(dataUnit) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'FORM/SAVINGCHANGES',
|
|
75
|
+
payload: {
|
|
76
|
+
dataUnit
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function dataLoaded(dataUnit) {
|
|
81
|
+
return {
|
|
82
|
+
type: 'FORM/DATALOADED',
|
|
83
|
+
payload: {
|
|
84
|
+
dataUnit
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function changesSaved(dataUnit) {
|
|
89
|
+
return {
|
|
90
|
+
type: 'FORM/CHANGESSAVED',
|
|
91
|
+
payload: {
|
|
92
|
+
dataUnit
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function removingRecord(dataUnit) {
|
|
97
|
+
return {
|
|
98
|
+
type: 'FORM/REMOVINGRECORD',
|
|
99
|
+
payload: {
|
|
100
|
+
dataUnit
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function recordRemoved(dataUnit) {
|
|
105
|
+
return {
|
|
106
|
+
type: 'FORM/RECORDREMOVED',
|
|
107
|
+
payload: {
|
|
108
|
+
dataUnit
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function invalidField(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
|
|
113
|
+
return {
|
|
114
|
+
type: 'FORM/INVALIDFIELD',
|
|
115
|
+
payload: {
|
|
116
|
+
tabController,
|
|
117
|
+
tabIndex,
|
|
118
|
+
dataUnit,
|
|
119
|
+
recordId,
|
|
120
|
+
recordIndex,
|
|
121
|
+
fieldName,
|
|
122
|
+
errorMessage
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function showHideNavigationButtons(buttonName, status) {
|
|
127
|
+
return {
|
|
128
|
+
type: 'FORM/SHOWHIDENAVBTN',
|
|
129
|
+
payload: {
|
|
130
|
+
buttonName,
|
|
131
|
+
status
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
//histórico
|
|
137
|
-
const selectCurrentTab = (state, formName) => {
|
|
138
|
-
const data = state.hist.present.currentTabIndex;
|
|
139
|
-
return data[formName] || 0;
|
|
140
|
-
};
|
|
141
|
-
const selectIsCollapsedFieldSet = (state, fieldSetName) => {
|
|
142
|
-
const data = state.hist.present.collapsedGroups;
|
|
143
|
-
return data[fieldSetName];
|
|
144
|
-
};
|
|
145
|
-
const selectRecordChanges = (state, dataUnit, recordId) => {
|
|
146
|
-
const data = selectDataUnitChanges(state, dataUnit);
|
|
147
|
-
return data ? data[recordId] : undefined;
|
|
148
|
-
};
|
|
149
|
-
const selectDataUnitChanges = (state, dataUnit) => {
|
|
150
|
-
const data = state.hist.present.changes;
|
|
151
|
-
return data[dataUnit];
|
|
152
|
-
};
|
|
153
|
-
const selectCurrentRecordIndex = (state, dataUnit) => {
|
|
154
|
-
const data = state.hist.present.currentRecordIndex;
|
|
155
|
-
return data[dataUnit] || 0;
|
|
156
|
-
};
|
|
157
|
-
const selectNewRecordIndex = (state, dataUnit) => {
|
|
158
|
-
const data = state.hist.present.newRecordIndex;
|
|
159
|
-
return data[dataUnit] || 0;
|
|
160
|
-
};
|
|
161
|
-
//não histórico
|
|
162
|
-
const selectLoadingData = (state, dataUnit) => {
|
|
163
|
-
const data = state.nonhist.dataLoading;
|
|
164
|
-
return data[dataUnit];
|
|
165
|
-
};
|
|
166
|
-
const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
|
|
167
|
-
const data = state.nonhist.invalidFields;
|
|
168
|
-
const dataUnitMessages = data[dataUnit] || {};
|
|
169
|
-
const recordMessages = dataUnitMessages[recordId] || {};
|
|
170
|
-
return recordMessages[fieldName] || "";
|
|
171
|
-
};
|
|
136
|
+
//histórico
|
|
137
|
+
const selectCurrentTab = (state, formName) => {
|
|
138
|
+
const data = state.hist.present.currentTabIndex;
|
|
139
|
+
return data[formName] || 0;
|
|
140
|
+
};
|
|
141
|
+
const selectIsCollapsedFieldSet = (state, fieldSetName) => {
|
|
142
|
+
const data = state.hist.present.collapsedGroups;
|
|
143
|
+
return data[fieldSetName];
|
|
144
|
+
};
|
|
145
|
+
const selectRecordChanges = (state, dataUnit, recordId) => {
|
|
146
|
+
const data = selectDataUnitChanges(state, dataUnit);
|
|
147
|
+
return data ? data[recordId] : undefined;
|
|
148
|
+
};
|
|
149
|
+
const selectDataUnitChanges = (state, dataUnit) => {
|
|
150
|
+
const data = state.hist.present.changes;
|
|
151
|
+
return data[dataUnit];
|
|
152
|
+
};
|
|
153
|
+
const selectCurrentRecordIndex = (state, dataUnit) => {
|
|
154
|
+
const data = state.hist.present.currentRecordIndex;
|
|
155
|
+
return data[dataUnit] || 0;
|
|
156
|
+
};
|
|
157
|
+
const selectNewRecordIndex = (state, dataUnit) => {
|
|
158
|
+
const data = state.hist.present.newRecordIndex;
|
|
159
|
+
return data[dataUnit] || 0;
|
|
160
|
+
};
|
|
161
|
+
//não histórico
|
|
162
|
+
const selectLoadingData = (state, dataUnit) => {
|
|
163
|
+
const data = state.nonhist.dataLoading;
|
|
164
|
+
return data[dataUnit];
|
|
165
|
+
};
|
|
166
|
+
const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
|
|
167
|
+
const data = state.nonhist.invalidFields;
|
|
168
|
+
const dataUnitMessages = data[dataUnit] || {};
|
|
169
|
+
const recordMessages = dataUnitMessages[recordId] || {};
|
|
170
|
+
return recordMessages[fieldName] || "";
|
|
171
|
+
};
|
|
172
172
|
const selectVisibleButtons = state => state.nonhist.visibleButtons;
|
|
173
173
|
|
|
174
|
-
class DataUnit {
|
|
175
|
-
constructor(name, unitLabel, cardinality = '1') {
|
|
176
|
-
this.name = name;
|
|
177
|
-
this.unitLabel = unitLabel;
|
|
178
|
-
this.cardinality = cardinality;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return this.
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this._store.
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
this.
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
this.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
this.records.
|
|
237
|
-
this._store.dispatch(
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
this.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
174
|
+
class DataUnit {
|
|
175
|
+
constructor(name, unitLabel, cardinality = '1', parentDU = null) {
|
|
176
|
+
this.name = name;
|
|
177
|
+
this.unitLabel = unitLabel;
|
|
178
|
+
this.cardinality = cardinality;
|
|
179
|
+
this._children = [];
|
|
180
|
+
if (parentDU != null) {
|
|
181
|
+
parentDU._children.push(this);
|
|
182
|
+
this.parentDU = parentDU;
|
|
183
|
+
this.parentDUName = parentDU.name;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
set store(store) {
|
|
187
|
+
this._store = store;
|
|
188
|
+
}
|
|
189
|
+
isLoading() {
|
|
190
|
+
return selectLoadingData(this._store.getState(), this.name);
|
|
191
|
+
}
|
|
192
|
+
hasChanges() {
|
|
193
|
+
const state = this._store.getState();
|
|
194
|
+
return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
|
|
195
|
+
}
|
|
196
|
+
hasNext() {
|
|
197
|
+
return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
|
|
198
|
+
}
|
|
199
|
+
hasPrevious() {
|
|
200
|
+
return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
|
|
201
|
+
}
|
|
202
|
+
hasCurrentRecord() {
|
|
203
|
+
return this.getCurrentRecord() != undefined;
|
|
204
|
+
}
|
|
205
|
+
previous() {
|
|
206
|
+
this._store.dispatch(previousRecord(this.name));
|
|
207
|
+
}
|
|
208
|
+
next() {
|
|
209
|
+
this._store.dispatch(nextRecord(this.name, this.records.length));
|
|
210
|
+
}
|
|
211
|
+
getValue(fieldName) {
|
|
212
|
+
const currentRecord = this.getCurrentRecord();
|
|
213
|
+
if (!currentRecord) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
const changes = this.getRecordChanges(currentRecord);
|
|
217
|
+
return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
|
|
218
|
+
}
|
|
219
|
+
getErrorMessage(fieldName) {
|
|
220
|
+
const currentRecord = this.getCurrentRecord();
|
|
221
|
+
return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
|
|
222
|
+
}
|
|
223
|
+
changeValue(fieldName, newValue) {
|
|
224
|
+
if (this.records.length == 0) {
|
|
225
|
+
this.insert();
|
|
226
|
+
}
|
|
227
|
+
if (this._changeDeboucing) {
|
|
228
|
+
window.clearTimeout(this._changeDeboucing);
|
|
229
|
+
}
|
|
230
|
+
this._changeDeboucing = window.setTimeout(() => {
|
|
231
|
+
const currentRecord = this.getCurrentRecord();
|
|
232
|
+
this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
|
|
233
|
+
}, 100);
|
|
234
|
+
}
|
|
235
|
+
cancel() {
|
|
236
|
+
this.records = this.records.filter(r => !r.record__id.startsWith('NEW_'));
|
|
237
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
238
|
+
}
|
|
239
|
+
insert() {
|
|
240
|
+
const insertionIndex = this.records.length;
|
|
241
|
+
const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
|
|
242
|
+
const newRecord = { record__id: 'NEW_' + (newRecordIndex + 1) };
|
|
243
|
+
this.bindToParent(newRecord);
|
|
244
|
+
this.records.push(newRecord);
|
|
245
|
+
this._store.dispatch(insertRecord(this.name, insertionIndex));
|
|
246
|
+
}
|
|
247
|
+
buildChange(r) {
|
|
248
|
+
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
249
|
+
let recordChanges;
|
|
250
|
+
if (duChanges) {
|
|
251
|
+
recordChanges = duChanges[r.record__id];
|
|
252
|
+
}
|
|
253
|
+
let subChanges = [];
|
|
254
|
+
this._children.forEach(duChild => {
|
|
255
|
+
subChanges = subChanges.concat(duChild.getSubChanges(r.record__id));
|
|
256
|
+
});
|
|
257
|
+
if (recordChanges || subChanges.length > 0) {
|
|
258
|
+
const change = {
|
|
259
|
+
"__data__unit": this.name,
|
|
260
|
+
"__record__id": r.record__id,
|
|
261
|
+
"__sub__changes": subChanges
|
|
262
|
+
};
|
|
263
|
+
if (recordChanges) {
|
|
264
|
+
Object.keys(recordChanges).forEach(fieldName => { change[fieldName] = recordChanges[fieldName]; });
|
|
265
|
+
}
|
|
266
|
+
return change;
|
|
267
|
+
}
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
getSubChanges(id) {
|
|
271
|
+
const result = [];
|
|
272
|
+
if (this._records) {
|
|
273
|
+
this._records.filter(r => r.parent__record__id === id).forEach(r => {
|
|
274
|
+
const c = this.buildChange(r);
|
|
275
|
+
if (c) {
|
|
276
|
+
result.push(c);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
}
|
|
282
|
+
getChangesToSave() {
|
|
283
|
+
let result = [];
|
|
284
|
+
if (this._records) {
|
|
285
|
+
this._records.forEach(r => {
|
|
286
|
+
const change = this.buildChange(r);
|
|
287
|
+
if (change) {
|
|
288
|
+
result.push(change);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
save() {
|
|
295
|
+
if (!this.validateRecords()) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this._store.dispatch(savingChanges(this.name));
|
|
299
|
+
let saveResult;
|
|
300
|
+
if (this.saveExecutor) {
|
|
301
|
+
saveResult = this.saveExecutor(this.getChangesToSave());
|
|
302
|
+
}
|
|
303
|
+
if (saveResult instanceof Promise) {
|
|
304
|
+
saveResult.then(r => this.processSaveResult(r));
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.processSaveResult(saveResult);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
load() {
|
|
311
|
+
this._store.dispatch(dataLoading(this.name));
|
|
312
|
+
let result;
|
|
313
|
+
if (this.loadExecutor) {
|
|
314
|
+
result = this.loadExecutor({ dataUnit: this.name });
|
|
315
|
+
}
|
|
316
|
+
if (result instanceof Promise) {
|
|
317
|
+
result.then(r => this.processLoadResult(r));
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
this.processLoadResult(result);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
remove() {
|
|
324
|
+
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
325
|
+
this._store.dispatch(removingRecord(this.name));
|
|
326
|
+
let removeResult;
|
|
327
|
+
if (this.removeExecutor) {
|
|
328
|
+
const record = this.getCurrentRecord();
|
|
329
|
+
removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
removeResult = true;
|
|
333
|
+
}
|
|
334
|
+
if (removeResult) {
|
|
335
|
+
if (removeResult instanceof Promise) {
|
|
336
|
+
removeResult.then(r => this.processRemoveResult(r, currentIndex));
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
this.processRemoveResult(removeResult, currentIndex);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
processSaveResult(result) {
|
|
344
|
+
if (result) {
|
|
345
|
+
if (result instanceof Array) {
|
|
346
|
+
result.forEach(item => this.processSaveResult(item));
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
if (result.dataUnit === this.name) {
|
|
350
|
+
result.records.forEach(savedRecord => {
|
|
351
|
+
let rID = savedRecord.oldRecord__id;
|
|
352
|
+
delete savedRecord.oldRecord__id;
|
|
353
|
+
if (rID === undefined) {
|
|
354
|
+
rID = savedRecord.record__id;
|
|
355
|
+
}
|
|
356
|
+
this.records.forEach((r, index) => {
|
|
357
|
+
if (r.record__id === rID) {
|
|
358
|
+
this.records[index] = Object.assign(r, savedRecord);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
366
|
+
this._store.dispatch(changesSaved(this.name));
|
|
367
|
+
}
|
|
368
|
+
processLoadResult(records) {
|
|
369
|
+
this.records = records;
|
|
370
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
371
|
+
this._store.dispatch(dataLoaded(this.name));
|
|
372
|
+
}
|
|
373
|
+
processRemoveResult(removed, recordIndex) {
|
|
374
|
+
if (removed) {
|
|
375
|
+
this.records.splice(recordIndex, 1);
|
|
376
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
377
|
+
}
|
|
378
|
+
this._store.dispatch(recordRemoved(this.name));
|
|
379
|
+
}
|
|
380
|
+
set records(records) {
|
|
381
|
+
this._records = records;
|
|
382
|
+
if (this.parentDU) {
|
|
383
|
+
this._records.forEach(r => this.bindToParent(r));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
bindToParent(r) {
|
|
387
|
+
if (this.parentDU) {
|
|
388
|
+
const parentRecord = this.parentDU.getCurrentRecord();
|
|
389
|
+
if (parentRecord) {
|
|
390
|
+
r.parent__record__id = parentRecord.record__id;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
get records() {
|
|
395
|
+
if (!this._records) {
|
|
396
|
+
this._records = [];
|
|
397
|
+
}
|
|
398
|
+
return this._records;
|
|
399
|
+
}
|
|
400
|
+
getCurrentRecord() {
|
|
401
|
+
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
402
|
+
return this.records[currentIndex];
|
|
403
|
+
}
|
|
404
|
+
getRecordChanges(currentRecord = undefined) {
|
|
405
|
+
if (currentRecord === undefined) {
|
|
406
|
+
currentRecord = this.getCurrentRecord();
|
|
407
|
+
}
|
|
408
|
+
return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
|
|
409
|
+
}
|
|
410
|
+
validateRecords() {
|
|
411
|
+
if (!this.recordsValidator) {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
415
|
+
const recordsToValidate = [];
|
|
416
|
+
this.records.forEach((record, i) => {
|
|
417
|
+
const changes = duChanges ? duChanges[record.record__id] : undefined;
|
|
418
|
+
if (changes) {
|
|
419
|
+
recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
const result = this.recordsValidator.validateRecords(this, recordsToValidate);
|
|
423
|
+
if (result.message) {
|
|
424
|
+
alert(result.message);
|
|
425
|
+
}
|
|
426
|
+
return result.isValid;
|
|
427
|
+
}
|
|
378
428
|
}
|
|
379
429
|
|
|
380
430
|
exports.DataUnit = DataUnit;
|