@sankhyalabs/sankhyablocks 1.3.31-beta.10 → 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/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +3 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +107 -48
- package/dist/cjs/snk-form_2.cjs.entry.js +18 -11
- 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 +30 -1
- package/dist/collection/components/snk-crud/snk-crud.js +6 -18
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +107 -71
- package/dist/collection/components/snk-form/snk-form.js +18 -28
- 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 +1 -1
- 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 +4 -1
- package/dist/components/snk-crud.js +1 -2
- package/dist/components/snk-data-unit.js +107 -49
- package/dist/components/snk-form2.js +17 -11
- 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 +3 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-unit.entry.js +107 -48
- package/dist/esm/snk-form_2.entry.js +18 -11
- 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-c3d20542.entry.js → p-5e1b7e51.entry.js} +1 -1
- 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-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 +8 -2
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +8 -0
- package/dist/types/components.d.ts +9 -18
- 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 +1 -1
- 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,166 @@
|
|
|
1
|
+
const snkDataUnitMessages = {
|
|
2
|
+
saveInfo: {
|
|
3
|
+
clone: "Duplicação realizada!",
|
|
4
|
+
insert: "Inclusão realizada!",
|
|
5
|
+
update: "Aleração realizada!"
|
|
6
|
+
},
|
|
7
|
+
cancelInfo: {
|
|
8
|
+
clone: "Duplicação descartada!",
|
|
9
|
+
insert: "A inclusão descartada!",
|
|
10
|
+
update: "A edição foi descartada!"
|
|
11
|
+
},
|
|
12
|
+
removeInfo: "Registro removido com sucesso!",
|
|
13
|
+
cancelConfirmationTitle: "Aviso",
|
|
14
|
+
cancelConfirmation: "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?",
|
|
15
|
+
removeConfirmationTitle: "Excluir",
|
|
16
|
+
removeConfirmation: "Deseja realmente excluir o registro atual?",
|
|
17
|
+
forbiddenUpdate: "Não é possível fazer alterações. Verifique as permissões de acesso.",
|
|
18
|
+
forbiddenInsert: "Não é possível incluir. Verifique as permissões de acesso.",
|
|
19
|
+
forbiddenClone: "Não é possível duplicar. Verifique as permissões de acesso.",
|
|
20
|
+
forbiddenRemove: "Não é possível remover. Verifique as permissões de acesso."
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const snkFormMessages = {
|
|
24
|
+
title: {
|
|
25
|
+
clone: "Duplicar registro",
|
|
26
|
+
insert: "Cadastrar registro",
|
|
27
|
+
update: "Alterar registro",
|
|
28
|
+
clean: "{{ENTITY_NAME}}"
|
|
29
|
+
},
|
|
30
|
+
goBackTitle: "Voltar"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const snkTaskbarMessages = {
|
|
34
|
+
titleUpdate: "Editar",
|
|
35
|
+
titlePrevious: "Anterior",
|
|
36
|
+
titleNext: "Próximo",
|
|
37
|
+
titleRefresh: "Atualizar",
|
|
38
|
+
titleClone: "Duplicar",
|
|
39
|
+
titleRemove: "Excluir",
|
|
40
|
+
titleMoreOptions: "Mais Opções",
|
|
41
|
+
titleInsert: "Cadastrar",
|
|
42
|
+
titleCancel: "Cancelar",
|
|
43
|
+
titleSave: "Salvar",
|
|
44
|
+
titleGridMode: "Modo Grade",
|
|
45
|
+
titleConfigGrid: "Configuração da grade",
|
|
46
|
+
titleFormMode: "Modo Formulário"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
class SnkMessageBuilder {
|
|
50
|
+
constructor() {
|
|
51
|
+
this._defaults = {
|
|
52
|
+
snkDataUnit: snkDataUnitMessages,
|
|
53
|
+
snkForm: snkFormMessages,
|
|
54
|
+
snkTaskbar: snkTaskbarMessages
|
|
55
|
+
};
|
|
56
|
+
this._currentOperation = OperationMap.CLEAN;
|
|
57
|
+
this.loadAppMessages().then((msgs) => {
|
|
58
|
+
this._appMessages = msgs;
|
|
59
|
+
}, error => {
|
|
60
|
+
console.info('O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages.js', error);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Existem mensagens sensíveis a operação. Por exemplo, a mensagem
|
|
65
|
+
* de inclusão pode ser diferente da mensagem de alteração do mesmo
|
|
66
|
+
* recurso. Para isso "currentOperation" pode variar de acordo com
|
|
67
|
+
* OperationMap.
|
|
68
|
+
*/
|
|
69
|
+
set currentOperation(op) {
|
|
70
|
+
this._currentOperation = op;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Método usado para se obter mensagens, respeitando o padrão do sistema
|
|
74
|
+
* ou as mensagens específicas de cada tela
|
|
75
|
+
*
|
|
76
|
+
* @param key Chave usada para obter mensagens. Deve-se usar o separador "."
|
|
77
|
+
* alcançar diversos níveis.
|
|
78
|
+
* @param params Quando a mensagem possui o padrão {{NOME}} as ocorrências
|
|
79
|
+
* serão substituidas pelo respectivo valor do param.
|
|
80
|
+
* @returns A mensagem formatada.
|
|
81
|
+
*/
|
|
82
|
+
getMessage(key, params) {
|
|
83
|
+
if (key == undefined) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
var parts = key.split(".");
|
|
87
|
+
let msg = this.resolveMessage(parts, this._appMessages);
|
|
88
|
+
if (msg == undefined) {
|
|
89
|
+
msg = this.resolveMessage(parts, this._defaults);
|
|
90
|
+
}
|
|
91
|
+
if (this.customMessageBuilder) {
|
|
92
|
+
const result = this.customMessageBuilder(key, msg, params);
|
|
93
|
+
msg = result.message;
|
|
94
|
+
params = result.params;
|
|
95
|
+
}
|
|
96
|
+
return this.postProcess(msg, params);
|
|
97
|
+
}
|
|
98
|
+
resolveMessage(keys, object) {
|
|
99
|
+
if (object == undefined) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const key = keys[0];
|
|
103
|
+
const result = object[key];
|
|
104
|
+
if (result) {
|
|
105
|
+
if (this.isOperationSensitive(result)) {
|
|
106
|
+
return result[this._currentOperation];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const isLeaf = keys.length === 1 ||
|
|
110
|
+
result == undefined ||
|
|
111
|
+
typeof result === "string";
|
|
112
|
+
return isLeaf ? result : this.resolveMessage(keys.slice(1), result);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
isOperationSensitive(value) {
|
|
117
|
+
return value[OperationMap.CLONE] != undefined ||
|
|
118
|
+
value[OperationMap.INSERT] != undefined ||
|
|
119
|
+
value[OperationMap.UPDATE] != undefined ||
|
|
120
|
+
value[OperationMap.CLEAN] != undefined;
|
|
121
|
+
}
|
|
122
|
+
postProcess(message, params) {
|
|
123
|
+
if (message) {
|
|
124
|
+
const propPattern = /(.*?)\{\{(.+?)\}\}/g;
|
|
125
|
+
let processed = "";
|
|
126
|
+
let tail = message;
|
|
127
|
+
let result;
|
|
128
|
+
while ((result = propPattern.exec(message)) !== null) {
|
|
129
|
+
const [match, head, attribute] = result;
|
|
130
|
+
const tailIndex = result.index + match.length;
|
|
131
|
+
tail = tailIndex < message.length ? message.substring(tailIndex) : "";
|
|
132
|
+
let replacement = params ? params[attribute] : undefined;
|
|
133
|
+
if (replacement == undefined) {
|
|
134
|
+
replacement = "";
|
|
135
|
+
}
|
|
136
|
+
processed += head + replacement;
|
|
137
|
+
}
|
|
138
|
+
return processed + tail;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return message;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
loadAppMessages() {
|
|
145
|
+
return new Promise((accept, reject) => {
|
|
146
|
+
const messagesUrl = window['applicationenv'] !== "dev" ? `/${window["MGE_MODULE_NAME"]}/labsApps/${window["APPLICATION_NAME"]}/messages/appmessages.js`
|
|
147
|
+
: '/messages/appmessages.js';
|
|
148
|
+
import(/* webpackIgnore: true */ messagesUrl)
|
|
149
|
+
.then(module => {
|
|
150
|
+
accept(module.default);
|
|
151
|
+
})
|
|
152
|
+
.catch(reason => {
|
|
153
|
+
reject(reason);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
var OperationMap;
|
|
159
|
+
(function (OperationMap) {
|
|
160
|
+
OperationMap["CLONE"] = "clone";
|
|
161
|
+
OperationMap["INSERT"] = "insert";
|
|
162
|
+
OperationMap["UPDATE"] = "update";
|
|
163
|
+
OperationMap["CLEAN"] = "clean";
|
|
164
|
+
})(OperationMap || (OperationMap = {}));
|
|
165
|
+
|
|
166
|
+
export { OperationMap as O, SnkMessageBuilder as S };
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["snk-crud",[[6,"snk-crud",{"configName":[1,"config-name"],"
|
|
13
|
+
return bootstrapLazy([["snk-crud",[[6,"snk-crud",{"configName":[1,"config-name"],"actionsList":[16],"recordsValidator":[8,"records-validator"],"_dataUnit":[32],"_dataState":[32]}]]],["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-data-unit",[[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",[[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],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["snk-form_2",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[8,"records-validator"],"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",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-taskbar",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -13,5 +13,5 @@ const patchBrowser = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["snk-crud",[[6,"snk-crud",{"configName":[1,"config-name"],"
|
|
16
|
+
return bootstrapLazy([["snk-crud",[[6,"snk-crud",{"configName":[1,"config-name"],"actionsList":[16],"recordsValidator":[8,"records-validator"],"_dataUnit":[32],"_dataState":[32]}]]],["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-data-unit",[[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",[[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],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64],"executeSearch":[64],"isDebugMode":[64]}]]],["snk-form_2",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[8,"records-validator"],"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",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-taskbar",[[6,"snk-taskbar",{"buttons":[1],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}]]]], options);
|
|
17
17
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h } from './index-6a83ac96.js';
|
|
2
2
|
import { ErrorException, StringUtils, DataUnit, DataType, ChangeOperation, DateUtils, ObjectUtils, WaitingChangeException, WarningException, DependencyType, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
|
|
3
3
|
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
+
import { S as SnkMessageBuilder } from './SnkMessageBuilder-3835f9d8.js';
|
|
4
5
|
|
|
5
6
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
7
|
|
|
@@ -6454,7 +6455,7 @@ class UrlUtils {
|
|
|
6454
6455
|
|
|
6455
6456
|
class DataFetcher {
|
|
6456
6457
|
constructor() {
|
|
6457
|
-
this.GRAPHQL_PATH =
|
|
6458
|
+
this.GRAPHQL_PATH = "/mge/graphql";
|
|
6458
6459
|
this.watingRequestsById = new Map();
|
|
6459
6460
|
}
|
|
6460
6461
|
static get() {
|
|
@@ -7703,6 +7704,7 @@ const SnkApplication = class {
|
|
|
7703
7704
|
}
|
|
7704
7705
|
componentWillLoad() {
|
|
7705
7706
|
this._errorHandler = new SnkErrorHandler(this);
|
|
7707
|
+
this.messagesBuilder = new SnkMessageBuilder();
|
|
7706
7708
|
ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/upload/file`);
|
|
7707
7709
|
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
|
|
7708
7710
|
return this.executeSearch(searchArgument, fieldName, dataUnit);
|
|
@@ -51,7 +51,7 @@ const SnkCrud = class {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
render() {
|
|
54
|
-
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", {
|
|
54
|
+
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) }))));
|
|
55
55
|
}
|
|
56
56
|
get _element() { return getElement(this); }
|
|
57
57
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-6a83ac96.js';
|
|
2
2
|
import { Action, ApplicationContext } from '@sankhyalabs/core';
|
|
3
3
|
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
+
import { O as OperationMap } from './SnkMessageBuilder-3835f9d8.js';
|
|
4
5
|
|
|
5
6
|
const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
|
|
6
7
|
|
|
@@ -21,19 +22,6 @@ const SnkDataUnit = class {
|
|
|
21
22
|
*/
|
|
22
23
|
this.autoLoad = true;
|
|
23
24
|
this._dataUnitObserver = (action) => {
|
|
24
|
-
let msg;
|
|
25
|
-
if (!this.isTransitionAction(action.type)) {
|
|
26
|
-
msg = this.getActionInfo(action.type);
|
|
27
|
-
}
|
|
28
|
-
if (msg) {
|
|
29
|
-
ApplicationUtils.info(msg);
|
|
30
|
-
}
|
|
31
|
-
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
32
|
-
this.insertionMode.emit();
|
|
33
|
-
}
|
|
34
|
-
if (action.type === Action.EDITION_CANCELED) {
|
|
35
|
-
this.cancelEdition.emit();
|
|
36
|
-
}
|
|
37
25
|
const duState = {
|
|
38
26
|
insertionMode: false,
|
|
39
27
|
hasNext: this.dataUnit.hasNext(),
|
|
@@ -50,6 +38,29 @@ const SnkDataUnit = class {
|
|
|
50
38
|
}
|
|
51
39
|
});
|
|
52
40
|
this.dataState = duState;
|
|
41
|
+
if (action.type === Action.DATA_SAVED) {
|
|
42
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
43
|
+
if (msg != undefined) {
|
|
44
|
+
this.showSuccessMessage(msg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
48
|
+
this.insertionMode.emit();
|
|
49
|
+
}
|
|
50
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
51
|
+
this.cancelEdition.emit();
|
|
52
|
+
const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
|
|
53
|
+
if (cancelFinishMsg != undefined) {
|
|
54
|
+
this.showSuccessMessage(cancelFinishMsg);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (action.type === Action.RECORDS_REMOVED) {
|
|
58
|
+
const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
59
|
+
if (removeFinishMsg != undefined) {
|
|
60
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this._application.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
53
64
|
};
|
|
54
65
|
}
|
|
55
66
|
observePageSize() {
|
|
@@ -97,6 +108,32 @@ const SnkDataUnit = class {
|
|
|
97
108
|
async interceptAction(action) {
|
|
98
109
|
return new Promise(resolve => {
|
|
99
110
|
switch (action.type) {
|
|
111
|
+
case Action.RECORDS_ADDED:
|
|
112
|
+
if (this.isAllowed("INSERT")) {
|
|
113
|
+
resolve(action);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case Action.RECORDS_COPIED:
|
|
120
|
+
if (this.isAllowed("CLONE")) {
|
|
121
|
+
resolve(action);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case Action.DATA_CHANGED:
|
|
128
|
+
case Action.CHANGING_DATA:
|
|
129
|
+
if (this.isAllowed("UPDATE")) {
|
|
130
|
+
resolve(action);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.dataUnit.cancelEdition();
|
|
134
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
100
137
|
case Action.SAVING_DATA:
|
|
101
138
|
if (this.beforeSave) {
|
|
102
139
|
const continueAction = this.beforeSave(this.dataUnit);
|
|
@@ -121,52 +158,82 @@ const SnkDataUnit = class {
|
|
|
121
158
|
break;
|
|
122
159
|
case Action.EDITION_CANCELED:
|
|
123
160
|
if (this.dataState.hasDirtyRecords) {
|
|
124
|
-
|
|
125
|
-
|
|
161
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
162
|
+
if (cancelConfirmation == undefined) {
|
|
163
|
+
resolve(action);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
167
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
168
|
+
.then((result) => resolve(result ? action : undefined));
|
|
169
|
+
}
|
|
126
170
|
}
|
|
127
171
|
else {
|
|
128
172
|
resolve(action);
|
|
129
173
|
}
|
|
130
174
|
break;
|
|
131
175
|
case Action.REMOVING_RECORDS:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
176
|
+
if (this.isAllowed("REMOVE")) {
|
|
177
|
+
const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
|
|
178
|
+
if (removeConfirmation == undefined) {
|
|
179
|
+
resolve(action);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
183
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", true, { btnConfirmDanger: true })
|
|
184
|
+
.then((result) => resolve(result ? action : undefined));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
135
189
|
}
|
|
136
|
-
ApplicationUtils.confirm(this.i18n("components.delete"), msg || this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
|
|
137
|
-
.then((result) => resolve(result ? action : undefined));
|
|
138
190
|
break;
|
|
139
191
|
default:
|
|
140
192
|
resolve(action);
|
|
141
193
|
}
|
|
142
194
|
});
|
|
143
195
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
196
|
+
showSuccessMessage(message) {
|
|
197
|
+
ApplicationUtils.info(message, { iconName: "check" });
|
|
198
|
+
}
|
|
199
|
+
isAllowed(flag) {
|
|
200
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
204
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
205
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
206
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
207
|
+
*/
|
|
208
|
+
getMessage(key, params = undefined) {
|
|
209
|
+
if (!params) {
|
|
210
|
+
params = this.getMessageParams();
|
|
154
211
|
}
|
|
212
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
213
|
+
}
|
|
214
|
+
getMessageParams() {
|
|
215
|
+
//TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
|
|
216
|
+
//precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
|
|
217
|
+
//mensagem
|
|
218
|
+
return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
|
|
155
219
|
}
|
|
156
|
-
|
|
157
|
-
if (this.
|
|
158
|
-
return
|
|
220
|
+
getMessageOperation() {
|
|
221
|
+
if (this.dataState.copyMode) {
|
|
222
|
+
return OperationMap.CLONE;
|
|
159
223
|
}
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
224
|
+
if (this.dataState.insertionMode) {
|
|
225
|
+
return OperationMap.INSERT;
|
|
162
226
|
}
|
|
227
|
+
if (this.dataState.isDirty) {
|
|
228
|
+
return OperationMap.UPDATE;
|
|
229
|
+
}
|
|
230
|
+
return OperationMap.CLEAN;
|
|
163
231
|
}
|
|
164
232
|
async loadDataUnit() {
|
|
165
233
|
if (!this.dataUnit) {
|
|
166
|
-
|
|
167
|
-
if (app && this.entityName) {
|
|
234
|
+
if (this._application && this.entityName) {
|
|
168
235
|
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
169
|
-
this.dataUnit = await
|
|
236
|
+
this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
|
|
170
237
|
this.dataUnit.pageSize = this.pageSize;
|
|
171
238
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
172
239
|
this.dataUnit.addInterceptor(this);
|
|
@@ -181,20 +248,12 @@ const SnkDataUnit = class {
|
|
|
181
248
|
}
|
|
182
249
|
}
|
|
183
250
|
}
|
|
184
|
-
i18n(key) {
|
|
185
|
-
const pt_br = {
|
|
186
|
-
"components.warning": "Aviso",
|
|
187
|
-
"components.delete": "Excluir",
|
|
188
|
-
"components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
|
|
189
|
-
"components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
|
|
190
|
-
"components.editionCanceled": "Todas as alterações foram descartadas.",
|
|
191
|
-
};
|
|
192
|
-
return pt_br[key];
|
|
193
|
-
}
|
|
194
251
|
//---------------------------------------------
|
|
195
252
|
// Lifecycle web component
|
|
196
253
|
//---------------------------------------------
|
|
197
254
|
componentWillLoad() {
|
|
255
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
256
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
198
257
|
this.loadDataUnit();
|
|
199
258
|
}
|
|
200
259
|
render() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-6a83ac96.js';
|
|
2
2
|
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { T as TaskbarElement } from './taskbar-elements-
|
|
3
|
+
import { T as TaskbarElement } from './taskbar-elements-6d01a640.js';
|
|
4
4
|
|
|
5
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
6
|
|
|
@@ -52,22 +52,29 @@ const SnkForm = class {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
57
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
58
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
59
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
|
|
60
|
+
*/
|
|
61
|
+
getMessage(key) {
|
|
62
|
+
return this._application.messagesBuilder.getMessage(key, this.getMessageParams());
|
|
63
|
+
}
|
|
64
|
+
getMessageParams() {
|
|
65
|
+
var _a;
|
|
66
|
+
return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
|
|
60
67
|
}
|
|
61
68
|
componentWillLoad() {
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
69
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
70
|
+
if (this._application) {
|
|
71
|
+
this._application.loadFormConfig(this.configName).then(cfg => {
|
|
65
72
|
this._configLoaded = true;
|
|
66
73
|
this._editionFormConfig = cfg;
|
|
67
74
|
this.loadInsertionConfig();
|
|
68
75
|
});
|
|
69
76
|
//Forçamos a carga dos acessos pra aproveitar a request inicial.
|
|
70
|
-
|
|
77
|
+
this._application.getAllAccess();
|
|
71
78
|
}
|
|
72
79
|
let parent = this._element.parentElement;
|
|
73
80
|
while (parent) {
|
|
@@ -96,7 +103,7 @@ const SnkForm = class {
|
|
|
96
103
|
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
97
104
|
return undefined;
|
|
98
105
|
}
|
|
99
|
-
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.
|
|
106
|
+
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 }))))));
|
|
100
107
|
}
|
|
101
108
|
get _element() { return getElement(this); }
|
|
102
109
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host } from './index-6a83ac96.js';
|
|
2
2
|
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { A as AuthorizationElements, T as TaskbarElement, b as buildElem } from './taskbar-elements-
|
|
3
|
+
import { A as AuthorizationElements, T as TaskbarElement, b as buildElem } from './taskbar-elements-6d01a640.js';
|
|
4
4
|
|
|
5
5
|
const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}";
|
|
6
6
|
|
|
@@ -31,23 +31,42 @@ const SnkTaskbar = class {
|
|
|
31
31
|
}
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
36
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
37
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
38
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
|
|
39
|
+
*/
|
|
34
40
|
getTitle(element) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
switch (element) {
|
|
42
|
+
case TaskbarElement.UPDATE:
|
|
43
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleUpdate", {});
|
|
44
|
+
case TaskbarElement.PREVIOUS:
|
|
45
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titlePrevious", {});
|
|
46
|
+
case TaskbarElement.NEXT:
|
|
47
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleNext", {});
|
|
48
|
+
case TaskbarElement.REFRESH:
|
|
49
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleRefresh", {});
|
|
50
|
+
case TaskbarElement.CLONE:
|
|
51
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleClone", {});
|
|
52
|
+
case TaskbarElement.REMOVE:
|
|
53
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleRemove", {});
|
|
54
|
+
case TaskbarElement.MORE_OPTIONS:
|
|
55
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleMoreOptions", {});
|
|
56
|
+
case TaskbarElement.INSERT:
|
|
57
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleInsert", {});
|
|
58
|
+
case TaskbarElement.CANCEL:
|
|
59
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleCancel", {});
|
|
60
|
+
case TaskbarElement.SAVE:
|
|
61
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleSave", {});
|
|
62
|
+
case TaskbarElement.GRID_MODE:
|
|
63
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleGridMode", {});
|
|
64
|
+
case TaskbarElement.CONFIG_GRID:
|
|
65
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleConfigGrid", {});
|
|
66
|
+
case TaskbarElement.FORM_MODE:
|
|
67
|
+
return this._application.messagesBuilder.getMessage("snkTaskbar.titleFormMode", {});
|
|
68
|
+
}
|
|
69
|
+
return "";
|
|
51
70
|
}
|
|
52
71
|
elementClick(elem) {
|
|
53
72
|
if (this.dataUnit) {
|
|
@@ -94,9 +113,9 @@ const SnkTaskbar = class {
|
|
|
94
113
|
}
|
|
95
114
|
// Lifecycle
|
|
96
115
|
componentWillLoad() {
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
116
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
117
|
+
if (this._application) {
|
|
118
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
100
119
|
}
|
|
101
120
|
else {
|
|
102
121
|
this._permissions = {};
|
|
@@ -42,7 +42,7 @@ const buildElem = (element, className, getTitle, action, isEnabled, actions) =>
|
|
|
42
42
|
case TaskbarElement.INSERT:
|
|
43
43
|
return iconTextButton("plus", element, className, getTitle, action, isEnabled);
|
|
44
44
|
case TaskbarElement.CANCEL:
|
|
45
|
-
return h("ez-button", { label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
|
|
45
|
+
return h("ez-button", { title: getTitle(element), label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
|
|
46
46
|
case TaskbarElement.SAVE:
|
|
47
47
|
return iconTextButton("save", element, className, getTitle, action, isEnabled);
|
|
48
48
|
case TaskbarElement.GRID_MODE:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,h as i,g as s}from"./p-cd1dc099.js";const h=class{constructor(i){t(this,i)}async gridToForm(t=!1){this._backToGrid=!t&&0===await this._viewStack.getSelectedIndex(),this._viewStack.show(1)}async executeAction(t){"GRID_MODE"===t?this._viewStack.show(0):"FORM_MODE"!==t&&"UPDATE"!==t||this.gridToForm("UPDATE"!==t)}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this._viewStack.show(0)}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit||this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}}render(){return i("ez-view-stack",{ref:t=>this._viewStack=t},i("stack-item",null,i("snk-grid",{configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList},i("slot",null))),i("stack-item",null,i("snk-form",{
|
|
1
|
+
import{r as t,h as i,g as s}from"./p-cd1dc099.js";const h=class{constructor(i){t(this,i)}async gridToForm(t=!1){this._backToGrid=!t&&0===await this._viewStack.getSelectedIndex(),this._viewStack.show(1)}async executeAction(t){"GRID_MODE"===t?this._viewStack.show(0):"FORM_MODE"!==t&&"UPDATE"!==t||this.gridToForm("UPDATE"!==t)}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this._viewStack.show(0)}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit||this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}}render(){return i("ez-view-stack",{ref:t=>this._viewStack=t},i("stack-item",null,i("snk-grid",{configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList},i("slot",null))),i("stack-item",null,i("snk-form",{configName:this.configName,actionsList:this.actionsList,onExit:()=>this._viewStack.show(0),recordsValidator:this.recordsValidator,onActionClick:t=>this.executeAction(t.detail)})))}get _element(){return s(this)}};h.style=".sc-snk-crud-h{display:flex;height:100%;width:100%}";export{h as snk_crud}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={saveInfo:{clone:"Duplicação realizada!",insert:"Inclusão realizada!",update:"Aleração realizada!"},cancelInfo:{clone:"Duplicação descartada!",insert:"A inclusão descartada!",update:"A edição foi descartada!"},removeInfo:"Registro removido com sucesso!",cancelConfirmationTitle:"Aviso",cancelConfirmation:"As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?",removeConfirmationTitle:"Excluir",removeConfirmation:"Deseja realmente excluir o registro atual?",forbiddenUpdate:"Não é possível fazer alterações. Verifique as permissões de acesso.",forbiddenInsert:"Não é possível incluir. Verifique as permissões de acesso.",forbiddenClone:"Não é possível duplicar. Verifique as permissões de acesso.",forbiddenRemove:"Não é possível remover. Verifique as permissões de acesso."},s={title:{clone:"Duplicar registro",insert:"Cadastrar registro",update:"Alterar registro",clean:"{{ENTITY_NAME}}"},goBackTitle:"Voltar"},r={titleUpdate:"Editar",titlePrevious:"Anterior",titleNext:"Próximo",titleRefresh:"Atualizar",titleClone:"Duplicar",titleRemove:"Excluir",titleMoreOptions:"Mais Opções",titleInsert:"Cadastrar",titleCancel:"Cancelar",titleSave:"Salvar",titleGridMode:"Modo Grade",titleConfigGrid:"Configuração da grade",titleFormMode:"Modo Formulário"};class a{constructor(){this._defaults={snkDataUnit:e,snkForm:s,snkTaskbar:r},this._currentOperation=i.CLEAN,this.loadAppMessages().then((e=>{this._appMessages=e}),(e=>{console.info("O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages.js",e)}))}set currentOperation(e){this._currentOperation=e}getMessage(e,s){if(null==e)return;var r=e.split(".");let a=this.resolveMessage(r,this._appMessages);if(null==a&&(a=this.resolveMessage(r,this._defaults)),this.customMessageBuilder){const r=this.customMessageBuilder(e,a,s);a=r.message,s=r.params}return this.postProcess(a,s)}resolveMessage(e,s){if(null==s)return;const r=s[e[0]];return r?this.isOperationSensitive(r)?r[this._currentOperation]:1===e.length||null==r||"string"==typeof r?r:this.resolveMessage(e.slice(1),r):void 0}isOperationSensitive(e){return null!=e[i.CLONE]||null!=e[i.INSERT]||null!=e[i.UPDATE]||null!=e[i.CLEAN]}postProcess(e,s){if(e){const r=/(.*?)\{\{(.+?)\}\}/g;let a,i="",t=e;for(;null!==(a=r.exec(e));){const[r,o,n]=a,l=a.index+r.length;t=l<e.length?e.substring(l):"";let d=s?s[n]:void 0;null==d&&(d=""),i+=o+d}return i+t}return e}loadAppMessages(){return new Promise(((e,s)=>{const r="dev"!==window.applicationenv?`/${window.MGE_MODULE_NAME}/labsApps/${window.APPLICATION_NAME}/messages/appmessages.js`:"/messages/appmessages.js";import(r).then((s=>{e(s.default)})).catch((e=>{s(e)}))}))}}var i;!function(e){e.CLONE="clone",e.INSERT="insert",e.UPDATE="update",e.CLEAN="clean"}(i||(i={}));export{i as O,a as S}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as s,h as i,g as e,H as a}from"./p-cd1dc099.js";import{Action as n,ApplicationContext as h}from"@sankhyalabs/core";import{ApplicationUtils as o}from"@sankhyalabs/ezui/dist/collection/utils";import{O as r}from"./p-72bccbb6.js";const c=class{constructor(i){t(this,i),this.dataStateChange=s(this,"dataStateChange",7),this.dataUnitReady=s(this,"dataUnitReady",7),this.insertionMode=s(this,"insertionMode",7),this.cancelEdition=s(this,"cancelEdition",7),this._onDataUnitResolve=[],this.pageSize=150,this.autoLoad=!0,this._dataUnitObserver=t=>{const s={insertionMode:!1,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:!1,isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:this.dataUnit.getSelectedRecords()};if(this.dataUnit.records.forEach((t=>{t.__record__id__.startsWith("NEW_")&&(s.insertionMode=!0,s.copyMode||(s.copyMode=null!=t.__record__source__id__))})),this.dataState=s,t.type===n.DATA_SAVED){const s=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0]);null!=s&&this.showSuccessMessage(s)}if(t.type!==n.RECORDS_ADDED&&t.type!==n.RECORDS_COPIED||this.insertionMode.emit(),t.type===n.EDITION_CANCELED){this.cancelEdition.emit();const t=this.getMessage("snkDataUnit.cancelInfo");null!=t&&this.showSuccessMessage(t)}if(t.type===n.RECORDS_REMOVED){const s=this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]);null!=s&&this.showSuccessMessage(s)}this._application.messagesBuilder.currentOperation=this.getMessageOperation()}}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,s){s!=t&&(this.dataUnit=void 0,this.dataUnitName=t,this.loadDataUnit())}observeEntityName(t,s){s!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,s){s!=t&&this.dataStateChange.emit(t)}observeDataUnit(){this.dataUnitReady.emit(this.dataUnit)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async interceptAction(t){return new Promise((s=>{switch(t.type){case n.RECORDS_ADDED:this.isAllowed("INSERT")?s(t):o.info(this.getMessage("snkDataUnit.forbiddenInsert"));break;case n.RECORDS_COPIED:this.isAllowed("CLONE")?s(t):o.info(this.getMessage("snkDataUnit.forbiddenClone"));break;case n.DATA_CHANGED:case n.CHANGING_DATA:this.isAllowed("UPDATE")?s(t):(this.dataUnit.cancelEdition(),o.info(this.getMessage("snkDataUnit.forbiddenUpdate")));break;case n.SAVING_DATA:if(this.beforeSave){const i=this.beforeSave(this.dataUnit);i instanceof Promise?i.then((i=>s(i?t:void 0))):s(i?t:void 0)}else s(t);break;case n.DATA_SAVED:this.afterSave?this.afterSave(this.dataUnit):s(t);break;case n.EDITION_CANCELED:if(this.dataState.hasDirtyRecords){const i=this.getMessage("snkDataUnit.cancelConfirmation");if(null==i)s(t);else{const e=this.getMessage("snkDataUnit.cancelConfirmationTitle");o.confirm(e,i).then((i=>s(i?t:void 0)))}}else s(t);break;case n.REMOVING_RECORDS:if(this.isAllowed("REMOVE")){const i=this.getMessage("snkDataUnit.removeConfirmation");if(null==i)s(t);else{const e=this.getMessage("snkDataUnit.removeConfirmationTitle");o.confirm(e,i,"delete",!0,{btnConfirmDanger:!0}).then((i=>s(i?t:void 0)))}}else o.info(this.getMessage("snkDataUnit.forbiddenRemove"));break;default:s(t)}}))}showSuccessMessage(t){o.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getMessage(t,s){return s||(s=this.getMessageParams()),this._application.messagesBuilder.getMessage(t,s)}getMessageParams(){return this.dataState.selectedRecords?this.dataState.selectedRecords[0]:void 0}getMessageOperation(){return this.dataState.copyMode?r.CLONE:this.dataState.insertionMode?r.INSERT:this.dataState.isDirty?r.UPDATE:r.CLEAN}async loadDataUnit(){if(!this.dataUnit&&this._application&&this.entityName){const t=this.dataUnitName?this.dataUnitName:this.entityName;let s;for(this.dataUnit=await this._application.getDataUnit(this.entityName,t),this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver);s=this._onDataUnitResolve.pop();)s(this.dataUnit);this.autoLoad&&this.dataUnit.loadData()}}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess().then((t=>this._permissions=t)),this.loadDataUnit()}render(){return i(a,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"]}}};c.style=".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";export{c as snk_data_unit}
|