@sankhyalabs/ezui 1.1.78 → 1.1.79
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_13.cjs.entry.js +2417 -0
- package/dist/cjs/ez-date-time-input.cjs.entry.js +2 -2
- 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-a2266984.js} +18 -23
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +0 -2
- package/dist/collection/components/ez-form/DataBinder.js +44 -0
- package/dist/collection/components/ez-form/ez-form.css +1 -15
- package/dist/collection/components/ez-form/ez-form.js +109 -428
- package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +45 -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 +5 -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 +380 -2065
- 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_13.entry.js +2401 -0
- package/dist/esm/ez-date-time-input.entry.js +2 -2
- 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-afe19542.js} +17 -21
- package/dist/esm/loader.js +2 -2
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-00b837e2.js +1 -0
- package/dist/ezui/{p-516d0e0f.entry.js → p-0a2056d9.entry.js} +1 -1
- package/dist/ezui/{p-a15093e3.entry.js → p-0d8368fc.entry.js} +1 -1
- package/dist/ezui/p-1e36e3ff.entry.js +1 -0
- package/dist/ezui/p-446ec85b.js +1 -0
- package/dist/ezui/{p-74f978db.entry.js → p-5509ee41.entry.js} +46 -46
- 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-f3c5f27e.entry.js → p-7a1f2e0e.entry.js} +1 -1
- package/dist/ezui/p-7de3c95d.js +1 -0
- package/dist/ezui/{p-8d6cdd3e.entry.js → p-857ead8e.entry.js} +1 -1
- package/dist/ezui/{p-c6d469fc.entry.js → p-920bb8c9.entry.js} +1 -1
- package/dist/ezui/p-9be02ecf.entry.js +1 -0
- package/dist/ezui/p-a4a39579.entry.js +1 -0
- package/dist/ezui/p-d5699f29.entry.js +1 -0
- package/dist/ezui/p-d64a3939.entry.js +1 -0
- package/dist/ezui/{p-5da66d3e.entry.js → p-da31cd21.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 +24 -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 +4 -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 +1 -1
- 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/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-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/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-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-a19f2af3.entry.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,301 +0,0 @@
|
|
|
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
|
-
import ApplicationUtils from "../../../utils/ApplicationUtils";
|
|
4
|
-
export default class DataUnit {
|
|
5
|
-
constructor(name, unitLabel, cardinality = "1", parentDU = null) {
|
|
6
|
-
this.name = name;
|
|
7
|
-
this.unitLabel = unitLabel;
|
|
8
|
-
this.cardinality = cardinality;
|
|
9
|
-
this._children = [];
|
|
10
|
-
this._fields = new Map();
|
|
11
|
-
this._requiredFields = [];
|
|
12
|
-
if (parentDU != null) {
|
|
13
|
-
parentDU._children.push(this);
|
|
14
|
-
this.parentDU = parentDU;
|
|
15
|
-
this.parentDUName = parentDU.name;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
set store(store) {
|
|
19
|
-
this._store = store;
|
|
20
|
-
}
|
|
21
|
-
set fields(value) {
|
|
22
|
-
if (value) {
|
|
23
|
-
value.forEach(f => this.addFieldMetadata(f));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
addFieldMetadata(field) {
|
|
27
|
-
this._fields.set(field.name, field);
|
|
28
|
-
if (field.required) {
|
|
29
|
-
this._requiredFields.push(field);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
getFieldMetadata(name) {
|
|
33
|
-
if (this._fields) {
|
|
34
|
-
return this._fields.get(name);
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
get requiredFields() {
|
|
39
|
-
return this._requiredFields;
|
|
40
|
-
}
|
|
41
|
-
isLoading() {
|
|
42
|
-
return selectLoadingData(this._store.getState(), this.name);
|
|
43
|
-
}
|
|
44
|
-
hasChanges() {
|
|
45
|
-
const state = this._store.getState();
|
|
46
|
-
return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
|
|
47
|
-
}
|
|
48
|
-
hasNext() {
|
|
49
|
-
return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
|
|
50
|
-
}
|
|
51
|
-
hasPrevious() {
|
|
52
|
-
return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
|
|
53
|
-
}
|
|
54
|
-
hasCurrentRecord() {
|
|
55
|
-
return this.getCurrentRecord() != undefined;
|
|
56
|
-
}
|
|
57
|
-
previous() {
|
|
58
|
-
this._store.dispatch(previousRecord(this.name));
|
|
59
|
-
}
|
|
60
|
-
next() {
|
|
61
|
-
this._store.dispatch(nextRecord(this.name, this.records.length));
|
|
62
|
-
}
|
|
63
|
-
getValue(fieldName) {
|
|
64
|
-
const currentRecord = this.getCurrentRecord();
|
|
65
|
-
if (!currentRecord) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
const changes = this.getRecordChanges(currentRecord);
|
|
69
|
-
return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
|
|
70
|
-
}
|
|
71
|
-
getErrorMessage(fieldName) {
|
|
72
|
-
const currentRecord = this.getCurrentRecord();
|
|
73
|
-
return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
|
|
74
|
-
}
|
|
75
|
-
changeValue(fieldName, newValue) {
|
|
76
|
-
if (this.records.length == 0) {
|
|
77
|
-
this.insert();
|
|
78
|
-
}
|
|
79
|
-
if (this._changeDeboucing) {
|
|
80
|
-
window.clearTimeout(this._changeDeboucing);
|
|
81
|
-
}
|
|
82
|
-
this._changeDeboucing = window.setTimeout(() => {
|
|
83
|
-
const currentRecord = this.getCurrentRecord();
|
|
84
|
-
this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
|
|
85
|
-
}, 100);
|
|
86
|
-
}
|
|
87
|
-
cancel() {
|
|
88
|
-
this.records = this.records.filter(r => !r.record__id.startsWith("NEW_"));
|
|
89
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
90
|
-
}
|
|
91
|
-
insert() {
|
|
92
|
-
const insertionIndex = this.records.length;
|
|
93
|
-
const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
|
|
94
|
-
const newRecord = { record__id: "NEW_" + (newRecordIndex + 1) };
|
|
95
|
-
this.bindToParent(newRecord);
|
|
96
|
-
this.records.push(newRecord);
|
|
97
|
-
this._store.dispatch(insertRecord(this.name, insertionIndex));
|
|
98
|
-
}
|
|
99
|
-
buildChange(r) {
|
|
100
|
-
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
101
|
-
let recordChanges;
|
|
102
|
-
if (duChanges) {
|
|
103
|
-
recordChanges = duChanges[r.record__id];
|
|
104
|
-
}
|
|
105
|
-
let subChanges = [];
|
|
106
|
-
this._children.forEach(duChild => {
|
|
107
|
-
subChanges = subChanges.concat(duChild.getSubChanges(r.record__id));
|
|
108
|
-
});
|
|
109
|
-
if (recordChanges || subChanges.length > 0) {
|
|
110
|
-
const change = {
|
|
111
|
-
"__data__unit": this.name,
|
|
112
|
-
"__record__id": r.record__id,
|
|
113
|
-
"__sub__changes": subChanges
|
|
114
|
-
};
|
|
115
|
-
if (recordChanges) {
|
|
116
|
-
Object.keys(recordChanges).forEach(fieldName => { [fieldName] = recordChanges[fieldName]; });
|
|
117
|
-
}
|
|
118
|
-
return change;
|
|
119
|
-
}
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
getSubChanges(id) {
|
|
123
|
-
const result = [];
|
|
124
|
-
if (this._records) {
|
|
125
|
-
this._records.filter(r => r.parent__record__id === id).forEach(r => {
|
|
126
|
-
const c = this.buildChange(r);
|
|
127
|
-
if (c) {
|
|
128
|
-
result.push(c);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
getChangesToSave() {
|
|
135
|
-
let result = [];
|
|
136
|
-
if (this._records) {
|
|
137
|
-
this._records.forEach(r => {
|
|
138
|
-
const change = this.buildChange(r);
|
|
139
|
-
if (change) {
|
|
140
|
-
result.push(change);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
save() {
|
|
147
|
-
if (!this.validateRecords("SAVE")) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
this._store.dispatch(savingChanges(this.name));
|
|
151
|
-
let saveResult;
|
|
152
|
-
if (this.saveExecutor) {
|
|
153
|
-
saveResult = this.saveExecutor(this.getChangesToSave());
|
|
154
|
-
}
|
|
155
|
-
if (saveResult instanceof Promise) {
|
|
156
|
-
saveResult
|
|
157
|
-
.then(r => this.processSaveResult(r))
|
|
158
|
-
.catch(e => {
|
|
159
|
-
this._store.dispatch(dataLoaded(this.name));
|
|
160
|
-
ApplicationUtils.error("Falha ao tentar salvar", e);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.processSaveResult(saveResult);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
load() {
|
|
168
|
-
this._store.dispatch(dataLoading(this.name));
|
|
169
|
-
let result;
|
|
170
|
-
if (this.loadExecutor) {
|
|
171
|
-
result = this.loadExecutor({ dataUnit: this.name });
|
|
172
|
-
}
|
|
173
|
-
if (result instanceof Promise) {
|
|
174
|
-
result.then(r => this.processLoadResult(r));
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
this.processLoadResult(result);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
remove() {
|
|
181
|
-
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
182
|
-
this._store.dispatch(removingRecord(this.name));
|
|
183
|
-
let removeResult;
|
|
184
|
-
if (this.removeExecutor) {
|
|
185
|
-
const record = this.getCurrentRecord();
|
|
186
|
-
removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
removeResult = true;
|
|
190
|
-
}
|
|
191
|
-
if (removeResult) {
|
|
192
|
-
if (removeResult instanceof Promise) {
|
|
193
|
-
removeResult.then(r => this.processRemoveResult(r, currentIndex));
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
this.processRemoveResult(removeResult, currentIndex);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
processSaveResult(result) {
|
|
201
|
-
if (result) {
|
|
202
|
-
if (result instanceof Array) {
|
|
203
|
-
result.forEach(item => this.processSaveResult(item));
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
if (result.__data__unit === this.name) {
|
|
207
|
-
if (this.cardinality === "1") {
|
|
208
|
-
this.records = [this.buildRecordFromSaveResult(this.records[0], result)];
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
//NÃO IPLEMENTADO AINDA
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
//FIXME: Isso está errado! tem que limpar todas as edições
|
|
217
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
218
|
-
this._store.dispatch(changesSaved(this.name));
|
|
219
|
-
}
|
|
220
|
-
buildRecordFromSaveResult(baseRecord, saveResult) {
|
|
221
|
-
const newRecord = baseRecord ? Object.assign({}, baseRecord) : { record__id: "" };
|
|
222
|
-
Object.keys(saveResult).forEach(attrib => {
|
|
223
|
-
if (!attrib.startsWith("__")) {
|
|
224
|
-
newRecord[attrib] = saveResult[attrib];
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
return newRecord;
|
|
228
|
-
}
|
|
229
|
-
processLoadResult(records) {
|
|
230
|
-
this.records = records;
|
|
231
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
232
|
-
this._store.dispatch(dataLoaded(this.name));
|
|
233
|
-
}
|
|
234
|
-
processRemoveResult(removed, recordIndex) {
|
|
235
|
-
if (removed) {
|
|
236
|
-
this.records.splice(recordIndex, 1);
|
|
237
|
-
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
238
|
-
}
|
|
239
|
-
this._store.dispatch(recordRemoved(this.name));
|
|
240
|
-
}
|
|
241
|
-
set records(records) {
|
|
242
|
-
this._records = records;
|
|
243
|
-
if (this.parentDU) {
|
|
244
|
-
this._records.forEach(r => this.bindToParent(r));
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
bindToParent(r) {
|
|
248
|
-
if (this.parentDU) {
|
|
249
|
-
const parentRecord = this.parentDU.getCurrentRecord();
|
|
250
|
-
if (parentRecord) {
|
|
251
|
-
r.parent__record__id = parentRecord.record__id;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
get records() {
|
|
256
|
-
if (!this._records) {
|
|
257
|
-
this._records = [];
|
|
258
|
-
}
|
|
259
|
-
return this._records;
|
|
260
|
-
}
|
|
261
|
-
getCurrentRecord() {
|
|
262
|
-
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
263
|
-
return this.records[currentIndex];
|
|
264
|
-
}
|
|
265
|
-
getRecordChanges(currentRecord = undefined) {
|
|
266
|
-
if (currentRecord === undefined) {
|
|
267
|
-
currentRecord = this.getCurrentRecord();
|
|
268
|
-
}
|
|
269
|
-
return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
|
|
270
|
-
}
|
|
271
|
-
validateRecords(triggedBy = "UNKNOWN") {
|
|
272
|
-
if (!this.recordsValidator) {
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
276
|
-
const recordsToValidate = [];
|
|
277
|
-
this.records.forEach((record, i) => {
|
|
278
|
-
const changes = duChanges ? duChanges[record.record__id] : undefined;
|
|
279
|
-
if (changes) {
|
|
280
|
-
recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
const result = this.recordsValidator.validateRecords(this, recordsToValidate, triggedBy);
|
|
284
|
-
if (result.message) {
|
|
285
|
-
ApplicationUtils.info(result.message);
|
|
286
|
-
}
|
|
287
|
-
return result.isValid;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
export class FieldMetadata {
|
|
291
|
-
}
|
|
292
|
-
export class UIProperty {
|
|
293
|
-
}
|
|
294
|
-
export class FieldDependency {
|
|
295
|
-
}
|
|
296
|
-
export var DependencyType;
|
|
297
|
-
(function (DependencyType) {
|
|
298
|
-
DependencyType["SEARCHING"] = "SEARCHING";
|
|
299
|
-
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
300
|
-
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
301
|
-
})(DependencyType || (DependencyType = {}));
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { Component, Host, h, Element, Prop } from "@stencil/core";
|
|
2
|
-
import DataUnit from "./DataUnit";
|
|
3
|
-
export class FormMetadata {
|
|
4
|
-
buildField(element) {
|
|
5
|
-
let label = element.getAttribute("label");
|
|
6
|
-
let name = element.getAttribute("name") || label;
|
|
7
|
-
let userInterface = element.getAttribute("ui") || "SHORTTEXT";
|
|
8
|
-
let properties = [];
|
|
9
|
-
if (userInterface === "OPTIONSELECTOR") {
|
|
10
|
-
if (!label) {
|
|
11
|
-
label = "Selecione uma das opções:";
|
|
12
|
-
}
|
|
13
|
-
const objOpts = {};
|
|
14
|
-
Array.from(element.getElementsByTagName("OPTION")).forEach((optElem, index) => {
|
|
15
|
-
const optValue = optElem.getAttribute("value") || index;
|
|
16
|
-
const optLabel = optElem.textContent;
|
|
17
|
-
objOpts[optValue] = optLabel;
|
|
18
|
-
});
|
|
19
|
-
properties.push({ name: "options", value: JSON.stringify(objOpts) });
|
|
20
|
-
}
|
|
21
|
-
else if (userInterface === "FILE") {
|
|
22
|
-
const urlElement = element.querySelector("URL");
|
|
23
|
-
const headersElement = element.querySelectorAll("HEADERS>HEADER");
|
|
24
|
-
if (urlElement) {
|
|
25
|
-
properties.push({ name: "URL", value: urlElement.textContent });
|
|
26
|
-
}
|
|
27
|
-
if (headersElement && headersElement.length > 0) {
|
|
28
|
-
const headers = {};
|
|
29
|
-
headersElement.forEach(header => {
|
|
30
|
-
headers[header.getAttribute("name")] = header.textContent;
|
|
31
|
-
});
|
|
32
|
-
properties.push({ name: "HEADERS", value: JSON.stringify(headers) });
|
|
33
|
-
}
|
|
34
|
-
this.addPropertyIfExists(properties, element, "maxfiles");
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (!label) {
|
|
38
|
-
label = element.textContent;
|
|
39
|
-
}
|
|
40
|
-
this.addPropertyIfExists(properties, element, "precision");
|
|
41
|
-
this.addPropertyIfExists(properties, element, "prettyprecision");
|
|
42
|
-
}
|
|
43
|
-
const defaultValue = element.getAttribute("defaultValue");
|
|
44
|
-
const required = element.getAttribute("required") === "true";
|
|
45
|
-
const readOnly = element.getAttribute("readonly") === "true";
|
|
46
|
-
return { name, userInterface, label, defaultValue, required, readOnly, properties };
|
|
47
|
-
}
|
|
48
|
-
addPropertyIfExists(properties, element, name) {
|
|
49
|
-
const value = element.getAttribute(name);
|
|
50
|
-
if (value) {
|
|
51
|
-
properties.push({ name, value });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
buildFieldSet(dataUnit, element) {
|
|
55
|
-
const label = element.getAttribute("label");
|
|
56
|
-
const fields = Array.from(element.getElementsByTagName("FIELD")).map(f => {
|
|
57
|
-
const field = this.buildField(f);
|
|
58
|
-
dataUnit.addFieldMetadata(field);
|
|
59
|
-
return { name: field.name };
|
|
60
|
-
});
|
|
61
|
-
return { label, fields };
|
|
62
|
-
}
|
|
63
|
-
fromElements(elements, label, name, dataUnit, autoLoad) {
|
|
64
|
-
const form = {
|
|
65
|
-
name: name || label,
|
|
66
|
-
dataUnit,
|
|
67
|
-
label,
|
|
68
|
-
autoLoad
|
|
69
|
-
};
|
|
70
|
-
Array.from(elements).forEach(child => {
|
|
71
|
-
const tagName = child.tagName.toUpperCase();
|
|
72
|
-
switch (tagName) {
|
|
73
|
-
case "FIELD":
|
|
74
|
-
if (!form.items) {
|
|
75
|
-
form.items = [];
|
|
76
|
-
}
|
|
77
|
-
const f = this.buildField(child);
|
|
78
|
-
dataUnit.addFieldMetadata(f);
|
|
79
|
-
form.items.push({ name: f.name });
|
|
80
|
-
break;
|
|
81
|
-
case "FIELD-SET":
|
|
82
|
-
if (!form.items) {
|
|
83
|
-
form.items = [];
|
|
84
|
-
}
|
|
85
|
-
form.items.push(this.buildFieldSet(dataUnit, child));
|
|
86
|
-
break;
|
|
87
|
-
case "SUB-FORM":
|
|
88
|
-
if (!form.subForms) {
|
|
89
|
-
form.subForms = [];
|
|
90
|
-
}
|
|
91
|
-
const label = child.getAttribute("label") || "Subform " + (form.subForms.length + 1);
|
|
92
|
-
const name = child.getAttribute("name") || label;
|
|
93
|
-
const subDuName = child.getAttribute("dataunit");
|
|
94
|
-
let subDu;
|
|
95
|
-
if (subDuName) {
|
|
96
|
-
subDu = new DataUnit(subDuName, "noname", child.hasAttribute("many") ? "N" : "1");
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
subDu = dataUnit;
|
|
100
|
-
}
|
|
101
|
-
form.subForms.push(this.fromElements(child.children, label, name, subDu, child.getAttribute("autoload") === "true"));
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return form;
|
|
106
|
-
}
|
|
107
|
-
connectedCallback() {
|
|
108
|
-
if (!this.dataunit) {
|
|
109
|
-
this.dataunit = "dataunit_" + (this.name || this.label || new Date().getTime());
|
|
110
|
-
}
|
|
111
|
-
const du = new DataUnit(this.dataunit, "noname", this.many ? "N" : "1");
|
|
112
|
-
this.metadata = this.fromElements(this._host.children, this.label, this.name, du, this.autoload);
|
|
113
|
-
}
|
|
114
|
-
render() {
|
|
115
|
-
return h(Host, null);
|
|
116
|
-
}
|
|
117
|
-
static get is() { return "form-metadata"; }
|
|
118
|
-
static get encapsulation() { return "shadow"; }
|
|
119
|
-
static get properties() { return {
|
|
120
|
-
"name": {
|
|
121
|
-
"type": "string",
|
|
122
|
-
"mutable": false,
|
|
123
|
-
"complexType": {
|
|
124
|
-
"original": "string",
|
|
125
|
-
"resolved": "string",
|
|
126
|
-
"references": {}
|
|
127
|
-
},
|
|
128
|
-
"required": false,
|
|
129
|
-
"optional": false,
|
|
130
|
-
"docs": {
|
|
131
|
-
"tags": [],
|
|
132
|
-
"text": ""
|
|
133
|
-
},
|
|
134
|
-
"attribute": "name",
|
|
135
|
-
"reflect": false
|
|
136
|
-
},
|
|
137
|
-
"label": {
|
|
138
|
-
"type": "string",
|
|
139
|
-
"mutable": false,
|
|
140
|
-
"complexType": {
|
|
141
|
-
"original": "string",
|
|
142
|
-
"resolved": "string",
|
|
143
|
-
"references": {}
|
|
144
|
-
},
|
|
145
|
-
"required": false,
|
|
146
|
-
"optional": false,
|
|
147
|
-
"docs": {
|
|
148
|
-
"tags": [],
|
|
149
|
-
"text": ""
|
|
150
|
-
},
|
|
151
|
-
"attribute": "label",
|
|
152
|
-
"reflect": false
|
|
153
|
-
},
|
|
154
|
-
"dataunit": {
|
|
155
|
-
"type": "string",
|
|
156
|
-
"mutable": true,
|
|
157
|
-
"complexType": {
|
|
158
|
-
"original": "string",
|
|
159
|
-
"resolved": "string",
|
|
160
|
-
"references": {}
|
|
161
|
-
},
|
|
162
|
-
"required": false,
|
|
163
|
-
"optional": false,
|
|
164
|
-
"docs": {
|
|
165
|
-
"tags": [],
|
|
166
|
-
"text": ""
|
|
167
|
-
},
|
|
168
|
-
"attribute": "dataunit",
|
|
169
|
-
"reflect": false
|
|
170
|
-
},
|
|
171
|
-
"many": {
|
|
172
|
-
"type": "boolean",
|
|
173
|
-
"mutable": false,
|
|
174
|
-
"complexType": {
|
|
175
|
-
"original": "boolean",
|
|
176
|
-
"resolved": "boolean",
|
|
177
|
-
"references": {}
|
|
178
|
-
},
|
|
179
|
-
"required": false,
|
|
180
|
-
"optional": false,
|
|
181
|
-
"docs": {
|
|
182
|
-
"tags": [],
|
|
183
|
-
"text": ""
|
|
184
|
-
},
|
|
185
|
-
"attribute": "many",
|
|
186
|
-
"reflect": false
|
|
187
|
-
},
|
|
188
|
-
"autoload": {
|
|
189
|
-
"type": "boolean",
|
|
190
|
-
"mutable": false,
|
|
191
|
-
"complexType": {
|
|
192
|
-
"original": "boolean",
|
|
193
|
-
"resolved": "boolean",
|
|
194
|
-
"references": {}
|
|
195
|
-
},
|
|
196
|
-
"required": false,
|
|
197
|
-
"optional": false,
|
|
198
|
-
"docs": {
|
|
199
|
-
"tags": [],
|
|
200
|
-
"text": ""
|
|
201
|
-
},
|
|
202
|
-
"attribute": "autoload",
|
|
203
|
-
"reflect": false
|
|
204
|
-
},
|
|
205
|
-
"metadata": {
|
|
206
|
-
"type": "unknown",
|
|
207
|
-
"mutable": true,
|
|
208
|
-
"complexType": {
|
|
209
|
-
"original": "Form",
|
|
210
|
-
"resolved": "Form",
|
|
211
|
-
"references": {
|
|
212
|
-
"Form": {
|
|
213
|
-
"location": "import",
|
|
214
|
-
"path": "./FormMetadata"
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"required": false,
|
|
219
|
-
"optional": false,
|
|
220
|
-
"docs": {
|
|
221
|
-
"tags": [],
|
|
222
|
-
"text": ""
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}; }
|
|
226
|
-
static get elementRef() { return "_host"; }
|
|
227
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Component, Host, h } from "@stencil/core";
|
|
2
|
-
export class PlaceHolder {
|
|
3
|
-
render() {
|
|
4
|
-
return h(Host, null);
|
|
5
|
-
}
|
|
6
|
-
static get is() { return "place-holder"; }
|
|
7
|
-
static get encapsulation() { return "shadow"; }
|
|
8
|
-
static get originalStyleUrls() { return {
|
|
9
|
-
"$": ["css/place-holder.css"]
|
|
10
|
-
}; }
|
|
11
|
-
static get styleUrls() { return {
|
|
12
|
-
"$": ["./css/place-holder.css"]
|
|
13
|
-
}; }
|
|
14
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { DateUtils } from "@sankhyalabs/core";
|
|
2
|
-
import { h } from "@stencil/core";
|
|
3
|
-
import { DependencyType } from "../DataUnit";
|
|
4
|
-
function scrollToView(forceScroll, elem) {
|
|
5
|
-
if (forceScroll) {
|
|
6
|
-
window.requestAnimationFrame(() => elem.scrollIntoView());
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export const Field = ({ dataUnit, field, forceScroll, enabled }) => {
|
|
10
|
-
const { name, form } = field;
|
|
11
|
-
const { label, userInterface, properties, required, dependencies, readOnly } = dataUnit.getFieldMetadata(name);
|
|
12
|
-
const value = dataUnit.getValue(name) || null;
|
|
13
|
-
const loadingData = dataUnit.isLoading();
|
|
14
|
-
const formattedLabel = required ? `* ${label} (obrigatório)` : label;
|
|
15
|
-
const errorMessage = dataUnit.getErrorMessage(name);
|
|
16
|
-
const key = `${dataUnit.name}-${name}`;
|
|
17
|
-
const isEnabled = enabled && !readOnly;
|
|
18
|
-
const changeFieldHandler = (newValue) => {
|
|
19
|
-
dataUnit.changeValue(name, newValue);
|
|
20
|
-
};
|
|
21
|
-
switch (userInterface) {
|
|
22
|
-
case "LONGTEXT":
|
|
23
|
-
return h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
|
|
24
|
-
h("ez-text-area", { value: value || "", label: formattedLabel, onEzChange: evt => changeFieldHandler(evt.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, enabled: isEnabled }));
|
|
25
|
-
case "CHECKBOX":
|
|
26
|
-
case "SWITCH":
|
|
27
|
-
return h("div", { class: "col col--sd-12 col--tb-3 padding--small align--middle padding-bottom--large" }, loadingData ? h("place-holder", null) :
|
|
28
|
-
h("ez-check", { value: value, label: label, enabled: isEnabled, mode: userInterface === "CHECKBOX" ? "regular" : "switch", onEzChange: (event) => changeFieldHandler(event.target["value"]), ref: elem => scrollToView(forceScroll, elem), key: key }));
|
|
29
|
-
case "OPTIONSELECTOR":
|
|
30
|
-
const optsObj = properties ? JSON.parse(getProp(properties, "options")) : {};
|
|
31
|
-
const normalized = Object.keys(optsObj).map(key => { return { value: key, label: optsObj[key] }; });
|
|
32
|
-
return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
|
|
33
|
-
h("ez-combo-box", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, options: normalized }));
|
|
34
|
-
case "SEARCH":
|
|
35
|
-
const context = {
|
|
36
|
-
__MAIN_FORM: form,
|
|
37
|
-
__DATA_UNIT: dataUnit.name,
|
|
38
|
-
__FIELD_NAME: name
|
|
39
|
-
};
|
|
40
|
-
properties.forEach(({ name, value }) => {
|
|
41
|
-
context[name] = value;
|
|
42
|
-
});
|
|
43
|
-
let criteriaList = [];
|
|
44
|
-
dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
|
|
45
|
-
var _a;
|
|
46
|
-
if (dependency.type === DependencyType.SEARCHING) {
|
|
47
|
-
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
48
|
-
let criteria = {
|
|
49
|
-
expression: dependency.expression,
|
|
50
|
-
paramNames: [...dependency.masterFields],
|
|
51
|
-
paramResolver: name => dataUnit.getValue(name)
|
|
52
|
-
};
|
|
53
|
-
criteriaList.push(criteria);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
if (criteriaList.length > 0) {
|
|
58
|
-
context["CRITERIA"] = criteriaList;
|
|
59
|
-
}
|
|
60
|
-
return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
|
|
61
|
-
h("ez-search", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, optionLoader: (argument) => {
|
|
62
|
-
if (form) {
|
|
63
|
-
return form.loadSearch(argument, context);
|
|
64
|
-
}
|
|
65
|
-
}, ref: elem => scrollToView(forceScroll, elem), key: key }));
|
|
66
|
-
case "FILE":
|
|
67
|
-
const target = getProp(properties, "URL");
|
|
68
|
-
const strHeaders = getProp(properties, "HEADERS");
|
|
69
|
-
const headers = strHeaders ? JSON.parse(strHeaders) : {};
|
|
70
|
-
const maxfiles = Number(getProp(properties, "maxfiles") || 0);
|
|
71
|
-
return (h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
|
|
72
|
-
h("ez-upload", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.detail), urlUpload: target, requestHeaders: headers, maxFiles: maxfiles })));
|
|
73
|
-
case "DATE":
|
|
74
|
-
return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
|
|
75
|
-
h("ez-date-input", { value: !value ? null : DateUtils.clearTime(value), label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
|
|
76
|
-
case "DECIMALNUMBER":
|
|
77
|
-
case "INTEGERNUMBER":
|
|
78
|
-
let precision = 0;
|
|
79
|
-
let prettyPrecision = 0;
|
|
80
|
-
if (userInterface === "DECIMALNUMBER") {
|
|
81
|
-
precision = Number(getProp(properties, "precision") || 2);
|
|
82
|
-
prettyPrecision = Number(getProp(properties, "prettyprecision") || precision);
|
|
83
|
-
}
|
|
84
|
-
return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
|
|
85
|
-
h("ez-numeric-input", { value: !value ? null : value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, precision: precision, prettyprecision: prettyPrecision, ref: elem => scrollToView(forceScroll, elem), key: key }));
|
|
86
|
-
//IMAGE, DATETIME, ELAPSEDTIME, PASSWORD, MASKEDTEXT, HTML
|
|
87
|
-
default:
|
|
88
|
-
return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
|
|
89
|
-
h("ez-text-input", { value: value, label: formattedLabel, enabled: isEnabled, loading: loadingData, onInput: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
function getProp(properties, name) {
|
|
93
|
-
var _a;
|
|
94
|
-
return properties ? (_a = properties.find(prop => prop.name === name)) === null || _a === void 0 ? void 0 : _a.value : null;
|
|
95
|
-
}
|