@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-77126.0 → 0.0.0-bugfix-dev-KB-77074.0
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/RecordValidationProcessor-10846595.js +108 -0
- package/dist/cjs/ez-card-item_3.cjs.entry.js +19 -12
- package/dist/cjs/ez-chart.cjs.entry.js +1 -1
- package/dist/cjs/ez-combo-box.cjs.entry.js +10 -46
- package/dist/cjs/ez-date-input.cjs.entry.js +2 -8
- package/dist/cjs/ez-date-time-input.cjs.entry.js +2 -8
- package/dist/cjs/ez-dialog.cjs.entry.js +2 -10
- package/dist/cjs/ez-form-view.cjs.entry.js +2 -2
- package/dist/cjs/ez-form.cjs.entry.js +324 -4
- package/dist/cjs/ez-grid.cjs.entry.js +70542 -14645
- package/dist/cjs/ez-list.cjs.entry.js +100 -151
- package/dist/cjs/ez-number-input.cjs.entry.js +0 -7
- package/dist/cjs/ez-popover.cjs.entry.js +1 -1
- package/dist/cjs/ez-popup.cjs.entry.js +1 -1
- package/dist/cjs/ez-search.cjs.entry.js +12 -28
- package/dist/cjs/ez-text-area.cjs.entry.js +4 -66
- package/dist/cjs/ez-text-input.cjs.entry.js +7 -49
- package/dist/cjs/ez-time-input.cjs.entry.js +0 -6
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/ez-card-item/ez-card-item.css +5 -14
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +14 -75
- package/dist/collection/components/ez-date-input/ez-date-input.js +4 -35
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +4 -35
- package/dist/collection/components/ez-dialog/ez-dialog.css +3 -3
- package/dist/collection/components/ez-dialog/ez-dialog.js +1 -9
- package/dist/collection/components/ez-filter-input/ez-filter-input.css +11 -0
- package/dist/collection/components/ez-filter-input/ez-filter-input.js +52 -22
- package/dist/collection/components/ez-form/ez-form.js +0 -1
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.js +2 -2
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +25 -80
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +0 -8
- package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +46 -167
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +0 -7
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +0 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +0 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +0 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +0 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +1 -4
- package/dist/collection/components/ez-grid/ez-grid.js +3 -90
- package/dist/collection/components/ez-list/ez-list.css +5 -5
- package/dist/collection/components/ez-list/ez-list.js +170 -152
- package/dist/collection/components/ez-number-input/ez-number-input.js +0 -25
- package/dist/collection/components/ez-popover/ez-popover.css +10 -3
- package/dist/collection/components/ez-popup/ez-popup.js +1 -1
- package/dist/collection/components/ez-search/ez-search.css +1 -1
- package/dist/collection/components/ez-search/ez-search.js +14 -55
- package/dist/collection/components/ez-text-area/ez-text-area.css +0 -49
- package/dist/collection/components/ez-text-area/ez-text-area.js +2 -102
- package/dist/collection/components/ez-text-input/ez-text-input.css +53 -27
- package/dist/collection/components/ez-text-input/ez-text-input.js +6 -84
- package/dist/collection/components/ez-time-input/ez-time-input.js +0 -24
- package/dist/collection/utils/form/DataBinder.js +3 -18
- package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +1 -1
- package/dist/custom-elements/index.js +70890 -15272
- package/dist/esm/RecordValidationProcessor-9c6cc267.js +105 -0
- package/dist/esm/ez-card-item_3.entry.js +19 -12
- package/dist/esm/ez-chart.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +11 -47
- package/dist/esm/ez-date-input.entry.js +2 -8
- package/dist/esm/ez-date-time-input.entry.js +2 -8
- package/dist/esm/ez-dialog.entry.js +2 -10
- package/dist/esm/ez-form-view.entry.js +2 -2
- package/dist/esm/ez-form.entry.js +323 -3
- package/dist/esm/ez-grid.entry.js +70542 -14645
- package/dist/esm/ez-list.entry.js +101 -152
- package/dist/esm/ez-number-input.entry.js +0 -7
- package/dist/esm/ez-popover.entry.js +1 -1
- package/dist/esm/ez-popup.entry.js +1 -1
- package/dist/esm/ez-search.entry.js +12 -28
- package/dist/esm/ez-text-area.entry.js +4 -66
- package/dist/esm/ez-text-input.entry.js +7 -49
- package/dist/esm/ez-time-input.entry.js +0 -6
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-188f1c4c.entry.js +1 -0
- package/dist/ezui/p-49456b34.entry.js +1 -0
- package/dist/ezui/p-5a90d7d1.entry.js +1 -0
- package/dist/ezui/p-5b205c80.entry.js +1 -0
- package/dist/ezui/p-62732269.entry.js +1 -0
- package/dist/ezui/p-86b6aa01.entry.js +1 -0
- package/dist/ezui/p-b3b94f72.entry.js +1 -0
- package/dist/ezui/p-b95632e8.entry.js +1 -0
- package/dist/ezui/p-bcd47eda.entry.js +1 -0
- package/dist/ezui/p-c3c3d640.entry.js +304 -0
- package/dist/ezui/p-cdc472cc.entry.js +1 -0
- package/dist/ezui/p-d2c06f38.entry.js +1 -0
- package/dist/ezui/p-d8f64bb7.entry.js +1 -0
- package/dist/ezui/p-dc4ada32.entry.js +1 -0
- package/dist/ezui/p-e85c48d7.entry.js +1 -0
- package/dist/ezui/p-f299c608.entry.js +1 -0
- package/dist/ezui/p-f42855b9.js +1 -0
- package/dist/ezui/p-f80ac647.entry.js +1 -0
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +1 -7
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +1 -6
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +1 -6
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +0 -2
- package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +11 -4
- package/dist/types/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +0 -12
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +2 -7
- package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +1 -2
- package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -19
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +1 -3
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/components/cellRendererStatus.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/components/selectionHeader.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +0 -1
- package/dist/types/components/ez-grid/controller/ag-grid/mock/Server.d.ts +1 -1
- package/dist/types/components/ez-grid/ez-grid.d.ts +1 -11
- package/dist/types/components/ez-list/ez-list.d.ts +26 -3
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +0 -4
- package/dist/types/components/ez-search/ez-search.d.ts +1 -6
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +0 -17
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +0 -9
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +0 -4
- package/dist/types/components.d.ts +42 -107
- package/dist/types/utils/form/DataBinder.d.ts +0 -3
- package/package.json +4 -11
- package/dist/cjs/DataBinder-3b083480.js +0 -445
- package/dist/cjs/FocusResolver-885f2173.js +0 -35
- package/dist/collection/utils/FocusResolver.js +0 -31
- package/dist/esm/DataBinder-02fa9bb9.js +0 -441
- package/dist/esm/FocusResolver-1ccbf850.js +0 -33
- package/dist/ezui/p-0a75bb05.entry.js +0 -1
- package/dist/ezui/p-0db68715.entry.js +0 -1
- package/dist/ezui/p-19098a3f.entry.js +0 -1
- package/dist/ezui/p-1f830a2f.entry.js +0 -1
- package/dist/ezui/p-2aa8e4b2.entry.js +0 -1
- package/dist/ezui/p-3dd919b7.entry.js +0 -1
- package/dist/ezui/p-455e737c.js +0 -1
- package/dist/ezui/p-8d0f02c7.entry.js +0 -309
- package/dist/ezui/p-91266ddd.entry.js +0 -1
- package/dist/ezui/p-97af4b13.entry.js +0 -1
- package/dist/ezui/p-a5b91a77.entry.js +0 -1
- package/dist/ezui/p-a80b1287.entry.js +0 -1
- package/dist/ezui/p-b54e17d2.entry.js +0 -1
- package/dist/ezui/p-bfad39eb.entry.js +0 -1
- package/dist/ezui/p-c27b2e17.entry.js +0 -1
- package/dist/ezui/p-cd2e78f0.entry.js +0 -1
- package/dist/ezui/p-d0ca26fe.entry.js +0 -1
- package/dist/ezui/p-dc628ed3.js +0 -1
- package/dist/ezui/p-ffd246f5.entry.js +0 -1
- package/dist/types/utils/FocusResolver.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sankhyalabs/ezui",
|
|
3
|
-
"version": "0.0.0-bugfix-dev-KB-
|
|
3
|
+
"version": "0.0.0-bugfix-dev-KB-77074.0",
|
|
4
4
|
"description": "Biblioteca de componentes Sankhya.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/custom-elements/index.js",
|
|
@@ -46,17 +46,9 @@
|
|
|
46
46
|
"author": "",
|
|
47
47
|
"license": "ISC",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@ag-grid-community/core": "^28.1.1",
|
|
50
|
-
"@ag-grid-community/styles": "^28.1.1",
|
|
51
|
-
"@ag-grid-enterprise/clipboard": "^28.1.1",
|
|
52
|
-
"@ag-grid-enterprise/core": "^28.1.1",
|
|
53
|
-
"@ag-grid-enterprise/menu": "^28.1.1",
|
|
54
|
-
"@ag-grid-enterprise/range-selection": "^28.1.1",
|
|
55
|
-
"@ag-grid-enterprise/server-side-row-model": "^28.1.1",
|
|
56
49
|
"@babel/preset-env": "^7.16.11",
|
|
57
50
|
"@commitlint/cli": "^18.4.3",
|
|
58
51
|
"@commitlint/config-conventional": "^18.4.3",
|
|
59
|
-
"@rollup/plugin-strip": "^3.0.4",
|
|
60
52
|
"@sankhyalabs/core": "^5.16.0",
|
|
61
53
|
"@sankhyalabs/docscss": "^1.0.4",
|
|
62
54
|
"@sankhyalabs/ez-design": "^4.0.0",
|
|
@@ -70,6 +62,8 @@
|
|
|
70
62
|
"@types/jest": "^26.0.20",
|
|
71
63
|
"@types/puppeteer": "^5.4.2",
|
|
72
64
|
"@types/uuid": "^9.0.2",
|
|
65
|
+
"ag-grid-community": "^28.1.1",
|
|
66
|
+
"ag-grid-enterprise": "^28.1.1",
|
|
73
67
|
"gulp": "^4.0.2",
|
|
74
68
|
"gulp-run": "^1.7.1",
|
|
75
69
|
"gulp-watch": "^5.0.1",
|
|
@@ -106,6 +100,5 @@
|
|
|
106
100
|
},
|
|
107
101
|
"resolutions": {
|
|
108
102
|
"postcss": "8.1.7"
|
|
109
|
-
}
|
|
110
|
-
"dependencies": {}
|
|
103
|
+
}
|
|
111
104
|
}
|
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const core = require('@sankhyalabs/core');
|
|
4
|
-
const ApplicationUtils = require('./ApplicationUtils-c9d1205c.js');
|
|
5
|
-
|
|
6
|
-
const buildFieldMetadata = (descriptor, config) => {
|
|
7
|
-
let { name, label, group } = Object.assign({}, config);
|
|
8
|
-
let { readOnly, required } = Object.assign({}, config);
|
|
9
|
-
let props;
|
|
10
|
-
let userInterface;
|
|
11
|
-
if (descriptor) {
|
|
12
|
-
label = label || descriptor.label;
|
|
13
|
-
name = name || descriptor.name;
|
|
14
|
-
required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
|
|
15
|
-
readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
|
|
16
|
-
props = descriptor.properties;
|
|
17
|
-
userInterface = descriptor.userInterface;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
name, label, group,
|
|
21
|
-
readOnly, required,
|
|
22
|
-
props,
|
|
23
|
-
userInterface: userInterface || core.UserInterface.SHORTTEXT,
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
class RecordValidationProcessor {
|
|
28
|
-
constructor(dataUnit, validationSource, validator) {
|
|
29
|
-
this._dataUnit = dataUnit;
|
|
30
|
-
this._validationSource = validationSource;
|
|
31
|
-
this._validator = validator;
|
|
32
|
-
}
|
|
33
|
-
validate(isSaving = true) {
|
|
34
|
-
return new Promise((accept, reject) => {
|
|
35
|
-
const records = this._dataUnit.getModifiedRecords();
|
|
36
|
-
for (let i = 0; i < records.length; i++) {
|
|
37
|
-
const record = records[i];
|
|
38
|
-
const invalidResults = [];
|
|
39
|
-
let validationResult = this.validateRequired(record);
|
|
40
|
-
if (validationResult && !validationResult.isValid) {
|
|
41
|
-
invalidResults.push(validationResult);
|
|
42
|
-
}
|
|
43
|
-
if (this._validator) {
|
|
44
|
-
validationResult = this._validator.validateRecord(record);
|
|
45
|
-
if (validationResult && !validationResult.isValid) {
|
|
46
|
-
invalidResults.push(validationResult);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (invalidResults.length > 0) {
|
|
50
|
-
if (!isSaving && invalidResults[0].invalidFields.length > 0) {
|
|
51
|
-
this._validationSource.markAsInvalid(invalidResults[0].invalidFields[0], record.__record__id__);
|
|
52
|
-
reject();
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
this.processValidationResult(invalidResults, record.__record__id__);
|
|
56
|
-
reject();
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return accept();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
validateRequired(record) {
|
|
64
|
-
const requiredFields = this._validationSource.getRequiredFields();
|
|
65
|
-
const invalidFields = [];
|
|
66
|
-
new Set(requiredFields).forEach(field => {
|
|
67
|
-
const value = record[field];
|
|
68
|
-
if (value == undefined || value === "") {
|
|
69
|
-
const errorMessage = this._validationSource.getMessageForField(field, record.__record__id__);
|
|
70
|
-
if (errorMessage) {
|
|
71
|
-
invalidFields.push({ name: field, message: errorMessage });
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
if (invalidFields.length > 0) {
|
|
79
|
-
return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
|
|
80
|
-
}
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
processValidationResult(validationResult, recordId) {
|
|
84
|
-
validationResult.forEach(invalidResult => {
|
|
85
|
-
const invalidFields = invalidResult.invalidFields;
|
|
86
|
-
this._dataUnit.savingCanceled(invalidFields, recordId);
|
|
87
|
-
if (invalidFields) {
|
|
88
|
-
invalidFields.forEach(field => {
|
|
89
|
-
this.markAsInvalid(field, recordId);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
if (invalidResult.infoMessage) {
|
|
93
|
-
ApplicationUtils.ApplicationUtils.info(invalidResult.infoMessage);
|
|
94
|
-
}
|
|
95
|
-
if (invalidResult.errorMessage) {
|
|
96
|
-
const { errorTitle, errorMessage } = invalidResult;
|
|
97
|
-
ApplicationUtils.ApplicationUtils.error(errorTitle, errorMessage);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
markAsInvalid(field, recordId) {
|
|
102
|
-
this._dataUnit.setInvalidField(field.name, field.message, recordId);
|
|
103
|
-
this._validationSource.markAsInvalid(field, recordId);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
class DataBinder {
|
|
108
|
-
constructor(dataUnit) {
|
|
109
|
-
this.onDataUnitEvent = (action) => {
|
|
110
|
-
var _a, _b;
|
|
111
|
-
switch (action.type) {
|
|
112
|
-
case core.Action.DATA_LOADED:
|
|
113
|
-
case core.Action.DATA_SAVED:
|
|
114
|
-
case core.Action.RECORDS_REMOVED:
|
|
115
|
-
case core.Action.RECORDS_ADDED:
|
|
116
|
-
case core.Action.RECORDS_COPIED:
|
|
117
|
-
case core.Action.EDITION_CANCELED:
|
|
118
|
-
case core.Action.SELECTION_CHANGED:
|
|
119
|
-
case core.Action.NEXT_SELECTED:
|
|
120
|
-
case core.Action.PREVIOUS_SELECTED:
|
|
121
|
-
this.clearInvalid();
|
|
122
|
-
case core.Action.DATA_CHANGED:
|
|
123
|
-
case core.Action.CHANGE_UNDONE:
|
|
124
|
-
case core.Action.CHANGE_REDONE:
|
|
125
|
-
case core.Action.RECORD_LOADED:
|
|
126
|
-
(_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
127
|
-
this.updateValue(field.fieldName, field.field);
|
|
128
|
-
});
|
|
129
|
-
this.clearFieldError(Object.keys(action.payload)[0]);
|
|
130
|
-
break;
|
|
131
|
-
case core.Action.FIELD_INVALIDATED:
|
|
132
|
-
(_b = this._fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
|
|
133
|
-
this.updateErrorMessage(field.fieldName, field.field);
|
|
134
|
-
});
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
this._uuid = core.StringUtils.generateUUID();
|
|
139
|
-
this._fields = new Map();
|
|
140
|
-
this._dataUnit = dataUnit;
|
|
141
|
-
this.applyDefaultValues();
|
|
142
|
-
this._dataUnit.subscribe(this.onDataUnitEvent);
|
|
143
|
-
this._dataUnit.addInterceptor(this);
|
|
144
|
-
this.setContextDataBinder(dataUnit);
|
|
145
|
-
}
|
|
146
|
-
get dataBinderId() {
|
|
147
|
-
return this._uuid;
|
|
148
|
-
}
|
|
149
|
-
setContextDataBinder(dataUnit) {
|
|
150
|
-
const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
151
|
-
const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
|
|
152
|
-
dataBindersByDataUnit.set(dataUnit.dataUnitId, dataBinders);
|
|
153
|
-
core.ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
|
|
154
|
-
}
|
|
155
|
-
applyDefaultValues() {
|
|
156
|
-
const recordIds = (this._dataUnit.getAddedRecords() || []).map(r => r.__record__id__);
|
|
157
|
-
if (recordIds.length > 0) {
|
|
158
|
-
const defaultValues = this.getDefaultValues();
|
|
159
|
-
if (defaultValues) {
|
|
160
|
-
Object.keys(defaultValues).forEach(field => {
|
|
161
|
-
this._dataUnit.setFieldValue(field, defaultValues[field], recordIds);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
bind(fields, currentContextName, formMetadata, recordsValidator) {
|
|
167
|
-
fields.forEach(fieldElement => {
|
|
168
|
-
const { fieldName, contextName } = fieldElement.dataset;
|
|
169
|
-
if (contextName == undefined || contextName === currentContextName) {
|
|
170
|
-
this.updateBind(fieldName, fieldElement);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
this._formMetadata = formMetadata;
|
|
174
|
-
this._recordValidatorProcessor = new RecordValidationProcessor(this._dataUnit, {
|
|
175
|
-
getRequiredFields: () => this.getFormRequiredFields(),
|
|
176
|
-
markAsInvalid: field => this.markInvalid(field),
|
|
177
|
-
getMessageForField: field => this.getErrorMessage(field),
|
|
178
|
-
}, recordsValidator);
|
|
179
|
-
}
|
|
180
|
-
getFormRequiredFields() {
|
|
181
|
-
return this._formMetadata.getRequiredFields();
|
|
182
|
-
}
|
|
183
|
-
disconnectDataUnit() {
|
|
184
|
-
const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
185
|
-
const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
|
|
186
|
-
const dataBindersFiltered = dataBinders.filter((dataBinder) => dataBinder.dataBinderId !== this.dataBinderId);
|
|
187
|
-
dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
|
|
188
|
-
core.ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
|
|
189
|
-
}
|
|
190
|
-
onDisconnectedCallback() {
|
|
191
|
-
this._dataUnit.unsubscribe(this.onDataUnitEvent);
|
|
192
|
-
this._dataUnit.removeInterceptor(this);
|
|
193
|
-
this.disconnectDataUnit();
|
|
194
|
-
}
|
|
195
|
-
getCurrentRecordId() {
|
|
196
|
-
const record = this._dataUnit.getSelectedRecord();
|
|
197
|
-
return record === null || record === void 0 ? void 0 : record.__record__id__;
|
|
198
|
-
}
|
|
199
|
-
markInvalid(field) {
|
|
200
|
-
if (this._fields.has(field.name)) {
|
|
201
|
-
const fieldElement = this._fields.get(field.name).field;
|
|
202
|
-
this.updateErrorMessage(field.name, fieldElement, field.message);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
setFocus(fieldName) {
|
|
206
|
-
if (!this._fields.has(fieldName)) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const fieldElement = this._fields.get(fieldName).field;
|
|
210
|
-
if (typeof fieldElement["setFocus"] != "function") {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
fieldElement["setFocus"]();
|
|
214
|
-
}
|
|
215
|
-
clearInvalid(recordId) {
|
|
216
|
-
this._dataUnit.clearInvalid(recordId);
|
|
217
|
-
this._fields.forEach(fieldBinder => {
|
|
218
|
-
const fieldElement = fieldBinder.field;
|
|
219
|
-
fieldElement["errorMessage"] = "";
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
clearFieldError(fieldName) {
|
|
223
|
-
var _a;
|
|
224
|
-
const field = (_a = this._fields.get(fieldName)) === null || _a === void 0 ? void 0 : _a.field;
|
|
225
|
-
if (field["errorMessage"]) {
|
|
226
|
-
field["errorMessage"] = "";
|
|
227
|
-
this._dataUnit.clearInvalid(this.getCurrentRecordId(), fieldName);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
updateValue(fieldName, field) {
|
|
231
|
-
const bind = this._fields.get(fieldName);
|
|
232
|
-
try {
|
|
233
|
-
if (bind) {
|
|
234
|
-
bind.listen = false;
|
|
235
|
-
}
|
|
236
|
-
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
237
|
-
this.updateErrorMessage(fieldName, field);
|
|
238
|
-
}
|
|
239
|
-
finally {
|
|
240
|
-
if (bind) {
|
|
241
|
-
bind.listen = true;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
validate() {
|
|
246
|
-
return this._recordValidatorProcessor.validate();
|
|
247
|
-
}
|
|
248
|
-
static async validateByDataunit(dataUnit) {
|
|
249
|
-
try {
|
|
250
|
-
const dataBinders = this.getDataBindersByDataUnit(dataUnit);
|
|
251
|
-
await Promise.all(dataBinders.map((dataBinder) => dataBinder.validate()));
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
catch (_a) {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
static getDataBindersByDataUnit(dataUnit) {
|
|
259
|
-
const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__");
|
|
260
|
-
return dataBindersByDataUnit.get(dataUnit.dataUnitId) || [];
|
|
261
|
-
}
|
|
262
|
-
updateErrorMessage(fieldName, field, message) {
|
|
263
|
-
if (message == undefined) {
|
|
264
|
-
message = this._dataUnit.getInvalidMessage(this.getCurrentRecordId(), fieldName);
|
|
265
|
-
}
|
|
266
|
-
if (!field["errorMessage"]) {
|
|
267
|
-
field["errorMessage"] = message;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
getErrorMessage(fieldName) {
|
|
271
|
-
if (this._fields.has(fieldName)) {
|
|
272
|
-
const fieldElement = this._fields.get(fieldName).field;
|
|
273
|
-
return fieldElement["errorMessage"];
|
|
274
|
-
}
|
|
275
|
-
return undefined;
|
|
276
|
-
}
|
|
277
|
-
updateBind(fieldName, field) {
|
|
278
|
-
const oldBind = this._fields.get(fieldName);
|
|
279
|
-
if (oldBind) {
|
|
280
|
-
oldBind.destroy();
|
|
281
|
-
}
|
|
282
|
-
this.bindSearchOptionsLoader(fieldName, field);
|
|
283
|
-
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
284
|
-
this.updateErrorMessage(fieldName, field);
|
|
285
|
-
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName) => this.cancelWaitingChange(fieldName), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
286
|
-
this.applyEzUploadContext(fieldName, field);
|
|
287
|
-
}
|
|
288
|
-
changeStarted(fieldName, waitingChange) {
|
|
289
|
-
/**
|
|
290
|
-
* se o waitingChange não é blocante, add um event listener pra
|
|
291
|
-
* fazer o accept da promise
|
|
292
|
-
*
|
|
293
|
-
* se não tiver promise no waitingChange, eu crio uma e resolvo no bind
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*/
|
|
297
|
-
if (this._dataUnit.records.length === 0) {
|
|
298
|
-
this._dataUnit.addRecord();
|
|
299
|
-
}
|
|
300
|
-
if (!waitingChange.blocking && waitingChange.promise == undefined) {
|
|
301
|
-
const bind = this._fields.get(fieldName);
|
|
302
|
-
if (bind) {
|
|
303
|
-
waitingChange.promise = new Promise((resolve, reject) => {
|
|
304
|
-
bind.waitingChangePromiseResolve = resolve;
|
|
305
|
-
bind.waitingChangePromiseReject = reject;
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
this._dataUnit.startChange(fieldName, waitingChange);
|
|
310
|
-
}
|
|
311
|
-
cancelWaitingChange(fieldName) {
|
|
312
|
-
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
313
|
-
this._dataUnit.cancelWaitingChange(fieldName);
|
|
314
|
-
const bind = this._fields.get(fieldName);
|
|
315
|
-
if (bind) {
|
|
316
|
-
bind.rejectWaitingChange(new core.WaitingChangeException("Change canceled", fieldName));
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
setFieldValue(fieldName, newValue) {
|
|
321
|
-
if (this._dataUnit.records.length === 0) {
|
|
322
|
-
this._dataUnit.addRecord();
|
|
323
|
-
}
|
|
324
|
-
this._dataUnit.clearInvalid(this.getCurrentRecordId(), fieldName);
|
|
325
|
-
const record = this._dataUnit.getSelectedRecord();
|
|
326
|
-
this._dataUnit.setFieldValue(fieldName, newValue, record ? [record.__record__id__] : undefined);
|
|
327
|
-
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
328
|
-
const bind = this._fields.get(fieldName);
|
|
329
|
-
if (bind) {
|
|
330
|
-
bind.acceptWaitingChange();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
bindSearchOptionsLoader(fieldName, field) {
|
|
335
|
-
if (field.nodeName === "EZ-SEARCH" && field["optionLoader"] == undefined) {
|
|
336
|
-
const loader = core.ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
|
|
337
|
-
if (loader) {
|
|
338
|
-
field["optionLoader"] = (arg) => {
|
|
339
|
-
return loader(arg, fieldName, this._dataUnit);
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
applyEzUploadContext(fieldName, field) {
|
|
345
|
-
var _a, _b;
|
|
346
|
-
if (field.nodeName === "EZ-UPLOAD") {
|
|
347
|
-
field["urlUpload"] = core.ApplicationContext.getContextValue("__EZUI__UPLOAD__ADD__URL__");
|
|
348
|
-
field["urlDelete"] = core.ApplicationContext.getContextValue("__EZUI__UPLOAD__DEL__URL__");
|
|
349
|
-
const descriptor = this._dataUnit.getField(fieldName);
|
|
350
|
-
const destination = (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.DESTINATION;
|
|
351
|
-
if (destination) {
|
|
352
|
-
field["requestHeaders"] = { XTRAINF: `{"destination": "${destination}"}` };
|
|
353
|
-
}
|
|
354
|
-
field["maxFiles"] = ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.MAX_FILES) || 0;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
interceptAction(action) {
|
|
358
|
-
if (action.type === core.Action.RECORDS_COPIED) {
|
|
359
|
-
const cleanFields = this._formMetadata.getCleanOnCopyFields();
|
|
360
|
-
if (cleanFields) {
|
|
361
|
-
const records = action.payload;
|
|
362
|
-
return new core.DataUnitAction(core.Action.RECORDS_COPIED, records.map(record => {
|
|
363
|
-
const newRecord = Object.assign({}, record);
|
|
364
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
365
|
-
return newRecord;
|
|
366
|
-
}));
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (action.type === core.Action.SAVING_DATA) {
|
|
370
|
-
return new Promise((resolve) => {
|
|
371
|
-
this.validate()
|
|
372
|
-
.then(() => resolve(action))
|
|
373
|
-
.catch(() => { });
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
if (action.type === core.Action.RECORDS_ADDED) {
|
|
377
|
-
const defaultValues = this.getDefaultValues();
|
|
378
|
-
if (defaultValues) {
|
|
379
|
-
const records = action.payload;
|
|
380
|
-
return new core.DataUnitAction(core.Action.RECORDS_ADDED, records.map(record => {
|
|
381
|
-
return Object.assign(Object.assign({}, record), defaultValues);
|
|
382
|
-
}));
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return action;
|
|
386
|
-
}
|
|
387
|
-
getDefaultValues() {
|
|
388
|
-
var _a;
|
|
389
|
-
const rawDefaultValues = (_a = this._formMetadata) === null || _a === void 0 ? void 0 : _a.getDefaultValues();
|
|
390
|
-
if (rawDefaultValues) {
|
|
391
|
-
const defaultValues = {};
|
|
392
|
-
for (const field in rawDefaultValues) {
|
|
393
|
-
defaultValues[field] = this._dataUnit.valueFromString(field, rawDefaultValues[field]);
|
|
394
|
-
}
|
|
395
|
-
return defaultValues;
|
|
396
|
-
}
|
|
397
|
-
return undefined;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
class Bind {
|
|
401
|
-
constructor() {
|
|
402
|
-
this.listen = true;
|
|
403
|
-
this.startChangeEventName = "ezStartChange";
|
|
404
|
-
this.cancelWaitingChangeEventName = "ezCancelWaitingChange";
|
|
405
|
-
this.changeEventName = "ezChange";
|
|
406
|
-
}
|
|
407
|
-
destroy() {
|
|
408
|
-
this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
|
|
409
|
-
this.field.removeEventListener(this.cancelWaitingChangeEventName, this.cancelWaitingChangeListener);
|
|
410
|
-
this.field.removeEventListener(this.changeEventName, this.changeListener);
|
|
411
|
-
}
|
|
412
|
-
acceptWaitingChange() {
|
|
413
|
-
if (this.waitingChangePromiseResolve) {
|
|
414
|
-
this.waitingChangePromiseResolve();
|
|
415
|
-
this.waitingChangePromiseReject = undefined;
|
|
416
|
-
this.waitingChangePromiseResolve = undefined;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
rejectWaitingChange(reason) {
|
|
420
|
-
if (this.waitingChangePromiseReject) {
|
|
421
|
-
this.waitingChangePromiseReject(reason);
|
|
422
|
-
this.waitingChangePromiseReject = undefined;
|
|
423
|
-
this.waitingChangePromiseResolve = undefined;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
static create(fieldName, field, startChangeCallback, cancelWaitingChangeCallback, changeCallback) {
|
|
427
|
-
const b = new Bind();
|
|
428
|
-
b.field = field;
|
|
429
|
-
b.fieldName = fieldName;
|
|
430
|
-
b.startChangeListener = (evt) => { if (b.listen)
|
|
431
|
-
startChangeCallback(fieldName, evt.detail); };
|
|
432
|
-
b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
|
|
433
|
-
b.cancelWaitingChangeListener = () => { if (b.listen)
|
|
434
|
-
cancelWaitingChangeCallback(fieldName); };
|
|
435
|
-
b.field.addEventListener(b.cancelWaitingChangeEventName, b.cancelWaitingChangeListener);
|
|
436
|
-
b.changeListener = (evt) => { if (b.listen)
|
|
437
|
-
changeCallback(fieldName, evt.detail); };
|
|
438
|
-
b.field.addEventListener(b.changeEventName, b.changeListener);
|
|
439
|
-
return b;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
exports.DataBinder = DataBinder;
|
|
444
|
-
exports.RecordValidationProcessor = RecordValidationProcessor;
|
|
445
|
-
exports.buildFieldMetadata = buildFieldMetadata;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class FocusResolver {
|
|
4
|
-
static resolveFocus(element, selectText = true) {
|
|
5
|
-
var _a;
|
|
6
|
-
if (!element)
|
|
7
|
-
return;
|
|
8
|
-
(_a = element.focus) === null || _a === void 0 ? void 0 : _a.call(element);
|
|
9
|
-
if (element.setFocus) {
|
|
10
|
-
element.setFocus({ selectText });
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
this.resolveFocusOnChild(element, selectText);
|
|
14
|
-
}
|
|
15
|
-
static resolveFocusOnChild(element, selectText = true) {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
if (this.isGridCell(element) && element.firstElementChild) {
|
|
18
|
-
this.resolveFocusOnChild(element.firstElementChild);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!element || !element.classList.contains('hydrated'))
|
|
22
|
-
return;
|
|
23
|
-
const firstChild = element.firstElementChild;
|
|
24
|
-
if (!(firstChild === null || firstChild === void 0 ? void 0 : firstChild.focus) && !(firstChild === null || firstChild === void 0 ? void 0 : firstChild.setFocus))
|
|
25
|
-
return;
|
|
26
|
-
(_a = firstChild === null || firstChild === void 0 ? void 0 : firstChild.focus) === null || _a === void 0 ? void 0 : _a.call(firstChild);
|
|
27
|
-
(_b = firstChild === null || firstChild === void 0 ? void 0 : firstChild.setFocus) === null || _b === void 0 ? void 0 : _b.call(firstChild, { selectText });
|
|
28
|
-
}
|
|
29
|
-
static isGridCell(element) {
|
|
30
|
-
var _a;
|
|
31
|
-
return ((_a = element === null || element === void 0 ? void 0 : element.getAttribute) === null || _a === void 0 ? void 0 : _a.call(element, "role")) === 'gridcell';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.FocusResolver = FocusResolver;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default class FocusResolver {
|
|
2
|
-
static resolveFocus(element, selectText = true) {
|
|
3
|
-
var _a;
|
|
4
|
-
if (!element)
|
|
5
|
-
return;
|
|
6
|
-
(_a = element.focus) === null || _a === void 0 ? void 0 : _a.call(element);
|
|
7
|
-
if (element.setFocus) {
|
|
8
|
-
element.setFocus({ selectText });
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
this.resolveFocusOnChild(element, selectText);
|
|
12
|
-
}
|
|
13
|
-
static resolveFocusOnChild(element, selectText = true) {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
if (this.isGridCell(element) && element.firstElementChild) {
|
|
16
|
-
this.resolveFocusOnChild(element.firstElementChild);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!element || !element.classList.contains('hydrated'))
|
|
20
|
-
return;
|
|
21
|
-
const firstChild = element.firstElementChild;
|
|
22
|
-
if (!(firstChild === null || firstChild === void 0 ? void 0 : firstChild.focus) && !(firstChild === null || firstChild === void 0 ? void 0 : firstChild.setFocus))
|
|
23
|
-
return;
|
|
24
|
-
(_a = firstChild === null || firstChild === void 0 ? void 0 : firstChild.focus) === null || _a === void 0 ? void 0 : _a.call(firstChild);
|
|
25
|
-
(_b = firstChild === null || firstChild === void 0 ? void 0 : firstChild.setFocus) === null || _b === void 0 ? void 0 : _b.call(firstChild, { selectText });
|
|
26
|
-
}
|
|
27
|
-
static isGridCell(element) {
|
|
28
|
-
var _a;
|
|
29
|
-
return ((_a = element === null || element === void 0 ? void 0 : element.getAttribute) === null || _a === void 0 ? void 0 : _a.call(element, "role")) === 'gridcell';
|
|
30
|
-
}
|
|
31
|
-
}
|