@sankhyalabs/sankhyablocks 1.3.31-beta.8 → 1.3.31-beta.9
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/{index-532bcc28.js → index-c6671817.js} +0 -3
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +67 -24
- package/dist/cjs/snk-crud.cjs.entry.js +64 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +6 -2
- package/dist/cjs/snk-form_2.cjs.entry.js +170 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -2
- package/dist/cjs/{taskbar-elements-9d47b416.js → taskbar-elements-7f99f0c9.js} +2 -2
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +2 -2
- package/dist/collection/components/snk-application/snk-application.js +71 -25
- package/dist/collection/components/snk-crud/snk-crud.css +5 -0
- package/dist/collection/components/snk-crud/snk-crud.js +149 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +19 -1
- package/dist/collection/components/snk-form/snk-form.js +59 -22
- package/dist/collection/components/snk-grid/snk-grid.js +33 -13
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -1
- package/dist/components/snk-application2.js +66 -23
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +102 -0
- package/dist/components/snk-data-unit.js +5 -1
- package/dist/components/snk-form.js +1 -116
- package/dist/components/snk-form2.js +134 -0
- package/dist/components/snk-grid.js +1 -83
- package/dist/components/snk-grid2.js +91 -0
- package/dist/components/snk-taskbar2.js +1 -1
- package/dist/esm/{index-0b078db7.js → index-6a83ac96.js} +0 -3
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +67 -24
- package/dist/esm/snk-crud.entry.js +60 -0
- package/dist/esm/snk-data-unit.entry.js +6 -2
- package/dist/esm/snk-form_2.entry.js +165 -0
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +2 -2
- package/dist/esm/{taskbar-elements-3ba30bf4.js → taskbar-elements-e0b8a285.js} +2 -2
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/{p-bc14f01e.entry.js → p-18fe0469.entry.js} +2 -2
- package/dist/sankhyablocks/p-4e2fcfe4.entry.js +1 -0
- package/dist/sankhyablocks/{p-1c19b89c.entry.js → p-5e2e9334.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8f7b9a85.entry.js → p-7fe9e5c2.entry.js} +1 -1
- package/dist/sankhyablocks/p-8650ae26.entry.js +1 -0
- package/dist/sankhyablocks/p-a5439706.js +1 -0
- package/dist/sankhyablocks/p-c3d20542.entry.js +1 -0
- package/dist/sankhyablocks/p-cd1dc099.js +2 -0
- package/dist/sankhyablocks/{p-a8305c35.entry.js → p-d25637c9.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +12 -3
- package/dist/types/components.d.ts +48 -5
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/snk-form.cjs.entry.js +0 -95
- package/dist/cjs/snk-grid.cjs.entry.js +0 -64
- package/dist/esm/snk-form.entry.js +0 -91
- package/dist/esm/snk-grid.entry.js +0 -60
- package/dist/sankhyablocks/p-560fdf54.entry.js +0 -1
- package/dist/sankhyablocks/p-574764bf.js +0 -1
- package/dist/sankhyablocks/p-9c225717.entry.js +0 -1
- package/dist/sankhyablocks/p-a45dba1a.js +0 -2
- package/dist/sankhyablocks/p-eaa0772f.entry.js +0 -1
|
@@ -7264,7 +7264,7 @@ class SnkErrorHandler {
|
|
|
7264
7264
|
}
|
|
7265
7265
|
else {
|
|
7266
7266
|
const title = (exception === null || exception === void 0 ? void 0 : exception.title) || "Erro detectado";
|
|
7267
|
-
const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${exception}"`;
|
|
7267
|
+
const message = (typeof exception === "string") ? exception : exception.message || `Erro interno "${ObjectUtils.objectToString(exception)}"`;
|
|
7268
7268
|
this._app.error(title, message);
|
|
7269
7269
|
}
|
|
7270
7270
|
}
|
|
@@ -7283,7 +7283,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
7283
7283
|
this.__registerHost();
|
|
7284
7284
|
this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
|
|
7285
7285
|
this.applicationLoading = createEvent(this, "applicationLoading", 7);
|
|
7286
|
+
this._authPromises = [];
|
|
7286
7287
|
this._duCache = new Map();
|
|
7288
|
+
this._duPromises = new Map();
|
|
7287
7289
|
this._requestListener = new RequestListenerLoadingBar();
|
|
7288
7290
|
}
|
|
7289
7291
|
get parameters() {
|
|
@@ -7302,17 +7304,27 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
7302
7304
|
return this._resourceID;
|
|
7303
7305
|
}
|
|
7304
7306
|
get auth() {
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
this.
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7307
|
+
if (this._auth) {
|
|
7308
|
+
return Promise.resolve(this._auth);
|
|
7309
|
+
}
|
|
7310
|
+
else {
|
|
7311
|
+
return new Promise((resolve, reject) => {
|
|
7312
|
+
const waitingAuth = this._authPromises.length > 0;
|
|
7313
|
+
this._authPromises.push(new PendingPromise(resolve, reject));
|
|
7314
|
+
if (!waitingAuth) {
|
|
7315
|
+
this.authFetcher.getData(this._resourceID).then((authList) => {
|
|
7316
|
+
this._auth = authList;
|
|
7317
|
+
while (this._authPromises.length > 0) {
|
|
7318
|
+
this._authPromises.pop().resolve(this._auth);
|
|
7319
|
+
}
|
|
7320
|
+
}).catch(error => {
|
|
7321
|
+
while (this._authPromises.length > 0) {
|
|
7322
|
+
this._authPromises.pop().reject(error);
|
|
7323
|
+
}
|
|
7324
|
+
});
|
|
7325
|
+
}
|
|
7326
|
+
});
|
|
7327
|
+
}
|
|
7316
7328
|
}
|
|
7317
7329
|
/**
|
|
7318
7330
|
* Caso o usuário logado seja o SUP.
|
|
@@ -7480,17 +7492,45 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
7480
7492
|
async openApp(resourceId, pkObject) {
|
|
7481
7493
|
Workspace.openAppActivity(resourceId, pkObject);
|
|
7482
7494
|
}
|
|
7495
|
+
getDuPromissesStack(dataUnitName) {
|
|
7496
|
+
let stack;
|
|
7497
|
+
if (dataUnitName) {
|
|
7498
|
+
stack = this._duPromises.get(dataUnitName);
|
|
7499
|
+
if (!stack) {
|
|
7500
|
+
stack = [];
|
|
7501
|
+
this._duPromises.set(dataUnitName, stack);
|
|
7502
|
+
}
|
|
7503
|
+
}
|
|
7504
|
+
return stack || [];
|
|
7505
|
+
}
|
|
7483
7506
|
/**
|
|
7484
|
-
* Cria o DataUnit a partir do nome da entidade.
|
|
7507
|
+
* Cria o DataUnit a partir do nome da entidade. É possível armazená-lo no cache
|
|
7508
|
+
* passando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit será usado
|
|
7485
7509
|
*/
|
|
7486
|
-
async createDataunit(entityName) {
|
|
7487
|
-
return new Promise(resolve => {
|
|
7488
|
-
const
|
|
7489
|
-
|
|
7510
|
+
async createDataunit(entityName, dataUnitName) {
|
|
7511
|
+
return new Promise((resolve, reject) => {
|
|
7512
|
+
const duPromisses = this.getDuPromissesStack(dataUnitName);
|
|
7513
|
+
const waitingDu = duPromisses.length > 0;
|
|
7514
|
+
duPromisses.push(new PendingPromise(resolve, reject));
|
|
7515
|
+
if (!waitingDu) {
|
|
7516
|
+
const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
|
|
7517
|
+
dataUnit.loadMetadata().then(() => {
|
|
7518
|
+
if (dataUnitName) {
|
|
7519
|
+
this._duCache.set(dataUnitName, dataUnit);
|
|
7520
|
+
}
|
|
7521
|
+
while (duPromisses.length > 0) {
|
|
7522
|
+
duPromisses.pop().resolve(dataUnit);
|
|
7523
|
+
}
|
|
7524
|
+
}).catch(reason => {
|
|
7525
|
+
while (duPromisses.length > 0) {
|
|
7526
|
+
duPromisses.pop().reject(reason);
|
|
7527
|
+
}
|
|
7528
|
+
});
|
|
7529
|
+
}
|
|
7490
7530
|
});
|
|
7491
7531
|
}
|
|
7492
7532
|
/**
|
|
7493
|
-
*
|
|
7533
|
+
* Obtem um DataUnit do cache ou cria um caso ainda não tenha sido criado.
|
|
7494
7534
|
*/
|
|
7495
7535
|
async getDataUnit(entityName, dataUnitName) {
|
|
7496
7536
|
return new Promise((resolve, reject) => {
|
|
@@ -7499,10 +7539,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
7499
7539
|
resolve(dataUnit);
|
|
7500
7540
|
}
|
|
7501
7541
|
else {
|
|
7502
|
-
this.createDataunit(entityName).then(dataUnit => {
|
|
7503
|
-
if (dataUnitName) {
|
|
7504
|
-
this._duCache.set(dataUnitName, dataUnit);
|
|
7505
|
-
}
|
|
7542
|
+
this.createDataunit(entityName, dataUnitName).then(dataUnit => {
|
|
7506
7543
|
resolve(dataUnit);
|
|
7507
7544
|
}).catch(reason => reject(reason));
|
|
7508
7545
|
}
|
|
@@ -7674,9 +7711,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
7674
7711
|
});
|
|
7675
7712
|
ApplicationContext.setContextValue("__EZUI__GRID_LICENSE__", agGridLicense);
|
|
7676
7713
|
ErrorTracking.init();
|
|
7677
|
-
ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
|
|
7678
7714
|
}
|
|
7679
7715
|
connectedCallback() {
|
|
7716
|
+
ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
|
|
7680
7717
|
DataFetcher.addRequestListener(this._requestListener);
|
|
7681
7718
|
}
|
|
7682
7719
|
disconnectedCallback() {
|
|
@@ -7744,6 +7781,12 @@ class RequestListenerLoadingBar {
|
|
|
7744
7781
|
}
|
|
7745
7782
|
;
|
|
7746
7783
|
}
|
|
7784
|
+
class PendingPromise {
|
|
7785
|
+
constructor(resolve, reject) {
|
|
7786
|
+
this.resolve = resolve;
|
|
7787
|
+
this.reject = reject;
|
|
7788
|
+
}
|
|
7789
|
+
}
|
|
7747
7790
|
function defineCustomElement() {
|
|
7748
7791
|
if (typeof customElements === "undefined") {
|
|
7749
7792
|
return;
|
|
@@ -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,102 @@
|
|
|
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", { formTitle: this.formTitle, 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
|
+
"formTitle": [1, "form-title"],
|
|
65
|
+
"actionsList": [16],
|
|
66
|
+
"recordsValidator": [8, "records-validator"],
|
|
67
|
+
"_dataUnit": [32],
|
|
68
|
+
"_dataState": [32]
|
|
69
|
+
}]);
|
|
70
|
+
function defineCustomElement$1() {
|
|
71
|
+
if (typeof customElements === "undefined") {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const components = ["snk-crud", "snk-form", "snk-grid", "snk-taskbar"];
|
|
75
|
+
components.forEach(tagName => { switch (tagName) {
|
|
76
|
+
case "snk-crud":
|
|
77
|
+
if (!customElements.get(tagName)) {
|
|
78
|
+
customElements.define(tagName, SnkCrud$1);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case "snk-form":
|
|
82
|
+
if (!customElements.get(tagName)) {
|
|
83
|
+
defineCustomElement$4();
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "snk-grid":
|
|
87
|
+
if (!customElements.get(tagName)) {
|
|
88
|
+
defineCustomElement$3();
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "snk-taskbar":
|
|
92
|
+
if (!customElements.get(tagName)) {
|
|
93
|
+
defineCustomElement$2();
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
} });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const SnkCrud = SnkCrud$1;
|
|
100
|
+
const defineCustomElement = defineCustomElement$1;
|
|
101
|
+
|
|
102
|
+
export { SnkCrud, defineCustomElement };
|
|
@@ -11,6 +11,7 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
11
11
|
this.dataStateChange = createEvent(this, "dataStateChange", 7);
|
|
12
12
|
this.dataUnitReady = createEvent(this, "dataUnitReady", 7);
|
|
13
13
|
this.insertionMode = createEvent(this, "insertionMode", 7);
|
|
14
|
+
this.cancelEdition = createEvent(this, "cancelEdition", 7);
|
|
14
15
|
this._onDataUnitResolve = [];
|
|
15
16
|
/**
|
|
16
17
|
* Determina quantas linhas são retornadas por página
|
|
@@ -31,6 +32,9 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
31
32
|
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
32
33
|
this.insertionMode.emit();
|
|
33
34
|
}
|
|
35
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
36
|
+
this.cancelEdition.emit();
|
|
37
|
+
}
|
|
34
38
|
const duState = {
|
|
35
39
|
insertionMode: false,
|
|
36
40
|
hasNext: this.dataUnit.hasNext(),
|
|
@@ -191,7 +195,7 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
191
195
|
//---------------------------------------------
|
|
192
196
|
// Lifecycle web component
|
|
193
197
|
//---------------------------------------------
|
|
194
|
-
|
|
198
|
+
componentWillLoad() {
|
|
195
199
|
this.loadDataUnit();
|
|
196
200
|
}
|
|
197
201
|
render() {
|
|
@@ -1,119 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { d as defineCustomElement$2 } from './snk-taskbar2.js';
|
|
4
|
-
|
|
5
|
-
const snkFormCss = ".sc-snk-form-h{display:block}";
|
|
6
|
-
|
|
7
|
-
const SnkForm$1 = /*@__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
|
-
componentWillLoad() {
|
|
46
|
-
let parent = this._element.parentElement;
|
|
47
|
-
while (parent) {
|
|
48
|
-
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
49
|
-
this._snkDataUnit = parent;
|
|
50
|
-
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
51
|
-
this._dataState = this._snkDataUnit.dataState;
|
|
52
|
-
if (!this._dataUnit) {
|
|
53
|
-
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
54
|
-
this._dataUnit = evt.detail;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
58
|
-
this._dataState = evt.detail;
|
|
59
|
-
});
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
parent = parent.parentElement;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
componentWillRender() {
|
|
66
|
-
if (this._dataUnit && !this._configLoaded) {
|
|
67
|
-
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
68
|
-
if (snkApplication) {
|
|
69
|
-
snkApplication.loadFormConfig(this.configName).then(cfg => {
|
|
70
|
-
this._configLoaded = true;
|
|
71
|
-
this._editionFormConfig = cfg;
|
|
72
|
-
this._insertionFormConfig = cfg.filter(fieldCfg => {
|
|
73
|
-
const def = this._dataUnit.getField(fieldCfg.name);
|
|
74
|
-
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
render() {
|
|
84
|
-
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
return (h("section", { class: "ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { 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.formTitle)), 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("div", { class: "ez-padding--small" }), 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() }))))));
|
|
88
|
-
}
|
|
89
|
-
get _element() { return this; }
|
|
90
|
-
static get style() { return snkFormCss; }
|
|
91
|
-
}, [2, "snk-form", {
|
|
92
|
-
"formTitle": [1, "form-title"],
|
|
93
|
-
"configName": [1, "config-name"],
|
|
94
|
-
"actionsList": [16],
|
|
95
|
-
"_dataUnit": [32],
|
|
96
|
-
"_configLoaded": [32],
|
|
97
|
-
"_dataState": [32]
|
|
98
|
-
}]);
|
|
99
|
-
function defineCustomElement$1() {
|
|
100
|
-
if (typeof customElements === "undefined") {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const components = ["snk-form", "snk-taskbar"];
|
|
104
|
-
components.forEach(tagName => { switch (tagName) {
|
|
105
|
-
case "snk-form":
|
|
106
|
-
if (!customElements.get(tagName)) {
|
|
107
|
-
customElements.define(tagName, SnkForm$1);
|
|
108
|
-
}
|
|
109
|
-
break;
|
|
110
|
-
case "snk-taskbar":
|
|
111
|
-
if (!customElements.get(tagName)) {
|
|
112
|
-
defineCustomElement$2();
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
} });
|
|
116
|
-
}
|
|
1
|
+
import { S as SnkForm$1, d as defineCustomElement$1 } from './snk-form2.js';
|
|
117
2
|
|
|
118
3
|
const SnkForm = SnkForm$1;
|
|
119
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -0,0 +1,134 @@
|
|
|
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}";
|
|
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
|
+
i18n(key) {
|
|
57
|
+
const pt_br = {
|
|
58
|
+
"components.back": "Voltar"
|
|
59
|
+
};
|
|
60
|
+
return pt_br[key];
|
|
61
|
+
}
|
|
62
|
+
componentWillLoad() {
|
|
63
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
64
|
+
if (snkApplication) {
|
|
65
|
+
snkApplication.loadFormConfig(this.configName).then(cfg => {
|
|
66
|
+
this._configLoaded = true;
|
|
67
|
+
this._editionFormConfig = cfg;
|
|
68
|
+
this.loadInsertionConfig();
|
|
69
|
+
});
|
|
70
|
+
//Forçamos a carga dos acessos pra aproveitar a request inicial.
|
|
71
|
+
snkApplication.getAllAccess();
|
|
72
|
+
}
|
|
73
|
+
let parent = this._element.parentElement;
|
|
74
|
+
while (parent) {
|
|
75
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
76
|
+
this._snkDataUnit = parent;
|
|
77
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
78
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
79
|
+
if (this._dataUnit) {
|
|
80
|
+
this.loadInsertionConfig();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
84
|
+
this._dataUnit = evt.detail;
|
|
85
|
+
this.loadInsertionConfig();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
89
|
+
this._dataState = evt.detail;
|
|
90
|
+
});
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
parent = parent.parentElement;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
return (h("section", { class: "ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { title: this.i18n("components.back"), 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.formTitle)), 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("div", { class: "ez-padding--small" }), 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 }))))));
|
|
101
|
+
}
|
|
102
|
+
get _element() { return this; }
|
|
103
|
+
static get style() { return snkFormCss; }
|
|
104
|
+
}, [2, "snk-form", {
|
|
105
|
+
"formTitle": [1, "form-title"],
|
|
106
|
+
"configName": [1, "config-name"],
|
|
107
|
+
"recordsValidator": [8, "records-validator"],
|
|
108
|
+
"actionsList": [16],
|
|
109
|
+
"_dataUnit": [32],
|
|
110
|
+
"_configLoaded": [32],
|
|
111
|
+
"_dataState": [32],
|
|
112
|
+
"_editionFormConfig": [32],
|
|
113
|
+
"_insertionFormConfig": [32]
|
|
114
|
+
}]);
|
|
115
|
+
function defineCustomElement() {
|
|
116
|
+
if (typeof customElements === "undefined") {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const components = ["snk-form", "snk-taskbar"];
|
|
120
|
+
components.forEach(tagName => { switch (tagName) {
|
|
121
|
+
case "snk-form":
|
|
122
|
+
if (!customElements.get(tagName)) {
|
|
123
|
+
customElements.define(tagName, SnkForm);
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case "snk-taskbar":
|
|
127
|
+
if (!customElements.get(tagName)) {
|
|
128
|
+
defineCustomElement$1();
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
} });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { SnkForm as S, defineCustomElement as d };
|
|
@@ -1,86 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
|
4
|
-
|
|
5
|
-
const snkGridCss = ".sc-snk-grid-h{display:flex;height:100%;width:100%}";
|
|
6
|
-
|
|
7
|
-
const SnkGrid$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
this.__registerHost();
|
|
11
|
-
this.actionClick = createEvent(this, "actionClick", 7);
|
|
12
|
-
}
|
|
13
|
-
getHeaderButtons() {
|
|
14
|
-
return this._dataState && this._dataState.selectedRecords.length > 0 ? "UPDATE,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,REFRESH" : "REFRESH";
|
|
15
|
-
}
|
|
16
|
-
actionClickHandler(evt) {
|
|
17
|
-
if (evt.detail === TaskbarElement.CONFIG_GRID && this._grid) {
|
|
18
|
-
this._grid.openGridConfig();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
componentWillLoad() {
|
|
22
|
-
let parent = this._element.parentElement;
|
|
23
|
-
while (parent) {
|
|
24
|
-
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
25
|
-
this._snkDataUnit = parent;
|
|
26
|
-
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
27
|
-
if (!this._dataUnit) {
|
|
28
|
-
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
29
|
-
this._dataUnit = evt.detail;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
33
|
-
this._dataState = evt.detail;
|
|
34
|
-
});
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
parent = parent.parentElement;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
componentWillRender() {
|
|
41
|
-
if (this._dataUnit && !this._configLoaded) {
|
|
42
|
-
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
43
|
-
if (snkApplication) {
|
|
44
|
-
snkApplication.loadGridConfig(this.configName).then(cfg => {
|
|
45
|
-
this._gridConfig = cfg;
|
|
46
|
-
this._configLoaded = true;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
render() {
|
|
52
|
-
if (!this._configLoaded || !this._dataUnit) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
return (h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" }, h("slot", null)), h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" }, h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))), h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig }, h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList }))));
|
|
56
|
-
}
|
|
57
|
-
get _element() { return this; }
|
|
58
|
-
static get style() { return snkGridCss; }
|
|
59
|
-
}, [6, "snk-grid", {
|
|
60
|
-
"configName": [1, "config-name"],
|
|
61
|
-
"actionsList": [16],
|
|
62
|
-
"_dataUnit": [32],
|
|
63
|
-
"_configLoaded": [32],
|
|
64
|
-
"_dataState": [32]
|
|
65
|
-
}]);
|
|
66
|
-
function defineCustomElement$1() {
|
|
67
|
-
if (typeof customElements === "undefined") {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const components = ["snk-grid", "snk-taskbar"];
|
|
71
|
-
components.forEach(tagName => { switch (tagName) {
|
|
72
|
-
case "snk-grid":
|
|
73
|
-
if (!customElements.get(tagName)) {
|
|
74
|
-
customElements.define(tagName, SnkGrid$1);
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
case "snk-taskbar":
|
|
78
|
-
if (!customElements.get(tagName)) {
|
|
79
|
-
defineCustomElement$2();
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
} });
|
|
83
|
-
}
|
|
1
|
+
import { S as SnkGrid$1, d as defineCustomElement$1 } from './snk-grid2.js';
|
|
84
2
|
|
|
85
3
|
const SnkGrid = SnkGrid$1;
|
|
86
4
|
const defineCustomElement = defineCustomElement$1;
|