@sankhyalabs/sankhyablocks 1.3.31-beta.1 → 1.3.31-beta.11
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/SnkMessageBuilder-13239761.js +188 -0
- package/dist/cjs/{index-1133bc2a.js → index-c6671817.js} +416 -9
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +283 -108
- package/dist/cjs/snk-crud.cjs.entry.js +64 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +277 -0
- package/dist/cjs/snk-form_2.cjs.entry.js +177 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +6 -3
- package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
- package/dist/cjs/taskbar-elements-73d524e5.js +70 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +5 -0
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +2 -2
- package/dist/collection/components/snk-application/snk-application.js +267 -63
- package/dist/collection/components/snk-crud/snk-crud.css +5 -0
- package/dist/collection/components/snk-crud/snk-crud.js +137 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +528 -0
- package/dist/collection/components/snk-form/snk-form.css +34 -0
- package/dist/collection/components/snk-form/snk-form.js +220 -0
- package/dist/collection/components/snk-grid/snk-grid.css +5 -0
- package/dist/collection/components/snk-grid/snk-grid.js +148 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +56 -13
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +5 -1
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +65 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +271 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +119 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +22 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +16 -0
- package/dist/components/SnkMessageBuilder.js +166 -0
- package/dist/components/snk-application2.js +284 -107
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +101 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +300 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +140 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +91 -0
- package/dist/components/snk-pesquisa2.js +5 -2
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +240 -0
- package/dist/esm/SnkMessageBuilder-3835f9d8.js +166 -0
- package/dist/esm/{index-ffda6382.js → index-6a83ac96.js} +416 -10
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +283 -108
- package/dist/esm/snk-crud.entry.js +60 -0
- package/dist/esm/snk-data-unit.entry.js +273 -0
- package/dist/esm/snk-form_2.entry.js +172 -0
- package/dist/esm/snk-pesquisa.entry.js +6 -3
- package/dist/esm/snk-taskbar.entry.js +155 -0
- package/dist/esm/taskbar-elements-6d01a640.js +68 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-4c7b32d6.entry.js +1 -0
- package/dist/sankhyablocks/p-5e1b7e51.entry.js +1 -0
- package/dist/sankhyablocks/p-72bccbb6.js +1 -0
- package/dist/sankhyablocks/p-8c74d163.entry.js +1 -0
- package/dist/sankhyablocks/p-bab507ad.entry.js +1 -0
- package/dist/sankhyablocks/p-cd1dc099.js +2 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-d25637c9.entry.js} +1 -1
- package/dist/sankhyablocks/p-dd10a5e3.js +1 -0
- package/dist/sankhyablocks/p-e942c604.entry.js +69 -0
- package/dist/sankhyablocks/p-f4d0394b.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +109 -15
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +25 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +53 -0
- package/dist/types/components.d.ts +372 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +3 -3
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
- package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/package.json +5 -5
- package/react/components.d.ts +5 -0
- package/react/components.js +5 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-d62412bb.entry.js +0 -1
- package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkCrud extends Components.SnkCrud, HTMLElement {}
|
|
4
|
+
export const SnkCrud: {
|
|
5
|
+
prototype: SnkCrud;
|
|
6
|
+
new (): SnkCrud;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$4 } from './snk-form2.js';
|
|
3
|
+
import { d as defineCustomElement$3 } from './snk-grid2.js';
|
|
4
|
+
import { d as defineCustomElement$2 } from './snk-taskbar2.js';
|
|
5
|
+
|
|
6
|
+
const snkCrudCss = ".sc-snk-crud-h{display:flex;height:100%;width:100%}";
|
|
7
|
+
|
|
8
|
+
const GRID_MODE = 0;
|
|
9
|
+
const FORM_MODE = 1;
|
|
10
|
+
const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.__registerHost();
|
|
14
|
+
}
|
|
15
|
+
async gridToForm(keepFormMode = false) {
|
|
16
|
+
this._backToGrid = !keepFormMode && await this._viewStack.getSelectedIndex() === GRID_MODE;
|
|
17
|
+
this._viewStack.show(FORM_MODE);
|
|
18
|
+
}
|
|
19
|
+
async executeAction(act) {
|
|
20
|
+
if (act === "GRID_MODE") {
|
|
21
|
+
this._viewStack.show(GRID_MODE);
|
|
22
|
+
}
|
|
23
|
+
else if (act === "FORM_MODE" || act === "UPDATE") {
|
|
24
|
+
this.gridToForm(act !== "UPDATE");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
insertionModeHandler() {
|
|
28
|
+
this.gridToForm();
|
|
29
|
+
}
|
|
30
|
+
cancelHandler() {
|
|
31
|
+
if (this._backToGrid) {
|
|
32
|
+
this._viewStack.show(GRID_MODE);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
componentWillLoad() {
|
|
36
|
+
let parent = this._element.parentElement;
|
|
37
|
+
while (parent) {
|
|
38
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
39
|
+
this._snkDataUnit = parent;
|
|
40
|
+
this._snkDataUnit.addEventListener("insertionMode", () => this.insertionModeHandler());
|
|
41
|
+
this._snkDataUnit.addEventListener("cancelEdition", () => this.cancelHandler());
|
|
42
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
43
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
44
|
+
if (!this._dataUnit) {
|
|
45
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
46
|
+
this._dataUnit = evt.detail;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
50
|
+
this._dataState = evt.detail;
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
parent = parent.parentElement;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, h("stack-item", null, h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList }, h("slot", null))), h("stack-item", null, h("snk-form", { configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, onActionClick: evt => this.executeAction(evt.detail) }))));
|
|
59
|
+
}
|
|
60
|
+
get _element() { return this; }
|
|
61
|
+
static get style() { return snkCrudCss; }
|
|
62
|
+
}, [6, "snk-crud", {
|
|
63
|
+
"configName": [1, "config-name"],
|
|
64
|
+
"actionsList": [16],
|
|
65
|
+
"recordsValidator": [8, "records-validator"],
|
|
66
|
+
"_dataUnit": [32],
|
|
67
|
+
"_dataState": [32]
|
|
68
|
+
}]);
|
|
69
|
+
function defineCustomElement$1() {
|
|
70
|
+
if (typeof customElements === "undefined") {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const components = ["snk-crud", "snk-form", "snk-grid", "snk-taskbar"];
|
|
74
|
+
components.forEach(tagName => { switch (tagName) {
|
|
75
|
+
case "snk-crud":
|
|
76
|
+
if (!customElements.get(tagName)) {
|
|
77
|
+
customElements.define(tagName, SnkCrud$1);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case "snk-form":
|
|
81
|
+
if (!customElements.get(tagName)) {
|
|
82
|
+
defineCustomElement$4();
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case "snk-grid":
|
|
86
|
+
if (!customElements.get(tagName)) {
|
|
87
|
+
defineCustomElement$3();
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case "snk-taskbar":
|
|
91
|
+
if (!customElements.get(tagName)) {
|
|
92
|
+
defineCustomElement$2();
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
} });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const SnkCrud = SnkCrud$1;
|
|
99
|
+
const defineCustomElement = defineCustomElement$1;
|
|
100
|
+
|
|
101
|
+
export { SnkCrud, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkDataUnit extends Components.SnkDataUnit, HTMLElement {}
|
|
4
|
+
export const SnkDataUnit: {
|
|
5
|
+
prototype: SnkDataUnit;
|
|
6
|
+
new (): SnkDataUnit;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { Action, ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
+
import { O as OperationMap } from './SnkMessageBuilder.js';
|
|
5
|
+
|
|
6
|
+
const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
|
|
7
|
+
|
|
8
|
+
const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.__registerHost();
|
|
12
|
+
this.dataStateChange = createEvent(this, "dataStateChange", 7);
|
|
13
|
+
this.dataUnitReady = createEvent(this, "dataUnitReady", 7);
|
|
14
|
+
this.insertionMode = createEvent(this, "insertionMode", 7);
|
|
15
|
+
this.cancelEdition = createEvent(this, "cancelEdition", 7);
|
|
16
|
+
this._onDataUnitResolve = [];
|
|
17
|
+
/**
|
|
18
|
+
* Determina quantas linhas são retornadas por página
|
|
19
|
+
*/
|
|
20
|
+
this.pageSize = 150;
|
|
21
|
+
/**
|
|
22
|
+
* Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit
|
|
23
|
+
*/
|
|
24
|
+
this.autoLoad = true;
|
|
25
|
+
this._dataUnitObserver = (action) => {
|
|
26
|
+
const duState = {
|
|
27
|
+
insertionMode: false,
|
|
28
|
+
hasNext: this.dataUnit.hasNext(),
|
|
29
|
+
hasPrevious: this.dataUnit.hasPrevious(),
|
|
30
|
+
copyMode: false,
|
|
31
|
+
isDirty: this.dataUnit.isDirty(),
|
|
32
|
+
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
33
|
+
selectedRecords: this.dataUnit.getSelectedRecords()
|
|
34
|
+
};
|
|
35
|
+
this.dataUnit.records.forEach(r => {
|
|
36
|
+
if (r.__record__id__.startsWith('NEW_')) {
|
|
37
|
+
duState.insertionMode = true;
|
|
38
|
+
duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.dataState = duState;
|
|
42
|
+
if (action.type === Action.DATA_SAVED) {
|
|
43
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
44
|
+
if (msg != undefined) {
|
|
45
|
+
this.showSuccessMessage(msg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
49
|
+
this.insertionMode.emit();
|
|
50
|
+
}
|
|
51
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
52
|
+
this.cancelEdition.emit();
|
|
53
|
+
const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
|
|
54
|
+
if (cancelFinishMsg != undefined) {
|
|
55
|
+
this.showSuccessMessage(cancelFinishMsg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (action.type === Action.RECORDS_REMOVED) {
|
|
59
|
+
const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
60
|
+
if (removeFinishMsg != undefined) {
|
|
61
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this._application.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
observePageSize() {
|
|
68
|
+
if (this.dataUnit) {
|
|
69
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
observeDataUnitName(newValue, oldValue) {
|
|
73
|
+
if (oldValue != newValue) {
|
|
74
|
+
this.dataUnit = undefined;
|
|
75
|
+
this.dataUnitName = newValue;
|
|
76
|
+
this.loadDataUnit();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
observeEntityName(newValue, oldValue) {
|
|
80
|
+
if (oldValue != newValue) {
|
|
81
|
+
this.dataUnit = undefined;
|
|
82
|
+
this.entityName = newValue;
|
|
83
|
+
this.loadDataUnit();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
observeDataState(newValue, oldValue) {
|
|
87
|
+
if (oldValue != newValue) {
|
|
88
|
+
this.dataStateChange.emit(newValue);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
observeDataUnit() {
|
|
92
|
+
this.dataUnitReady.emit(this.dataUnit);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Pode-se obter o dataUnit através desse método. Outra forma, é ouvir o evento de
|
|
96
|
+
*
|
|
97
|
+
* @returns dataUnit
|
|
98
|
+
*/
|
|
99
|
+
async getDataUnit() {
|
|
100
|
+
return new Promise((resolve) => {
|
|
101
|
+
if (this.dataUnit) {
|
|
102
|
+
resolve(this.dataUnit);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this._onDataUnitResolve.push(resolve);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async interceptAction(action) {
|
|
110
|
+
return new Promise(resolve => {
|
|
111
|
+
switch (action.type) {
|
|
112
|
+
case Action.RECORDS_ADDED:
|
|
113
|
+
if (this.isAllowed("INSERT")) {
|
|
114
|
+
resolve(action);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case Action.RECORDS_COPIED:
|
|
121
|
+
if (this.isAllowed("CLONE")) {
|
|
122
|
+
resolve(action);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case Action.DATA_CHANGED:
|
|
129
|
+
case Action.CHANGING_DATA:
|
|
130
|
+
if (this.isAllowed("UPDATE")) {
|
|
131
|
+
resolve(action);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this.dataUnit.cancelEdition();
|
|
135
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case Action.SAVING_DATA:
|
|
139
|
+
if (this.beforeSave) {
|
|
140
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
141
|
+
if (continueAction instanceof Promise) {
|
|
142
|
+
continueAction.then(result => resolve(result ? action : undefined));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
resolve(continueAction ? action : undefined);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
resolve(action);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case Action.DATA_SAVED:
|
|
153
|
+
if (this.afterSave) {
|
|
154
|
+
this.afterSave(this.dataUnit);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
resolve(action);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case Action.EDITION_CANCELED:
|
|
161
|
+
if (this.dataState.hasDirtyRecords) {
|
|
162
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
163
|
+
if (cancelConfirmation == undefined) {
|
|
164
|
+
resolve(action);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
168
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
169
|
+
.then((result) => resolve(result ? action : undefined));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
resolve(action);
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case Action.REMOVING_RECORDS:
|
|
177
|
+
if (this.isAllowed("REMOVE")) {
|
|
178
|
+
const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
|
|
179
|
+
if (removeConfirmation == undefined) {
|
|
180
|
+
resolve(action);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
184
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", true, { btnConfirmDanger: true })
|
|
185
|
+
.then((result) => resolve(result ? action : undefined));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
resolve(action);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
showSuccessMessage(message) {
|
|
198
|
+
ApplicationUtils.info(message, { iconName: "check" });
|
|
199
|
+
}
|
|
200
|
+
isAllowed(flag) {
|
|
201
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
205
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
206
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
207
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
208
|
+
*/
|
|
209
|
+
getMessage(key, params = undefined) {
|
|
210
|
+
if (!params) {
|
|
211
|
+
params = this.getMessageParams();
|
|
212
|
+
}
|
|
213
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
214
|
+
}
|
|
215
|
+
getMessageParams() {
|
|
216
|
+
//TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
|
|
217
|
+
//precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
|
|
218
|
+
//mensagem
|
|
219
|
+
return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
|
|
220
|
+
}
|
|
221
|
+
getMessageOperation() {
|
|
222
|
+
if (this.dataState.copyMode) {
|
|
223
|
+
return OperationMap.CLONE;
|
|
224
|
+
}
|
|
225
|
+
if (this.dataState.insertionMode) {
|
|
226
|
+
return OperationMap.INSERT;
|
|
227
|
+
}
|
|
228
|
+
if (this.dataState.isDirty) {
|
|
229
|
+
return OperationMap.UPDATE;
|
|
230
|
+
}
|
|
231
|
+
return OperationMap.CLEAN;
|
|
232
|
+
}
|
|
233
|
+
async loadDataUnit() {
|
|
234
|
+
if (!this.dataUnit) {
|
|
235
|
+
if (this._application && this.entityName) {
|
|
236
|
+
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
237
|
+
this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
|
|
238
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
239
|
+
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
240
|
+
this.dataUnit.addInterceptor(this);
|
|
241
|
+
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
242
|
+
let resolver;
|
|
243
|
+
while (resolver = this._onDataUnitResolve.pop()) {
|
|
244
|
+
resolver(this.dataUnit);
|
|
245
|
+
}
|
|
246
|
+
if (this.autoLoad) {
|
|
247
|
+
this.dataUnit.loadData();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//---------------------------------------------
|
|
253
|
+
// Lifecycle web component
|
|
254
|
+
//---------------------------------------------
|
|
255
|
+
componentWillLoad() {
|
|
256
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
257
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
258
|
+
this.loadDataUnit();
|
|
259
|
+
}
|
|
260
|
+
render() {
|
|
261
|
+
return (h(Host, null));
|
|
262
|
+
}
|
|
263
|
+
get element() { return this; }
|
|
264
|
+
static get watchers() { return {
|
|
265
|
+
"pageSize": ["observePageSize"],
|
|
266
|
+
"dataUnitName": ["observeDataUnitName"],
|
|
267
|
+
"entityName": ["observeEntityName"],
|
|
268
|
+
"dataState": ["observeDataState"],
|
|
269
|
+
"dataUnit": ["observeDataUnit"]
|
|
270
|
+
}; }
|
|
271
|
+
static get style() { return snkDataUnitCss; }
|
|
272
|
+
}, [2, "snk-data-unit", {
|
|
273
|
+
"dataState": [1040],
|
|
274
|
+
"dataUnitName": [1, "data-unit-name"],
|
|
275
|
+
"entityName": [1, "entity-name"],
|
|
276
|
+
"pageSize": [2, "page-size"],
|
|
277
|
+
"dataUnit": [1040],
|
|
278
|
+
"beforeSave": [16],
|
|
279
|
+
"afterSave": [16],
|
|
280
|
+
"autoLoad": [4, "auto-load"],
|
|
281
|
+
"getDataUnit": [64]
|
|
282
|
+
}]);
|
|
283
|
+
function defineCustomElement$1() {
|
|
284
|
+
if (typeof customElements === "undefined") {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const components = ["snk-data-unit"];
|
|
288
|
+
components.forEach(tagName => { switch (tagName) {
|
|
289
|
+
case "snk-data-unit":
|
|
290
|
+
if (!customElements.get(tagName)) {
|
|
291
|
+
customElements.define(tagName, SnkDataUnit$1);
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
} });
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const SnkDataUnit = SnkDataUnit$1;
|
|
298
|
+
const defineCustomElement = defineCustomElement$1;
|
|
299
|
+
|
|
300
|
+
export { SnkDataUnit, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkForm extends Components.SnkForm, HTMLElement {}
|
|
4
|
+
export const SnkForm: {
|
|
5
|
+
prototype: SnkForm;
|
|
6
|
+
new (): SnkForm;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { d as defineCustomElement$1 } from './snk-taskbar2.js';
|
|
4
|
+
|
|
5
|
+
const snkFormCss = ".sc-snk-form-h{display:block}.snk-form.sc-snk-form{position:relative;padding:var(--space--large);padding-top:var(--space--medium)}.snk-form__header.sc-snk-form{position:relative;padding-top:var(--space--medium);padding-bottom:var(--space--medium);margin-bottom:var(--space--medium)}.snk-form__header--fixed.sc-snk-form{position:sticky;top:0;background:var(--background--body);z-index:var(--more-visible, 2);padding-left:var(--space--large);padding-right:var(--space--large);margin-left:calc(var(--space--large) * -1);margin-right:calc(var(--space--large) * -1);width:calc(100% + (var(--space--large) * 2))}";
|
|
6
|
+
|
|
7
|
+
const SnkForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
this.exit = createEvent(this, "exit", 7);
|
|
12
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
13
|
+
}
|
|
14
|
+
getFormConfig() {
|
|
15
|
+
return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
|
|
16
|
+
}
|
|
17
|
+
getInsertionHiddenFields(formConfig) {
|
|
18
|
+
const hiddenFields = [];
|
|
19
|
+
formConfig === null || formConfig === void 0 ? void 0 : formConfig.forEach(cfg => {
|
|
20
|
+
const def = this._dataUnit.getField(cfg.name);
|
|
21
|
+
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
22
|
+
hiddenFields.push(cfg.name);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return hiddenFields;
|
|
26
|
+
}
|
|
27
|
+
exitForm() {
|
|
28
|
+
if (this._dataUnit.isDirty()) {
|
|
29
|
+
this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.exit.emit();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
getDisabledButtons() {
|
|
36
|
+
const disabled = [];
|
|
37
|
+
if (!this._dataState.hasPrevious) {
|
|
38
|
+
disabled.push("PREVIOUS");
|
|
39
|
+
}
|
|
40
|
+
if (!this._dataState.hasNext) {
|
|
41
|
+
disabled.push("NEXT");
|
|
42
|
+
}
|
|
43
|
+
return disabled;
|
|
44
|
+
}
|
|
45
|
+
loadInsertionConfig() {
|
|
46
|
+
if (this._dataUnit && this._configLoaded) {
|
|
47
|
+
this._insertionFormConfig = this._editionFormConfig.filter(fieldCfg => {
|
|
48
|
+
const def = this._dataUnit.getField(fieldCfg.name);
|
|
49
|
+
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
58
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
59
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
60
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
|
|
61
|
+
*/
|
|
62
|
+
getMessage(key) {
|
|
63
|
+
return this._application.messagesBuilder.getMessage(key, this.getMessageParams());
|
|
64
|
+
}
|
|
65
|
+
getMessageParams() {
|
|
66
|
+
var _a;
|
|
67
|
+
return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
|
|
68
|
+
}
|
|
69
|
+
componentWillLoad() {
|
|
70
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
71
|
+
if (this._application) {
|
|
72
|
+
this._application.loadFormConfig(this.configName).then(cfg => {
|
|
73
|
+
this._configLoaded = true;
|
|
74
|
+
this._editionFormConfig = cfg;
|
|
75
|
+
this.loadInsertionConfig();
|
|
76
|
+
});
|
|
77
|
+
//Forçamos a carga dos acessos pra aproveitar a request inicial.
|
|
78
|
+
this._application.getAllAccess();
|
|
79
|
+
}
|
|
80
|
+
let parent = this._element.parentElement;
|
|
81
|
+
while (parent) {
|
|
82
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
83
|
+
this._snkDataUnit = parent;
|
|
84
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
85
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
86
|
+
if (this._dataUnit) {
|
|
87
|
+
this.loadInsertionConfig();
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
91
|
+
this._dataUnit = evt.detail;
|
|
92
|
+
this.loadInsertionConfig();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
96
|
+
this._dataState = evt.detail;
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
parent = parent.parentElement;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
render() {
|
|
104
|
+
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
return (h("section", { class: "snk-form" }, h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", buttons: this._dataState.isDirty ? "CANCEL,SAVE" : "PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,INSERT", primaryButton: this._dataState.isDirty ? "SAVE" : "INSERT", disabledButtons: this.getDisabledButtons(), actionsList: this.actionsList, dataUnit: this._dataUnit }))), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator }))))));
|
|
108
|
+
}
|
|
109
|
+
get _element() { return this; }
|
|
110
|
+
static get style() { return snkFormCss; }
|
|
111
|
+
}, [2, "snk-form", {
|
|
112
|
+
"configName": [1, "config-name"],
|
|
113
|
+
"recordsValidator": [8, "records-validator"],
|
|
114
|
+
"actionsList": [16],
|
|
115
|
+
"_dataUnit": [32],
|
|
116
|
+
"_configLoaded": [32],
|
|
117
|
+
"_dataState": [32],
|
|
118
|
+
"_editionFormConfig": [32],
|
|
119
|
+
"_insertionFormConfig": [32]
|
|
120
|
+
}]);
|
|
121
|
+
function defineCustomElement() {
|
|
122
|
+
if (typeof customElements === "undefined") {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const components = ["snk-form", "snk-taskbar"];
|
|
126
|
+
components.forEach(tagName => { switch (tagName) {
|
|
127
|
+
case "snk-form":
|
|
128
|
+
if (!customElements.get(tagName)) {
|
|
129
|
+
customElements.define(tagName, SnkForm);
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
case "snk-taskbar":
|
|
133
|
+
if (!customElements.get(tagName)) {
|
|
134
|
+
defineCustomElement$1();
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
} });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { SnkForm as S, defineCustomElement as d };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkGrid extends Components.SnkGrid, HTMLElement {}
|
|
4
|
+
export const SnkGrid: {
|
|
5
|
+
prototype: SnkGrid;
|
|
6
|
+
new (): SnkGrid;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|