@sankhyalabs/ezui 1.1.78 → 1.1.81
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/dist/cjs/{AssetsUtils-dd585fba.js → AssetsUtils-02db4f46.js} +1 -1
- package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
- package/dist/cjs/ez-application.cjs.entry.js +1 -1
- package/dist/cjs/ez-button_3.cjs.entry.js +520 -0
- package/dist/cjs/ez-calendar_14.cjs.entry.js +2598 -0
- package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
- package/dist/cjs/{ez-button_11.cjs.entry.js → ez-grid.cjs.entry.js} +14 -1410
- package/dist/cjs/ez-icon.cjs.entry.js +30 -0
- package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal_2.cjs.entry.js +370 -0
- package/dist/cjs/ez-popover.cjs.entry.js +2 -2
- package/dist/cjs/ez-popup.cjs.entry.js +1 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +3 -3
- package/dist/cjs/ez-toast.cjs.entry.js +1 -1
- package/dist/cjs/ezui.cjs.js +2 -2
- package/dist/cjs/{index-4e4bae01.js → index-2003dec4.js} +0 -10
- package/dist/cjs/{index-40ebb2be.js → index-4fc4a0a4.js} +86 -63
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +0 -2
- package/dist/collection/components/ez-form/DataBinder.js +50 -0
- package/dist/collection/components/ez-form/ez-form.css +1 -15
- package/dist/collection/components/ez-form/ez-form.js +112 -427
- package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +46 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +11 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.js +14 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +9 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +5 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.js +13 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.js +5 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/TextArea.tpl.js +5 -0
- package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +5 -0
- package/dist/collection/components/ez-form/store/form.slice.js +38 -0
- package/dist/collection/components/ez-form/structure/FormItem.js +11 -0
- package/dist/collection/components/ez-form/structure/FormSheet.js +5 -0
- package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +86 -0
- package/dist/collection/components/test-du/test-du.js +65 -23
- package/dist/custom-elements/index.d.ts +0 -12
- package/dist/custom-elements/index.js +462 -2104
- package/dist/esm/{AssetsUtils-3803e935.js → AssetsUtils-76ca41e1.js} +1 -1
- package/dist/esm/ez-action-chip.entry.js +1 -1
- package/dist/esm/ez-application.entry.js +1 -1
- package/dist/esm/ez-button_3.entry.js +514 -0
- package/dist/esm/ez-calendar_14.entry.js +2581 -0
- package/dist/esm/ez-dialog.entry.js +1 -1
- package/dist/esm/{ez-button_11.entry.js → ez-grid.entry.js} +4 -1390
- package/dist/esm/ez-icon.entry.js +26 -0
- package/dist/esm/ez-label-chip.entry.js +1 -1
- package/dist/esm/ez-modal_2.entry.js +365 -0
- package/dist/esm/ez-popover.entry.js +2 -2
- package/dist/esm/ez-popup.entry.js +1 -1
- package/dist/esm/ez-time-input.entry.js +3 -3
- package/dist/esm/ez-toast.entry.js +1 -1
- package/dist/esm/ezui.js +2 -2
- package/dist/esm/{index-1dacecd3.js → index-077c7fcf.js} +0 -10
- package/dist/esm/{index-ca8700cb.js → index-e31373d9.js} +85 -61
- package/dist/esm/loader.js +2 -2
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-516d0e0f.entry.js → p-0a2056d9.entry.js} +1 -1
- package/dist/ezui/{p-74f978db.entry.js → p-1c8d64d0.entry.js} +46 -46
- package/dist/ezui/p-1e36e3ff.entry.js +1 -0
- package/dist/ezui/p-446ec85b.js +1 -0
- package/dist/ezui/{p-a18a2d7b.entry.js → p-57ea4b84.entry.js} +1 -1
- package/dist/ezui/{p-5a86e18a.entry.js → p-6d157776.entry.js} +1 -1
- package/dist/ezui/p-7de3c95d.js +1 -0
- package/dist/ezui/p-8b9ef58b.entry.js +1 -0
- package/dist/ezui/{p-c6d469fc.entry.js → p-920bb8c9.entry.js} +1 -1
- package/dist/ezui/p-983bd291.js +1 -0
- package/dist/ezui/p-9dbf569a.entry.js +1 -0
- package/dist/ezui/p-a4a39579.entry.js +1 -0
- package/dist/ezui/{p-8d6cdd3e.entry.js → p-aef3394b.entry.js} +1 -1
- package/dist/ezui/p-d64a3939.entry.js +1 -0
- package/dist/ezui/{p-5da66d3e.entry.js → p-da31cd21.entry.js} +1 -1
- package/dist/ezui/{p-f3c5f27e.entry.js → p-da63000f.entry.js} +1 -1
- package/dist/types/components/ez-form/DataBinder.d.ts +10 -0
- package/dist/types/components/ez-form/ez-form.d.ts +25 -32
- package/dist/types/components/ez-form/fieldbuilder/FieldBuilder.d.ts +2 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +3 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +4 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +8 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +4 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +8 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +4 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +4 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +4 -0
- package/dist/types/components/ez-form/store/form.slice.d.ts +24 -0
- package/dist/types/components/ez-form/structure/FormItem.d.ts +9 -0
- package/dist/types/components/ez-form/structure/FormSheet.d.ts +9 -0
- package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +27 -0
- package/dist/types/components/test-du/test-du.d.ts +8 -2
- package/dist/types/components.d.ts +9 -63
- package/package.json +2 -2
- package/react/components.d.ts +0 -2
- package/react/components.js +0 -2
- package/react/components.js.map +1 -1
- package/dist/cjs/ApplicationUtils-d1c1db56.js +0 -35
- package/dist/cjs/DataUnit-fdd7c70e.js +0 -474
- package/dist/cjs/DateUtils-716769e0.js +0 -46
- package/dist/cjs/ez-calendar.cjs.entry.js +0 -217
- package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +0 -634
- package/dist/cjs/ez-combo-box.cjs.entry.js +0 -254
- package/dist/cjs/ez-date-time-input.cjs.entry.js +0 -133
- package/dist/cjs/ez-form.cjs.entry.js +0 -1838
- package/dist/cjs/ez-number-input.cjs.entry.js +0 -74
- package/dist/cjs/form-metadata.cjs.entry.js +0 -129
- package/dist/collection/components/ez-form/assets/trash-can-outline.svg +0 -3
- package/dist/collection/components/ez-form/store/Form.actions.js +0 -132
- package/dist/collection/components/ez-form/store/Form.reducer.js +0 -194
- package/dist/collection/components/ez-form/store/Form.selectors.js +0 -44
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +0 -301
- package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +0 -8
- package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +0 -24
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +0 -227
- package/dist/collection/components/ez-form/subcomponents/place-holder.js +0 -14
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +0 -95
- package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +0 -27
- package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +0 -41
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +0 -37
- package/dist/esm/ApplicationUtils-01280a9d.js +0 -33
- package/dist/esm/DataUnit-1cd45202.js +0 -464
- package/dist/esm/DateUtils-0a1bbd7a.js +0 -44
- package/dist/esm/ez-calendar.entry.js +0 -213
- package/dist/esm/ez-collapsible-box_6.entry.js +0 -625
- package/dist/esm/ez-combo-box.entry.js +0 -250
- package/dist/esm/ez-date-time-input.entry.js +0 -129
- package/dist/esm/ez-form.entry.js +0 -1834
- package/dist/esm/ez-number-input.entry.js +0 -70
- package/dist/esm/form-metadata.entry.js +0 -125
- package/dist/ezui/assets/trash-can-outline.svg +0 -3
- package/dist/ezui/p-14bee38e.entry.js +0 -1
- package/dist/ezui/p-37a611ea.js +0 -1
- package/dist/ezui/p-3a09c678.entry.js +0 -1
- package/dist/ezui/p-43c15c94.entry.js +0 -1
- package/dist/ezui/p-7107d7ef.js +0 -1
- package/dist/ezui/p-72ff3c95.entry.js +0 -1
- package/dist/ezui/p-88f45a83.entry.js +0 -1
- package/dist/ezui/p-8f4851a6.js +0 -1
- package/dist/ezui/p-9dfd537e.js +0 -1
- package/dist/ezui/p-a0331955.entry.js +0 -1
- package/dist/ezui/p-a15093e3.entry.js +0 -1
- package/dist/ezui/p-a19f2af3.entry.js +0 -1
- package/dist/ezui/p-c89629eb.js +0 -1
- package/dist/ezui/p-da929c01.js +0 -1
- package/dist/types/components/ez-form/store/Form.actions.d.ts +0 -111
- package/dist/types/components/ez-form/store/Form.reducer.d.ts +0 -20
- package/dist/types/components/ez-form/store/Form.selectors.d.ts +0 -14
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +0 -91
- package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +0 -24
- package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +0 -16
- package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +0 -3
- package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +0 -11
- package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +0 -13
- package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +0 -14
- package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +0 -19
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ApplicationUtils = require('./ApplicationUtils-d1c1db56.js');
|
|
4
|
-
|
|
5
|
-
function changeFieldValue(dataUnit, recordId, fieldName, value) {
|
|
6
|
-
return {
|
|
7
|
-
type: "FORM/CHANGEFIELD",
|
|
8
|
-
payload: { dataUnit, recordId, fieldName, value }
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function changeTab(formId, index) {
|
|
12
|
-
return {
|
|
13
|
-
type: "FORM/CHANGETAB",
|
|
14
|
-
payload: { formId, index }
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function clearEdition(dataUnit, recordsLimit) {
|
|
18
|
-
return {
|
|
19
|
-
type: "FORM/CLEAREDITION",
|
|
20
|
-
payload: {
|
|
21
|
-
dataUnit,
|
|
22
|
-
recordsLimit
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function collapseExpandGroup(collapseId, collapsed) {
|
|
27
|
-
return {
|
|
28
|
-
type: "FORM/COLLAPSEGROUP",
|
|
29
|
-
payload: { collapseId, collapsed }
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function previousRecord(dataUnit) {
|
|
33
|
-
return {
|
|
34
|
-
type: "FORM/NAVIGATE",
|
|
35
|
-
payload: {
|
|
36
|
-
dataUnit,
|
|
37
|
-
limit: 0,
|
|
38
|
-
backward: true
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function nextRecord(dataUnit, limit) {
|
|
43
|
-
return {
|
|
44
|
-
type: "FORM/NAVIGATE",
|
|
45
|
-
payload: {
|
|
46
|
-
dataUnit,
|
|
47
|
-
limit,
|
|
48
|
-
backward: false
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function insertRecord(dataUnit, insertionIndex) {
|
|
53
|
-
return {
|
|
54
|
-
type: "FORM/INSERT",
|
|
55
|
-
payload: {
|
|
56
|
-
dataUnit,
|
|
57
|
-
insertionIndex
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function formLoad() {
|
|
62
|
-
return {
|
|
63
|
-
type: "FORM/LOAD"
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function dataLoading(dataUnit) {
|
|
67
|
-
return {
|
|
68
|
-
type: "FORM/DATALOADING",
|
|
69
|
-
payload: {
|
|
70
|
-
dataUnit
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function savingChanges(dataUnit) {
|
|
75
|
-
return {
|
|
76
|
-
type: "FORM/SAVINGCHANGES",
|
|
77
|
-
payload: {
|
|
78
|
-
dataUnit
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function dataLoaded(dataUnit) {
|
|
83
|
-
return {
|
|
84
|
-
type: "FORM/DATALOADED",
|
|
85
|
-
payload: {
|
|
86
|
-
dataUnit
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function changesSaved(dataUnit) {
|
|
91
|
-
return {
|
|
92
|
-
type: "FORM/CHANGESSAVED",
|
|
93
|
-
payload: {
|
|
94
|
-
dataUnit
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function removingRecord(dataUnit) {
|
|
99
|
-
return {
|
|
100
|
-
type: "FORM/REMOVINGRECORD",
|
|
101
|
-
payload: {
|
|
102
|
-
dataUnit
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function recordRemoved(dataUnit) {
|
|
107
|
-
return {
|
|
108
|
-
type: "FORM/RECORDREMOVED",
|
|
109
|
-
payload: {
|
|
110
|
-
dataUnit
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function invalidField(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
|
|
115
|
-
return {
|
|
116
|
-
type: "FORM/INVALIDFIELD",
|
|
117
|
-
payload: {
|
|
118
|
-
tabController,
|
|
119
|
-
tabIndex,
|
|
120
|
-
dataUnit,
|
|
121
|
-
recordId,
|
|
122
|
-
recordIndex,
|
|
123
|
-
fieldName,
|
|
124
|
-
errorMessage
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function showHideNavigationButtons(buttonName, status) {
|
|
129
|
-
return {
|
|
130
|
-
type: "FORM/SHOWHIDENAVBTN",
|
|
131
|
-
payload: {
|
|
132
|
-
buttonName,
|
|
133
|
-
status
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
//histórico
|
|
139
|
-
const selectCurrentTab = (state, formName) => {
|
|
140
|
-
const data = state.hist.present.currentTabIndex;
|
|
141
|
-
return data[formName] || 0;
|
|
142
|
-
};
|
|
143
|
-
const selectIsCollapsedFieldSet = (state, fieldSetName) => {
|
|
144
|
-
const data = state.hist.present.collapsedGroups;
|
|
145
|
-
return data[fieldSetName];
|
|
146
|
-
};
|
|
147
|
-
const selectRecordChanges = (state, dataUnit, recordId) => {
|
|
148
|
-
const data = selectDataUnitChanges(state, dataUnit);
|
|
149
|
-
return data ? data[recordId] : undefined;
|
|
150
|
-
};
|
|
151
|
-
const selectDataUnitChanges = (state, dataUnit) => {
|
|
152
|
-
const data = state.hist.present.changes;
|
|
153
|
-
return data[dataUnit];
|
|
154
|
-
};
|
|
155
|
-
const selectCurrentRecordIndex = (state, dataUnit) => {
|
|
156
|
-
const data = state.hist.present.currentRecordIndex;
|
|
157
|
-
return data[dataUnit] || 0;
|
|
158
|
-
};
|
|
159
|
-
const selectNewRecordIndex = (state, dataUnit) => {
|
|
160
|
-
const data = state.hist.present.newRecordIndex;
|
|
161
|
-
return data[dataUnit] || 0;
|
|
162
|
-
};
|
|
163
|
-
//não histórico
|
|
164
|
-
const selectLoadingData = (state, dataUnit) => {
|
|
165
|
-
const data = state.nonhist.dataLoading;
|
|
166
|
-
return data[dataUnit];
|
|
167
|
-
};
|
|
168
|
-
const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
|
|
169
|
-
const data = state.nonhist.invalidFields;
|
|
170
|
-
const dataUnitMessages = data[dataUnit] || {};
|
|
171
|
-
const recordMessages = dataUnitMessages[recordId] || {};
|
|
172
|
-
return recordMessages[fieldName] || "";
|
|
173
|
-
};
|
|
174
|
-
const selectVisibleButtons = state => state.nonhist.visibleButtons;
|
|
175
|
-
|
|
176
|
-
class DataUnit {
|
|
177
|
-
constructor(name, unitLabel, cardinality = "1", parentDU = null) {
|
|
178
|
-
this.name = name;
|
|
179
|
-
this.unitLabel = unitLabel;
|
|
180
|
-
this.cardinality = cardinality;
|
|
181
|
-
this._children = [];
|
|
182
|
-
this._fields = new Map();
|
|
183
|
-
this._requiredFields = [];
|
|
184
|
-
if (parentDU != null) {
|
|
185
|
-
parentDU._children.push(this);
|
|
186
|
-
this.parentDU = parentDU;
|
|
187
|
-
this.parentDUName = parentDU.name;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
set store(store) {
|
|
191
|
-
this._store = store;
|
|
192
|
-
}
|
|
193
|
-
set fields(value) {
|
|
194
|
-
if (value) {
|
|
195
|
-
value.forEach(f => this.addFieldMetadata(f));
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
addFieldMetadata(field) {
|
|
199
|
-
this._fields.set(field.name, field);
|
|
200
|
-
if (field.required) {
|
|
201
|
-
this._requiredFields.push(field);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
getFieldMetadata(name) {
|
|
205
|
-
if (this._fields) {
|
|
206
|
-
return this._fields.get(name);
|
|
207
|
-
}
|
|
208
|
-
return undefined;
|
|
209
|
-
}
|
|
210
|
-
get requiredFields() {
|
|
211
|
-
return this._requiredFields;
|
|
212
|
-
}
|
|
213
|
-
isLoading() {
|
|
214
|
-
return selectLoadingData(this._store.getState(), this.name);
|
|
215
|
-
}
|
|
216
|
-
hasChanges() {
|
|
217
|
-
const state = this._store.getState();
|
|
218
|
-
return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
|
|
219
|
-
}
|
|
220
|
-
hasNext() {
|
|
221
|
-
return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
|
|
222
|
-
}
|
|
223
|
-
hasPrevious() {
|
|
224
|
-
return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
|
|
225
|
-
}
|
|
226
|
-
hasCurrentRecord() {
|
|
227
|
-
return this.getCurrentRecord() != undefined;
|
|
228
|
-
}
|
|
229
|
-
previous() {
|
|
230
|
-
this._store.dispatch(previousRecord(this.name));
|
|
231
|
-
}
|
|
232
|
-
next() {
|
|
233
|
-
this._store.dispatch(nextRecord(this.name, this.records.length));
|
|
234
|
-
}
|
|
235
|
-
getValue(fieldName) {
|
|
236
|
-
const currentRecord = this.getCurrentRecord();
|
|
237
|
-
if (!currentRecord) {
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
const changes = this.getRecordChanges(currentRecord);
|
|
241
|
-
return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
|
|
242
|
-
}
|
|
243
|
-
getErrorMessage(fieldName) {
|
|
244
|
-
const currentRecord = this.getCurrentRecord();
|
|
245
|
-
return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
|
|
246
|
-
}
|
|
247
|
-
changeValue(fieldName, newValue) {
|
|
248
|
-
if (this.records.length == 0) {
|
|
249
|
-
this.insert();
|
|
250
|
-
}
|
|
251
|
-
if (this._changeDeboucing) {
|
|
252
|
-
window.clearTimeout(this._changeDeboucing);
|
|
253
|
-
}
|
|
254
|
-
this._changeDeboucing = window.setTimeout(() => {
|
|
255
|
-
const currentRecord = this.getCurrentRecord();
|
|
256
|
-
this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
|
|
257
|
-
}, 100);
|
|
258
|
-
}
|
|
259
|
-
cancel() {
|
|
260
|
-
this.records = this.records.filter(r => !r.record__id.startsWith("NEW_"));
|
|
261
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
262
|
-
}
|
|
263
|
-
insert() {
|
|
264
|
-
const insertionIndex = this.records.length;
|
|
265
|
-
const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
|
|
266
|
-
const newRecord = { record__id: "NEW_" + (newRecordIndex + 1) };
|
|
267
|
-
this.bindToParent(newRecord);
|
|
268
|
-
this.records.push(newRecord);
|
|
269
|
-
this._store.dispatch(insertRecord(this.name, insertionIndex));
|
|
270
|
-
}
|
|
271
|
-
buildChange(r) {
|
|
272
|
-
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
273
|
-
let recordChanges;
|
|
274
|
-
if (duChanges) {
|
|
275
|
-
recordChanges = duChanges[r.record__id];
|
|
276
|
-
}
|
|
277
|
-
let subChanges = [];
|
|
278
|
-
this._children.forEach(duChild => {
|
|
279
|
-
subChanges = subChanges.concat(duChild.getSubChanges(r.record__id));
|
|
280
|
-
});
|
|
281
|
-
if (recordChanges || subChanges.length > 0) {
|
|
282
|
-
const change = {
|
|
283
|
-
"__data__unit": this.name,
|
|
284
|
-
"__record__id": r.record__id,
|
|
285
|
-
"__sub__changes": subChanges
|
|
286
|
-
};
|
|
287
|
-
if (recordChanges) {
|
|
288
|
-
Object.keys(recordChanges).forEach(fieldName => { });
|
|
289
|
-
}
|
|
290
|
-
return change;
|
|
291
|
-
}
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
|
294
|
-
getSubChanges(id) {
|
|
295
|
-
const result = [];
|
|
296
|
-
if (this._records) {
|
|
297
|
-
this._records.filter(r => r.parent__record__id === id).forEach(r => {
|
|
298
|
-
const c = this.buildChange(r);
|
|
299
|
-
if (c) {
|
|
300
|
-
result.push(c);
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
return result;
|
|
305
|
-
}
|
|
306
|
-
getChangesToSave() {
|
|
307
|
-
let result = [];
|
|
308
|
-
if (this._records) {
|
|
309
|
-
this._records.forEach(r => {
|
|
310
|
-
const change = this.buildChange(r);
|
|
311
|
-
if (change) {
|
|
312
|
-
result.push(change);
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
return result;
|
|
317
|
-
}
|
|
318
|
-
save() {
|
|
319
|
-
if (!this.validateRecords("SAVE")) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
this._store.dispatch(savingChanges(this.name));
|
|
323
|
-
let saveResult;
|
|
324
|
-
if (this.saveExecutor) {
|
|
325
|
-
saveResult = this.saveExecutor(this.getChangesToSave());
|
|
326
|
-
}
|
|
327
|
-
if (saveResult instanceof Promise) {
|
|
328
|
-
saveResult
|
|
329
|
-
.then(r => this.processSaveResult(r))
|
|
330
|
-
.catch(e => {
|
|
331
|
-
this._store.dispatch(dataLoaded(this.name));
|
|
332
|
-
ApplicationUtils.ApplicationUtils.error("Falha ao tentar salvar", e);
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
this.processSaveResult(saveResult);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
load() {
|
|
340
|
-
this._store.dispatch(dataLoading(this.name));
|
|
341
|
-
let result;
|
|
342
|
-
if (this.loadExecutor) {
|
|
343
|
-
result = this.loadExecutor({ dataUnit: this.name });
|
|
344
|
-
}
|
|
345
|
-
if (result instanceof Promise) {
|
|
346
|
-
result.then(r => this.processLoadResult(r));
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
this.processLoadResult(result);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
remove() {
|
|
353
|
-
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
354
|
-
this._store.dispatch(removingRecord(this.name));
|
|
355
|
-
let removeResult;
|
|
356
|
-
if (this.removeExecutor) {
|
|
357
|
-
const record = this.getCurrentRecord();
|
|
358
|
-
removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
removeResult = true;
|
|
362
|
-
}
|
|
363
|
-
if (removeResult) {
|
|
364
|
-
if (removeResult instanceof Promise) {
|
|
365
|
-
removeResult.then(r => this.processRemoveResult(r, currentIndex));
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
this.processRemoveResult(removeResult, currentIndex);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
processSaveResult(result) {
|
|
373
|
-
if (result) {
|
|
374
|
-
if (result instanceof Array) {
|
|
375
|
-
result.forEach(item => this.processSaveResult(item));
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
if (result.__data__unit === this.name) {
|
|
379
|
-
if (this.cardinality === "1") {
|
|
380
|
-
this.records = [this.buildRecordFromSaveResult(this.records[0], result)];
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
//FIXME: Isso está errado! tem que limpar todas as edições
|
|
386
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
387
|
-
this._store.dispatch(changesSaved(this.name));
|
|
388
|
-
}
|
|
389
|
-
buildRecordFromSaveResult(baseRecord, saveResult) {
|
|
390
|
-
const newRecord = baseRecord ? Object.assign({}, baseRecord) : { record__id: "" };
|
|
391
|
-
Object.keys(saveResult).forEach(attrib => {
|
|
392
|
-
if (!attrib.startsWith("__")) {
|
|
393
|
-
newRecord[attrib] = saveResult[attrib];
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
return newRecord;
|
|
397
|
-
}
|
|
398
|
-
processLoadResult(records) {
|
|
399
|
-
this.records = records;
|
|
400
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
401
|
-
this._store.dispatch(dataLoaded(this.name));
|
|
402
|
-
}
|
|
403
|
-
processRemoveResult(removed, recordIndex) {
|
|
404
|
-
if (removed) {
|
|
405
|
-
this.records.splice(recordIndex, 1);
|
|
406
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
407
|
-
}
|
|
408
|
-
this._store.dispatch(recordRemoved(this.name));
|
|
409
|
-
}
|
|
410
|
-
set records(records) {
|
|
411
|
-
this._records = records;
|
|
412
|
-
if (this.parentDU) {
|
|
413
|
-
this._records.forEach(r => this.bindToParent(r));
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
bindToParent(r) {
|
|
417
|
-
if (this.parentDU) {
|
|
418
|
-
const parentRecord = this.parentDU.getCurrentRecord();
|
|
419
|
-
if (parentRecord) {
|
|
420
|
-
r.parent__record__id = parentRecord.record__id;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
get records() {
|
|
425
|
-
if (!this._records) {
|
|
426
|
-
this._records = [];
|
|
427
|
-
}
|
|
428
|
-
return this._records;
|
|
429
|
-
}
|
|
430
|
-
getCurrentRecord() {
|
|
431
|
-
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
432
|
-
return this.records[currentIndex];
|
|
433
|
-
}
|
|
434
|
-
getRecordChanges(currentRecord = undefined) {
|
|
435
|
-
if (currentRecord === undefined) {
|
|
436
|
-
currentRecord = this.getCurrentRecord();
|
|
437
|
-
}
|
|
438
|
-
return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
|
|
439
|
-
}
|
|
440
|
-
validateRecords(triggedBy = "UNKNOWN") {
|
|
441
|
-
if (!this.recordsValidator) {
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
445
|
-
const recordsToValidate = [];
|
|
446
|
-
this.records.forEach((record, i) => {
|
|
447
|
-
const changes = duChanges ? duChanges[record.record__id] : undefined;
|
|
448
|
-
if (changes) {
|
|
449
|
-
recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
const result = this.recordsValidator.validateRecords(this, recordsToValidate, triggedBy);
|
|
453
|
-
if (result.message) {
|
|
454
|
-
ApplicationUtils.ApplicationUtils.info(result.message);
|
|
455
|
-
}
|
|
456
|
-
return result.isValid;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
exports.DependencyType = void 0;
|
|
460
|
-
(function (DependencyType) {
|
|
461
|
-
DependencyType["SEARCHING"] = "SEARCHING";
|
|
462
|
-
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
463
|
-
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
464
|
-
})(exports.DependencyType || (exports.DependencyType = {}));
|
|
465
|
-
|
|
466
|
-
exports.DataUnit = DataUnit;
|
|
467
|
-
exports.changeTab = changeTab;
|
|
468
|
-
exports.collapseExpandGroup = collapseExpandGroup;
|
|
469
|
-
exports.formLoad = formLoad;
|
|
470
|
-
exports.invalidField = invalidField;
|
|
471
|
-
exports.selectCurrentTab = selectCurrentTab;
|
|
472
|
-
exports.selectIsCollapsedFieldSet = selectIsCollapsedFieldSet;
|
|
473
|
-
exports.selectVisibleButtons = selectVisibleButtons;
|
|
474
|
-
exports.showHideNavigationButtons = showHideNavigationButtons;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class DateUtils {
|
|
4
|
-
static clearTime(date, adjustDayLightSavingTime = true) {
|
|
5
|
-
const newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
|
|
6
|
-
return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
|
|
7
|
-
}
|
|
8
|
-
static strToDate(strValue, adjustDayLightSavingTime = true, monthYearMode = false) {
|
|
9
|
-
/** monthYearMode é um booleano para usar o formato MM/YYYY.
|
|
10
|
-
* Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
|
|
11
|
-
* Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
|
|
12
|
-
let parts;
|
|
13
|
-
if (monthYearMode) {
|
|
14
|
-
parts = /^(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
parts = /^(3[01]|[1-2]\d|0[1-9]|[1-9])[^\d]?(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
|
|
18
|
-
}
|
|
19
|
-
if (!parts) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
var day = monthYearMode ? 1 : Number(parts[1]);
|
|
23
|
-
var month = Number(parts[(monthYearMode ? 1 : 2)]);
|
|
24
|
-
var year = Number(parts[(monthYearMode ? 2 : 3)]);
|
|
25
|
-
var hour = Number(parts[(monthYearMode ? 3 : 4)] || 0);
|
|
26
|
-
var min = Number(parts[(monthYearMode ? 4 : 5)] || 0);
|
|
27
|
-
var sec = Number(parts[(monthYearMode ? 5 : 6)] || 0);
|
|
28
|
-
if (year < 100) {
|
|
29
|
-
year += year < 30 ? 2000 : 1900;
|
|
30
|
-
}
|
|
31
|
-
let date = new Date(year, month - 1, day, hour, min, sec, 0);
|
|
32
|
-
if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
|
|
33
|
-
date = DateUtils.adjustDLST(date);
|
|
34
|
-
}
|
|
35
|
-
return date;
|
|
36
|
-
}
|
|
37
|
-
static adjustDLST(date) {
|
|
38
|
-
//Work around para corrigir o Bug do horário de verão.
|
|
39
|
-
if (date.getHours() == 23) {
|
|
40
|
-
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
|
|
41
|
-
}
|
|
42
|
-
return date;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.DateUtils = DateUtils;
|