@sankhyalabs/ezui 1.1.161 → 1.2.0-beta.1
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/{ApplicationUtils-4a223c7a.js → ApplicationUtils-483c0a9e.js} +26 -7
- package/dist/cjs/CSSVarsUtils-09b431cc.js +55 -0
- package/dist/cjs/DialogType-a1e288e6.js +8 -0
- package/dist/cjs/ez-actions-button.cjs.entry.js +101 -0
- package/dist/cjs/ez-combo-box.cjs.entry.js +8 -4
- package/dist/cjs/ez-date-input.cjs.entry.js +6 -6
- package/dist/cjs/ez-date-time-input.cjs.entry.js +7 -7
- package/dist/cjs/ez-dialog.cjs.entry.js +33 -14
- package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-form.cjs.entry.js +101 -86
- package/dist/cjs/ez-grid-config.cjs.entry.js +3 -2
- package/dist/cjs/ez-grid.cjs.entry.js +97155 -92841
- package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-popover.cjs.entry.js +6 -0
- package/dist/cjs/ez-radio-button.cjs.entry.js +49 -0
- package/dist/cjs/ez-search.cjs.entry.js +1 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-upload.cjs.entry.js +2 -1
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/ez-actions-button/ez-actions-button.css +49 -0
- package/dist/collection/components/ez-actions-button/ez-actions-button.js +177 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +31 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +4 -1
- package/dist/collection/components/ez-date-input/ez-date-input.js +5 -3
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +6 -6
- package/dist/collection/components/ez-dialog/DialogType.js +6 -0
- package/dist/collection/components/ez-dialog/ez-dialog.css +9 -1
- package/dist/collection/components/ez-dialog/ez-dialog.js +53 -26
- package/dist/collection/components/ez-form/DataBinder.js +46 -18
- package/dist/collection/components/ez-form/ez-form.js +75 -68
- package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +2 -2
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +24 -165
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +71 -44
- package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js +4 -4
- package/dist/collection/components/ez-grid/ez-grid.js +36 -321
- package/dist/collection/components/ez-grid/subcomponents/ez-grid-config/ez-grid-config.js +2 -1
- package/dist/collection/components/ez-popover/ez-popover.js +6 -0
- package/dist/collection/components/ez-radio-button/ez-radio-button.css +204 -0
- package/dist/collection/components/ez-radio-button/ez-radio-button.js +160 -0
- package/dist/collection/utils/ApplicationUtils.js +25 -7
- package/dist/collection/utils/CSSVarsUtils.js +34 -0
- package/dist/collection/utils/index.js +1 -0
- package/dist/custom-elements/index.d.ts +12 -6
- package/dist/custom-elements/index.js +97132 -92676
- package/dist/esm/{ApplicationUtils-35350d20.js → ApplicationUtils-5f87ae60.js} +26 -7
- package/dist/esm/CSSVarsUtils-499b75c2.js +53 -0
- package/dist/esm/DialogType-72afa679.js +8 -0
- package/dist/esm/ez-actions-button.entry.js +97 -0
- package/dist/esm/ez-combo-box.entry.js +8 -4
- package/dist/esm/ez-date-input.entry.js +6 -6
- package/dist/esm/ez-date-time-input.entry.js +7 -7
- package/dist/esm/ez-dialog.entry.js +33 -14
- package/dist/esm/ez-filter-input.entry.js +1 -1
- package/dist/esm/ez-form.entry.js +101 -86
- package/dist/esm/ez-grid-config.entry.js +3 -2
- package/dist/esm/ez-grid.entry.js +96694 -92380
- package/dist/esm/ez-number-input.entry.js +1 -1
- package/dist/esm/ez-popover.entry.js +6 -0
- package/dist/esm/ez-radio-button.entry.js +45 -0
- package/dist/esm/ez-search.entry.js +1 -1
- package/dist/esm/ez-time-input.entry.js +1 -1
- package/dist/esm/ez-upload.entry.js +2 -1
- 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-0b099e95.entry.js +1 -0
- package/dist/ezui/{p-ff7b4b13.entry.js → p-240a76f1.entry.js} +1 -1
- package/dist/ezui/p-3263a002.js +1 -0
- package/dist/ezui/p-787fbdfe.js +1 -0
- package/dist/ezui/p-78fc16d7.entry.js +1 -0
- package/dist/ezui/{p-4c3d136c.entry.js → p-7d29e829.entry.js} +1 -1
- package/dist/ezui/p-898b9906.js +1 -0
- package/dist/ezui/p-8aaca58b.entry.js +1 -0
- package/dist/ezui/p-99440dbc.entry.js +1 -0
- package/dist/ezui/p-a7064bc1.entry.js +1 -0
- package/dist/ezui/{p-53bbba8e.entry.js → p-ad071710.entry.js} +1 -1
- package/dist/ezui/p-b0195dae.entry.js +1 -0
- package/dist/ezui/p-ba2bfa01.entry.js +1 -0
- package/dist/ezui/p-bedef638.entry.js +1 -0
- package/dist/ezui/p-d1bc45bd.entry.js +1 -0
- package/dist/ezui/{p-003d53b1.entry.js → p-d75c3aae.entry.js} +1 -1
- package/dist/ezui/p-e5c572c1.entry.js +304 -0
- package/dist/ezui/p-f4819fa3.entry.js +1 -0
- package/dist/types/components/ez-actions-button/ez-actions-button.d.ts +37 -0
- package/dist/types/components/ez-dialog/DialogType.d.ts +5 -0
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +22 -3
- package/dist/types/components/ez-form/DataBinder.d.ts +6 -1
- package/dist/types/components/ez-form/ez-form.d.ts +27 -3
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +2 -1
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +0 -85
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +2 -23
- package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +14 -11
- package/dist/types/components/ez-grid/ez-grid.d.ts +8 -66
- package/dist/types/components/ez-radio-button/ez-radio-button.d.ts +36 -0
- package/dist/types/components.d.ts +129 -76
- package/dist/types/utils/ApplicationUtils.d.ts +4 -1
- package/dist/types/utils/CSSVarsUtils.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +5 -5
- package/react/components.d.ts +2 -1
- package/react/components.js +2 -1
- package/react/components.js.map +1 -1
- package/dist/cjs/CSSVarsUtils-1034b7b6.js +0 -21
- package/dist/cjs/test-du.cjs.entry.js +0 -103
- package/dist/collection/components/test-du/test-du.css +0 -3
- package/dist/collection/components/test-du/test-du.js +0 -104
- package/dist/collection/utils/interfaces/PageableComponent.js +0 -1
- package/dist/esm/CSSVarsUtils-eb4c5af6.js +0 -19
- package/dist/esm/test-du.entry.js +0 -99
- package/dist/ezui/p-0cd386db.js +0 -1
- package/dist/ezui/p-403de0a4.entry.js +0 -1
- package/dist/ezui/p-4c3cd534.entry.js +0 -1
- package/dist/ezui/p-6668c3b0.entry.js +0 -1
- package/dist/ezui/p-7fd6deec.entry.js +0 -1
- package/dist/ezui/p-8be1a4d6.entry.js +0 -1
- package/dist/ezui/p-8d73594f.entry.js +0 -369
- package/dist/ezui/p-933a7475.js +0 -1
- package/dist/ezui/p-988ff301.entry.js +0 -1
- package/dist/ezui/p-cf56d3e8.entry.js +0 -1
- package/dist/ezui/p-da156da3.entry.js +0 -1
- package/dist/ezui/p-ec7b7e26.entry.js +0 -1
- package/dist/types/components/test-du/test-du.d.ts +0 -9
- package/dist/types/utils/interfaces/PageableComponent.d.ts +0 -12
|
@@ -68,10 +68,7 @@ export class EzDateTimeInput {
|
|
|
68
68
|
}
|
|
69
69
|
handleKeyDown(event) {
|
|
70
70
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
71
|
-
if (event.
|
|
72
|
-
this.changeValue(new Date());
|
|
73
|
-
}
|
|
74
|
-
else if (event.shiftKey && event.key === "Tab") {
|
|
71
|
+
if (event.shiftKey && event.key === "Tab") {
|
|
75
72
|
if (input.selectionStart > 0) {
|
|
76
73
|
let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
|
|
77
74
|
if (selectIni !== -1) {
|
|
@@ -171,7 +168,7 @@ export class EzDateTimeInput {
|
|
|
171
168
|
? value
|
|
172
169
|
: undefined;
|
|
173
170
|
}
|
|
174
|
-
handleInput() {
|
|
171
|
+
handleInput(event) {
|
|
175
172
|
const newValue = this.getParsedDateTime();
|
|
176
173
|
const currentValue = this.validateValue(this.value);
|
|
177
174
|
const newValueValidated = this.validateValue(newValue);
|
|
@@ -179,6 +176,9 @@ export class EzDateTimeInput {
|
|
|
179
176
|
this._focused = true;
|
|
180
177
|
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
181
178
|
}
|
|
179
|
+
if (event['data'] === "H" || event['data'] === "h") {
|
|
180
|
+
this.changeValue(new Date());
|
|
181
|
+
}
|
|
182
182
|
}
|
|
183
183
|
setInputValue() {
|
|
184
184
|
const textValue = this.getTextValue(this.value) || '';
|
|
@@ -192,7 +192,7 @@ export class EzDateTimeInput {
|
|
|
192
192
|
}
|
|
193
193
|
render() {
|
|
194
194
|
return (h(Host, null,
|
|
195
|
-
h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() },
|
|
195
|
+
h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() },
|
|
196
196
|
h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })),
|
|
197
197
|
h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
198
198
|
}
|
|
@@ -105,6 +105,10 @@ h2 {
|
|
|
105
105
|
padding: var(--dialog__container-padding)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
.dialog__container--default {
|
|
109
|
+
border-radius: 6px 6px 6px 6px;
|
|
110
|
+
}
|
|
111
|
+
|
|
108
112
|
.dialog__critical--indicator {
|
|
109
113
|
box-sizing: border-box;
|
|
110
114
|
width: 12px;
|
|
@@ -166,10 +170,14 @@ h2 {
|
|
|
166
170
|
align-self: center;
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
.
|
|
173
|
+
.title__label {
|
|
170
174
|
padding-left: var(--dialog__title--padding-left);
|
|
171
175
|
}
|
|
172
176
|
|
|
177
|
+
.title__label--no-icon{
|
|
178
|
+
padding-left: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
173
181
|
.title-icon {
|
|
174
182
|
outline: none;
|
|
175
183
|
border: none;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Component, h, Prop, Method, Event, forceUpdate } from "@stencil/core";
|
|
2
|
+
import { DialogType } from "./DialogType";
|
|
2
3
|
class Message {
|
|
3
|
-
constructor(title, message,
|
|
4
|
+
constructor(title, message, dialogType, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger, callBack) {
|
|
4
5
|
this.title = title;
|
|
5
6
|
this.message = message;
|
|
6
|
-
this.
|
|
7
|
+
this.dialogType = dialogType;
|
|
7
8
|
this.confirm = confirm;
|
|
8
9
|
this.icon = icon;
|
|
9
10
|
this.labelCancel = labelCancel;
|
|
@@ -21,10 +22,6 @@ export class EzDialog {
|
|
|
21
22
|
* Define se o componente será utilizado no modo de confirmação.
|
|
22
23
|
*/
|
|
23
24
|
this.confirm = false;
|
|
24
|
-
/**
|
|
25
|
-
* Define se o componente terá o visual de erro ou de aviso
|
|
26
|
-
*/
|
|
27
|
-
this.critical = false;
|
|
28
25
|
/**
|
|
29
26
|
* Controla a exibição do componente
|
|
30
27
|
*/
|
|
@@ -48,12 +45,37 @@ export class EzDialog {
|
|
|
48
45
|
/**
|
|
49
46
|
* Faz com que o componente seja exibido.
|
|
50
47
|
*/
|
|
51
|
-
async show(title, message,
|
|
48
|
+
async show(title, message, dialogType, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger) {
|
|
52
49
|
this.opened = true;
|
|
53
50
|
return new Promise(resolve => {
|
|
54
|
-
this._messageQueue.push(new Message(title, message,
|
|
51
|
+
this._messageQueue.push(new Message(title, message, dialogType, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger, resolve));
|
|
55
52
|
});
|
|
56
53
|
}
|
|
54
|
+
isCritical(dialogType) {
|
|
55
|
+
return dialogType === DialogType.CRITICAL;
|
|
56
|
+
}
|
|
57
|
+
getIconElement(message) {
|
|
58
|
+
if (message.icon) {
|
|
59
|
+
return h("ez-icon", { class: this.isCritical(message.dialogType) ? "changeable__icon critical" : "changeable__icon", size: "small", iconName: message.icon });
|
|
60
|
+
}
|
|
61
|
+
if (message.dialogType === DialogType.DEFAULT) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
return h("div", { class: this.isCritical(message.dialogType) ? "title-icon title-icon--critical" : "title-icon" });
|
|
65
|
+
}
|
|
66
|
+
getTypeIndicatorElement(message) {
|
|
67
|
+
if (message.dialogType === DialogType.DEFAULT) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
return h("div", { class: this.isCritical(message.dialogType) ? "dialog__critical--indicator" : "dialog__warning--indicator" });
|
|
71
|
+
}
|
|
72
|
+
getClassContainer(message) {
|
|
73
|
+
const type = message.dialogType || DialogType.DEFAULT;
|
|
74
|
+
return type === DialogType.DEFAULT ? "dialog__container dialog__container--default" : "dialog__container";
|
|
75
|
+
}
|
|
76
|
+
getClassTitleLabel(message) {
|
|
77
|
+
return this.getIconElement(message) == undefined ? "title title__label title__label--no-icon" : "title title__label";
|
|
78
|
+
}
|
|
57
79
|
componentWillRender() {
|
|
58
80
|
if (!this._currentMessage) {
|
|
59
81
|
if (this._messageQueue.length > 0) {
|
|
@@ -61,7 +83,7 @@ export class EzDialog {
|
|
|
61
83
|
}
|
|
62
84
|
else {
|
|
63
85
|
if (this.opened) {
|
|
64
|
-
this._currentMessage = new Message(this.ezTitle, this.message, this.
|
|
86
|
+
this._currentMessage = new Message(this.ezTitle, this.message, this.dialogType, this.confirm, this.personalizedIconPath, this.labelCancel, this.labelConfirm, this.btnConfirmDanger, null);
|
|
65
87
|
}
|
|
66
88
|
}
|
|
67
89
|
}
|
|
@@ -70,15 +92,12 @@ export class EzDialog {
|
|
|
70
92
|
if (this.opened && this._currentMessage) {
|
|
71
93
|
return (h("div", { class: "overlay" },
|
|
72
94
|
h("div", { class: "dialog" },
|
|
73
|
-
|
|
74
|
-
h("div", { class:
|
|
95
|
+
this.getTypeIndicatorElement(this._currentMessage),
|
|
96
|
+
h("div", { class: this.getClassContainer(this._currentMessage) },
|
|
75
97
|
h("div", { class: "title__container" },
|
|
76
98
|
h("div", { class: "title__box" },
|
|
77
|
-
this._currentMessage
|
|
78
|
-
|
|
79
|
-
:
|
|
80
|
-
h("div", { class: this._currentMessage.critical ? "title-icon title-icon--critical" : "title-icon" }),
|
|
81
|
-
h("div", { class: "title title--label", innerHTML: this._currentMessage.title })),
|
|
99
|
+
this.getIconElement(this._currentMessage),
|
|
100
|
+
h("div", { class: this.getClassTitleLabel(this._currentMessage), innerHTML: this._currentMessage.title })),
|
|
82
101
|
h("button", { class: "btn-close", onClick: () => this.handleButtonClick(false) })),
|
|
83
102
|
h("div", { class: "message", innerHTML: this._currentMessage.message }),
|
|
84
103
|
this._currentMessage.confirm &&
|
|
@@ -118,23 +137,27 @@ export class EzDialog {
|
|
|
118
137
|
"reflect": false,
|
|
119
138
|
"defaultValue": "false"
|
|
120
139
|
},
|
|
121
|
-
"
|
|
122
|
-
"type": "
|
|
140
|
+
"dialogType": {
|
|
141
|
+
"type": "string",
|
|
123
142
|
"mutable": true,
|
|
124
143
|
"complexType": {
|
|
125
|
-
"original": "
|
|
126
|
-
"resolved": "
|
|
127
|
-
"references": {
|
|
144
|
+
"original": "DialogType",
|
|
145
|
+
"resolved": "DialogType.CRITICAL | DialogType.DEFAULT | DialogType.WARN",
|
|
146
|
+
"references": {
|
|
147
|
+
"DialogType": {
|
|
148
|
+
"location": "import",
|
|
149
|
+
"path": "./DialogType"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
128
152
|
},
|
|
129
153
|
"required": false,
|
|
130
154
|
"optional": false,
|
|
131
155
|
"docs": {
|
|
132
156
|
"tags": [],
|
|
133
|
-
"text": "Define se o componente ter\u00E1 o visual de erro ou de aviso"
|
|
157
|
+
"text": "Define se o componente ter\u00E1 o visual padr\u00E3o, de erro ou de aviso"
|
|
134
158
|
},
|
|
135
|
-
"attribute": "
|
|
136
|
-
"reflect": false
|
|
137
|
-
"defaultValue": "false"
|
|
159
|
+
"attribute": "dialog-type",
|
|
160
|
+
"reflect": false
|
|
138
161
|
},
|
|
139
162
|
"message": {
|
|
140
163
|
"type": "string",
|
|
@@ -259,7 +282,7 @@ export class EzDialog {
|
|
|
259
282
|
},
|
|
260
283
|
"show": {
|
|
261
284
|
"complexType": {
|
|
262
|
-
"signature": "(title: string, message: string,
|
|
285
|
+
"signature": "(title: string, message: string, dialogType: DialogType, confirm: boolean, icon: string, labelCancel: string, labelConfirm: string, btnConfirmDanger: boolean) => Promise<boolean>",
|
|
263
286
|
"parameters": [{
|
|
264
287
|
"tags": [],
|
|
265
288
|
"text": ""
|
|
@@ -288,6 +311,10 @@ export class EzDialog {
|
|
|
288
311
|
"references": {
|
|
289
312
|
"Promise": {
|
|
290
313
|
"location": "global"
|
|
314
|
+
},
|
|
315
|
+
"DialogType": {
|
|
316
|
+
"location": "import",
|
|
317
|
+
"path": "./DialogType"
|
|
291
318
|
}
|
|
292
319
|
},
|
|
293
320
|
"return": "Promise<boolean>"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApplicationContext, Action, WaitingChangeException } from "@sankhyalabs/core";
|
|
2
2
|
export default class DataBinder {
|
|
3
3
|
constructor(dataUnit) {
|
|
4
|
+
this._invalidFields = new Map();
|
|
4
5
|
this.onDataUnitEvent = (action) => {
|
|
5
6
|
var _a;
|
|
6
7
|
switch (action.type) {
|
|
@@ -9,15 +10,16 @@ export default class DataBinder {
|
|
|
9
10
|
case Action.RECORDS_REMOVED:
|
|
10
11
|
case Action.RECORDS_ADDED:
|
|
11
12
|
case Action.RECORDS_COPIED:
|
|
12
|
-
case Action.DATA_CHANGED:
|
|
13
13
|
case Action.EDITION_CANCELED:
|
|
14
|
-
case Action.CHANGE_UNDONE:
|
|
15
|
-
case Action.CHANGE_REDONE:
|
|
16
14
|
case Action.SELECTION_CHANGED:
|
|
17
15
|
case Action.NEXT_SELECTED:
|
|
18
16
|
case Action.PREVIOUS_SELECTED:
|
|
17
|
+
this.clearInvalid();
|
|
18
|
+
case Action.DATA_CHANGED:
|
|
19
|
+
case Action.CHANGE_UNDONE:
|
|
20
|
+
case Action.CHANGE_REDONE:
|
|
19
21
|
(_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
20
|
-
this.updateValue(field.fieldName, field.field
|
|
22
|
+
this.updateValue(field.fieldName, field.field);
|
|
21
23
|
});
|
|
22
24
|
break;
|
|
23
25
|
}
|
|
@@ -35,24 +37,45 @@ export default class DataBinder {
|
|
|
35
37
|
onDisconnectedCallback() {
|
|
36
38
|
this._dataUnit.unsubscribe(this.onDataUnitEvent);
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
markInvalid(field) {
|
|
41
|
+
this._invalidFields.set(field.name, field);
|
|
42
|
+
if (this._fields.has(field.name)) {
|
|
43
|
+
this.updateErrorMessage(field.name, this._fields.get(field.name).field);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
clearInvalid() {
|
|
47
|
+
this._invalidFields.clear();
|
|
48
|
+
this._fields.forEach(fieldBinder => {
|
|
49
|
+
const fieldName = fieldBinder.field.dataset.fieldName;
|
|
50
|
+
this.updateErrorMessage(fieldName, fieldBinder.field);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
updateValue(fieldName, field) {
|
|
54
|
+
const bind = this._fields.get(fieldName);
|
|
55
|
+
try {
|
|
56
|
+
if (bind) {
|
|
57
|
+
bind.listen = false;
|
|
58
|
+
}
|
|
59
|
+
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
60
|
+
this.updateErrorMessage(fieldName, field);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (bind) {
|
|
64
|
+
bind.listen = true;
|
|
65
|
+
}
|
|
48
66
|
}
|
|
49
67
|
}
|
|
68
|
+
updateErrorMessage(fieldName, field) {
|
|
69
|
+
const invalidField = this._invalidFields.get(fieldName);
|
|
70
|
+
field["errorMessage"] = invalidField ? invalidField.message : "";
|
|
71
|
+
}
|
|
50
72
|
updateBind(fieldName, field) {
|
|
51
73
|
const oldBind = this._fields.get(fieldName);
|
|
52
74
|
if (oldBind) {
|
|
53
75
|
oldBind.destroy();
|
|
54
76
|
}
|
|
55
|
-
this.
|
|
77
|
+
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
78
|
+
this.updateErrorMessage(fieldName, field);
|
|
56
79
|
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName) => this.cancelWaitingChange(fieldName), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
57
80
|
this.bindSearchOptionsLoader(fieldName, field);
|
|
58
81
|
this.applyEzUploadContext(fieldName, field);
|
|
@@ -93,6 +116,7 @@ export default class DataBinder {
|
|
|
93
116
|
if (this._dataUnit.records.length === 0) {
|
|
94
117
|
this._dataUnit.addRecord();
|
|
95
118
|
}
|
|
119
|
+
this._invalidFields.delete(fieldName);
|
|
96
120
|
this._dataUnit.setFieldValue(fieldName, newValue);
|
|
97
121
|
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
98
122
|
const bind = this._fields.get(fieldName);
|
|
@@ -127,6 +151,7 @@ export default class DataBinder {
|
|
|
127
151
|
}
|
|
128
152
|
class Bind {
|
|
129
153
|
constructor() {
|
|
154
|
+
this.listen = true;
|
|
130
155
|
this.startChangeEventName = "ezStartChange";
|
|
131
156
|
this.cancelWaitingChangeEventName = "ezCancelWaitingChange";
|
|
132
157
|
this.changeEventName = "ezChange";
|
|
@@ -154,11 +179,14 @@ class Bind {
|
|
|
154
179
|
const b = new Bind();
|
|
155
180
|
b.field = field;
|
|
156
181
|
b.fieldName = fieldName;
|
|
157
|
-
b.startChangeListener = (evt) => {
|
|
182
|
+
b.startChangeListener = (evt) => { if (b.listen)
|
|
183
|
+
startChangeCallback(fieldName, evt.detail); };
|
|
158
184
|
b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
|
|
159
|
-
b.cancelWaitingChangeListener = () => {
|
|
185
|
+
b.cancelWaitingChangeListener = () => { if (b.listen)
|
|
186
|
+
cancelWaitingChangeCallback(fieldName); };
|
|
160
187
|
b.field.addEventListener(b.cancelWaitingChangeEventName, b.cancelWaitingChangeListener);
|
|
161
|
-
b.changeListener = (evt) => {
|
|
188
|
+
b.changeListener = (evt) => { if (b.listen)
|
|
189
|
+
changeCallback(fieldName, evt.detail); };
|
|
162
190
|
b.field.addEventListener(b.changeEventName, b.changeListener);
|
|
163
191
|
return b;
|
|
164
192
|
}
|
|
@@ -21,88 +21,66 @@ export class EzForm {
|
|
|
21
21
|
return Promise.resolve();
|
|
22
22
|
}
|
|
23
23
|
validate() {
|
|
24
|
-
return new Promise(
|
|
25
|
-
|
|
26
|
-
const requiredFields = this._staticFields
|
|
27
|
-
.filter(f => f.dataset.required)
|
|
28
|
-
.map(f => f.dataset.fieldName)
|
|
29
|
-
.concat(metadata.getRequiredFields());
|
|
30
|
-
let isReject = false;
|
|
24
|
+
return new Promise((accept, reject) => {
|
|
25
|
+
var _a;
|
|
31
26
|
const records = this.dataUnit.getModifiedRecords();
|
|
32
27
|
for (let i = 0; i < records.length; i++) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const record = records[i];
|
|
29
|
+
const invalidResults = [];
|
|
30
|
+
let validationResult = this.validateRequired(record);
|
|
31
|
+
if (validationResult && !validationResult.isValid) {
|
|
32
|
+
invalidResults.push(validationResult);
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
validationResult = (_a = this.recordsValidator) === null || _a === void 0 ? void 0 : _a.validateRecord(this, record);
|
|
35
|
+
if (validationResult && !validationResult.isValid) {
|
|
36
|
+
invalidResults.push(validationResult);
|
|
37
|
+
}
|
|
38
|
+
if (invalidResults.length > 0) {
|
|
39
|
+
this.processValidationResult(invalidResults);
|
|
40
|
+
reject();
|
|
41
|
+
break;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
reject();
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
accept();
|
|
49
|
-
}
|
|
44
|
+
accept();
|
|
50
45
|
});
|
|
51
46
|
}
|
|
52
47
|
observeConfig() {
|
|
53
48
|
this.processMetadata();
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const fieldElem = dataFields[i];
|
|
62
|
-
if (fieldElem && fieldElem['isInvalid']) {
|
|
63
|
-
const hasError = await fieldElem['isInvalid']();
|
|
64
|
-
if (hasError && fieldElem['dataset']) {
|
|
65
|
-
invalidFields.push(fieldElem['dataset'].fieldName);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
;
|
|
70
|
-
}
|
|
71
|
-
const isValid = invalidFields.length === 0;
|
|
72
|
-
if (!isValid) {
|
|
73
|
-
ApplicationUtils.info("Há pelo menos um campo com conteúdo inválido.");
|
|
74
|
-
}
|
|
75
|
-
return isValid;
|
|
76
|
-
}
|
|
77
|
-
validateRequired(requiredFields, record) {
|
|
50
|
+
validateRequired(record) {
|
|
51
|
+
const metadata = selectFormMetadata(this._store.getState());
|
|
52
|
+
const requiredFields = this._staticFields
|
|
53
|
+
.filter(f => f.dataset.required)
|
|
54
|
+
.map(f => f.dataset.fieldName)
|
|
55
|
+
.concat(metadata.getRequiredFields());
|
|
78
56
|
const invalidFields = [];
|
|
79
57
|
requiredFields.forEach(field => {
|
|
80
58
|
const value = record[field];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* TODO: fieldElem vai ser vazio quando o campo está em uma aba que
|
|
84
|
-
* está escondida.
|
|
85
|
-
* Temos que tratar esse caso para apresentar a mensagem de erro
|
|
86
|
-
* na aba, isso será tratado no card: https://sankhya.atlassian.net/browse/SKA-44182
|
|
87
|
-
*/
|
|
88
|
-
if (fieldElem) {
|
|
89
|
-
/**
|
|
90
|
-
* Devido o StencilJS não possuir Getter e Setter, para casos que o Watch não for chamado,
|
|
91
|
-
* é necessário limpar a propriedade antes de setar o valor novamente, para que o Watch seja disparado novamente,
|
|
92
|
-
* solução necessária para controlar componentes com herança (Exemplo: EzSearch -> EzComboBox -> EzTextInput).
|
|
93
|
-
*/
|
|
94
|
-
fieldElem["errorMessage"] = "";
|
|
95
|
-
if (value === null || value === undefined || value === "") {
|
|
96
|
-
invalidFields.push(field);
|
|
97
|
-
fieldElem["errorMessage"] = "Essa informação é obrigatória";
|
|
98
|
-
}
|
|
59
|
+
if (value == undefined || value === "") {
|
|
60
|
+
invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
|
|
99
61
|
}
|
|
100
62
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ApplicationUtils.info("Há pelo menos um campo obrigatório não preenchido.");
|
|
63
|
+
if (invalidFields.length > 0) {
|
|
64
|
+
return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
|
|
104
65
|
}
|
|
105
|
-
return
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
processValidationResult(validationResult) {
|
|
69
|
+
validationResult.forEach(invalidResult => {
|
|
70
|
+
const invalidFields = invalidResult.invalidFields;
|
|
71
|
+
if (invalidFields) {
|
|
72
|
+
invalidFields.forEach(field => {
|
|
73
|
+
this._dataBinder.markInvalid(field);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (invalidResult.infoMessage) {
|
|
77
|
+
ApplicationUtils.info(invalidResult.infoMessage);
|
|
78
|
+
}
|
|
79
|
+
if (invalidResult.errorMessage) {
|
|
80
|
+
const { errorTitle, errorMessage } = invalidResult;
|
|
81
|
+
ApplicationUtils.error(errorTitle, errorMessage);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
106
84
|
}
|
|
107
85
|
getDynamicContent() {
|
|
108
86
|
var _a;
|
|
@@ -144,6 +122,13 @@ export class EzForm {
|
|
|
144
122
|
}));
|
|
145
123
|
}
|
|
146
124
|
}
|
|
125
|
+
if (action.type === Action.SAVING_DATA) {
|
|
126
|
+
return new Promise((resolve) => {
|
|
127
|
+
this.validate()
|
|
128
|
+
.then(() => resolve(action))
|
|
129
|
+
.catch(() => { });
|
|
130
|
+
});
|
|
131
|
+
}
|
|
147
132
|
if (action.type === Action.RECORDS_ADDED) {
|
|
148
133
|
const metadata = selectFormMetadata(this._store.getState());
|
|
149
134
|
const defaultValues = metadata.getDefaultValues();
|
|
@@ -209,7 +194,7 @@ export class EzForm {
|
|
|
209
194
|
"optional": false,
|
|
210
195
|
"docs": {
|
|
211
196
|
"tags": [],
|
|
212
|
-
"text": ""
|
|
197
|
+
"text": "Reposit\u00F3rio de dados, controla a manipula\u00E7\u00E3o dos dados"
|
|
213
198
|
}
|
|
214
199
|
},
|
|
215
200
|
"config": {
|
|
@@ -231,7 +216,26 @@ export class EzForm {
|
|
|
231
216
|
"optional": false,
|
|
232
217
|
"docs": {
|
|
233
218
|
"tags": [],
|
|
234
|
-
"text": ""
|
|
219
|
+
"text": "Configura\u00E7\u00E3o dos campos."
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"recordsValidator": {
|
|
223
|
+
"type": "unknown",
|
|
224
|
+
"mutable": false,
|
|
225
|
+
"complexType": {
|
|
226
|
+
"original": "RecordValidator",
|
|
227
|
+
"resolved": "RecordValidator",
|
|
228
|
+
"references": {
|
|
229
|
+
"RecordValidator": {
|
|
230
|
+
"location": "local"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"required": false,
|
|
235
|
+
"optional": false,
|
|
236
|
+
"docs": {
|
|
237
|
+
"tags": [],
|
|
238
|
+
"text": "Validador respons\u00E1vel por checar a integridade das informa\u00E7\u00F5es do registro"
|
|
235
239
|
}
|
|
236
240
|
}
|
|
237
241
|
}; }
|
|
@@ -298,6 +302,9 @@ export class EzForm {
|
|
|
298
302
|
"Record": {
|
|
299
303
|
"location": "import",
|
|
300
304
|
"path": "@sankhyalabs/core"
|
|
305
|
+
},
|
|
306
|
+
"ValidationResult": {
|
|
307
|
+
"location": "local"
|
|
301
308
|
}
|
|
302
309
|
},
|
|
303
310
|
"return": "Promise<void>"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
|
-
export const buildTextInput = ({ name, label }) => {
|
|
2
|
+
export const buildTextInput = ({ name, label, readOnly }) => {
|
|
3
3
|
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
4
|
-
h("ez-text-input", { label: label, "data-field-name": name, key: name })));
|
|
4
|
+
h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
5
5
|
};
|