@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.
Files changed (56) hide show
  1. package/dist/cjs/SnkMessageBuilder-13239761.js +188 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  4. package/dist/cjs/snk-application.cjs.entry.js +3 -1
  5. package/dist/cjs/snk-crud.cjs.entry.js +1 -1
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +107 -48
  7. package/dist/cjs/snk-form_2.cjs.entry.js +18 -11
  8. package/dist/cjs/snk-taskbar.cjs.entry.js +39 -20
  9. package/dist/cjs/{taskbar-elements-7f99f0c9.js → taskbar-elements-73d524e5.js} +1 -1
  10. package/dist/collection/components/snk-application/snk-application.js +30 -1
  11. package/dist/collection/components/snk-crud/snk-crud.js +6 -18
  12. package/dist/collection/components/snk-data-unit/snk-data-unit.js +107 -71
  13. package/dist/collection/components/snk-form/snk-form.js +18 -28
  14. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -1
  15. package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -19
  16. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
  17. package/dist/collection/lib/message/SnkMessageBuilder.js +119 -0
  18. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +22 -0
  19. package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
  20. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +16 -0
  21. package/dist/components/SnkMessageBuilder.js +166 -0
  22. package/dist/components/snk-application2.js +4 -1
  23. package/dist/components/snk-crud.js +1 -2
  24. package/dist/components/snk-data-unit.js +107 -49
  25. package/dist/components/snk-form2.js +17 -11
  26. package/dist/components/snk-taskbar2.js +39 -20
  27. package/dist/esm/SnkMessageBuilder-3835f9d8.js +166 -0
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/sankhyablocks.js +1 -1
  30. package/dist/esm/snk-application.entry.js +3 -1
  31. package/dist/esm/snk-crud.entry.js +1 -1
  32. package/dist/esm/snk-data-unit.entry.js +107 -48
  33. package/dist/esm/snk-form_2.entry.js +18 -11
  34. package/dist/esm/snk-taskbar.entry.js +39 -20
  35. package/dist/esm/{taskbar-elements-e0b8a285.js → taskbar-elements-6d01a640.js} +1 -1
  36. package/dist/sankhyablocks/{p-c3d20542.entry.js → p-5e1b7e51.entry.js} +1 -1
  37. package/dist/sankhyablocks/p-72bccbb6.js +1 -0
  38. package/dist/sankhyablocks/p-8c74d163.entry.js +1 -0
  39. package/dist/sankhyablocks/p-bab507ad.entry.js +1 -0
  40. package/dist/sankhyablocks/p-dd10a5e3.js +1 -0
  41. package/dist/sankhyablocks/p-e942c604.entry.js +69 -0
  42. package/dist/sankhyablocks/p-f4d0394b.entry.js +1 -0
  43. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  44. package/dist/types/components/snk-application/snk-application.d.ts +8 -2
  45. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +8 -0
  46. package/dist/types/components.d.ts +9 -18
  47. package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
  48. package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
  49. package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
  50. package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
  51. package/package.json +1 -1
  52. package/dist/sankhyablocks/p-18fe0469.entry.js +0 -69
  53. package/dist/sankhyablocks/p-5b5afdbe.entry.js +0 -1
  54. package/dist/sankhyablocks/p-7fe9e5c2.entry.js +0 -1
  55. package/dist/sankhyablocks/p-8650ae26.entry.js +0 -1
  56. package/dist/sankhyablocks/p-a5439706.js +0 -1
@@ -0,0 +1,10 @@
1
+ const snkFormMessages = {
2
+ title: {
3
+ clone: "Duplicar registro",
4
+ insert: "Cadastrar registro",
5
+ update: "Alterar registro",
6
+ clean: "{{ENTITY_NAME}}"
7
+ },
8
+ goBackTitle: "Voltar"
9
+ };
10
+ export default snkFormMessages;
@@ -0,0 +1,16 @@
1
+ const snkTaskbarMessages = {
2
+ titleUpdate: "Editar",
3
+ titlePrevious: "Anterior",
4
+ titleNext: "Próximo",
5
+ titleRefresh: "Atualizar",
6
+ titleClone: "Duplicar",
7
+ titleRemove: "Excluir",
8
+ titleMoreOptions: "Mais Opções",
9
+ titleInsert: "Cadastrar",
10
+ titleCancel: "Cancelar",
11
+ titleSave: "Salvar",
12
+ titleGridMode: "Modo Grade",
13
+ titleConfigGrid: "Configuração da grade",
14
+ titleFormMode: "Modo Formulário"
15
+ };
16
+ export default snkTaskbarMessages;
@@ -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 };
@@ -1,6 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
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.js';
4
5
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
5
6
 
6
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -6455,7 +6456,7 @@ class UrlUtils {
6455
6456
 
6456
6457
  class DataFetcher {
6457
6458
  constructor() {
6458
- this.GRAPHQL_PATH = window['applicationenv'] === "sankhyaom" ? "/mge/graphql" : "";
6459
+ this.GRAPHQL_PATH = "/mge/graphql";
6459
6460
  this.watingRequestsById = new Map();
6460
6461
  }
6461
6462
  static get() {
@@ -7705,6 +7706,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7705
7706
  }
7706
7707
  componentWillLoad() {
7707
7708
  this._errorHandler = new SnkErrorHandler(this);
7709
+ this.messagesBuilder = new SnkMessageBuilder();
7708
7710
  ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/upload/file`);
7709
7711
  ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
7710
7712
  return this.executeSearch(searchArgument, fieldName, dataUnit);
@@ -7730,6 +7732,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7730
7732
  }
7731
7733
  static get style() { return snkApplicationCss; }
7732
7734
  }, [2, "snk-application", {
7735
+ "messagesBuilder": [1040],
7733
7736
  "isUserSup": [64],
7734
7737
  "hasAccess": [64],
7735
7738
  "getAllAccess": [64],
@@ -55,13 +55,12 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
55
55
  }
56
56
  }
57
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) }))));
58
+ return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, h("stack-item", null, h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList }, h("slot", null))), h("stack-item", null, h("snk-form", { configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, onActionClick: evt => this.executeAction(evt.detail) }))));
59
59
  }
60
60
  get _element() { return this; }
61
61
  static get style() { return snkCrudCss; }
62
62
  }, [6, "snk-crud", {
63
63
  "configName": [1, "config-name"],
64
- "formTitle": [1, "form-title"],
65
64
  "actionsList": [16],
66
65
  "recordsValidator": [8, "records-validator"],
67
66
  "_dataUnit": [32],
@@ -1,6 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
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.js';
4
5
 
5
6
  const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
6
7
 
@@ -22,19 +23,6 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
22
23
  */
23
24
  this.autoLoad = true;
24
25
  this._dataUnitObserver = (action) => {
25
- let msg;
26
- if (!this.isTransitionAction(action.type)) {
27
- msg = this.getActionInfo(action.type);
28
- }
29
- if (msg) {
30
- ApplicationUtils.info(msg);
31
- }
32
- if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
33
- this.insertionMode.emit();
34
- }
35
- if (action.type === Action.EDITION_CANCELED) {
36
- this.cancelEdition.emit();
37
- }
38
26
  const duState = {
39
27
  insertionMode: false,
40
28
  hasNext: this.dataUnit.hasNext(),
@@ -51,6 +39,29 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
51
39
  }
52
40
  });
53
41
  this.dataState = duState;
42
+ if (action.type === Action.DATA_SAVED) {
43
+ const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
44
+ if (msg != undefined) {
45
+ this.showSuccessMessage(msg);
46
+ }
47
+ }
48
+ if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
49
+ this.insertionMode.emit();
50
+ }
51
+ if (action.type === Action.EDITION_CANCELED) {
52
+ this.cancelEdition.emit();
53
+ const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
54
+ if (cancelFinishMsg != undefined) {
55
+ this.showSuccessMessage(cancelFinishMsg);
56
+ }
57
+ }
58
+ if (action.type === Action.RECORDS_REMOVED) {
59
+ const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
60
+ if (removeFinishMsg != undefined) {
61
+ this.showSuccessMessage(removeFinishMsg);
62
+ }
63
+ }
64
+ this._application.messagesBuilder.currentOperation = this.getMessageOperation();
54
65
  };
55
66
  }
56
67
  observePageSize() {
@@ -98,6 +109,32 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
98
109
  async interceptAction(action) {
99
110
  return new Promise(resolve => {
100
111
  switch (action.type) {
112
+ case Action.RECORDS_ADDED:
113
+ if (this.isAllowed("INSERT")) {
114
+ resolve(action);
115
+ }
116
+ else {
117
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
118
+ }
119
+ break;
120
+ case Action.RECORDS_COPIED:
121
+ if (this.isAllowed("CLONE")) {
122
+ resolve(action);
123
+ }
124
+ else {
125
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
126
+ }
127
+ break;
128
+ case Action.DATA_CHANGED:
129
+ case Action.CHANGING_DATA:
130
+ if (this.isAllowed("UPDATE")) {
131
+ resolve(action);
132
+ }
133
+ else {
134
+ this.dataUnit.cancelEdition();
135
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenUpdate"));
136
+ }
137
+ break;
101
138
  case Action.SAVING_DATA:
102
139
  if (this.beforeSave) {
103
140
  const continueAction = this.beforeSave(this.dataUnit);
@@ -122,52 +159,82 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
122
159
  break;
123
160
  case Action.EDITION_CANCELED:
124
161
  if (this.dataState.hasDirtyRecords) {
125
- ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
126
- .then((result) => resolve(result ? action : undefined));
162
+ const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
163
+ if (cancelConfirmation == undefined) {
164
+ resolve(action);
165
+ }
166
+ else {
167
+ const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
168
+ ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
169
+ .then((result) => resolve(result ? action : undefined));
170
+ }
127
171
  }
128
172
  else {
129
173
  resolve(action);
130
174
  }
131
175
  break;
132
176
  case Action.REMOVING_RECORDS:
133
- let msg = undefined;
134
- if (this.messageBuilder) {
135
- msg = this.messageBuilder(action.type, this.dataState, this.dataUnit);
177
+ if (this.isAllowed("REMOVE")) {
178
+ const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
179
+ if (removeConfirmation == undefined) {
180
+ resolve(action);
181
+ }
182
+ else {
183
+ const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
184
+ ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", true, { btnConfirmDanger: true })
185
+ .then((result) => resolve(result ? action : undefined));
186
+ }
187
+ }
188
+ else {
189
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
136
190
  }
137
- ApplicationUtils.confirm(this.i18n("components.delete"), msg || this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
138
- .then((result) => resolve(result ? action : undefined));
139
191
  break;
140
192
  default:
141
193
  resolve(action);
142
194
  }
143
195
  });
144
196
  }
145
- isTransitionAction(action) {
146
- switch (action) {
147
- case Action.LOADING_METADATA:
148
- case Action.LOADING_DATA:
149
- case Action.SAVING_DATA:
150
- case Action.REMOVING_RECORDS:
151
- case Action.CHANGING_DATA:
152
- return true;
153
- default:
154
- return false;
197
+ showSuccessMessage(message) {
198
+ ApplicationUtils.info(message, { iconName: "check" });
199
+ }
200
+ isAllowed(flag) {
201
+ return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
202
+ }
203
+ /**
204
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
205
+ * através de um pequeno modulo na estrutura da aplicação:
206
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
207
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
208
+ */
209
+ getMessage(key, params = undefined) {
210
+ if (!params) {
211
+ params = this.getMessageParams();
155
212
  }
213
+ return this._application.messagesBuilder.getMessage(key, params);
214
+ }
215
+ getMessageParams() {
216
+ //TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
217
+ //precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
218
+ //mensagem
219
+ return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
156
220
  }
157
- getActionInfo(action) {
158
- if (this.messageBuilder) {
159
- return this.messageBuilder(action, this.dataState, this.dataUnit);
221
+ getMessageOperation() {
222
+ if (this.dataState.copyMode) {
223
+ return OperationMap.CLONE;
160
224
  }
161
- if (action === Action.EDITION_CANCELED) {
162
- return this.i18n("components.editionCanceled");
225
+ if (this.dataState.insertionMode) {
226
+ return OperationMap.INSERT;
163
227
  }
228
+ if (this.dataState.isDirty) {
229
+ return OperationMap.UPDATE;
230
+ }
231
+ return OperationMap.CLEAN;
164
232
  }
165
233
  async loadDataUnit() {
166
234
  if (!this.dataUnit) {
167
- const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
168
- if (app && this.entityName) {
235
+ if (this._application && this.entityName) {
169
236
  const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
170
- this.dataUnit = await app.getDataUnit(this.entityName, cacheName);
237
+ this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
171
238
  this.dataUnit.pageSize = this.pageSize;
172
239
  this.dataUnit.unsubscribe(this._dataUnitObserver);
173
240
  this.dataUnit.addInterceptor(this);
@@ -182,20 +249,12 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
182
249
  }
183
250
  }
184
251
  }
185
- i18n(key) {
186
- const pt_br = {
187
- "components.warning": "Aviso",
188
- "components.delete": "Excluir",
189
- "components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
190
- "components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
191
- "components.editionCanceled": "Todas as alterações foram descartadas.",
192
- };
193
- return pt_br[key];
194
- }
195
252
  //---------------------------------------------
196
253
  // Lifecycle web component
197
254
  //---------------------------------------------
198
255
  componentWillLoad() {
256
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
257
+ this._application.getAllAccess().then(access => this._permissions = access);
199
258
  this.loadDataUnit();
200
259
  }
201
260
  render() {
@@ -216,7 +275,6 @@ const SnkDataUnit$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
216
275
  "entityName": [1, "entity-name"],
217
276
  "pageSize": [2, "page-size"],
218
277
  "dataUnit": [1040],
219
- "messageBuilder": [16],
220
278
  "beforeSave": [16],
221
279
  "afterSave": [16],
222
280
  "autoLoad": [4, "auto-load"],
@@ -53,22 +53,29 @@ const SnkForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
53
53
  });
54
54
  }
55
55
  }
56
- i18n(key) {
57
- const pt_br = {
58
- "components.back": "Voltar"
59
- };
60
- return pt_br[key];
56
+ /**
57
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
58
+ * através de um pequeno modulo na estrutura da aplicação:
59
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
60
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
61
+ */
62
+ getMessage(key) {
63
+ return this._application.messagesBuilder.getMessage(key, this.getMessageParams());
64
+ }
65
+ getMessageParams() {
66
+ var _a;
67
+ return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
61
68
  }
62
69
  componentWillLoad() {
63
- const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
64
- if (snkApplication) {
65
- snkApplication.loadFormConfig(this.configName).then(cfg => {
70
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
71
+ if (this._application) {
72
+ this._application.loadFormConfig(this.configName).then(cfg => {
66
73
  this._configLoaded = true;
67
74
  this._editionFormConfig = cfg;
68
75
  this.loadInsertionConfig();
69
76
  });
70
77
  //Forçamos a carga dos acessos pra aproveitar a request inicial.
71
- snkApplication.getAllAccess();
78
+ this._application.getAllAccess();
72
79
  }
73
80
  let parent = this._element.parentElement;
74
81
  while (parent) {
@@ -97,12 +104,11 @@ const SnkForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
97
104
  if (!this._configLoaded || !this._dataUnit || !this._dataState) {
98
105
  return undefined;
99
106
  }
100
- 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.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("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 }))))));
107
+ return (h("section", { class: "snk-form" }, h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", buttons: this._dataState.isDirty ? "CANCEL,SAVE" : "PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,INSERT", primaryButton: this._dataState.isDirty ? "SAVE" : "INSERT", disabledButtons: this.getDisabledButtons(), actionsList: this.actionsList, dataUnit: this._dataUnit }))), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator }))))));
101
108
  }
102
109
  get _element() { return this; }
103
110
  static get style() { return snkFormCss; }
104
111
  }, [2, "snk-form", {
105
- "formTitle": [1, "form-title"],
106
112
  "configName": [1, "config-name"],
107
113
  "recordsValidator": [8, "records-validator"],
108
114
  "actionsList": [16],
@@ -43,7 +43,7 @@ const buildElem = (element, className, getTitle, action, isEnabled, actions) =>
43
43
  case TaskbarElement.INSERT:
44
44
  return iconTextButton("plus", element, className, getTitle, action, isEnabled);
45
45
  case TaskbarElement.CANCEL:
46
- return h("ez-button", { label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
46
+ return h("ez-button", { title: getTitle(element), label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
47
47
  case TaskbarElement.SAVE:
48
48
  return iconTextButton("save", element, className, getTitle, action, isEnabled);
49
49
  case TaskbarElement.GRID_MODE:
@@ -96,23 +96,42 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
96
96
  }
97
97
  return true;
98
98
  }
99
+ /**
100
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
101
+ * através de um pequeno modulo na estrutura da aplicação:
102
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
103
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
104
+ */
99
105
  getTitle(element) {
100
- const pt_br = {
101
- [TaskbarElement.UPDATE]: "Editar",
102
- [TaskbarElement.PREVIOUS]: "Anterior",
103
- [TaskbarElement.NEXT]: "Próximo",
104
- [TaskbarElement.REFRESH]: "Atualizar",
105
- [TaskbarElement.CLONE]: "Duplicar",
106
- [TaskbarElement.REMOVE]: "Excluir",
107
- [TaskbarElement.MORE_OPTIONS]: "Mais Opções",
108
- [TaskbarElement.INSERT]: "Cadastrar",
109
- [TaskbarElement.CANCEL]: "Cancelar",
110
- [TaskbarElement.SAVE]: "Salvar",
111
- [TaskbarElement.GRID_MODE]: "Modo Grade",
112
- [TaskbarElement.CONFIG_GRID]: "Configuração da grade",
113
- [TaskbarElement.FORM_MODE]: "Modo Formulário"
114
- };
115
- return pt_br[element] ? pt_br[element] : "";
106
+ switch (element) {
107
+ case TaskbarElement.UPDATE:
108
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleUpdate", {});
109
+ case TaskbarElement.PREVIOUS:
110
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titlePrevious", {});
111
+ case TaskbarElement.NEXT:
112
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleNext", {});
113
+ case TaskbarElement.REFRESH:
114
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleRefresh", {});
115
+ case TaskbarElement.CLONE:
116
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleClone", {});
117
+ case TaskbarElement.REMOVE:
118
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleRemove", {});
119
+ case TaskbarElement.MORE_OPTIONS:
120
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleMoreOptions", {});
121
+ case TaskbarElement.INSERT:
122
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleInsert", {});
123
+ case TaskbarElement.CANCEL:
124
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleCancel", {});
125
+ case TaskbarElement.SAVE:
126
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleSave", {});
127
+ case TaskbarElement.GRID_MODE:
128
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleGridMode", {});
129
+ case TaskbarElement.CONFIG_GRID:
130
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleConfigGrid", {});
131
+ case TaskbarElement.FORM_MODE:
132
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleFormMode", {});
133
+ }
134
+ return "";
116
135
  }
117
136
  elementClick(elem) {
118
137
  if (this.dataUnit) {
@@ -159,9 +178,9 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
159
178
  }
160
179
  // Lifecycle
161
180
  componentWillLoad() {
162
- const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
163
- if (snkApplication) {
164
- snkApplication.getAllAccess().then(access => this._permissions = access);
181
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
182
+ if (this._application) {
183
+ this._application.getAllAccess().then(access => this._permissions = access);
165
184
  }
166
185
  else {
167
186
  this._permissions = {};