@sankhyalabs/ezui 1.1.120 → 1.1.123
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-93721afc.js → ApplicationUtils-4a223c7a.js} +15 -9
- package/dist/cjs/{AssetsUtils-4909c6de.js → AssetsUtils-78164781.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.cjs.entry.js +2 -2
- package/dist/cjs/ez-calendar.cjs.entry.js +1 -1
- package/dist/cjs/ez-check.cjs.entry.js +1 -1
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-combo-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-date-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-date-time-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-dialog.cjs.entry.js +15 -11
- package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-form.cjs.entry.js +80 -24
- package/dist/cjs/ez-grid.cjs.entry.js +37 -29
- package/dist/cjs/ez-icon.cjs.entry.js +1 -1
- package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
- package/dist/cjs/ez-list.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal.cjs.entry.js +1 -1
- package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
- 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 +1 -1
- package/dist/cjs/ez-tabselector.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-area.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +2 -2
- package/dist/cjs/ez-toast.cjs.entry.js +1 -1
- package/dist/cjs/ez-upload.cjs.entry.js +12 -5
- package/dist/cjs/ezui.cjs.js +2 -2
- package/dist/cjs/grid-config.cjs.entry.js +2 -2
- package/dist/cjs/{index-88286449.js → index-0e284e03.js} +5 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/select-box.cjs.entry.js +1 -1
- package/dist/cjs/test-du.cjs.entry.js +27 -38
- package/dist/collection/components/ez-button/ez-button.css +23 -1
- package/dist/collection/components/ez-dialog/ez-dialog.css +16 -2
- package/dist/collection/components/ez-dialog/ez-dialog.js +26 -13
- package/dist/collection/components/ez-form/DataBinder.js +65 -17
- package/dist/collection/components/ez-form/ez-form.js +31 -6
- package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +1 -1
- package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +31 -28
- package/dist/collection/components/ez-grid/ez-grid.js +5 -0
- package/dist/collection/components/ez-upload/ez-upload.js +29 -3
- package/dist/collection/components/test-du/test-du.js +34 -39
- package/dist/collection/utils/ApplicationUtils.js +15 -9
- package/dist/custom-elements/index.js +181 -112
- package/dist/esm/{ApplicationUtils-3ca0e68d.js → ApplicationUtils-35350d20.js} +15 -9
- package/dist/esm/{AssetsUtils-9b1329a3.js → AssetsUtils-aab9ca8f.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.entry.js +2 -2
- package/dist/esm/ez-calendar.entry.js +1 -1
- package/dist/esm/ez-check.entry.js +1 -1
- package/dist/esm/ez-collapsible-box.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +1 -1
- package/dist/esm/ez-date-input.entry.js +1 -1
- package/dist/esm/ez-date-time-input.entry.js +1 -1
- package/dist/esm/ez-dialog.entry.js +15 -11
- package/dist/esm/ez-filter-input.entry.js +1 -1
- package/dist/esm/ez-form.entry.js +81 -25
- package/dist/esm/ez-grid.entry.js +37 -29
- package/dist/esm/ez-icon.entry.js +1 -1
- package/dist/esm/ez-label-chip.entry.js +1 -1
- package/dist/esm/ez-list.entry.js +1 -1
- package/dist/esm/ez-modal.entry.js +1 -1
- package/dist/esm/ez-number-input.entry.js +1 -1
- 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 +1 -1
- package/dist/esm/ez-tabselector.entry.js +1 -1
- package/dist/esm/ez-text-area.entry.js +1 -1
- package/dist/esm/ez-text-input.entry.js +1 -1
- package/dist/esm/ez-time-input.entry.js +2 -2
- package/dist/esm/ez-toast.entry.js +1 -1
- package/dist/esm/ez-upload.entry.js +12 -5
- package/dist/esm/ezui.js +2 -2
- package/dist/esm/grid-config.entry.js +2 -2
- package/dist/esm/{index-6b8bfbeb.js → index-bf1aef20.js} +5 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/select-box.entry.js +1 -1
- package/dist/esm/test-du.entry.js +28 -39
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-05cca198.entry.js +1 -0
- package/dist/ezui/{p-8c447785.entry.js → p-0927092b.entry.js} +1 -1
- package/dist/ezui/{p-363fc3af.entry.js → p-0965bcae.entry.js} +1 -1
- package/dist/ezui/{p-f8d3c04d.entry.js → p-0cb4aec1.entry.js} +1 -1
- package/dist/ezui/p-0cd386db.js +1 -0
- package/dist/ezui/{p-97f77023.entry.js → p-1c28d99b.entry.js} +1 -1
- package/dist/ezui/{p-502d7e0d.entry.js → p-1ced597f.entry.js} +1 -1
- package/dist/ezui/{p-8f2d46f8.entry.js → p-1db59c89.entry.js} +1 -1
- package/dist/ezui/{p-6f39077b.entry.js → p-28ce145e.entry.js} +1 -1
- package/dist/ezui/{p-25e050f5.entry.js → p-2d55888f.entry.js} +1 -1
- package/dist/ezui/{p-83d5f1ca.entry.js → p-2d894fed.entry.js} +1 -1
- package/dist/ezui/{p-c86cd69e.entry.js → p-4262a462.entry.js} +2 -2
- package/dist/ezui/{p-2f14fe3d.entry.js → p-46d1340b.entry.js} +1 -1
- package/dist/ezui/p-4884b056.entry.js +1 -0
- package/dist/ezui/p-495cdb4c.entry.js +1 -0
- package/dist/ezui/{p-477bb703.js → p-51b878f7.js} +1 -1
- package/dist/ezui/{p-01169201.entry.js → p-5e989ecf.entry.js} +1 -1
- package/dist/ezui/{p-89a57641.js → p-60138b72.js} +1 -1
- package/dist/ezui/{p-a5f1f9c4.entry.js → p-6745931a.entry.js} +1 -1
- package/dist/ezui/p-6aa0c6f1.entry.js +1 -0
- package/dist/ezui/{p-804c118a.entry.js → p-7df61f4a.entry.js} +1 -1
- package/dist/ezui/{p-43feac7d.entry.js → p-8543a1b3.entry.js} +1 -1
- package/dist/ezui/{p-b8678ee6.entry.js → p-8a0e5e59.entry.js} +1 -1
- package/dist/ezui/p-91e51dc9.entry.js +1 -0
- package/dist/ezui/{p-d3d3e2ac.entry.js → p-9a9b2936.entry.js} +1 -1
- package/dist/ezui/{p-31b0e21a.entry.js → p-a44dcc62.entry.js} +1 -1
- package/dist/ezui/p-a4a21738.entry.js +1 -0
- package/dist/ezui/{p-542d3d29.entry.js → p-bd29c55f.entry.js} +1 -1
- package/dist/ezui/{p-c6f2aa6c.entry.js → p-c621cab9.entry.js} +1 -1
- package/dist/ezui/{p-76b64956.entry.js → p-dc0aa563.entry.js} +1 -1
- package/dist/ezui/{p-055f1b6a.entry.js → p-e62f5c77.entry.js} +1 -1
- package/dist/ezui/{p-f78c7ec9.entry.js → p-ef8f1275.entry.js} +1 -1
- package/dist/ezui/{p-59a8448a.entry.js → p-fa9157c1.entry.js} +1 -1
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +4 -1
- package/dist/types/components/ez-form/DataBinder.d.ts +4 -0
- package/dist/types/components/ez-form/ez-form.d.ts +7 -0
- package/dist/types/components/ez-grid/controller/DataUnitBridge.d.ts +1 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +1 -0
- package/dist/types/components/ez-upload/ez-upload.d.ts +5 -0
- package/dist/types/components/test-du/test-du.d.ts +2 -0
- package/dist/types/components.d.ts +10 -2
- package/dist/types/utils/ApplicationUtils.d.ts +6 -3
- package/package.json +3 -2
- package/dist/assets/actions-sprite.svg +0 -257
- package/dist/collection/components/assets/actions-sprite.svg +0 -257
- package/dist/ezui/p-126d33e2.entry.js +0 -1
- package/dist/ezui/p-1339fde7.entry.js +0 -1
- package/dist/ezui/p-149a8241.entry.js +0 -1
- package/dist/ezui/p-24ff7d92.entry.js +0 -1
- package/dist/ezui/p-3c71a597.js +0 -1
- package/dist/ezui/p-95fc543c.entry.js +0 -1
- package/dist/ezui/p-c13353f1.entry.js +0 -1
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { Component, h, Prop, Method, Event, forceUpdate } from "@stencil/core";
|
|
2
2
|
class Message {
|
|
3
|
-
constructor(title, message, critical, confirm, icon, callBack) {
|
|
3
|
+
constructor(title, message, critical, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger, callBack) {
|
|
4
4
|
this.title = title;
|
|
5
5
|
this.message = message;
|
|
6
6
|
this.critical = critical;
|
|
7
7
|
this.confirm = confirm;
|
|
8
8
|
this.icon = icon;
|
|
9
|
+
this.labelCancel = labelCancel;
|
|
10
|
+
this.labelConfirm = labelConfirm;
|
|
11
|
+
this.btnConfirmDanger = btnConfirmDanger;
|
|
9
12
|
this.callBack = callBack;
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
export class EzDialog {
|
|
13
16
|
constructor() {
|
|
17
|
+
this.labelConfirm = 'Sim';
|
|
18
|
+
this.labelCancel = 'Não';
|
|
19
|
+
this.btnConfirmDanger = false;
|
|
14
20
|
/**
|
|
15
21
|
* Define se o componente será utilizado no modo de confirmação.
|
|
16
22
|
*/
|
|
@@ -42,10 +48,10 @@ export class EzDialog {
|
|
|
42
48
|
/**
|
|
43
49
|
* Faz com que o componente seja exibido.
|
|
44
50
|
*/
|
|
45
|
-
async show(title, message, critical, confirm, icon) {
|
|
51
|
+
async show(title, message, critical, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger) {
|
|
46
52
|
this.opened = true;
|
|
47
53
|
return new Promise(resolve => {
|
|
48
|
-
this._messageQueue.push(new Message(title, message, critical, confirm, icon, resolve));
|
|
54
|
+
this._messageQueue.push(new Message(title, message, critical, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger, resolve));
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
componentWillRender() {
|
|
@@ -55,7 +61,7 @@ export class EzDialog {
|
|
|
55
61
|
}
|
|
56
62
|
else {
|
|
57
63
|
if (this.opened) {
|
|
58
|
-
this._currentMessage = new Message(this.ezTitle, this.message, this.critical, this.confirm, this.personalizedIconPath, null);
|
|
64
|
+
this._currentMessage = new Message(this.ezTitle, this.message, this.critical, this.confirm, this.personalizedIconPath, this.labelCancel, this.labelConfirm, this.btnConfirmDanger, null);
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
}
|
|
@@ -75,15 +81,13 @@ export class EzDialog {
|
|
|
75
81
|
h("div", { class: "title title--label", innerHTML: this._currentMessage.title })),
|
|
76
82
|
h("button", { class: "btn-close", onClick: () => this.handleButtonClick(false) })),
|
|
77
83
|
h("div", { class: "message", innerHTML: this._currentMessage.message }),
|
|
78
|
-
this._currentMessage.confirm
|
|
84
|
+
this._currentMessage.confirm &&
|
|
79
85
|
h("div", { class: "button-yes-no__container" },
|
|
80
|
-
h("ez-button", { class: "
|
|
81
|
-
h("ez-button", {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
h("ez-button", { label: "Ok", onClick: () => this.handleButtonClick(true) }))
|
|
86
|
-
: undefined))));
|
|
86
|
+
h("ez-button", { class: "button__cancel", label: this._currentMessage.labelCancel, onClick: () => this.handleButtonClick(false) }),
|
|
87
|
+
h("ez-button", { class: !this._currentMessage.btnConfirmDanger ? "button__confirm" : "button__confirm--danger", label: this._currentMessage.labelConfirm, onClick: () => this.handleButtonClick(true) })),
|
|
88
|
+
!this._currentMessage.confirm &&
|
|
89
|
+
h("div", { class: "button__confirm--container" },
|
|
90
|
+
h("ez-button", { label: 'Ok', class: "button__confirm", onClick: () => this.handleButtonClick(true) }))))));
|
|
87
91
|
}
|
|
88
92
|
return null;
|
|
89
93
|
}
|
|
@@ -255,7 +259,7 @@ export class EzDialog {
|
|
|
255
259
|
},
|
|
256
260
|
"show": {
|
|
257
261
|
"complexType": {
|
|
258
|
-
"signature": "(title: string, message: string, critical: boolean, confirm: boolean, icon: string) => Promise<boolean>",
|
|
262
|
+
"signature": "(title: string, message: string, critical: boolean, confirm: boolean, icon: string, labelCancel: string, labelConfirm: string, btnConfirmDanger: boolean) => Promise<boolean>",
|
|
259
263
|
"parameters": [{
|
|
260
264
|
"tags": [],
|
|
261
265
|
"text": ""
|
|
@@ -271,6 +275,15 @@ export class EzDialog {
|
|
|
271
275
|
}, {
|
|
272
276
|
"tags": [],
|
|
273
277
|
"text": ""
|
|
278
|
+
}, {
|
|
279
|
+
"tags": [],
|
|
280
|
+
"text": ""
|
|
281
|
+
}, {
|
|
282
|
+
"tags": [],
|
|
283
|
+
"text": ""
|
|
284
|
+
}, {
|
|
285
|
+
"tags": [],
|
|
286
|
+
"text": ""
|
|
274
287
|
}],
|
|
275
288
|
"references": {
|
|
276
289
|
"Promise": {
|
|
@@ -1,32 +1,62 @@
|
|
|
1
|
-
import { ApplicationContext } from "@sankhyalabs/core";
|
|
1
|
+
import { ApplicationContext, Action } from "@sankhyalabs/core";
|
|
2
2
|
export default class DataBinder {
|
|
3
3
|
constructor(dataUnit) {
|
|
4
|
+
this.onDataUnitEvent = (action) => {
|
|
5
|
+
var _a;
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case Action.DATA_LOADED:
|
|
8
|
+
case Action.DATA_SAVED:
|
|
9
|
+
case Action.RECORDS_REMOVED:
|
|
10
|
+
case Action.RECORDS_ADDED:
|
|
11
|
+
case Action.RECORDS_COPIED:
|
|
12
|
+
case Action.DATA_CHANGED:
|
|
13
|
+
case Action.EDITION_CANCELED:
|
|
14
|
+
case Action.CHANGE_UNDONE:
|
|
15
|
+
case Action.CHANGE_REDONE:
|
|
16
|
+
case Action.SELECTION_CHANGED:
|
|
17
|
+
case Action.NEXT_SELECTED:
|
|
18
|
+
case Action.PREVIOUS_SELECTED:
|
|
19
|
+
(_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
20
|
+
this.updateValue(field.fieldName, field.field);
|
|
21
|
+
});
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
4
25
|
this._fields = new Map();
|
|
5
26
|
this._dataUnit = dataUnit;
|
|
6
|
-
this._dataUnit.subscribe(
|
|
7
|
-
var _a;
|
|
8
|
-
(_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
9
|
-
this.updateValue(field.fieldName, field.field);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
27
|
+
this._dataUnit.subscribe(this.onDataUnitEvent);
|
|
12
28
|
}
|
|
13
29
|
bind(fields) {
|
|
14
30
|
fields.forEach(fieldElement => {
|
|
15
31
|
const fieldName = fieldElement.dataset.fieldName;
|
|
16
32
|
this.updateBind(fieldName, fieldElement);
|
|
17
|
-
this.updateValue(fieldName, fieldElement);
|
|
18
33
|
});
|
|
19
34
|
}
|
|
35
|
+
onDisconnectedCallback() {
|
|
36
|
+
this._dataUnit.unsubscribe(this.onDataUnitEvent);
|
|
37
|
+
}
|
|
20
38
|
updateValue(fieldName, field) {
|
|
21
|
-
field["value"]
|
|
39
|
+
const oldValue = field["value"];
|
|
40
|
+
const newValue = this._dataUnit.getFieldValue(fieldName);
|
|
41
|
+
if (oldValue != newValue) {
|
|
42
|
+
field["value"] = newValue;
|
|
43
|
+
}
|
|
22
44
|
}
|
|
23
45
|
updateBind(fieldName, field) {
|
|
24
46
|
const oldBind = this._fields.get(fieldName);
|
|
25
47
|
if (oldBind) {
|
|
26
48
|
oldBind.destroy();
|
|
27
49
|
}
|
|
28
|
-
|
|
50
|
+
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
51
|
+
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
29
52
|
this.bindSearchOptionsLoader(fieldName, field);
|
|
53
|
+
this.applyEzUploadContext(fieldName, field);
|
|
54
|
+
}
|
|
55
|
+
changeStarted(fieldName, waitingChange) {
|
|
56
|
+
if (this._dataUnit.records.length === 0) {
|
|
57
|
+
this._dataUnit.addRecord();
|
|
58
|
+
}
|
|
59
|
+
this._dataUnit.startChange(fieldName, waitingChange);
|
|
30
60
|
}
|
|
31
61
|
setFieldValue(fieldName, newValue) {
|
|
32
62
|
if (this._dataUnit.records.length === 0) {
|
|
@@ -44,19 +74,37 @@ export default class DataBinder {
|
|
|
44
74
|
}
|
|
45
75
|
}
|
|
46
76
|
}
|
|
77
|
+
applyEzUploadContext(fieldName, field) {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
if (field.nodeName === "EZ-UPLOAD") {
|
|
80
|
+
field["urlUpload"] = ApplicationContext.getContextValue("__EZUI__UPLOAD__ADD__URL__");
|
|
81
|
+
field["urlDelete"] = ApplicationContext.getContextValue("__EZUI__UPLOAD__DEL__URL__");
|
|
82
|
+
const descriptor = this._dataUnit.getField(fieldName);
|
|
83
|
+
const destination = (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.DESTINATION;
|
|
84
|
+
if (destination) {
|
|
85
|
+
field["requestHeaders"] = { XTRAINF: `{"destination": "${destination}"}` };
|
|
86
|
+
}
|
|
87
|
+
field["maxFiles"] = ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.MAX_FILES) || 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
47
90
|
}
|
|
48
91
|
class Bind {
|
|
92
|
+
constructor() {
|
|
93
|
+
this.startChangeEventName = "ezStartChange";
|
|
94
|
+
this.changeEventName = "ezChange";
|
|
95
|
+
}
|
|
49
96
|
destroy() {
|
|
50
|
-
this.field.removeEventListener(this.
|
|
97
|
+
this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
|
|
98
|
+
this.field.removeEventListener(this.changeEventName, this.changeListener);
|
|
51
99
|
}
|
|
52
|
-
static create(fieldName, field,
|
|
100
|
+
static create(fieldName, field, startChangeCallback, changeCallback) {
|
|
53
101
|
const b = new Bind();
|
|
54
|
-
b.fieldName = fieldName;
|
|
55
102
|
b.field = field;
|
|
56
|
-
|
|
57
|
-
b.
|
|
58
|
-
b.
|
|
59
|
-
b.
|
|
103
|
+
b.fieldName = fieldName;
|
|
104
|
+
b.startChangeListener = (evt) => { startChangeCallback(fieldName, evt.detail); };
|
|
105
|
+
b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
|
|
106
|
+
b.changeListener = (evt) => { changeCallback(fieldName, evt.detail); };
|
|
107
|
+
b.field.addEventListener(b.changeEventName, b.changeListener);
|
|
60
108
|
return b;
|
|
61
109
|
}
|
|
62
110
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, h, Host, Prop, Element, forceUpdate, Method, Watch } from "@stencil/core";
|
|
1
|
+
import { Component, h, Host, Prop, Element, forceUpdate, Method, Watch, Event } from "@stencil/core";
|
|
2
2
|
import { DataUnit, Action, DataUnitAction } from "@sankhyalabs/core";
|
|
3
3
|
import { FormSheet } from "./structure/FormSheet";
|
|
4
4
|
import { buildFromConfig, buildFromDataUnit } from "./structure/FormSheetMetadata";
|
|
@@ -7,6 +7,13 @@ import { formReducer, selectCurrentSheet, selectFormMetadata, loadMetadata, chan
|
|
|
7
7
|
import DataBinder from "./DataBinder";
|
|
8
8
|
import ApplicationUtils from "../../utils/ApplicationUtils";
|
|
9
9
|
export class EzForm {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.onDataUnitAction = (action) => {
|
|
12
|
+
if (action.type === Action.METADATA_LOADED) {
|
|
13
|
+
this.processMetadata();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
10
17
|
submit() {
|
|
11
18
|
return Promise.resolve();
|
|
12
19
|
}
|
|
@@ -99,11 +106,7 @@ export class EzForm {
|
|
|
99
106
|
this.dataUnit = new DataUnit("ez-form");
|
|
100
107
|
}
|
|
101
108
|
this.dataUnit.addInterceptor(this);
|
|
102
|
-
this.dataUnit.subscribe(
|
|
103
|
-
if (action.type === Action.METADATA_LOADED) {
|
|
104
|
-
this.processMetadata();
|
|
105
|
-
}
|
|
106
|
-
});
|
|
109
|
+
this.dataUnit.subscribe(this.onDataUnitAction);
|
|
107
110
|
this._dataBinder = new DataBinder(this.dataUnit);
|
|
108
111
|
this._store = createStore(formReducer);
|
|
109
112
|
this._store.subscribe(() => forceUpdate(this));
|
|
@@ -112,6 +115,12 @@ export class EzForm {
|
|
|
112
115
|
}
|
|
113
116
|
componentDidRender() {
|
|
114
117
|
this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")));
|
|
118
|
+
this.ezReady.emit();
|
|
119
|
+
}
|
|
120
|
+
disconnectedCallback() {
|
|
121
|
+
this.dataUnit.unsubscribe(this.onDataUnitAction);
|
|
122
|
+
this.dataUnit.removeInterceptor(this);
|
|
123
|
+
this._dataBinder.onDisconnectedCallback();
|
|
115
124
|
}
|
|
116
125
|
render() {
|
|
117
126
|
return (h(Host, null, this.isStatic() ? null : this.getDynamicContent()));
|
|
@@ -167,6 +176,22 @@ export class EzForm {
|
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
178
|
}; }
|
|
179
|
+
static get events() { return [{
|
|
180
|
+
"method": "ezReady",
|
|
181
|
+
"name": "ezReady",
|
|
182
|
+
"bubbles": true,
|
|
183
|
+
"cancelable": true,
|
|
184
|
+
"composed": true,
|
|
185
|
+
"docs": {
|
|
186
|
+
"tags": [],
|
|
187
|
+
"text": "Evento disparado quando o formul\u00E1rio est\u00E1 dispon\u00EDvel na DOM."
|
|
188
|
+
},
|
|
189
|
+
"complexType": {
|
|
190
|
+
"original": "void",
|
|
191
|
+
"resolved": "void",
|
|
192
|
+
"references": {}
|
|
193
|
+
}
|
|
194
|
+
}]; }
|
|
170
195
|
static get methods() { return {
|
|
171
196
|
"submit": {
|
|
172
197
|
"complexType": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
export const buildFile = ({ name, label, readOnly }) => {
|
|
3
3
|
return (h("div", { class: "col col--sd-12 padding-horizontal--small" },
|
|
4
|
-
h("ez-upload", { enabled: !readOnly, label: label,
|
|
4
|
+
h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
5
5
|
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { Action } from "@sankhyalabs/core";
|
|
2
2
|
export default class DataUnitBridge {
|
|
3
3
|
constructor(gridController, dataUnit) {
|
|
4
|
+
this.processAction = (action) => {
|
|
5
|
+
switch (action.type) {
|
|
6
|
+
case Action.METADATA_LOADED:
|
|
7
|
+
this._gridController.setColumnsDef(this.buildColumnDefs(), true);
|
|
8
|
+
break;
|
|
9
|
+
case Action.RECORDS_REMOVED:
|
|
10
|
+
const { records } = action.payload;
|
|
11
|
+
this._gridController.removeRows(records);
|
|
12
|
+
break;
|
|
13
|
+
case Action.RECORDS_ADDED:
|
|
14
|
+
case Action.RECORDS_COPIED:
|
|
15
|
+
this._gridController.addRows(action.payload);
|
|
16
|
+
break;
|
|
17
|
+
case Action.EDITION_CANCELED:
|
|
18
|
+
case Action.DATA_SAVED:
|
|
19
|
+
this._gridController.refresh();
|
|
20
|
+
break;
|
|
21
|
+
case Action.SELECTION_CHANGED:
|
|
22
|
+
const { selection } = action.payload;
|
|
23
|
+
this._gridController.selectRows(selection);
|
|
24
|
+
break;
|
|
25
|
+
case Action.DATA_CHANGED:
|
|
26
|
+
const changes = Object.assign({}, action.payload);
|
|
27
|
+
delete changes.records;
|
|
28
|
+
this._gridController.changeValues(changes, action.payload.records);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
4
31
|
this._gridController = gridController;
|
|
5
32
|
this._dataUnit = dataUnit;
|
|
6
|
-
this._dataUnit.subscribe(
|
|
7
|
-
}
|
|
8
|
-
processAction(action) {
|
|
9
|
-
switch (action.type) {
|
|
10
|
-
case Action.METADATA_LOADED:
|
|
11
|
-
this._gridController.setColumnsDef(this.buildColumnDefs(), true);
|
|
12
|
-
break;
|
|
13
|
-
case Action.RECORDS_REMOVED:
|
|
14
|
-
const { records } = action.payload;
|
|
15
|
-
this._gridController.removeRows(records);
|
|
16
|
-
break;
|
|
17
|
-
case Action.RECORDS_ADDED:
|
|
18
|
-
case Action.RECORDS_COPIED:
|
|
19
|
-
this._gridController.addRows(action.payload);
|
|
20
|
-
break;
|
|
21
|
-
case Action.EDITION_CANCELED:
|
|
22
|
-
case Action.DATA_SAVED:
|
|
23
|
-
this._gridController.refresh();
|
|
24
|
-
break;
|
|
25
|
-
case Action.SELECTION_CHANGED:
|
|
26
|
-
const { selection } = action.payload;
|
|
27
|
-
this._gridController.selectRows(selection);
|
|
28
|
-
break;
|
|
29
|
-
case Action.DATA_CHANGED:
|
|
30
|
-
const changes = Object.assign({}, action.payload);
|
|
31
|
-
delete changes.records;
|
|
32
|
-
this._gridController.changeValues(changes, action.payload.records);
|
|
33
|
-
}
|
|
33
|
+
this._dataUnit.subscribe(this.processAction);
|
|
34
34
|
}
|
|
35
35
|
buildColumnDefs() {
|
|
36
36
|
const columnDefs = [];
|
|
@@ -44,4 +44,7 @@ export default class DataUnitBridge {
|
|
|
44
44
|
}
|
|
45
45
|
return columnDefs;
|
|
46
46
|
}
|
|
47
|
+
onDisconnectedCallback() {
|
|
48
|
+
this._dataUnit.unsubscribe(this.processAction);
|
|
49
|
+
}
|
|
47
50
|
}
|
|
@@ -95,6 +95,11 @@ export class EzGrid {
|
|
|
95
95
|
this._gridController.setColumnsDef(this._dataUnitBridge.buildColumnDefs(), true);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
disconnectedCallback() {
|
|
99
|
+
if (this._dataUnitBridge) {
|
|
100
|
+
this._dataUnitBridge.onDisconnectedCallback();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
98
103
|
getPaginationControl() {
|
|
99
104
|
if (this.pageSize === -1) {
|
|
100
105
|
return null;
|
|
@@ -10,6 +10,9 @@ export class EzUpload {
|
|
|
10
10
|
this.enabled = true;
|
|
11
11
|
}
|
|
12
12
|
changeValue(newValue) {
|
|
13
|
+
//Observamos o mundo externo, se um novo valor foi atribuído,
|
|
14
|
+
//precisamos cancelar a alteração anterior, isso envolve, percorrer
|
|
15
|
+
//a lista de ponteiros e cancelar todos os uploads em andamento.
|
|
13
16
|
if (newValue !== this._updatingValue) {
|
|
14
17
|
this._filePointers.forEach(f => {
|
|
15
18
|
if (this.isRemoteFile(f)) {
|
|
@@ -18,8 +21,8 @@ export class EzUpload {
|
|
|
18
21
|
});
|
|
19
22
|
this._filePointers = new Map();
|
|
20
23
|
this.updateFilePointers();
|
|
24
|
+
this._updatingValue = undefined;
|
|
21
25
|
}
|
|
22
|
-
this._updatingValue = undefined;
|
|
23
26
|
}
|
|
24
27
|
updateFilePointers() {
|
|
25
28
|
if (this.value) {
|
|
@@ -89,6 +92,7 @@ export class EzUpload {
|
|
|
89
92
|
}
|
|
90
93
|
async doAddFile(file) {
|
|
91
94
|
if (this.validateFile(file)) {
|
|
95
|
+
this.ezStartChange.emit({ waitmessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio." });
|
|
92
96
|
const uploadingFile = new RemoteFile(file);
|
|
93
97
|
this._filePointers.set(file.name, uploadingFile);
|
|
94
98
|
uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
|
|
@@ -108,8 +112,10 @@ export class EzUpload {
|
|
|
108
112
|
this._updatingValue.push(f);
|
|
109
113
|
}
|
|
110
114
|
});
|
|
111
|
-
this.
|
|
112
|
-
|
|
115
|
+
if (this._filePointers.size === this._updatingValue.length) {
|
|
116
|
+
this.value = this._updatingValue;
|
|
117
|
+
this.ezChange.emit(this.value);
|
|
118
|
+
}
|
|
113
119
|
}
|
|
114
120
|
buildProgressId(uploading) {
|
|
115
121
|
let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
|
|
@@ -435,6 +441,26 @@ export class EzUpload {
|
|
|
435
441
|
}
|
|
436
442
|
}
|
|
437
443
|
}
|
|
444
|
+
}, {
|
|
445
|
+
"method": "ezStartChange",
|
|
446
|
+
"name": "ezStartChange",
|
|
447
|
+
"bubbles": true,
|
|
448
|
+
"cancelable": true,
|
|
449
|
+
"composed": true,
|
|
450
|
+
"docs": {
|
|
451
|
+
"tags": [],
|
|
452
|
+
"text": "Evento emitido ao iniciar a altera\u00E7\u00E3o (remover ou adicionar um arquivo)."
|
|
453
|
+
},
|
|
454
|
+
"complexType": {
|
|
455
|
+
"original": "WaitingChange",
|
|
456
|
+
"resolved": "WaitingChange",
|
|
457
|
+
"references": {
|
|
458
|
+
"WaitingChange": {
|
|
459
|
+
"location": "import",
|
|
460
|
+
"path": "@sankhyalabs/core"
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
438
464
|
}]; }
|
|
439
465
|
static get methods() { return {
|
|
440
466
|
"addFiles": {
|
|
@@ -1,49 +1,24 @@
|
|
|
1
|
-
import { Component, h } from '@stencil/core';
|
|
2
|
-
import { DataUnit, DataType, UserInterface } from '@sankhyalabs/core';
|
|
1
|
+
import { Component, h, State } from '@stencil/core';
|
|
2
|
+
import { DataUnit, DataType, UserInterface, ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { ApplicationUtils } from '../../utils';
|
|
3
4
|
export class TestDu {
|
|
4
|
-
/*private _ezButton// : HTMLEzButton;
|
|
5
|
-
private _ezComboBox// : HTMLEzComboBox;
|
|
6
|
-
private _ezDateInput// : HTMLEzDateInput;
|
|
7
|
-
private _ezDateTimeInput// : HTMLEzDateTimeInput;
|
|
8
|
-
private _ezNumberInput// : HTMLEzNumberInput
|
|
9
|
-
private _ezSearch// : HTMLEzSearch
|
|
10
|
-
private _ezUpload// : HTMLEzUpload
|
|
11
|
-
private _ezFilterInput// : HTMLEzFilterInput*/
|
|
12
5
|
componentWillLoad() {
|
|
6
|
+
ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", "http://localhost:8080/mge/ez.uploading");
|
|
13
7
|
this.dataUnit = new DataUnit("testes_com_formulario");
|
|
8
|
+
this.dataUnit.subscribe(() => this.isDirty = this.dataUnit.isDirty());
|
|
14
9
|
this.dataUnit.metadata = {
|
|
15
10
|
name: "dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",
|
|
16
11
|
label: "Parceiro",
|
|
17
12
|
fields: [
|
|
18
13
|
{
|
|
19
|
-
name: "
|
|
20
|
-
label: "
|
|
21
|
-
dataType: DataType.
|
|
22
|
-
userInterface: UserInterface.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: "RECDESP",
|
|
28
|
-
label: "Receita/Despesa",
|
|
29
|
-
dataType: DataType.TEXT,
|
|
30
|
-
userInterface: UserInterface.OPTIONSELECTOR,
|
|
31
|
-
required: true,
|
|
32
|
-
properties: { options: `{"-1": "Despesa", "1": "Receita"}` }
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "P",
|
|
36
|
-
label: "pera",
|
|
37
|
-
dataType: DataType.TEXT,
|
|
38
|
-
userInterface: UserInterface.OPTIONSELECTOR,
|
|
39
|
-
properties: { options: `{"M": "Madura", "V": "Verde", "P": "Passada"}` }
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "ME",
|
|
43
|
-
label: "ME",
|
|
44
|
-
dataType: DataType.NUMBER,
|
|
45
|
-
userInterface: UserInterface.DECIMALNUMBER,
|
|
46
|
-
properties: { precision: 4, prettyPrecision: 1 }
|
|
14
|
+
name: "ANEXO",
|
|
15
|
+
label: "Anexo",
|
|
16
|
+
dataType: DataType.OBJECT,
|
|
17
|
+
userInterface: UserInterface.FILE,
|
|
18
|
+
properties: {
|
|
19
|
+
DESTINATION: "MULTIFILE",
|
|
20
|
+
MAX_FILES: "2"
|
|
21
|
+
}
|
|
47
22
|
}
|
|
48
23
|
]
|
|
49
24
|
};
|
|
@@ -61,9 +36,26 @@ export class TestDu {
|
|
|
61
36
|
total: 100,
|
|
62
37
|
hasMore: true
|
|
63
38
|
}));
|
|
39
|
+
this.dataUnit.saveLoader = (_dataUnit, changes) => {
|
|
40
|
+
const savedRecords = [];
|
|
41
|
+
changes.forEach(change => {
|
|
42
|
+
savedRecords.push(Object.assign(Object.assign({}, change.record), change.updatingFields));
|
|
43
|
+
});
|
|
44
|
+
return Promise.resolve(savedRecords);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
save() {
|
|
48
|
+
this.dataUnit.saveData().catch(e => {
|
|
49
|
+
if (e.kind === "WAITING_CHANGE_ERROR") {
|
|
50
|
+
ApplicationUtils.alert(`Alterando campo ${e.fieldName}`, e.message);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
64
53
|
}
|
|
65
54
|
render() {
|
|
66
|
-
return (h("
|
|
55
|
+
return (h("div", null,
|
|
56
|
+
h("button", { onClick: () => this.dataUnit.loadData() }, "Carregar"),
|
|
57
|
+
h("button", { onClick: () => this.save(), disabled: !this.isDirty }, "Salvar"),
|
|
58
|
+
h("ez-form", { dataUnit: this.dataUnit })));
|
|
67
59
|
}
|
|
68
60
|
static get is() { return "test-du"; }
|
|
69
61
|
static get originalStyleUrls() { return {
|
|
@@ -72,4 +64,7 @@ export class TestDu {
|
|
|
72
64
|
static get styleUrls() { return {
|
|
73
65
|
"$": ["test-du.css"]
|
|
74
66
|
}; }
|
|
67
|
+
static get states() { return {
|
|
68
|
+
"isDirty": {}
|
|
69
|
+
}; }
|
|
75
70
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
export default class ApplicationUtils {
|
|
2
|
-
static async showDialog(title, message, icon = null, confirm, critical = false) {
|
|
2
|
+
static async showDialog(title, message, icon = null, confirm, critical = false, options) {
|
|
3
|
+
if (options) {
|
|
4
|
+
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
5
|
+
}
|
|
3
6
|
return new Promise(resolve => {
|
|
4
7
|
let dialog = document.querySelector("ez-dialog");
|
|
5
8
|
if (!dialog) {
|
|
6
9
|
dialog = document.createElement("ez-dialog");
|
|
7
10
|
window.document.body.appendChild(dialog);
|
|
8
11
|
}
|
|
9
|
-
dialog.show(title, message, critical, confirm, icon).then(ok => resolve(ok));
|
|
12
|
+
dialog.show(title, message, critical, confirm, icon, options.labelCancel, options.labelConfirm, options.btnConfirmDanger).then(ok => resolve(ok));
|
|
10
13
|
});
|
|
11
14
|
}
|
|
12
|
-
static async alert(title, message, icon = null) {
|
|
13
|
-
return ApplicationUtils.showDialog(title, message, icon, false, false);
|
|
15
|
+
static async alert(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
16
|
+
return ApplicationUtils.showDialog(title, message, icon, false, false, options);
|
|
14
17
|
}
|
|
15
|
-
static async error(title, message, icon = null) {
|
|
16
|
-
return ApplicationUtils.showDialog(title, message, icon, false, true);
|
|
18
|
+
static async error(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
19
|
+
return ApplicationUtils.showDialog(title, message, icon, false, true, options);
|
|
17
20
|
}
|
|
18
|
-
static async confirm(title, message, icon = null, critical = false) {
|
|
19
|
-
return ApplicationUtils.showDialog(title, message, icon, true, critical);
|
|
21
|
+
static async confirm(title, message, icon = null, critical = false, options = ApplicationUtils.defaultMessageOptions) {
|
|
22
|
+
return ApplicationUtils.showDialog(title, message, icon, true, critical, options);
|
|
20
23
|
}
|
|
21
24
|
static async info(message, options = ApplicationUtils.defaultMessageOptions) {
|
|
22
25
|
let toast = document.querySelector("ez-toast");
|
|
@@ -28,6 +31,9 @@ export default class ApplicationUtils {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
ApplicationUtils.defaultMessageOptions = {
|
|
31
|
-
canClose: true
|
|
34
|
+
canClose: true,
|
|
35
|
+
labelCancel: 'Não',
|
|
36
|
+
labelConfirm: 'Sim',
|
|
37
|
+
btnConfirmDanger: false
|
|
32
38
|
};
|
|
33
39
|
;
|