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