@sankhyalabs/sankhyablocks 1.3.31-beta.10 → 1.3.31-beta.12
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/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +18 -7
- package/dist/cjs/snk-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +107 -48
- package/dist/cjs/snk-form_2.cjs.entry.js +19 -12
- package/dist/cjs/snk-taskbar.cjs.entry.js +39 -20
- package/dist/cjs/{taskbar-elements-7f99f0c9.js → taskbar-elements-73d524e5.js} +1 -1
- package/dist/collection/components/snk-application/snk-application.js +75 -4
- package/dist/collection/components/snk-crud/snk-crud.css +1 -0
- package/dist/collection/components/snk-crud/snk-crud.js +10 -23
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +108 -72
- package/dist/collection/components/snk-form/snk-form.js +20 -32
- package/dist/collection/components/snk-grid/snk-grid.js +4 -2
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -1
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -19
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -5
- package/dist/collection/lib/index.js +1 -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 +20 -7
- package/dist/components/snk-crud.js +3 -4
- package/dist/components/snk-data-unit.js +108 -50
- package/dist/components/snk-form2.js +18 -12
- package/dist/components/snk-grid2.js +1 -1
- package/dist/components/snk-taskbar2.js +39 -20
- package/dist/esm/SnkMessageBuilder-3835f9d8.js +166 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +18 -7
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-data-unit.entry.js +108 -49
- package/dist/esm/snk-form_2.entry.js +19 -12
- package/dist/esm/snk-taskbar.entry.js +39 -20
- package/dist/esm/{taskbar-elements-e0b8a285.js → taskbar-elements-6d01a640.js} +1 -1
- package/dist/sankhyablocks/p-2df33095.entry.js +1 -0
- package/dist/sankhyablocks/{p-c3d20542.entry.js → p-56a32417.entry.js} +1 -1
- package/dist/sankhyablocks/p-72bccbb6.js +1 -0
- package/dist/sankhyablocks/p-962d9bdd.entry.js +69 -0
- package/dist/sankhyablocks/p-9b427c4c.entry.js +1 -0
- package/dist/sankhyablocks/p-bab507ad.entry.js +1 -0
- package/dist/sankhyablocks/p-dd10a5e3.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +14 -4
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +8 -0
- package/dist/types/components.d.ts +15 -20
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +5 -6
- package/dist/types/lib/index.d.ts +1 -0
- 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 +2 -2
- package/dist/sankhyablocks/p-18fe0469.entry.js +0 -69
- package/dist/sankhyablocks/p-5b5afdbe.entry.js +0 -1
- package/dist/sankhyablocks/p-7fe9e5c2.entry.js +0 -1
- package/dist/sankhyablocks/p-8650ae26.entry.js +0 -1
- package/dist/sankhyablocks/p-a5439706.js +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _interopNamespace(e) {
|
|
4
|
+
if (e && e.__esModule) return e;
|
|
5
|
+
var n = Object.create(null);
|
|
6
|
+
if (e) {
|
|
7
|
+
Object.keys(e).forEach(function (k) {
|
|
8
|
+
if (k !== 'default') {
|
|
9
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return e[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n['default'] = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const snkDataUnitMessages = {
|
|
24
|
+
saveInfo: {
|
|
25
|
+
clone: "Duplicação realizada!",
|
|
26
|
+
insert: "Inclusão realizada!",
|
|
27
|
+
update: "Aleração realizada!"
|
|
28
|
+
},
|
|
29
|
+
cancelInfo: {
|
|
30
|
+
clone: "Duplicação descartada!",
|
|
31
|
+
insert: "A inclusão descartada!",
|
|
32
|
+
update: "A edição foi descartada!"
|
|
33
|
+
},
|
|
34
|
+
removeInfo: "Registro removido com sucesso!",
|
|
35
|
+
cancelConfirmationTitle: "Aviso",
|
|
36
|
+
cancelConfirmation: "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?",
|
|
37
|
+
removeConfirmationTitle: "Excluir",
|
|
38
|
+
removeConfirmation: "Deseja realmente excluir o registro atual?",
|
|
39
|
+
forbiddenUpdate: "Não é possível fazer alterações. Verifique as permissões de acesso.",
|
|
40
|
+
forbiddenInsert: "Não é possível incluir. Verifique as permissões de acesso.",
|
|
41
|
+
forbiddenClone: "Não é possível duplicar. Verifique as permissões de acesso.",
|
|
42
|
+
forbiddenRemove: "Não é possível remover. Verifique as permissões de acesso."
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const snkFormMessages = {
|
|
46
|
+
title: {
|
|
47
|
+
clone: "Duplicar registro",
|
|
48
|
+
insert: "Cadastrar registro",
|
|
49
|
+
update: "Alterar registro",
|
|
50
|
+
clean: "{{ENTITY_NAME}}"
|
|
51
|
+
},
|
|
52
|
+
goBackTitle: "Voltar"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const snkTaskbarMessages = {
|
|
56
|
+
titleUpdate: "Editar",
|
|
57
|
+
titlePrevious: "Anterior",
|
|
58
|
+
titleNext: "Próximo",
|
|
59
|
+
titleRefresh: "Atualizar",
|
|
60
|
+
titleClone: "Duplicar",
|
|
61
|
+
titleRemove: "Excluir",
|
|
62
|
+
titleMoreOptions: "Mais Opções",
|
|
63
|
+
titleInsert: "Cadastrar",
|
|
64
|
+
titleCancel: "Cancelar",
|
|
65
|
+
titleSave: "Salvar",
|
|
66
|
+
titleGridMode: "Modo Grade",
|
|
67
|
+
titleConfigGrid: "Configuração da grade",
|
|
68
|
+
titleFormMode: "Modo Formulário"
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
class SnkMessageBuilder {
|
|
72
|
+
constructor() {
|
|
73
|
+
this._defaults = {
|
|
74
|
+
snkDataUnit: snkDataUnitMessages,
|
|
75
|
+
snkForm: snkFormMessages,
|
|
76
|
+
snkTaskbar: snkTaskbarMessages
|
|
77
|
+
};
|
|
78
|
+
this._currentOperation = exports.OperationMap.CLEAN;
|
|
79
|
+
this.loadAppMessages().then((msgs) => {
|
|
80
|
+
this._appMessages = msgs;
|
|
81
|
+
}, error => {
|
|
82
|
+
console.info('O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages.js', error);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Existem mensagens sensíveis a operação. Por exemplo, a mensagem
|
|
87
|
+
* de inclusão pode ser diferente da mensagem de alteração do mesmo
|
|
88
|
+
* recurso. Para isso "currentOperation" pode variar de acordo com
|
|
89
|
+
* OperationMap.
|
|
90
|
+
*/
|
|
91
|
+
set currentOperation(op) {
|
|
92
|
+
this._currentOperation = op;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Método usado para se obter mensagens, respeitando o padrão do sistema
|
|
96
|
+
* ou as mensagens específicas de cada tela
|
|
97
|
+
*
|
|
98
|
+
* @param key Chave usada para obter mensagens. Deve-se usar o separador "."
|
|
99
|
+
* alcançar diversos níveis.
|
|
100
|
+
* @param params Quando a mensagem possui o padrão {{NOME}} as ocorrências
|
|
101
|
+
* serão substituidas pelo respectivo valor do param.
|
|
102
|
+
* @returns A mensagem formatada.
|
|
103
|
+
*/
|
|
104
|
+
getMessage(key, params) {
|
|
105
|
+
if (key == undefined) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
var parts = key.split(".");
|
|
109
|
+
let msg = this.resolveMessage(parts, this._appMessages);
|
|
110
|
+
if (msg == undefined) {
|
|
111
|
+
msg = this.resolveMessage(parts, this._defaults);
|
|
112
|
+
}
|
|
113
|
+
if (this.customMessageBuilder) {
|
|
114
|
+
const result = this.customMessageBuilder(key, msg, params);
|
|
115
|
+
msg = result.message;
|
|
116
|
+
params = result.params;
|
|
117
|
+
}
|
|
118
|
+
return this.postProcess(msg, params);
|
|
119
|
+
}
|
|
120
|
+
resolveMessage(keys, object) {
|
|
121
|
+
if (object == undefined) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const key = keys[0];
|
|
125
|
+
const result = object[key];
|
|
126
|
+
if (result) {
|
|
127
|
+
if (this.isOperationSensitive(result)) {
|
|
128
|
+
return result[this._currentOperation];
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const isLeaf = keys.length === 1 ||
|
|
132
|
+
result == undefined ||
|
|
133
|
+
typeof result === "string";
|
|
134
|
+
return isLeaf ? result : this.resolveMessage(keys.slice(1), result);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
isOperationSensitive(value) {
|
|
139
|
+
return value[exports.OperationMap.CLONE] != undefined ||
|
|
140
|
+
value[exports.OperationMap.INSERT] != undefined ||
|
|
141
|
+
value[exports.OperationMap.UPDATE] != undefined ||
|
|
142
|
+
value[exports.OperationMap.CLEAN] != undefined;
|
|
143
|
+
}
|
|
144
|
+
postProcess(message, params) {
|
|
145
|
+
if (message) {
|
|
146
|
+
const propPattern = /(.*?)\{\{(.+?)\}\}/g;
|
|
147
|
+
let processed = "";
|
|
148
|
+
let tail = message;
|
|
149
|
+
let result;
|
|
150
|
+
while ((result = propPattern.exec(message)) !== null) {
|
|
151
|
+
const [match, head, attribute] = result;
|
|
152
|
+
const tailIndex = result.index + match.length;
|
|
153
|
+
tail = tailIndex < message.length ? message.substring(tailIndex) : "";
|
|
154
|
+
let replacement = params ? params[attribute] : undefined;
|
|
155
|
+
if (replacement == undefined) {
|
|
156
|
+
replacement = "";
|
|
157
|
+
}
|
|
158
|
+
processed += head + replacement;
|
|
159
|
+
}
|
|
160
|
+
return processed + tail;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return message;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
loadAppMessages() {
|
|
167
|
+
return new Promise((accept, reject) => {
|
|
168
|
+
const messagesUrl = window['applicationenv'] !== "dev" ? `/${window["MGE_MODULE_NAME"]}/labsApps/${window["APPLICATION_NAME"]}/messages/appmessages.js`
|
|
169
|
+
: '/messages/appmessages.js';
|
|
170
|
+
Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ messagesUrl)); })
|
|
171
|
+
.then(module => {
|
|
172
|
+
accept(module.default);
|
|
173
|
+
})
|
|
174
|
+
.catch(reason => {
|
|
175
|
+
reject(reason);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.OperationMap = void 0;
|
|
181
|
+
(function (OperationMap) {
|
|
182
|
+
OperationMap["CLONE"] = "clone";
|
|
183
|
+
OperationMap["INSERT"] = "insert";
|
|
184
|
+
OperationMap["UPDATE"] = "update";
|
|
185
|
+
OperationMap["CLEAN"] = "clean";
|
|
186
|
+
})(exports.OperationMap || (exports.OperationMap = {}));
|
|
187
|
+
|
|
188
|
+
exports.SnkMessageBuilder = SnkMessageBuilder;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["snk-crud.cjs",[[6,"snk-crud",{"configName":[1,"config-name"],"
|
|
17
|
+
return index.bootstrapLazy([["snk-crud.cjs",[[6,"snk-crud",{"configName":[1,"config-name"],"actionsList":[16],"recordsValidator":[16],"_dataUnit":[32],"_dataState":[32]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"autoLoad":[4,"auto-load"],"getDataUnit":[64]}]]],["snk-application.cjs",[[2,"snk-application",{"messagesBuilder":[1040],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"alert":[64],"error":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["snk-form_2.cjs",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32]}],[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32],"_gridConfig":[32]}]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-taskbar.cjs",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["snk-crud.cjs",[[6,"snk-crud",{"configName":[1,"config-name"],"
|
|
18
|
+
return index.bootstrapLazy([["snk-crud.cjs",[[6,"snk-crud",{"configName":[1,"config-name"],"actionsList":[16],"recordsValidator":[16],"_dataUnit":[32],"_dataState":[32]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"autoLoad":[4,"auto-load"],"getDataUnit":[64]}]]],["snk-application.cjs",[[2,"snk-application",{"messagesBuilder":[1040],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"alert":[64],"error":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["snk-form_2.cjs",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32]}],[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"_dataUnit":[32],"_configLoaded":[32],"_dataState":[32],"_gridConfig":[32]}]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-taskbar.cjs",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-c6671817.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
|
+
const SnkMessageBuilder = require('./SnkMessageBuilder-13239761.js');
|
|
8
9
|
|
|
9
10
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
10
11
|
|
|
@@ -6458,7 +6459,7 @@ class UrlUtils {
|
|
|
6458
6459
|
|
|
6459
6460
|
class DataFetcher {
|
|
6460
6461
|
constructor() {
|
|
6461
|
-
this.GRAPHQL_PATH =
|
|
6462
|
+
this.GRAPHQL_PATH = "/mge/graphql";
|
|
6462
6463
|
this.watingRequestsById = new Map();
|
|
6463
6464
|
}
|
|
6464
6465
|
static get() {
|
|
@@ -6514,20 +6515,23 @@ class DataFetcher {
|
|
|
6514
6515
|
resolveURL() {
|
|
6515
6516
|
return UrlUtils.getUrlBase();
|
|
6516
6517
|
}
|
|
6517
|
-
getContext() {
|
|
6518
|
+
getContext(module) {
|
|
6518
6519
|
const urlParams = UrlUtils.getQueryParams(location.search);
|
|
6519
6520
|
return {
|
|
6520
|
-
baseUrl: `${this.resolveURL()}/
|
|
6521
|
+
baseUrl: `${this.resolveURL()}/${module}/service.sbr`,
|
|
6521
6522
|
appName: "SankhyaBlocks",
|
|
6522
6523
|
mgeSession: `${window['skw_session'] || urlParams.mgeSession}`,
|
|
6523
6524
|
globalID: "85C0093DFA240EAB699B4E47A10215BD",
|
|
6525
|
+
//FIXME: Precisamos ajustar para buscar o resourceId pela aplicação
|
|
6524
6526
|
resourceID: "br.com.sankhya.mov.bancaria"
|
|
6525
6527
|
};
|
|
6526
6528
|
}
|
|
6527
6529
|
async callServiceBroker(serviceName, payload) {
|
|
6528
6530
|
return new Promise((accept, reject) => {
|
|
6529
|
-
const
|
|
6530
|
-
const
|
|
6531
|
+
const parts = serviceName.split("@");
|
|
6532
|
+
const [module, name] = parts.length === 2 ? parts : ['mge', serviceName];
|
|
6533
|
+
const ctx = this.getContext(module);
|
|
6534
|
+
const url = `${ctx.baseUrl}?serviceName=${name}&counter=21&application=${ctx.appName}&outputType=json&preventTransform=false&mgeSession=${ctx.mgeSession}&resourceID=${ctx.resourceID}&globalID=${ctx.globalID}&allowConcurrentCalls=true`;
|
|
6531
6535
|
document.cookie = `JSESSIONID=${ctx.mgeSession};`;
|
|
6532
6536
|
const http = new XMLHttpRequest();
|
|
6533
6537
|
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url }));
|
|
@@ -7565,11 +7569,17 @@ const SnkApplication = class {
|
|
|
7565
7569
|
async error(title, message, icon, options) {
|
|
7566
7570
|
return utils.ApplicationUtils.error(title, message, icon, options);
|
|
7567
7571
|
}
|
|
7572
|
+
/**
|
|
7573
|
+
* Exibe um diálogo de mensagem comum
|
|
7574
|
+
*/
|
|
7575
|
+
async message(title, message, icon, options) {
|
|
7576
|
+
return utils.ApplicationUtils.message(title, message, icon, options);
|
|
7577
|
+
}
|
|
7568
7578
|
/**
|
|
7569
7579
|
* Exibe um diálogo de confirmação
|
|
7570
7580
|
*/
|
|
7571
|
-
async confirm(title, message, icon,
|
|
7572
|
-
return utils.ApplicationUtils.confirm(title, message, icon,
|
|
7581
|
+
async confirm(title, message, icon, dialogType, options) {
|
|
7582
|
+
return utils.ApplicationUtils.confirm(title, message, icon, dialogType, options);
|
|
7573
7583
|
}
|
|
7574
7584
|
/**
|
|
7575
7585
|
* Mostra uma informação efêmera (de segundo plano).
|
|
@@ -7707,6 +7717,7 @@ const SnkApplication = class {
|
|
|
7707
7717
|
}
|
|
7708
7718
|
componentWillLoad() {
|
|
7709
7719
|
this._errorHandler = new SnkErrorHandler(this);
|
|
7720
|
+
this.messagesBuilder = new SnkMessageBuilder.SnkMessageBuilder();
|
|
7710
7721
|
core.ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/upload/file`);
|
|
7711
7722
|
core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
|
|
7712
7723
|
return this.executeSearch(searchArgument, fieldName, dataUnit);
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-c6671817.js');
|
|
6
6
|
|
|
7
|
-
const snkCrudCss = ".sc-snk-crud-h{display:flex;height:100%;width:100%}";
|
|
7
|
+
const snkCrudCss = ".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";
|
|
8
8
|
|
|
9
9
|
const GRID_MODE = 0;
|
|
10
10
|
const FORM_MODE = 1;
|
|
@@ -55,7 +55,7 @@ const SnkCrud = class {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
render() {
|
|
58
|
-
return (index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, index.h("stack-item", null, index.h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList }, index.h("slot",
|
|
58
|
+
return (index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, index.h("stack-item", null, index.h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList }, index.h("slot", { name: "SnkGridHeader" }), index.h("slot", { name: "SnkGridFooter" }))), index.h("stack-item", null, index.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
59
|
}
|
|
60
60
|
get _element() { return index.getElement(this); }
|
|
61
61
|
};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-c6671817.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
|
+
const SnkMessageBuilder = require('./SnkMessageBuilder-13239761.js');
|
|
8
9
|
|
|
9
10
|
const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
|
|
10
11
|
|
|
@@ -25,19 +26,6 @@ const SnkDataUnit = class {
|
|
|
25
26
|
*/
|
|
26
27
|
this.autoLoad = true;
|
|
27
28
|
this._dataUnitObserver = (action) => {
|
|
28
|
-
let msg;
|
|
29
|
-
if (!this.isTransitionAction(action.type)) {
|
|
30
|
-
msg = this.getActionInfo(action.type);
|
|
31
|
-
}
|
|
32
|
-
if (msg) {
|
|
33
|
-
utils.ApplicationUtils.info(msg);
|
|
34
|
-
}
|
|
35
|
-
if (action.type === core.Action.RECORDS_ADDED || action.type === core.Action.RECORDS_COPIED) {
|
|
36
|
-
this.insertionMode.emit();
|
|
37
|
-
}
|
|
38
|
-
if (action.type === core.Action.EDITION_CANCELED) {
|
|
39
|
-
this.cancelEdition.emit();
|
|
40
|
-
}
|
|
41
29
|
const duState = {
|
|
42
30
|
insertionMode: false,
|
|
43
31
|
hasNext: this.dataUnit.hasNext(),
|
|
@@ -54,6 +42,29 @@ const SnkDataUnit = class {
|
|
|
54
42
|
}
|
|
55
43
|
});
|
|
56
44
|
this.dataState = duState;
|
|
45
|
+
if (action.type === core.Action.DATA_SAVED) {
|
|
46
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
47
|
+
if (msg != undefined) {
|
|
48
|
+
this.showSuccessMessage(msg);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (action.type === core.Action.RECORDS_ADDED || action.type === core.Action.RECORDS_COPIED) {
|
|
52
|
+
this.insertionMode.emit();
|
|
53
|
+
}
|
|
54
|
+
if (action.type === core.Action.EDITION_CANCELED) {
|
|
55
|
+
this.cancelEdition.emit();
|
|
56
|
+
const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
|
|
57
|
+
if (cancelFinishMsg != undefined) {
|
|
58
|
+
this.showSuccessMessage(cancelFinishMsg);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (action.type === core.Action.RECORDS_REMOVED) {
|
|
62
|
+
const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
63
|
+
if (removeFinishMsg != undefined) {
|
|
64
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this._application.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
57
68
|
};
|
|
58
69
|
}
|
|
59
70
|
observePageSize() {
|
|
@@ -101,6 +112,32 @@ const SnkDataUnit = class {
|
|
|
101
112
|
async interceptAction(action) {
|
|
102
113
|
return new Promise(resolve => {
|
|
103
114
|
switch (action.type) {
|
|
115
|
+
case core.Action.RECORDS_ADDED:
|
|
116
|
+
if (this.isAllowed("INSERT")) {
|
|
117
|
+
resolve(action);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case core.Action.RECORDS_COPIED:
|
|
124
|
+
if (this.isAllowed("CLONE")) {
|
|
125
|
+
resolve(action);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case core.Action.DATA_CHANGED:
|
|
132
|
+
case core.Action.CHANGING_DATA:
|
|
133
|
+
if (this.isAllowed("UPDATE")) {
|
|
134
|
+
resolve(action);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.dataUnit.cancelEdition();
|
|
138
|
+
utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
104
141
|
case core.Action.SAVING_DATA:
|
|
105
142
|
if (this.beforeSave) {
|
|
106
143
|
const continueAction = this.beforeSave(this.dataUnit);
|
|
@@ -125,52 +162,82 @@ const SnkDataUnit = class {
|
|
|
125
162
|
break;
|
|
126
163
|
case core.Action.EDITION_CANCELED:
|
|
127
164
|
if (this.dataState.hasDirtyRecords) {
|
|
128
|
-
|
|
129
|
-
|
|
165
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
166
|
+
if (cancelConfirmation == undefined) {
|
|
167
|
+
resolve(action);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
171
|
+
utils.ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
172
|
+
.then((result) => resolve(result ? action : undefined));
|
|
173
|
+
}
|
|
130
174
|
}
|
|
131
175
|
else {
|
|
132
176
|
resolve(action);
|
|
133
177
|
}
|
|
134
178
|
break;
|
|
135
179
|
case core.Action.REMOVING_RECORDS:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
180
|
+
if (this.isAllowed("REMOVE")) {
|
|
181
|
+
const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
|
|
182
|
+
if (removeConfirmation == undefined) {
|
|
183
|
+
resolve(action);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
187
|
+
utils.ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", utils.DialogType.CRITICAL, { btnConfirmDanger: true })
|
|
188
|
+
.then((result) => resolve(result ? action : undefined));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
139
193
|
}
|
|
140
|
-
utils.ApplicationUtils.confirm(this.i18n("components.delete"), msg || this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
|
|
141
|
-
.then((result) => resolve(result ? action : undefined));
|
|
142
194
|
break;
|
|
143
195
|
default:
|
|
144
196
|
resolve(action);
|
|
145
197
|
}
|
|
146
198
|
});
|
|
147
199
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
200
|
+
showSuccessMessage(message) {
|
|
201
|
+
utils.ApplicationUtils.info(message, { iconName: "check" });
|
|
202
|
+
}
|
|
203
|
+
isAllowed(flag) {
|
|
204
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
208
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
209
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
210
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
211
|
+
*/
|
|
212
|
+
getMessage(key, params = undefined) {
|
|
213
|
+
if (!params) {
|
|
214
|
+
params = this.getMessageParams();
|
|
158
215
|
}
|
|
216
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
217
|
+
}
|
|
218
|
+
getMessageParams() {
|
|
219
|
+
//TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
|
|
220
|
+
//precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
|
|
221
|
+
//mensagem
|
|
222
|
+
return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
|
|
159
223
|
}
|
|
160
|
-
|
|
161
|
-
if (this.
|
|
162
|
-
return
|
|
224
|
+
getMessageOperation() {
|
|
225
|
+
if (this.dataState.copyMode) {
|
|
226
|
+
return SnkMessageBuilder.OperationMap.CLONE;
|
|
163
227
|
}
|
|
164
|
-
if (
|
|
165
|
-
return
|
|
228
|
+
if (this.dataState.insertionMode) {
|
|
229
|
+
return SnkMessageBuilder.OperationMap.INSERT;
|
|
166
230
|
}
|
|
231
|
+
if (this.dataState.isDirty) {
|
|
232
|
+
return SnkMessageBuilder.OperationMap.UPDATE;
|
|
233
|
+
}
|
|
234
|
+
return SnkMessageBuilder.OperationMap.CLEAN;
|
|
167
235
|
}
|
|
168
236
|
async loadDataUnit() {
|
|
169
237
|
if (!this.dataUnit) {
|
|
170
|
-
|
|
171
|
-
if (app && this.entityName) {
|
|
238
|
+
if (this._application && this.entityName) {
|
|
172
239
|
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
173
|
-
this.dataUnit = await
|
|
240
|
+
this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
|
|
174
241
|
this.dataUnit.pageSize = this.pageSize;
|
|
175
242
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
176
243
|
this.dataUnit.addInterceptor(this);
|
|
@@ -185,20 +252,12 @@ const SnkDataUnit = class {
|
|
|
185
252
|
}
|
|
186
253
|
}
|
|
187
254
|
}
|
|
188
|
-
i18n(key) {
|
|
189
|
-
const pt_br = {
|
|
190
|
-
"components.warning": "Aviso",
|
|
191
|
-
"components.delete": "Excluir",
|
|
192
|
-
"components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
|
|
193
|
-
"components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
|
|
194
|
-
"components.editionCanceled": "Todas as alterações foram descartadas.",
|
|
195
|
-
};
|
|
196
|
-
return pt_br[key];
|
|
197
|
-
}
|
|
198
255
|
//---------------------------------------------
|
|
199
256
|
// Lifecycle web component
|
|
200
257
|
//---------------------------------------------
|
|
201
258
|
componentWillLoad() {
|
|
259
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
260
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
202
261
|
this.loadDataUnit();
|
|
203
262
|
}
|
|
204
263
|
render() {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-c6671817.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const taskbarElements = require('./taskbar-elements-
|
|
7
|
+
const taskbarElements = require('./taskbar-elements-73d524e5.js');
|
|
8
8
|
|
|
9
9
|
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))}";
|
|
10
10
|
|
|
@@ -56,22 +56,29 @@ const SnkForm = class {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
61
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
62
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
63
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
|
|
64
|
+
*/
|
|
65
|
+
getMessage(key) {
|
|
66
|
+
return this._application.messagesBuilder.getMessage(key, this.getMessageParams());
|
|
67
|
+
}
|
|
68
|
+
getMessageParams() {
|
|
69
|
+
var _a;
|
|
70
|
+
return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
|
|
64
71
|
}
|
|
65
72
|
componentWillLoad() {
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
73
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
74
|
+
if (this._application) {
|
|
75
|
+
this._application.loadFormConfig(this.configName).then(cfg => {
|
|
69
76
|
this._configLoaded = true;
|
|
70
77
|
this._editionFormConfig = cfg;
|
|
71
78
|
this.loadInsertionConfig();
|
|
72
79
|
});
|
|
73
80
|
//Forçamos a carga dos acessos pra aproveitar a request inicial.
|
|
74
|
-
|
|
81
|
+
this._application.getAllAccess();
|
|
75
82
|
}
|
|
76
83
|
let parent = this._element.parentElement;
|
|
77
84
|
while (parent) {
|
|
@@ -100,7 +107,7 @@ const SnkForm = class {
|
|
|
100
107
|
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
101
108
|
return undefined;
|
|
102
109
|
}
|
|
103
|
-
return (index.h("section", { class: "snk-form" }, index.h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, index.h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, index.h("ez-button", { title: this.
|
|
110
|
+
return (index.h("section", { class: "snk-form" }, index.h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, index.h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, index.h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), index.h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))), index.h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, index.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 }))), index.h("section", null, index.h("div", { class: "ez-row" }, index.h("div", { class: "ez-col ez-col--sd-12" }, index.h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator }))))));
|
|
104
111
|
}
|
|
105
112
|
get _element() { return index.getElement(this); }
|
|
106
113
|
};
|
|
@@ -160,7 +167,7 @@ const SnkGrid = class {
|
|
|
160
167
|
if (!this._configLoaded || !this._dataUnit) {
|
|
161
168
|
return undefined;
|
|
162
169
|
}
|
|
163
|
-
return (index.h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, index.h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" }, index.h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" }, index.h("slot",
|
|
170
|
+
return (index.h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, index.h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" }, index.h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" }, index.h("slot", { name: "SnkGridHeader" })), index.h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" }, index.h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))), index.h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: evt => { this.saveConfig(evt.detail); }, onEzDoubleClick: () => this.gridDoubleClick.emit() }, index.h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList })), index.h("div", { class: "ez-col ez-col--sd-12" }, index.h("slot", { name: "SnkGridFooter" }))));
|
|
164
171
|
}
|
|
165
172
|
get _element() { return index.getElement(this); }
|
|
166
173
|
};
|