@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,44 +1,44 @@
|
|
|
1
|
-
//histórico
|
|
2
|
-
export const selectCurrentTab = (state, formName) => {
|
|
3
|
-
const data = state.hist.present.currentTabIndex;
|
|
4
|
-
return data[formName] || 0;
|
|
5
|
-
};
|
|
6
|
-
export const selectIsCollapsedFieldSet = (state, fieldSetName) => {
|
|
7
|
-
const data = state.hist.present.collapsedGroups;
|
|
8
|
-
return data[fieldSetName];
|
|
9
|
-
};
|
|
10
|
-
export const selectRecordChanges = (state, dataUnit, recordId) => {
|
|
11
|
-
const data = selectDataUnitChanges(state, dataUnit);
|
|
12
|
-
return data ? data[recordId] : undefined;
|
|
13
|
-
};
|
|
14
|
-
export const selectDataUnitChanges = (state, dataUnit) => {
|
|
15
|
-
const data = state.hist.present.changes;
|
|
16
|
-
return data[dataUnit];
|
|
17
|
-
};
|
|
18
|
-
export const selectCurrentRecordIndex = (state, dataUnit) => {
|
|
19
|
-
const data = state.hist.present.currentRecordIndex;
|
|
20
|
-
return data[dataUnit] || 0;
|
|
21
|
-
};
|
|
22
|
-
export const selectNewRecordIndex = (state, dataUnit) => {
|
|
23
|
-
const data = state.hist.present.newRecordIndex;
|
|
24
|
-
return data[dataUnit] || 0;
|
|
25
|
-
};
|
|
26
|
-
export const selectUndoState = state => { return { canUndo: state.hist.past.length > 0, canRedo: state.hist.future.length > 0 }; };
|
|
27
|
-
//não histórico
|
|
28
|
-
export const selectLoadingData = (state, dataUnit) => {
|
|
29
|
-
const data = state.nonhist.dataLoading;
|
|
30
|
-
return data[dataUnit];
|
|
31
|
-
};
|
|
32
|
-
export const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
|
|
33
|
-
const data = state.nonhist.invalidFields;
|
|
34
|
-
const dataUnitMessages = data[dataUnit] || {};
|
|
35
|
-
const recordMessages = dataUnitMessages[recordId] || {};
|
|
36
|
-
return recordMessages[fieldName] || "";
|
|
37
|
-
};
|
|
38
|
-
export const selectInvalidFields = (state, dataUnit, recordId) => {
|
|
39
|
-
const data = state.nonhist.invalidFields;
|
|
40
|
-
const dataUnitMessages = data[dataUnit] || {};
|
|
41
|
-
const recordMessages = dataUnitMessages[recordId] || {};
|
|
42
|
-
return Object.keys(recordMessages);
|
|
43
|
-
};
|
|
44
|
-
export const selectVisibleButtons = state => state.nonhist.visibleButtons;
|
|
1
|
+
//histórico
|
|
2
|
+
export const selectCurrentTab = (state, formName) => {
|
|
3
|
+
const data = state.hist.present.currentTabIndex;
|
|
4
|
+
return data[formName] || 0;
|
|
5
|
+
};
|
|
6
|
+
export const selectIsCollapsedFieldSet = (state, fieldSetName) => {
|
|
7
|
+
const data = state.hist.present.collapsedGroups;
|
|
8
|
+
return data[fieldSetName];
|
|
9
|
+
};
|
|
10
|
+
export const selectRecordChanges = (state, dataUnit, recordId) => {
|
|
11
|
+
const data = selectDataUnitChanges(state, dataUnit);
|
|
12
|
+
return data ? data[recordId] : undefined;
|
|
13
|
+
};
|
|
14
|
+
export const selectDataUnitChanges = (state, dataUnit) => {
|
|
15
|
+
const data = state.hist.present.changes;
|
|
16
|
+
return data[dataUnit];
|
|
17
|
+
};
|
|
18
|
+
export const selectCurrentRecordIndex = (state, dataUnit) => {
|
|
19
|
+
const data = state.hist.present.currentRecordIndex;
|
|
20
|
+
return data[dataUnit] || 0;
|
|
21
|
+
};
|
|
22
|
+
export const selectNewRecordIndex = (state, dataUnit) => {
|
|
23
|
+
const data = state.hist.present.newRecordIndex;
|
|
24
|
+
return data[dataUnit] || 0;
|
|
25
|
+
};
|
|
26
|
+
export const selectUndoState = state => { return { canUndo: state.hist.past.length > 0, canRedo: state.hist.future.length > 0 }; };
|
|
27
|
+
//não histórico
|
|
28
|
+
export const selectLoadingData = (state, dataUnit) => {
|
|
29
|
+
const data = state.nonhist.dataLoading;
|
|
30
|
+
return data[dataUnit];
|
|
31
|
+
};
|
|
32
|
+
export const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
|
|
33
|
+
const data = state.nonhist.invalidFields;
|
|
34
|
+
const dataUnitMessages = data[dataUnit] || {};
|
|
35
|
+
const recordMessages = dataUnitMessages[recordId] || {};
|
|
36
|
+
return recordMessages[fieldName] || "";
|
|
37
|
+
};
|
|
38
|
+
export const selectInvalidFields = (state, dataUnit, recordId) => {
|
|
39
|
+
const data = state.nonhist.invalidFields;
|
|
40
|
+
const dataUnitMessages = data[dataUnit] || {};
|
|
41
|
+
const recordMessages = dataUnitMessages[recordId] || {};
|
|
42
|
+
return Object.keys(recordMessages);
|
|
43
|
+
};
|
|
44
|
+
export const selectVisibleButtons = state => state.nonhist.visibleButtons;
|
|
@@ -1,207 +1,251 @@
|
|
|
1
|
-
import { changeFieldValue, changesSaved, clearEdition, dataLoaded, dataLoading, insertRecord, nextRecord, previousRecord, recordRemoved, removingRecord, savingChanges } from '../store/Form.actions';
|
|
2
|
-
import { selectRecordChanges, selectCurrentRecordIndex, selectLoadingData, selectNewRecordIndex, selectDataUnitChanges, selectErrorMessage } from '../store/Form.selectors';
|
|
3
|
-
export default class DataUnit {
|
|
4
|
-
constructor(name, unitLabel, cardinality = '1') {
|
|
5
|
-
this.name = name;
|
|
6
|
-
this.unitLabel = unitLabel;
|
|
7
|
-
this.cardinality = cardinality;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
1
|
+
import { changeFieldValue, changesSaved, clearEdition, dataLoaded, dataLoading, insertRecord, nextRecord, previousRecord, recordRemoved, removingRecord, savingChanges } from '../store/Form.actions';
|
|
2
|
+
import { selectRecordChanges, selectCurrentRecordIndex, selectLoadingData, selectNewRecordIndex, selectDataUnitChanges, selectErrorMessage } from '../store/Form.selectors';
|
|
3
|
+
export default class DataUnit {
|
|
4
|
+
constructor(name, unitLabel, cardinality = '1', parentDU = null) {
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.unitLabel = unitLabel;
|
|
7
|
+
this.cardinality = cardinality;
|
|
8
|
+
this._children = [];
|
|
9
|
+
if (parentDU != null) {
|
|
10
|
+
parentDU._children.push(this);
|
|
11
|
+
this.parentDU = parentDU;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
set store(store) {
|
|
15
|
+
this._store = store;
|
|
16
|
+
}
|
|
17
|
+
isLoading() {
|
|
18
|
+
return selectLoadingData(this._store.getState(), this.name);
|
|
19
|
+
}
|
|
20
|
+
hasChanges() {
|
|
21
|
+
const state = this._store.getState();
|
|
22
|
+
return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
|
|
23
|
+
}
|
|
24
|
+
hasNext() {
|
|
25
|
+
return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
|
|
26
|
+
}
|
|
27
|
+
hasPrevious() {
|
|
28
|
+
return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
|
|
29
|
+
}
|
|
30
|
+
hasCurrentRecord() {
|
|
31
|
+
return this.getCurrentRecord() != undefined;
|
|
32
|
+
}
|
|
33
|
+
previous() {
|
|
34
|
+
this._store.dispatch(previousRecord(this.name));
|
|
35
|
+
}
|
|
36
|
+
next() {
|
|
37
|
+
this._store.dispatch(nextRecord(this.name, this.records.length));
|
|
38
|
+
}
|
|
39
|
+
getValue(fieldName) {
|
|
40
|
+
const currentRecord = this.getCurrentRecord();
|
|
41
|
+
if (!currentRecord) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const changes = this.getRecordChanges(currentRecord);
|
|
45
|
+
return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
|
|
46
|
+
}
|
|
47
|
+
getErrorMessage(fieldName) {
|
|
48
|
+
const currentRecord = this.getCurrentRecord();
|
|
49
|
+
return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
|
|
50
|
+
}
|
|
51
|
+
changeValue(fieldName, newValue) {
|
|
52
|
+
if (this.records.length == 0) {
|
|
53
|
+
this.insert();
|
|
54
|
+
}
|
|
55
|
+
if (this._changeDeboucing) {
|
|
56
|
+
window.clearTimeout(this._changeDeboucing);
|
|
57
|
+
}
|
|
58
|
+
this._changeDeboucing = window.setTimeout(() => {
|
|
59
|
+
const currentRecord = this.getCurrentRecord();
|
|
60
|
+
this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
|
|
61
|
+
}, 100);
|
|
62
|
+
}
|
|
63
|
+
cancel() {
|
|
64
|
+
this.records = this.records.filter(r => !r.record__id.startsWith('NEW_'));
|
|
65
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
66
|
+
}
|
|
67
|
+
insert() {
|
|
68
|
+
const insertionIndex = this.records.length;
|
|
69
|
+
const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
|
|
70
|
+
const newRecord = { record__id: 'NEW_' + (newRecordIndex + 1) };
|
|
71
|
+
this.bindToParent(newRecord);
|
|
72
|
+
this.records.push(newRecord);
|
|
73
|
+
this._store.dispatch(insertRecord(this.name, insertionIndex));
|
|
74
|
+
}
|
|
75
|
+
buildChange(r) {
|
|
76
|
+
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
77
|
+
const recordChanges = duChanges[r.record__id];
|
|
78
|
+
let subChanges = [];
|
|
79
|
+
this._children.forEach(duChild => {
|
|
80
|
+
subChanges = subChanges.concat(duChild.getSubChanges(r.record__id));
|
|
81
|
+
});
|
|
82
|
+
if (recordChanges || subChanges.length > 0) {
|
|
83
|
+
const change = {
|
|
84
|
+
"__data__unit": this.name,
|
|
85
|
+
"__record__id": r.record__id,
|
|
86
|
+
"__sub__changes": subChanges
|
|
87
|
+
};
|
|
88
|
+
if (recordChanges) {
|
|
89
|
+
Object.keys(recordChanges).forEach(fieldName => { change[fieldName] = recordChanges[fieldName]; });
|
|
90
|
+
}
|
|
91
|
+
return change;
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
getSubChanges(id) {
|
|
96
|
+
const result = [];
|
|
97
|
+
if (this._records) {
|
|
98
|
+
this._records.filter(r => r.parent__record__id === id).forEach(r => {
|
|
99
|
+
const c = this.buildChange(r);
|
|
100
|
+
if (c) {
|
|
101
|
+
result.push(c);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
getChangesToSave() {
|
|
108
|
+
let result = [];
|
|
109
|
+
if (this._records) {
|
|
110
|
+
this._records.forEach(r => {
|
|
111
|
+
const change = this.buildChange(r);
|
|
112
|
+
result.push(change);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
save() {
|
|
118
|
+
if (!this.validateRecords()) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this._store.dispatch(savingChanges(this.name));
|
|
122
|
+
let saveResult;
|
|
123
|
+
if (this.saveExecutor) {
|
|
124
|
+
saveResult = this.saveExecutor(this.getChangesToSave());
|
|
125
|
+
}
|
|
126
|
+
if (saveResult instanceof Promise) {
|
|
127
|
+
saveResult.then(r => this.processSaveResult(r));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.processSaveResult(saveResult);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
load() {
|
|
134
|
+
this._store.dispatch(dataLoading(this.name));
|
|
135
|
+
let result;
|
|
136
|
+
if (this.loadExecutor) {
|
|
137
|
+
result = this.loadExecutor({ dataUnit: this.name });
|
|
138
|
+
}
|
|
139
|
+
if (result instanceof Promise) {
|
|
140
|
+
result.then(r => this.processLoadResult(r));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.processLoadResult(result);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
remove() {
|
|
147
|
+
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
148
|
+
this._store.dispatch(removingRecord(this.name));
|
|
149
|
+
let removeResult;
|
|
150
|
+
if (this.removeExecutor) {
|
|
151
|
+
const record = this.getCurrentRecord();
|
|
152
|
+
removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
removeResult = true;
|
|
156
|
+
}
|
|
157
|
+
if (removeResult) {
|
|
158
|
+
if (removeResult instanceof Promise) {
|
|
159
|
+
removeResult.then(r => this.processRemoveResult(r, currentIndex));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.processRemoveResult(removeResult, currentIndex);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
processSaveResult(result) {
|
|
167
|
+
if (result) {
|
|
168
|
+
if (result instanceof Array) {
|
|
169
|
+
result.forEach(item => this.processSaveResult(item));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if (result.dataUnit === this.name) {
|
|
173
|
+
result.records.forEach(savedRecord => {
|
|
174
|
+
let rID = savedRecord.oldRecord__id;
|
|
175
|
+
delete savedRecord.oldRecord__id;
|
|
176
|
+
if (rID === undefined) {
|
|
177
|
+
rID = savedRecord.record__id;
|
|
178
|
+
}
|
|
179
|
+
this.records.forEach((r, index) => {
|
|
180
|
+
if (r.record__id === rID) {
|
|
181
|
+
this.records[index] = Object.assign(r, savedRecord);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
189
|
+
this._store.dispatch(changesSaved(this.name));
|
|
190
|
+
}
|
|
191
|
+
processLoadResult(records) {
|
|
192
|
+
this.records = records;
|
|
193
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
194
|
+
this._store.dispatch(dataLoaded(this.name));
|
|
195
|
+
}
|
|
196
|
+
processRemoveResult(removed, recordIndex) {
|
|
197
|
+
if (removed) {
|
|
198
|
+
this.records.splice(recordIndex, 1);
|
|
199
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
200
|
+
}
|
|
201
|
+
this._store.dispatch(recordRemoved(this.name));
|
|
202
|
+
}
|
|
203
|
+
set records(records) {
|
|
204
|
+
this._records = records;
|
|
205
|
+
if (this.parentDU) {
|
|
206
|
+
this._records.forEach(r => this.bindToParent(r));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
bindToParent(r) {
|
|
210
|
+
if (this.parentDU) {
|
|
211
|
+
const parentRecord = this.parentDU.getCurrentRecord();
|
|
212
|
+
if (parentRecord) {
|
|
213
|
+
r.parent__record__id = parentRecord.record__id;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
get records() {
|
|
218
|
+
if (!this._records) {
|
|
219
|
+
this._records = [];
|
|
220
|
+
}
|
|
221
|
+
return this._records;
|
|
222
|
+
}
|
|
223
|
+
getCurrentRecord() {
|
|
224
|
+
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
225
|
+
return this.records[currentIndex];
|
|
226
|
+
}
|
|
227
|
+
getRecordChanges(currentRecord = undefined) {
|
|
228
|
+
if (currentRecord === undefined) {
|
|
229
|
+
currentRecord = this.getCurrentRecord();
|
|
230
|
+
}
|
|
231
|
+
return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
|
|
232
|
+
}
|
|
233
|
+
validateRecords() {
|
|
234
|
+
if (!this.recordsValidator) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
238
|
+
const recordsToValidate = [];
|
|
239
|
+
this.records.forEach((record, i) => {
|
|
240
|
+
const changes = duChanges[record.record__id];
|
|
241
|
+
if (changes) {
|
|
242
|
+
recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
const result = this.recordsValidator.validateRecords(this, recordsToValidate);
|
|
246
|
+
if (result.message) {
|
|
247
|
+
alert(result.message);
|
|
248
|
+
}
|
|
249
|
+
return result.isValid;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export class Form {
|
|
2
|
-
}
|
|
3
|
-
export class Field {
|
|
4
|
-
}
|
|
5
|
-
export class FieldSet {
|
|
6
|
-
}
|
|
7
|
-
export class UIProperty {
|
|
8
|
-
}
|
|
9
|
-
export class FieldDependency {
|
|
10
|
-
}
|
|
11
|
-
export var DependencyType;
|
|
12
|
-
(function (DependencyType) {
|
|
13
|
-
DependencyType["SEARCHING"] = "SEARCHING";
|
|
14
|
-
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
15
|
-
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
16
|
-
})(DependencyType || (DependencyType = {}));
|
|
1
|
+
export class Form {
|
|
2
|
+
}
|
|
3
|
+
export class Field {
|
|
4
|
+
}
|
|
5
|
+
export class FieldSet {
|
|
6
|
+
}
|
|
7
|
+
export class UIProperty {
|
|
8
|
+
}
|
|
9
|
+
export class FieldDependency {
|
|
10
|
+
}
|
|
11
|
+
export var DependencyType;
|
|
12
|
+
(function (DependencyType) {
|
|
13
|
+
DependencyType["SEARCHING"] = "SEARCHING";
|
|
14
|
+
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
15
|
+
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
16
|
+
})(DependencyType || (DependencyType = {}));
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: flex;
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 42px;
|
|
5
|
-
border-radius: 12px;
|
|
6
|
-
background: var(--background--medium);
|
|
7
|
-
background-image: linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);
|
|
8
|
-
background-repeat: no-repeat;
|
|
9
|
-
background-size: 800px 1000px;
|
|
10
|
-
animation-duration: 1s;
|
|
11
|
-
animation-fill-mode: forwards;
|
|
12
|
-
animation-iteration-count: infinite;
|
|
13
|
-
animation-name: placeholderShimmer;
|
|
14
|
-
animation-timing-function: linear;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@keyframes placeholderShimmer{
|
|
18
|
-
0%{
|
|
19
|
-
background-position: -800px 0;
|
|
20
|
-
}
|
|
21
|
-
100%{
|
|
22
|
-
background-position: 800px 0;
|
|
23
|
-
}
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 42px;
|
|
5
|
+
border-radius: 12px;
|
|
6
|
+
background: var(--background--medium);
|
|
7
|
+
background-image: linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);
|
|
8
|
+
background-repeat: no-repeat;
|
|
9
|
+
background-size: 800px 1000px;
|
|
10
|
+
animation-duration: 1s;
|
|
11
|
+
animation-fill-mode: forwards;
|
|
12
|
+
animation-iteration-count: infinite;
|
|
13
|
+
animation-name: placeholderShimmer;
|
|
14
|
+
animation-timing-function: linear;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@keyframes placeholderShimmer{
|
|
18
|
+
0%{
|
|
19
|
+
background-position: -800px 0;
|
|
20
|
+
}
|
|
21
|
+
100%{
|
|
22
|
+
background-position: 800px 0;
|
|
23
|
+
}
|
|
24
24
|
}
|