@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.
Files changed (62) 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 +18 -7
  5. package/dist/cjs/snk-crud.cjs.entry.js +2 -2
  6. package/dist/cjs/snk-data-unit.cjs.entry.js +107 -48
  7. package/dist/cjs/snk-form_2.cjs.entry.js +19 -12
  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 +75 -4
  11. package/dist/collection/components/snk-crud/snk-crud.css +1 -0
  12. package/dist/collection/components/snk-crud/snk-crud.js +10 -23
  13. package/dist/collection/components/snk-data-unit/snk-data-unit.js +108 -72
  14. package/dist/collection/components/snk-form/snk-form.js +20 -32
  15. package/dist/collection/components/snk-grid/snk-grid.js +4 -2
  16. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -1
  17. package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -19
  18. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -5
  19. package/dist/collection/lib/index.js +1 -0
  20. package/dist/collection/lib/message/SnkMessageBuilder.js +119 -0
  21. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +22 -0
  22. package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
  23. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +16 -0
  24. package/dist/components/SnkMessageBuilder.js +166 -0
  25. package/dist/components/snk-application2.js +20 -7
  26. package/dist/components/snk-crud.js +3 -4
  27. package/dist/components/snk-data-unit.js +108 -50
  28. package/dist/components/snk-form2.js +18 -12
  29. package/dist/components/snk-grid2.js +1 -1
  30. package/dist/components/snk-taskbar2.js +39 -20
  31. package/dist/esm/SnkMessageBuilder-3835f9d8.js +166 -0
  32. package/dist/esm/loader.js +1 -1
  33. package/dist/esm/sankhyablocks.js +1 -1
  34. package/dist/esm/snk-application.entry.js +18 -7
  35. package/dist/esm/snk-crud.entry.js +2 -2
  36. package/dist/esm/snk-data-unit.entry.js +108 -49
  37. package/dist/esm/snk-form_2.entry.js +19 -12
  38. package/dist/esm/snk-taskbar.entry.js +39 -20
  39. package/dist/esm/{taskbar-elements-e0b8a285.js → taskbar-elements-6d01a640.js} +1 -1
  40. package/dist/sankhyablocks/p-2df33095.entry.js +1 -0
  41. package/dist/sankhyablocks/{p-c3d20542.entry.js → p-56a32417.entry.js} +1 -1
  42. package/dist/sankhyablocks/p-72bccbb6.js +1 -0
  43. package/dist/sankhyablocks/p-962d9bdd.entry.js +69 -0
  44. package/dist/sankhyablocks/p-9b427c4c.entry.js +1 -0
  45. package/dist/sankhyablocks/p-bab507ad.entry.js +1 -0
  46. package/dist/sankhyablocks/p-dd10a5e3.js +1 -0
  47. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  48. package/dist/types/components/snk-application/snk-application.d.ts +14 -4
  49. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +8 -0
  50. package/dist/types/components.d.ts +15 -20
  51. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +5 -6
  52. package/dist/types/lib/index.d.ts +1 -0
  53. package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
  54. package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
  55. package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
  56. package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
  57. package/package.json +2 -2
  58. package/dist/sankhyablocks/p-18fe0469.entry.js +0 -69
  59. package/dist/sankhyablocks/p-5b5afdbe.entry.js +0 -1
  60. package/dist/sankhyablocks/p-7fe9e5c2.entry.js +0 -1
  61. package/dist/sankhyablocks/p-8650ae26.entry.js +0 -1
  62. package/dist/sankhyablocks/p-a5439706.js +0 -1
@@ -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-7f99f0c9.js');
7
+ const taskbarElements = require('./taskbar-elements-73d524e5.js');
8
8
 
9
9
  const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}";
10
10
 
@@ -35,23 +35,42 @@ const SnkTaskbar = class {
35
35
  }
36
36
  return true;
37
37
  }
38
+ /**
39
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
40
+ * através de um pequeno modulo na estrutura da aplicação:
41
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
42
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
43
+ */
38
44
  getTitle(element) {
39
- const pt_br = {
40
- [taskbarElements.TaskbarElement.UPDATE]: "Editar",
41
- [taskbarElements.TaskbarElement.PREVIOUS]: "Anterior",
42
- [taskbarElements.TaskbarElement.NEXT]: "Próximo",
43
- [taskbarElements.TaskbarElement.REFRESH]: "Atualizar",
44
- [taskbarElements.TaskbarElement.CLONE]: "Duplicar",
45
- [taskbarElements.TaskbarElement.REMOVE]: "Excluir",
46
- [taskbarElements.TaskbarElement.MORE_OPTIONS]: "Mais Opções",
47
- [taskbarElements.TaskbarElement.INSERT]: "Cadastrar",
48
- [taskbarElements.TaskbarElement.CANCEL]: "Cancelar",
49
- [taskbarElements.TaskbarElement.SAVE]: "Salvar",
50
- [taskbarElements.TaskbarElement.GRID_MODE]: "Modo Grade",
51
- [taskbarElements.TaskbarElement.CONFIG_GRID]: "Configuração da grade",
52
- [taskbarElements.TaskbarElement.FORM_MODE]: "Modo Formulário"
53
- };
54
- return pt_br[element] ? pt_br[element] : "";
45
+ switch (element) {
46
+ case taskbarElements.TaskbarElement.UPDATE:
47
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleUpdate", {});
48
+ case taskbarElements.TaskbarElement.PREVIOUS:
49
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titlePrevious", {});
50
+ case taskbarElements.TaskbarElement.NEXT:
51
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleNext", {});
52
+ case taskbarElements.TaskbarElement.REFRESH:
53
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleRefresh", {});
54
+ case taskbarElements.TaskbarElement.CLONE:
55
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleClone", {});
56
+ case taskbarElements.TaskbarElement.REMOVE:
57
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleRemove", {});
58
+ case taskbarElements.TaskbarElement.MORE_OPTIONS:
59
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleMoreOptions", {});
60
+ case taskbarElements.TaskbarElement.INSERT:
61
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleInsert", {});
62
+ case taskbarElements.TaskbarElement.CANCEL:
63
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleCancel", {});
64
+ case taskbarElements.TaskbarElement.SAVE:
65
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleSave", {});
66
+ case taskbarElements.TaskbarElement.GRID_MODE:
67
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleGridMode", {});
68
+ case taskbarElements.TaskbarElement.CONFIG_GRID:
69
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleConfigGrid", {});
70
+ case taskbarElements.TaskbarElement.FORM_MODE:
71
+ return this._application.messagesBuilder.getMessage("snkTaskbar.titleFormMode", {});
72
+ }
73
+ return "";
55
74
  }
56
75
  elementClick(elem) {
57
76
  if (this.dataUnit) {
@@ -98,9 +117,9 @@ const SnkTaskbar = class {
98
117
  }
99
118
  // Lifecycle
100
119
  componentWillLoad() {
101
- const snkApplication = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
102
- if (snkApplication) {
103
- snkApplication.getAllAccess().then(access => this._permissions = access);
120
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
121
+ if (this._application) {
122
+ this._application.getAllAccess().then(access => this._permissions = access);
104
123
  }
105
124
  else {
106
125
  this._permissions = {};
@@ -44,7 +44,7 @@ const buildElem = (element, className, getTitle, action, isEnabled, actions) =>
44
44
  case exports.TaskbarElement.INSERT:
45
45
  return iconTextButton("plus", element, className, getTitle, action, isEnabled);
46
46
  case exports.TaskbarElement.CANCEL:
47
- return index.h("ez-button", { label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
47
+ return index.h("ez-button", { title: getTitle(element), label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
48
48
  case exports.TaskbarElement.SAVE:
49
49
  return iconTextButton("save", element, className, getTitle, action, isEnabled);
50
50
  case exports.TaskbarElement.GRID_MODE:
@@ -1,4 +1,4 @@
1
- import { Component, h, Method, Event } from "@stencil/core";
1
+ import { Component, h, Method, Event, Prop } from "@stencil/core";
2
2
  import { DataType, ErrorTracking } from "@sankhyalabs/core";
3
3
  import { DependencyType } from "@sankhyalabs/core";
4
4
  import DataUnitFetcher from "../../lib/http/data-fetcher/fetchers/dataunit-fetcher";
@@ -15,6 +15,12 @@ import AuthFetcher, { AutorizationType } from "../../lib/http/data-fetcher/fetch
15
15
  import MGEAuthorization from '../../lib/auth/mgeauthorization.module';
16
16
  import { SnkErrorHandler } from "./errorhandler/snk-error-handler";
17
17
  import { agGridLicense } from '../../lib/licenses/sankhyalicense.module';
18
+ import { SnkMessageBuilder } from "../../lib/message/SnkMessageBuilder";
19
+ /**
20
+ * É possível customizar as mensagens dos blocos de construção através de um pequeno modulo na estrutura da aplicação:
21
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
22
+ * Para conhecer os detalhes do módulo, vide os arquivos neste projeto "/src/lib/message/resources/*.msg.ts"
23
+ */
18
24
  export class SnkApplication {
19
25
  constructor() {
20
26
  this._authPromises = [];
@@ -297,11 +303,17 @@ export class SnkApplication {
297
303
  async error(title, message, icon, options) {
298
304
  return ApplicationUtils.error(title, message, icon, options);
299
305
  }
306
+ /**
307
+ * Exibe um diálogo de mensagem comum
308
+ */
309
+ async message(title, message, icon, options) {
310
+ return ApplicationUtils.message(title, message, icon, options);
311
+ }
300
312
  /**
301
313
  * Exibe um diálogo de confirmação
302
314
  */
303
- async confirm(title, message, icon, critical, options) {
304
- return ApplicationUtils.confirm(title, message, icon, critical, options);
315
+ async confirm(title, message, icon, dialogType, options) {
316
+ return ApplicationUtils.confirm(title, message, icon, dialogType, options);
305
317
  }
306
318
  /**
307
319
  * Mostra uma informação efêmera (de segundo plano).
@@ -441,6 +453,7 @@ export class SnkApplication {
441
453
  }
442
454
  componentWillLoad() {
443
455
  this._errorHandler = new SnkErrorHandler(this);
456
+ this.messagesBuilder = new SnkMessageBuilder();
444
457
  ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/upload/file`);
445
458
  ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
446
459
  return this.executeSearch(searchArgument, fieldName, dataUnit);
@@ -474,6 +487,28 @@ export class SnkApplication {
474
487
  static get styleUrls() { return {
475
488
  "$": ["snk-application.css"]
476
489
  }; }
490
+ static get properties() { return {
491
+ "messagesBuilder": {
492
+ "type": "unknown",
493
+ "mutable": true,
494
+ "complexType": {
495
+ "original": "SnkMessageBuilder",
496
+ "resolved": "SnkMessageBuilder",
497
+ "references": {
498
+ "SnkMessageBuilder": {
499
+ "location": "import",
500
+ "path": "../../lib/message/SnkMessageBuilder"
501
+ }
502
+ }
503
+ },
504
+ "required": false,
505
+ "optional": false,
506
+ "docs": {
507
+ "tags": [],
508
+ "text": "messagesBuilder \u00E9 um utilit\u00E1rio respons\u00E1vel por flexibilizar e padronizar\no uso de mensagens nos blocos de constru\u00E7\u00E3o."
509
+ }
510
+ }
511
+ }; }
477
512
  static get events() { return [{
478
513
  "method": "applicationLoaded",
479
514
  "name": "applicationLoaded",
@@ -936,9 +971,41 @@ export class SnkApplication {
936
971
  "tags": []
937
972
  }
938
973
  },
974
+ "message": {
975
+ "complexType": {
976
+ "signature": "(title: string, message: string, icon?: string, options?: MessageOptions) => Promise<boolean>",
977
+ "parameters": [{
978
+ "tags": [],
979
+ "text": ""
980
+ }, {
981
+ "tags": [],
982
+ "text": ""
983
+ }, {
984
+ "tags": [],
985
+ "text": ""
986
+ }, {
987
+ "tags": [],
988
+ "text": ""
989
+ }],
990
+ "references": {
991
+ "Promise": {
992
+ "location": "global"
993
+ },
994
+ "MessageOptions": {
995
+ "location": "import",
996
+ "path": "@sankhyalabs/ezui/dist/collection/utils"
997
+ }
998
+ },
999
+ "return": "Promise<boolean>"
1000
+ },
1001
+ "docs": {
1002
+ "text": "Exibe um di\u00E1logo de mensagem comum",
1003
+ "tags": []
1004
+ }
1005
+ },
939
1006
  "confirm": {
940
1007
  "complexType": {
941
- "signature": "(title: string, message: string, icon?: string, critical?: boolean, options?: MessageOptions) => Promise<boolean>",
1008
+ "signature": "(title: string, message: string, icon?: string, dialogType?: DialogType, options?: MessageOptions) => Promise<boolean>",
942
1009
  "parameters": [{
943
1010
  "tags": [],
944
1011
  "text": ""
@@ -959,6 +1026,10 @@ export class SnkApplication {
959
1026
  "Promise": {
960
1027
  "location": "global"
961
1028
  },
1029
+ "DialogType": {
1030
+ "location": "import",
1031
+ "path": "@sankhyalabs/ezui/dist/collection/utils"
1032
+ },
962
1033
  "MessageOptions": {
963
1034
  "location": "import",
964
1035
  "path": "@sankhyalabs/ezui/dist/collection/utils"
@@ -1,5 +1,6 @@
1
1
  :host {
2
2
  display: flex;
3
+ flex-direction: column;
3
4
  height: 100%;
4
5
  width: 100%;
5
6
  }
@@ -1,6 +1,11 @@
1
1
  import { Component, h, Prop, Element, State } from '@stencil/core';
2
2
  const GRID_MODE = 0;
3
3
  const FORM_MODE = 1;
4
+ /**
5
+ * É possível customizar as mensagens dos blocos de construção através de um pequeno modulo na estrutura da aplicação:
6
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
7
+ * Para conhecer os detalhes do módulo, vide os arquivos neste projeto "/src/lib/message/resources/*.msg.ts"
8
+ */
4
9
  export class SnkCrud {
5
10
  async gridToForm(keepFormMode = false) {
6
11
  this._backToGrid = !keepFormMode && await this._viewStack.getSelectedIndex() === GRID_MODE;
@@ -48,9 +53,10 @@ export class SnkCrud {
48
53
  return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref },
49
54
  h("stack-item", null,
50
55
  h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList },
51
- h("slot", null))),
56
+ h("slot", { name: "SnkGridHeader" }),
57
+ h("slot", { name: "SnkGridFooter" }))),
52
58
  h("stack-item", null,
53
- h("snk-form", { formTitle: this.formTitle, configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, onActionClick: evt => this.executeAction(evt.detail) }))));
59
+ h("snk-form", { configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, onActionClick: evt => this.executeAction(evt.detail) }))));
54
60
  }
55
61
  static get is() { return "snk-crud"; }
56
62
  static get encapsulation() { return "scoped"; }
@@ -78,23 +84,6 @@ export class SnkCrud {
78
84
  "attribute": "config-name",
79
85
  "reflect": false
80
86
  },
81
- "formTitle": {
82
- "type": "string",
83
- "mutable": false,
84
- "complexType": {
85
- "original": "string",
86
- "resolved": "string",
87
- "references": {}
88
- },
89
- "required": false,
90
- "optional": false,
91
- "docs": {
92
- "tags": [],
93
- "text": ""
94
- },
95
- "attribute": "form-title",
96
- "reflect": false
97
- },
98
87
  "actionsList": {
99
88
  "type": "unknown",
100
89
  "mutable": false,
@@ -119,7 +108,7 @@ export class SnkCrud {
119
108
  }
120
109
  },
121
110
  "recordsValidator": {
122
- "type": "any",
111
+ "type": "unknown",
123
112
  "mutable": false,
124
113
  "complexType": {
125
114
  "original": "RecordValidator",
@@ -136,9 +125,7 @@ export class SnkCrud {
136
125
  "docs": {
137
126
  "tags": [],
138
127
  "text": "Validador respons\u00E1vel por checar a integridade das informa\u00E7\u00F5es do registro"
139
- },
140
- "attribute": "records-validator",
141
- "reflect": false
128
+ }
142
129
  }
143
130
  }; }
144
131
  static get states() { return {
@@ -1,6 +1,7 @@
1
1
  import { Component, Host, h, Event, Element, Prop, Watch, Method } from '@stencil/core';
2
2
  import { Action, ApplicationContext } from '@sankhyalabs/core';
3
- import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
3
+ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
+ import { OperationMap } from '../../lib/message/SnkMessageBuilder';
4
5
  export class SnkDataUnit {
5
6
  constructor() {
6
7
  this._onDataUnitResolve = [];
@@ -13,19 +14,6 @@ export class SnkDataUnit {
13
14
  */
14
15
  this.autoLoad = true;
15
16
  this._dataUnitObserver = (action) => {
16
- let msg;
17
- if (!this.isTransitionAction(action.type)) {
18
- msg = this.getActionInfo(action.type);
19
- }
20
- if (msg) {
21
- ApplicationUtils.info(msg);
22
- }
23
- if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
24
- this.insertionMode.emit();
25
- }
26
- if (action.type === Action.EDITION_CANCELED) {
27
- this.cancelEdition.emit();
28
- }
29
17
  const duState = {
30
18
  insertionMode: false,
31
19
  hasNext: this.dataUnit.hasNext(),
@@ -42,6 +30,29 @@ export class SnkDataUnit {
42
30
  }
43
31
  });
44
32
  this.dataState = duState;
33
+ if (action.type === Action.DATA_SAVED) {
34
+ const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
35
+ if (msg != undefined) {
36
+ this.showSuccessMessage(msg);
37
+ }
38
+ }
39
+ if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
40
+ this.insertionMode.emit();
41
+ }
42
+ if (action.type === Action.EDITION_CANCELED) {
43
+ this.cancelEdition.emit();
44
+ const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
45
+ if (cancelFinishMsg != undefined) {
46
+ this.showSuccessMessage(cancelFinishMsg);
47
+ }
48
+ }
49
+ if (action.type === Action.RECORDS_REMOVED) {
50
+ const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
51
+ if (removeFinishMsg != undefined) {
52
+ this.showSuccessMessage(removeFinishMsg);
53
+ }
54
+ }
55
+ this._application.messagesBuilder.currentOperation = this.getMessageOperation();
45
56
  };
46
57
  }
47
58
  observePageSize() {
@@ -89,6 +100,32 @@ export class SnkDataUnit {
89
100
  async interceptAction(action) {
90
101
  return new Promise(resolve => {
91
102
  switch (action.type) {
103
+ case Action.RECORDS_ADDED:
104
+ if (this.isAllowed("INSERT")) {
105
+ resolve(action);
106
+ }
107
+ else {
108
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
109
+ }
110
+ break;
111
+ case Action.RECORDS_COPIED:
112
+ if (this.isAllowed("CLONE")) {
113
+ resolve(action);
114
+ }
115
+ else {
116
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
117
+ }
118
+ break;
119
+ case Action.DATA_CHANGED:
120
+ case Action.CHANGING_DATA:
121
+ if (this.isAllowed("UPDATE")) {
122
+ resolve(action);
123
+ }
124
+ else {
125
+ this.dataUnit.cancelEdition();
126
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenUpdate"));
127
+ }
128
+ break;
92
129
  case Action.SAVING_DATA:
93
130
  if (this.beforeSave) {
94
131
  const continueAction = this.beforeSave(this.dataUnit);
@@ -113,52 +150,82 @@ export class SnkDataUnit {
113
150
  break;
114
151
  case Action.EDITION_CANCELED:
115
152
  if (this.dataState.hasDirtyRecords) {
116
- ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
117
- .then((result) => resolve(result ? action : undefined));
153
+ const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
154
+ if (cancelConfirmation == undefined) {
155
+ resolve(action);
156
+ }
157
+ else {
158
+ const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
159
+ ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
160
+ .then((result) => resolve(result ? action : undefined));
161
+ }
118
162
  }
119
163
  else {
120
164
  resolve(action);
121
165
  }
122
166
  break;
123
167
  case Action.REMOVING_RECORDS:
124
- let msg = undefined;
125
- if (this.messageBuilder) {
126
- msg = this.messageBuilder(action.type, this.dataState, this.dataUnit);
168
+ if (this.isAllowed("REMOVE")) {
169
+ const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
170
+ if (removeConfirmation == undefined) {
171
+ resolve(action);
172
+ }
173
+ else {
174
+ const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
175
+ ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", DialogType.CRITICAL, { btnConfirmDanger: true })
176
+ .then((result) => resolve(result ? action : undefined));
177
+ }
178
+ }
179
+ else {
180
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
127
181
  }
128
- ApplicationUtils.confirm(this.i18n("components.delete"), msg || this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
129
- .then((result) => resolve(result ? action : undefined));
130
182
  break;
131
183
  default:
132
184
  resolve(action);
133
185
  }
134
186
  });
135
187
  }
136
- isTransitionAction(action) {
137
- switch (action) {
138
- case Action.LOADING_METADATA:
139
- case Action.LOADING_DATA:
140
- case Action.SAVING_DATA:
141
- case Action.REMOVING_RECORDS:
142
- case Action.CHANGING_DATA:
143
- return true;
144
- default:
145
- return false;
188
+ showSuccessMessage(message) {
189
+ ApplicationUtils.info(message, { iconName: "check" });
190
+ }
191
+ isAllowed(flag) {
192
+ return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
193
+ }
194
+ /**
195
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
196
+ * através de um pequeno modulo na estrutura da aplicação:
197
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
198
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
199
+ */
200
+ getMessage(key, params = undefined) {
201
+ if (!params) {
202
+ params = this.getMessageParams();
146
203
  }
204
+ return this._application.messagesBuilder.getMessage(key, params);
147
205
  }
148
- getActionInfo(action) {
149
- if (this.messageBuilder) {
150
- return this.messageBuilder(action, this.dataState, this.dataUnit);
206
+ getMessageParams() {
207
+ //TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
208
+ //precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
209
+ //mensagem
210
+ return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
211
+ }
212
+ getMessageOperation() {
213
+ if (this.dataState.copyMode) {
214
+ return OperationMap.CLONE;
215
+ }
216
+ if (this.dataState.insertionMode) {
217
+ return OperationMap.INSERT;
151
218
  }
152
- if (action === Action.EDITION_CANCELED) {
153
- return this.i18n("components.editionCanceled");
219
+ if (this.dataState.isDirty) {
220
+ return OperationMap.UPDATE;
154
221
  }
222
+ return OperationMap.CLEAN;
155
223
  }
156
224
  async loadDataUnit() {
157
225
  if (!this.dataUnit) {
158
- const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
159
- if (app && this.entityName) {
226
+ if (this._application && this.entityName) {
160
227
  const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
161
- this.dataUnit = await app.getDataUnit(this.entityName, cacheName);
228
+ this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
162
229
  this.dataUnit.pageSize = this.pageSize;
163
230
  this.dataUnit.unsubscribe(this._dataUnitObserver);
164
231
  this.dataUnit.addInterceptor(this);
@@ -173,20 +240,12 @@ export class SnkDataUnit {
173
240
  }
174
241
  }
175
242
  }
176
- i18n(key) {
177
- const pt_br = {
178
- "components.warning": "Aviso",
179
- "components.delete": "Excluir",
180
- "components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
181
- "components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
182
- "components.editionCanceled": "Todas as alterações foram descartadas.",
183
- };
184
- return pt_br[key];
185
- }
186
243
  //---------------------------------------------
187
244
  // Lifecycle web component
188
245
  //---------------------------------------------
189
246
  componentWillLoad() {
247
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
248
+ this._application.getAllAccess().then(access => this._permissions = access);
190
249
  this.loadDataUnit();
191
250
  }
192
251
  render() {
@@ -292,29 +351,6 @@ export class SnkDataUnit {
292
351
  "text": "Uma vez instanciado, pode-se obter o dataUnit por esta propriedade"
293
352
  }
294
353
  },
295
- "messageBuilder": {
296
- "type": "unknown",
297
- "mutable": false,
298
- "complexType": {
299
- "original": "(messageKey: string, dataState: DataState, dataUnit: DataUnit) => string",
300
- "resolved": "(messageKey: string, dataState: DataState, dataUnit: DataUnit) => string",
301
- "references": {
302
- "DataState": {
303
- "location": "local"
304
- },
305
- "DataUnit": {
306
- "location": "import",
307
- "path": "@sankhyalabs/core"
308
- }
309
- }
310
- },
311
- "required": false,
312
- "optional": false,
313
- "docs": {
314
- "tags": [],
315
- "text": "Abstra\u00E7\u00E3o para obter-se mensagens de acordo com o estado dos dados."
316
- }
317
- },
318
354
  "beforeSave": {
319
355
  "type": "unknown",
320
356
  "mutable": false,
@@ -43,22 +43,29 @@ export class SnkForm {
43
43
  });
44
44
  }
45
45
  }
46
- i18n(key) {
47
- const pt_br = {
48
- "components.back": "Voltar"
49
- };
50
- return pt_br[key];
46
+ /**
47
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
48
+ * através de um pequeno modulo na estrutura da aplicação:
49
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
50
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
51
+ */
52
+ getMessage(key) {
53
+ return this._application.messagesBuilder.getMessage(key, this.getMessageParams());
54
+ }
55
+ getMessageParams() {
56
+ var _a;
57
+ return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
51
58
  }
52
59
  componentWillLoad() {
53
- const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
54
- if (snkApplication) {
55
- snkApplication.loadFormConfig(this.configName).then(cfg => {
60
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
61
+ if (this._application) {
62
+ this._application.loadFormConfig(this.configName).then(cfg => {
56
63
  this._configLoaded = true;
57
64
  this._editionFormConfig = cfg;
58
65
  this.loadInsertionConfig();
59
66
  });
60
67
  //Forçamos a carga dos acessos pra aproveitar a request inicial.
61
- snkApplication.getAllAccess();
68
+ this._application.getAllAccess();
62
69
  }
63
70
  let parent = this._element.parentElement;
64
71
  while (parent) {
@@ -90,8 +97,8 @@ export class SnkForm {
90
97
  return (h("section", { class: "snk-form" },
91
98
  h("div", { class: "snk-form__header snk-form__header--fixed ez-row" },
92
99
  h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" },
93
- h("ez-button", { title: this.i18n("components.back"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }),
94
- h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.formTitle)),
100
+ h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }),
101
+ h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))),
95
102
  h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" },
96
103
  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 }))),
97
104
  h("section", null,
@@ -108,23 +115,6 @@ export class SnkForm {
108
115
  "$": ["snk-form.css"]
109
116
  }; }
110
117
  static get properties() { return {
111
- "formTitle": {
112
- "type": "string",
113
- "mutable": false,
114
- "complexType": {
115
- "original": "string",
116
- "resolved": "string",
117
- "references": {}
118
- },
119
- "required": false,
120
- "optional": false,
121
- "docs": {
122
- "tags": [],
123
- "text": "Texto que aparece de forma descritiva no cabe\u00E7alho do form"
124
- },
125
- "attribute": "form-title",
126
- "reflect": false
127
- },
128
118
  "configName": {
129
119
  "type": "string",
130
120
  "mutable": false,
@@ -143,7 +133,7 @@ export class SnkForm {
143
133
  "reflect": false
144
134
  },
145
135
  "recordsValidator": {
146
- "type": "any",
136
+ "type": "unknown",
147
137
  "mutable": false,
148
138
  "complexType": {
149
139
  "original": "RecordValidator",
@@ -160,9 +150,7 @@ export class SnkForm {
160
150
  "docs": {
161
151
  "tags": [],
162
152
  "text": "Validador respons\u00E1vel por checar a integridade das informa\u00E7\u00F5es do registro"
163
- },
164
- "attribute": "records-validator",
165
- "reflect": false
153
+ }
166
154
  },
167
155
  "actionsList": {
168
156
  "type": "unknown",
@@ -51,11 +51,13 @@ export class SnkGrid {
51
51
  return (h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" },
52
52
  h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" },
53
53
  h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" },
54
- h("slot", null)),
54
+ h("slot", { name: "SnkGridHeader" })),
55
55
  h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" },
56
56
  h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))),
57
57
  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() },
58
- h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList }))));
58
+ h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList })),
59
+ h("div", { class: "ez-col ez-col--sd-12" },
60
+ h("slot", { name: "SnkGridFooter" }))));
59
61
  }
60
62
  static get is() { return "snk-grid"; }
61
63
  static get encapsulation() { return "scoped"; }