@sankhyalabs/ezui 1.1.8 → 1.1.9
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-9a4a35ca.js} +415 -371
- package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
- package/dist/cjs/ez-button_14.cjs.entry.js +1911 -1911
- package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
- package/dist/cjs/ez-modal.cjs.entry.js +104 -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 +368 -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 +251 -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 +224 -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 +3125 -3081
- package/dist/esm/{DataUnit-69e518fa.js → DataUnit-d5d4c9a3.js} +415 -371
- package/dist/esm/ez-action-chip.entry.js +41 -41
- package/dist/esm/ez-button_14.entry.js +1911 -1911
- package/dist/esm/ez-label-chip.entry.js +120 -120
- package/dist/esm/ez-modal.entry.js +104 -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-b0974f4f.entry.js → p-0fcdfb51.entry.js} +1 -1
- package/dist/ezui/p-dac7a6c2.js +1 -0
- package/dist/ezui/{p-db11c600.entry.js → p-dbef7060.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 +26 -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 +60 -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,132 +1,132 @@
|
|
|
1
|
-
export function changeFieldValue(dataUnit, recordId, fieldName, value) {
|
|
2
|
-
return {
|
|
3
|
-
type: 'FORM/CHANGEFIELD',
|
|
4
|
-
payload: { dataUnit, recordId, fieldName, value }
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export function changeTab(formId, index) {
|
|
8
|
-
return {
|
|
9
|
-
type: 'FORM/CHANGETAB',
|
|
10
|
-
payload: { formId, index }
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function clearEdition(dataUnit, recordsLimit) {
|
|
14
|
-
return {
|
|
15
|
-
type: 'FORM/CLEAREDITION',
|
|
16
|
-
payload: {
|
|
17
|
-
dataUnit,
|
|
18
|
-
recordsLimit
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function collapseExpandGroup(collapseId, collapsed) {
|
|
23
|
-
return {
|
|
24
|
-
type: 'FORM/COLLAPSEGROUP',
|
|
25
|
-
payload: { collapseId, collapsed }
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export function previousRecord(dataUnit) {
|
|
29
|
-
return {
|
|
30
|
-
type: 'FORM/NAVIGATE',
|
|
31
|
-
payload: {
|
|
32
|
-
dataUnit,
|
|
33
|
-
limit: 0,
|
|
34
|
-
backward: true
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export function nextRecord(dataUnit, limit) {
|
|
39
|
-
return {
|
|
40
|
-
type: 'FORM/NAVIGATE',
|
|
41
|
-
payload: {
|
|
42
|
-
dataUnit,
|
|
43
|
-
limit,
|
|
44
|
-
backward: false
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function insertRecord(dataUnit, insertionIndex) {
|
|
49
|
-
return {
|
|
50
|
-
type: 'FORM/INSERT',
|
|
51
|
-
payload: {
|
|
52
|
-
dataUnit,
|
|
53
|
-
insertionIndex
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export function formLoad() {
|
|
58
|
-
return {
|
|
59
|
-
type: 'FORM/LOAD'
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export function dataLoading(dataUnit) {
|
|
63
|
-
return {
|
|
64
|
-
type: 'FORM/DATALOADING',
|
|
65
|
-
payload: {
|
|
66
|
-
dataUnit
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export function savingChanges(dataUnit) {
|
|
71
|
-
return {
|
|
72
|
-
type: 'FORM/SAVINGCHANGES',
|
|
73
|
-
payload: {
|
|
74
|
-
dataUnit
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export function dataLoaded(dataUnit) {
|
|
79
|
-
return {
|
|
80
|
-
type: 'FORM/DATALOADED',
|
|
81
|
-
payload: {
|
|
82
|
-
dataUnit
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
export function changesSaved(dataUnit) {
|
|
87
|
-
return {
|
|
88
|
-
type: 'FORM/CHANGESSAVED',
|
|
89
|
-
payload: {
|
|
90
|
-
dataUnit
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function removingRecord(dataUnit) {
|
|
95
|
-
return {
|
|
96
|
-
type: 'FORM/REMOVINGRECORD',
|
|
97
|
-
payload: {
|
|
98
|
-
dataUnit
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export function recordRemoved(dataUnit) {
|
|
103
|
-
return {
|
|
104
|
-
type: 'FORM/RECORDREMOVED',
|
|
105
|
-
payload: {
|
|
106
|
-
dataUnit
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
export 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
|
-
export function showHideNavigationButtons(buttonName, status) {
|
|
125
|
-
return {
|
|
126
|
-
type: 'FORM/SHOWHIDENAVBTN',
|
|
127
|
-
payload: {
|
|
128
|
-
buttonName,
|
|
129
|
-
status
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
1
|
+
export function changeFieldValue(dataUnit, recordId, fieldName, value) {
|
|
2
|
+
return {
|
|
3
|
+
type: 'FORM/CHANGEFIELD',
|
|
4
|
+
payload: { dataUnit, recordId, fieldName, value }
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function changeTab(formId, index) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'FORM/CHANGETAB',
|
|
10
|
+
payload: { formId, index }
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function clearEdition(dataUnit, recordsLimit) {
|
|
14
|
+
return {
|
|
15
|
+
type: 'FORM/CLEAREDITION',
|
|
16
|
+
payload: {
|
|
17
|
+
dataUnit,
|
|
18
|
+
recordsLimit
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function collapseExpandGroup(collapseId, collapsed) {
|
|
23
|
+
return {
|
|
24
|
+
type: 'FORM/COLLAPSEGROUP',
|
|
25
|
+
payload: { collapseId, collapsed }
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function previousRecord(dataUnit) {
|
|
29
|
+
return {
|
|
30
|
+
type: 'FORM/NAVIGATE',
|
|
31
|
+
payload: {
|
|
32
|
+
dataUnit,
|
|
33
|
+
limit: 0,
|
|
34
|
+
backward: true
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function nextRecord(dataUnit, limit) {
|
|
39
|
+
return {
|
|
40
|
+
type: 'FORM/NAVIGATE',
|
|
41
|
+
payload: {
|
|
42
|
+
dataUnit,
|
|
43
|
+
limit,
|
|
44
|
+
backward: false
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function insertRecord(dataUnit, insertionIndex) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'FORM/INSERT',
|
|
51
|
+
payload: {
|
|
52
|
+
dataUnit,
|
|
53
|
+
insertionIndex
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function formLoad() {
|
|
58
|
+
return {
|
|
59
|
+
type: 'FORM/LOAD'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function dataLoading(dataUnit) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'FORM/DATALOADING',
|
|
65
|
+
payload: {
|
|
66
|
+
dataUnit
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function savingChanges(dataUnit) {
|
|
71
|
+
return {
|
|
72
|
+
type: 'FORM/SAVINGCHANGES',
|
|
73
|
+
payload: {
|
|
74
|
+
dataUnit
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function dataLoaded(dataUnit) {
|
|
79
|
+
return {
|
|
80
|
+
type: 'FORM/DATALOADED',
|
|
81
|
+
payload: {
|
|
82
|
+
dataUnit
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function changesSaved(dataUnit) {
|
|
87
|
+
return {
|
|
88
|
+
type: 'FORM/CHANGESSAVED',
|
|
89
|
+
payload: {
|
|
90
|
+
dataUnit
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function removingRecord(dataUnit) {
|
|
95
|
+
return {
|
|
96
|
+
type: 'FORM/REMOVINGRECORD',
|
|
97
|
+
payload: {
|
|
98
|
+
dataUnit
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function recordRemoved(dataUnit) {
|
|
103
|
+
return {
|
|
104
|
+
type: 'FORM/RECORDREMOVED',
|
|
105
|
+
payload: {
|
|
106
|
+
dataUnit
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export 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
|
+
export function showHideNavigationButtons(buttonName, status) {
|
|
125
|
+
return {
|
|
126
|
+
type: 'FORM/SHOWHIDENAVBTN',
|
|
127
|
+
payload: {
|
|
128
|
+
buttonName,
|
|
129
|
+
status
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
const inicialHistState = {
|
|
2
|
-
currentTabIndex: {},
|
|
3
|
-
currentRecordIndex: {},
|
|
4
|
-
changes: {},
|
|
5
|
-
collapsedGroups: {},
|
|
6
|
-
newRecordIndex: {}
|
|
7
|
-
};
|
|
8
|
-
const inicialNonHistState = {
|
|
9
|
-
dataLoading: {},
|
|
10
|
-
invalidFields: {},
|
|
11
|
-
visibleButtons: {
|
|
12
|
-
previousVisible: true,
|
|
13
|
-
nextVisible: true,
|
|
14
|
-
addVisible: true,
|
|
15
|
-
removeVisible: true,
|
|
16
|
-
saveVisible: true,
|
|
17
|
-
cancelVisible: true,
|
|
18
|
-
reloadVisible: true
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export default function formReducer(state = inicialHistState, action) {
|
|
22
|
-
switch (action.type) {
|
|
23
|
-
case 'FORM/COLLAPSEGROUP':
|
|
24
|
-
return collapseGroup(state, action.payload);
|
|
25
|
-
case 'FORM/CHANGETAB':
|
|
26
|
-
return changeTab(state, action.payload.formId, action.payload.index);
|
|
27
|
-
case 'FORM/NAVIGATE':
|
|
28
|
-
return navigate(state, action.payload);
|
|
29
|
-
case 'FORM/INSERT':
|
|
30
|
-
return insertRecord(state, action.payload);
|
|
31
|
-
case 'FORM/CHANGEFIELD':
|
|
32
|
-
return changeFieldValue(state, action.payload);
|
|
33
|
-
case 'FORM/CLEAREDITION':
|
|
34
|
-
return clearEdition(state, action.payload);
|
|
35
|
-
case 'FORM/INVALIDFIELD':
|
|
36
|
-
return navigateToInvalid(state, action.payload);
|
|
37
|
-
default:
|
|
38
|
-
return state;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function formNonHistoricReducer(state = inicialNonHistState, action) {
|
|
42
|
-
switch (action.type) {
|
|
43
|
-
case 'FORM/DATALOADING':
|
|
44
|
-
return dataLoading(state, action.payload);
|
|
45
|
-
case 'FORM/DATALOADED':
|
|
46
|
-
return dataLoaded(state, action.payload);
|
|
47
|
-
case 'FORM/SAVINGCHANGES':
|
|
48
|
-
return savingChanges(state, action.payload);
|
|
49
|
-
case 'FORM/CHANGESSAVED':
|
|
50
|
-
return changesSaved(state, action.payload);
|
|
51
|
-
case 'FORM/REMOVINGRECORD':
|
|
52
|
-
return removingRecord(state, action.payload);
|
|
53
|
-
case 'FORM/RECORDREMOVED':
|
|
54
|
-
return recordRemoved(state, action.payload);
|
|
55
|
-
case 'FORM/INVALIDFIELD':
|
|
56
|
-
return invalidField(state, action.payload);
|
|
57
|
-
case 'FORM/CLEAREDITION':
|
|
58
|
-
return clearAllInvalidFields(state, action.payload);
|
|
59
|
-
case 'FORM/CHANGEFIELD':
|
|
60
|
-
return clearInvalidField(state, action.payload);
|
|
61
|
-
case 'FORM/SHOWHIDENAVBTN':
|
|
62
|
-
return showHideNavBtn(state, action.payload);
|
|
63
|
-
default:
|
|
64
|
-
return state;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function collapseGroup(state, { collapseId, collapsed }) {
|
|
68
|
-
const currentCollapsed = Object.assign({}, state.collapsedGroups);
|
|
69
|
-
if (collapsed) {
|
|
70
|
-
currentCollapsed[collapseId] = true;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
delete currentCollapsed[collapseId];
|
|
74
|
-
}
|
|
75
|
-
return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
|
|
76
|
-
}
|
|
77
|
-
function changeTab(state, formId, index) {
|
|
78
|
-
const currentTabIndex = Object.assign({}, state.currentTabIndex);
|
|
79
|
-
currentTabIndex[formId] = index;
|
|
80
|
-
return Object.assign(Object.assign({}, state), { currentTabIndex });
|
|
81
|
-
}
|
|
82
|
-
function navigate(state, { dataUnit, limit, backward }) {
|
|
83
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
84
|
-
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
85
|
-
return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
|
|
86
|
-
}
|
|
87
|
-
function gotoIndex(state, dataUnit, index) {
|
|
88
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
89
|
-
currentRecordIndex[dataUnit] = index;
|
|
90
|
-
return Object.assign(Object.assign({}, state), { currentRecordIndex });
|
|
91
|
-
}
|
|
92
|
-
function insertRecord(state, { dataUnit, insertionIndex }) {
|
|
93
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
94
|
-
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
95
|
-
currentRecordIndex[dataUnit] = insertionIndex;
|
|
96
|
-
newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
|
|
97
|
-
return Object.assign(Object.assign({}, state), { currentRecordIndex,
|
|
98
|
-
newRecordIndex });
|
|
99
|
-
}
|
|
100
|
-
function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
|
|
101
|
-
const changes = Object.assign({}, state.changes);
|
|
102
|
-
const dataUnitChanges = Object.assign({}, changes[dataUnit]);
|
|
103
|
-
const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
|
|
104
|
-
recordChanges[fieldName] = value;
|
|
105
|
-
dataUnitChanges[recordId] = recordChanges;
|
|
106
|
-
changes[dataUnit] = dataUnitChanges;
|
|
107
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
108
|
-
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
109
|
-
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
110
|
-
delete errorMessages[fieldName];
|
|
111
|
-
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
112
|
-
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
113
|
-
return Object.assign(Object.assign({}, state), { changes,
|
|
114
|
-
invalidFields, invalidFieldSelected: undefined });
|
|
115
|
-
}
|
|
116
|
-
function clearEdition(state, { dataUnit, recordsLimit }) {
|
|
117
|
-
const changes = Object.assign({}, state.changes);
|
|
118
|
-
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
119
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
120
|
-
delete changes[dataUnit];
|
|
121
|
-
delete newRecordIndex[dataUnit];
|
|
122
|
-
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
123
|
-
currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
|
|
124
|
-
return Object.assign(Object.assign({}, state), { changes,
|
|
125
|
-
newRecordIndex,
|
|
126
|
-
currentRecordIndex });
|
|
127
|
-
}
|
|
128
|
-
function navigateToInvalid(state, payload) {
|
|
129
|
-
let newState = Object.assign({}, state);
|
|
130
|
-
if (newState.invalidFieldSelected === undefined) {
|
|
131
|
-
newState.invalidFieldSelected = true;
|
|
132
|
-
newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
|
|
133
|
-
newState = changeTab(newState, payload.tabController, payload.tabIndex);
|
|
134
|
-
}
|
|
135
|
-
return newState;
|
|
136
|
-
}
|
|
137
|
-
function dataLoading(state, { dataUnit }) {
|
|
138
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
139
|
-
dataLoading[dataUnit] = true;
|
|
140
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
141
|
-
}
|
|
142
|
-
function dataLoaded(state, { dataUnit }) {
|
|
143
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
144
|
-
delete dataLoading[dataUnit];
|
|
145
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
146
|
-
}
|
|
147
|
-
function savingChanges(state, { dataUnit }) {
|
|
148
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
149
|
-
dataLoading[dataUnit] = true;
|
|
150
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
151
|
-
}
|
|
152
|
-
function changesSaved(state, { dataUnit }) {
|
|
153
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
154
|
-
delete dataLoading[dataUnit];
|
|
155
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
156
|
-
}
|
|
157
|
-
function removingRecord(state, { dataUnit }) {
|
|
158
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
159
|
-
dataLoading[dataUnit] = true;
|
|
160
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
161
|
-
}
|
|
162
|
-
function recordRemoved(state, { dataUnit }) {
|
|
163
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
164
|
-
delete dataLoading[dataUnit];
|
|
165
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
166
|
-
}
|
|
167
|
-
function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
|
|
168
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
169
|
-
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
170
|
-
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
171
|
-
errorMessages[fieldName] = errorMessage;
|
|
172
|
-
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
173
|
-
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
174
|
-
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
175
|
-
}
|
|
176
|
-
function clearAllInvalidFields(state, { dataUnit }) {
|
|
177
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
178
|
-
delete invalidFields[dataUnit];
|
|
179
|
-
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
180
|
-
}
|
|
181
|
-
function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
|
|
182
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
183
|
-
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
184
|
-
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
185
|
-
delete errorMessages[fieldName];
|
|
186
|
-
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
187
|
-
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
188
|
-
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
189
|
-
}
|
|
190
|
-
function showHideNavBtn(state, { buttonName, status }) {
|
|
191
|
-
const visibleButtons = Object.assign({}, state.visibleButtons);
|
|
192
|
-
visibleButtons[buttonName] = status;
|
|
193
|
-
return Object.assign(Object.assign({}, state), { visibleButtons });
|
|
194
|
-
}
|
|
1
|
+
const inicialHistState = {
|
|
2
|
+
currentTabIndex: {},
|
|
3
|
+
currentRecordIndex: {},
|
|
4
|
+
changes: {},
|
|
5
|
+
collapsedGroups: {},
|
|
6
|
+
newRecordIndex: {}
|
|
7
|
+
};
|
|
8
|
+
const inicialNonHistState = {
|
|
9
|
+
dataLoading: {},
|
|
10
|
+
invalidFields: {},
|
|
11
|
+
visibleButtons: {
|
|
12
|
+
previousVisible: true,
|
|
13
|
+
nextVisible: true,
|
|
14
|
+
addVisible: true,
|
|
15
|
+
removeVisible: true,
|
|
16
|
+
saveVisible: true,
|
|
17
|
+
cancelVisible: true,
|
|
18
|
+
reloadVisible: true
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export default function formReducer(state = inicialHistState, action) {
|
|
22
|
+
switch (action.type) {
|
|
23
|
+
case 'FORM/COLLAPSEGROUP':
|
|
24
|
+
return collapseGroup(state, action.payload);
|
|
25
|
+
case 'FORM/CHANGETAB':
|
|
26
|
+
return changeTab(state, action.payload.formId, action.payload.index);
|
|
27
|
+
case 'FORM/NAVIGATE':
|
|
28
|
+
return navigate(state, action.payload);
|
|
29
|
+
case 'FORM/INSERT':
|
|
30
|
+
return insertRecord(state, action.payload);
|
|
31
|
+
case 'FORM/CHANGEFIELD':
|
|
32
|
+
return changeFieldValue(state, action.payload);
|
|
33
|
+
case 'FORM/CLEAREDITION':
|
|
34
|
+
return clearEdition(state, action.payload);
|
|
35
|
+
case 'FORM/INVALIDFIELD':
|
|
36
|
+
return navigateToInvalid(state, action.payload);
|
|
37
|
+
default:
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function formNonHistoricReducer(state = inicialNonHistState, action) {
|
|
42
|
+
switch (action.type) {
|
|
43
|
+
case 'FORM/DATALOADING':
|
|
44
|
+
return dataLoading(state, action.payload);
|
|
45
|
+
case 'FORM/DATALOADED':
|
|
46
|
+
return dataLoaded(state, action.payload);
|
|
47
|
+
case 'FORM/SAVINGCHANGES':
|
|
48
|
+
return savingChanges(state, action.payload);
|
|
49
|
+
case 'FORM/CHANGESSAVED':
|
|
50
|
+
return changesSaved(state, action.payload);
|
|
51
|
+
case 'FORM/REMOVINGRECORD':
|
|
52
|
+
return removingRecord(state, action.payload);
|
|
53
|
+
case 'FORM/RECORDREMOVED':
|
|
54
|
+
return recordRemoved(state, action.payload);
|
|
55
|
+
case 'FORM/INVALIDFIELD':
|
|
56
|
+
return invalidField(state, action.payload);
|
|
57
|
+
case 'FORM/CLEAREDITION':
|
|
58
|
+
return clearAllInvalidFields(state, action.payload);
|
|
59
|
+
case 'FORM/CHANGEFIELD':
|
|
60
|
+
return clearInvalidField(state, action.payload);
|
|
61
|
+
case 'FORM/SHOWHIDENAVBTN':
|
|
62
|
+
return showHideNavBtn(state, action.payload);
|
|
63
|
+
default:
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function collapseGroup(state, { collapseId, collapsed }) {
|
|
68
|
+
const currentCollapsed = Object.assign({}, state.collapsedGroups);
|
|
69
|
+
if (collapsed) {
|
|
70
|
+
currentCollapsed[collapseId] = true;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
delete currentCollapsed[collapseId];
|
|
74
|
+
}
|
|
75
|
+
return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
|
|
76
|
+
}
|
|
77
|
+
function changeTab(state, formId, index) {
|
|
78
|
+
const currentTabIndex = Object.assign({}, state.currentTabIndex);
|
|
79
|
+
currentTabIndex[formId] = index;
|
|
80
|
+
return Object.assign(Object.assign({}, state), { currentTabIndex });
|
|
81
|
+
}
|
|
82
|
+
function navigate(state, { dataUnit, limit, backward }) {
|
|
83
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
84
|
+
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
85
|
+
return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
|
|
86
|
+
}
|
|
87
|
+
function gotoIndex(state, dataUnit, index) {
|
|
88
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
89
|
+
currentRecordIndex[dataUnit] = index;
|
|
90
|
+
return Object.assign(Object.assign({}, state), { currentRecordIndex });
|
|
91
|
+
}
|
|
92
|
+
function insertRecord(state, { dataUnit, insertionIndex }) {
|
|
93
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
94
|
+
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
95
|
+
currentRecordIndex[dataUnit] = insertionIndex;
|
|
96
|
+
newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
|
|
97
|
+
return Object.assign(Object.assign({}, state), { currentRecordIndex,
|
|
98
|
+
newRecordIndex });
|
|
99
|
+
}
|
|
100
|
+
function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
|
|
101
|
+
const changes = Object.assign({}, state.changes);
|
|
102
|
+
const dataUnitChanges = Object.assign({}, changes[dataUnit]);
|
|
103
|
+
const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
|
|
104
|
+
recordChanges[fieldName] = value;
|
|
105
|
+
dataUnitChanges[recordId] = recordChanges;
|
|
106
|
+
changes[dataUnit] = dataUnitChanges;
|
|
107
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
108
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
109
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
110
|
+
delete errorMessages[fieldName];
|
|
111
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
112
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
113
|
+
return Object.assign(Object.assign({}, state), { changes,
|
|
114
|
+
invalidFields, invalidFieldSelected: undefined });
|
|
115
|
+
}
|
|
116
|
+
function clearEdition(state, { dataUnit, recordsLimit }) {
|
|
117
|
+
const changes = Object.assign({}, state.changes);
|
|
118
|
+
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
119
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
120
|
+
delete changes[dataUnit];
|
|
121
|
+
delete newRecordIndex[dataUnit];
|
|
122
|
+
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
123
|
+
currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
|
|
124
|
+
return Object.assign(Object.assign({}, state), { changes,
|
|
125
|
+
newRecordIndex,
|
|
126
|
+
currentRecordIndex });
|
|
127
|
+
}
|
|
128
|
+
function navigateToInvalid(state, payload) {
|
|
129
|
+
let newState = Object.assign({}, state);
|
|
130
|
+
if (newState.invalidFieldSelected === undefined) {
|
|
131
|
+
newState.invalidFieldSelected = true;
|
|
132
|
+
newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
|
|
133
|
+
newState = changeTab(newState, payload.tabController, payload.tabIndex);
|
|
134
|
+
}
|
|
135
|
+
return newState;
|
|
136
|
+
}
|
|
137
|
+
function dataLoading(state, { dataUnit }) {
|
|
138
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
139
|
+
dataLoading[dataUnit] = true;
|
|
140
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
141
|
+
}
|
|
142
|
+
function dataLoaded(state, { dataUnit }) {
|
|
143
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
144
|
+
delete dataLoading[dataUnit];
|
|
145
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
146
|
+
}
|
|
147
|
+
function savingChanges(state, { dataUnit }) {
|
|
148
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
149
|
+
dataLoading[dataUnit] = true;
|
|
150
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
151
|
+
}
|
|
152
|
+
function changesSaved(state, { dataUnit }) {
|
|
153
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
154
|
+
delete dataLoading[dataUnit];
|
|
155
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
156
|
+
}
|
|
157
|
+
function removingRecord(state, { dataUnit }) {
|
|
158
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
159
|
+
dataLoading[dataUnit] = true;
|
|
160
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
161
|
+
}
|
|
162
|
+
function recordRemoved(state, { dataUnit }) {
|
|
163
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
164
|
+
delete dataLoading[dataUnit];
|
|
165
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
166
|
+
}
|
|
167
|
+
function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
|
|
168
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
169
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
170
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
171
|
+
errorMessages[fieldName] = errorMessage;
|
|
172
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
173
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
174
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
175
|
+
}
|
|
176
|
+
function clearAllInvalidFields(state, { dataUnit }) {
|
|
177
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
178
|
+
delete invalidFields[dataUnit];
|
|
179
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
180
|
+
}
|
|
181
|
+
function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
|
|
182
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
183
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
184
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
185
|
+
delete errorMessages[fieldName];
|
|
186
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
187
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
188
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
189
|
+
}
|
|
190
|
+
function showHideNavBtn(state, { buttonName, status }) {
|
|
191
|
+
const visibleButtons = Object.assign({}, state.visibleButtons);
|
|
192
|
+
visibleButtons[buttonName] = status;
|
|
193
|
+
return Object.assign(Object.assign({}, state), { visibleButtons });
|
|
194
|
+
}
|