@sankhyalabs/sankhyablocks 2.1.3 → 2.1.4

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 (127) hide show
  1. package/dist/cjs/AuthorizationConfig-79ffae4b.js +7 -0
  2. package/dist/cjs/{form-config-fetcher-2de7c16a.js → ConfigStorage-c112de1d.js} +101 -1
  3. package/dist/cjs/{SnkMessageBuilder-89482d28.js → SnkMessageBuilder-61f00e7f.js} +33 -5
  4. package/dist/cjs/{constants-9056ca9e.js → constants-a47a5190.js} +15 -0
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  7. package/dist/cjs/snk-application.cjs.entry.js +30 -64
  8. package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
  9. package/dist/cjs/{snk-field-config_2.cjs.entry.js → snk-configurator_3.cjs.entry.js} +134 -13
  10. package/dist/cjs/snk-crud.cjs.entry.js +23 -6
  11. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  12. package/dist/cjs/{snk-configurator_6.cjs.entry.js → snk-filter-bar_7.cjs.entry.js} +498 -188
  13. package/dist/cjs/snk-form-config.cjs.entry.js +30 -24
  14. package/dist/cjs/snk-form.cjs.entry.js +30 -17
  15. package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
  16. package/dist/cjs/{taskbar-elements-d762e436.js → taskbar-elements-a0b857c0.js} +4 -8
  17. package/dist/collection/collection-manifest.json +3 -2
  18. package/dist/collection/components/snk-application/snk-application.js +3 -2
  19. package/dist/collection/components/snk-configurator/AuthorizationConfig.js +5 -0
  20. package/dist/collection/components/snk-configurator/snk-configurator.css +124 -0
  21. package/dist/collection/components/snk-configurator/snk-configurator.js +126 -181
  22. package/dist/collection/components/snk-crud/snk-crud.js +23 -5
  23. package/dist/collection/components/snk-form/snk-form.js +37 -54
  24. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +47 -28
  25. package/dist/collection/components/snk-grid/snk-grid.js +69 -20
  26. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.css +166 -0
  27. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +605 -0
  28. package/dist/collection/components/snk-grid/subcomponents/snk-select-box/snk-select-box.css +9 -0
  29. package/dist/collection/components/snk-grid/subcomponents/snk-select-box/snk-select-box.js +70 -0
  30. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +4 -8
  31. package/dist/collection/components/snk-taskbar/snk-taskbar.js +9 -1
  32. package/dist/collection/lib/configs/ConfigStorage.js +15 -15
  33. package/dist/collection/lib/message/SnkMessageBuilder.js +5 -3
  34. package/dist/collection/lib/message/resources/snk-configurator.msg.js +0 -3
  35. package/dist/collection/lib/message/resources/snk-form.msg.js +3 -0
  36. package/dist/collection/lib/message/resources/snk-grid.msg.js +26 -0
  37. package/dist/collection/lib/utils/constants.js +14 -0
  38. package/dist/components/AuthorizationConfig.js +7 -0
  39. package/dist/components/{form-config-fetcher.js → ConfigStorage.js} +100 -2
  40. package/dist/components/SnkMessageBuilder.js +33 -5
  41. package/dist/components/constants.js +15 -1
  42. package/dist/components/index.d.ts +2 -1
  43. package/dist/components/index.js +2 -1
  44. package/dist/components/snk-application2.js +2 -36
  45. package/dist/components/snk-configurator2.js +63 -165
  46. package/dist/components/snk-crud.js +53 -29
  47. package/dist/components/snk-form-config2.js +25 -19
  48. package/dist/components/snk-form2.js +33 -32
  49. package/dist/components/{snk-config-modal.d.ts → snk-grid-config.d.ts} +4 -4
  50. package/dist/components/snk-grid-config.js +6 -0
  51. package/dist/components/snk-grid-config2.js +497 -0
  52. package/dist/components/snk-grid2.js +65 -27
  53. package/dist/components/snk-select-box.d.ts +11 -0
  54. package/dist/components/snk-select-box.js +6 -0
  55. package/dist/components/snk-select-box2.js +38 -0
  56. package/dist/components/snk-taskbar2.js +14 -22
  57. package/dist/esm/AuthorizationConfig-dcbd207a.js +7 -0
  58. package/dist/esm/{form-config-fetcher-96c6c2dc.js → ConfigStorage-99025655.js} +100 -2
  59. package/dist/esm/{SnkMessageBuilder-a27fc561.js → SnkMessageBuilder-f5ef87df.js} +33 -5
  60. package/dist/esm/{constants-c6039d3d.js → constants-babe1a08.js} +15 -1
  61. package/dist/esm/loader.js +1 -1
  62. package/dist/esm/sankhyablocks.js +1 -1
  63. package/dist/esm/snk-application.entry.js +3 -37
  64. package/dist/esm/snk-config-options.entry.js +1 -1
  65. package/dist/esm/{snk-field-config_2.entry.js → snk-configurator_3.entry.js} +134 -14
  66. package/dist/esm/snk-crud.entry.js +23 -6
  67. package/dist/esm/snk-data-unit.entry.js +1 -1
  68. package/dist/esm/{snk-configurator_6.entry.js → snk-filter-bar_7.entry.js} +499 -190
  69. package/dist/esm/snk-form-config.entry.js +25 -19
  70. package/dist/esm/snk-form.entry.js +30 -17
  71. package/dist/esm/snk-tab-config.entry.js +1 -1
  72. package/dist/esm/{taskbar-elements-1092b0b7.js → taskbar-elements-4d6584cd.js} +4 -8
  73. package/dist/sankhyablocks/p-105cd4a8.entry.js +1 -0
  74. package/dist/sankhyablocks/p-4131d41e.entry.js +1 -0
  75. package/dist/sankhyablocks/{p-8706fe65.entry.js → p-43aff8f5.entry.js} +1 -1
  76. package/dist/sankhyablocks/p-53f33e9d.entry.js +1 -0
  77. package/dist/sankhyablocks/p-639b8f6e.entry.js +76 -0
  78. package/dist/sankhyablocks/{p-a5b26df2.js → p-6673c77c.js} +1 -1
  79. package/dist/sankhyablocks/p-6ba8f415.js +26 -0
  80. package/dist/sankhyablocks/{p-2517529d.js → p-877bd6cf.js} +1 -1
  81. package/dist/sankhyablocks/p-87896198.entry.js +1 -0
  82. package/dist/sankhyablocks/p-bd6d4a83.js +1 -0
  83. package/dist/sankhyablocks/p-cae38f51.entry.js +1 -0
  84. package/dist/sankhyablocks/{p-f37cdeb5.entry.js → p-cd03ea9e.entry.js} +1 -1
  85. package/dist/sankhyablocks/p-dc36cfbf.js +1 -0
  86. package/dist/sankhyablocks/{p-92782503.entry.js → p-eb94df0b.entry.js} +1 -1
  87. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  88. package/dist/types/components/snk-application/snk-application.d.ts +0 -1
  89. package/dist/types/components/snk-configurator/AuthorizationConfig.d.ts +4 -0
  90. package/dist/types/components/snk-configurator/snk-configurator.d.ts +21 -24
  91. package/dist/types/components/snk-crud/snk-crud.d.ts +6 -0
  92. package/dist/types/components/snk-form/snk-form.d.ts +6 -9
  93. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +7 -3
  94. package/dist/types/components/snk-grid/snk-grid.d.ts +13 -3
  95. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +66 -0
  96. package/dist/types/components/snk-grid/subcomponents/snk-select-box/snk-select-box.d.ts +7 -0
  97. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +3 -4
  98. package/dist/types/components.d.ts +104 -74
  99. package/dist/types/lib/configs/ConfigStorage.d.ts +3 -3
  100. package/dist/types/lib/message/resources/snk-configurator.msg.d.ts +0 -1
  101. package/dist/types/lib/message/resources/snk-grid.msg.d.ts +2 -0
  102. package/dist/types/lib/utils/constants.d.ts +14 -0
  103. package/package.json +1 -1
  104. package/react/components.d.ts +2 -1
  105. package/react/components.js +2 -1
  106. package/react/components.js.map +1 -1
  107. package/dist/cjs/configurableElementsStorage-93459c72.js +0 -20
  108. package/dist/cjs/snk-config-modal.cjs.entry.js +0 -62
  109. package/dist/collection/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.js +0 -16
  110. package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.css +0 -122
  111. package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.js +0 -137
  112. package/dist/components/snk-config-modal.js +0 -6
  113. package/dist/components/snk-config-modal2.js +0 -91
  114. package/dist/esm/configurableElementsStorage-cdc144b5.js +0 -18
  115. package/dist/esm/snk-config-modal.entry.js +0 -58
  116. package/dist/sankhyablocks/p-361299e8.js +0 -26
  117. package/dist/sankhyablocks/p-429c5e3f.entry.js +0 -1
  118. package/dist/sankhyablocks/p-4fab64ec.js +0 -1
  119. package/dist/sankhyablocks/p-60eef7cd.entry.js +0 -1
  120. package/dist/sankhyablocks/p-626cf022.entry.js +0 -1
  121. package/dist/sankhyablocks/p-6511d132.entry.js +0 -1
  122. package/dist/sankhyablocks/p-8c14bbfb.entry.js +0 -76
  123. package/dist/sankhyablocks/p-c4ae984b.entry.js +0 -1
  124. package/dist/sankhyablocks/p-ce7c38a1.entry.js +0 -1
  125. package/dist/sankhyablocks/p-d50651a3.js +0 -1
  126. package/dist/types/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.d.ts +0 -8
  127. package/dist/types/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.d.ts +0 -38
@@ -1,187 +1,94 @@
1
- import { ApplicationContext, ObjectUtils } from '@sankhyalabs/core';
1
+ import { ApplicationContext } from '@sankhyalabs/core';
2
2
  import { h } from '@stencil/core';
3
- import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
4
- import { CONFIG_EVENTS, VIEW_MODE } from '../../lib/utils/constants';
5
- import ConfigurableElementsStorage from './subcomponents/configModalProvider/configurableElementsStorage';
3
+ import { VIEW_MODE } from '../../lib/utils/constants';
4
+ import { AuthorizationConfig } from './AuthorizationConfig';
6
5
  const GRID_MODE = VIEW_MODE.grid;
7
6
  const FORM_MODE = VIEW_MODE.form;
8
7
  export class SnkConfigurator {
9
8
  constructor() {
9
+ this._opened = false;
10
10
  /**
11
- * Nome do componente que será vinculado ao `data-configurator-parent` para controlar o modal de configurações.
11
+ * Define qual modo de visualização está ativo.
12
12
  */
13
- this.name = "snkConfigurator";
14
- /**
15
- * Define se o campo está habilitado.
16
- */
17
- this.enabled = true;
13
+ this.viewMode = GRID_MODE.name;
18
14
  }
19
- /**
20
- * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
21
- * através de um pequeno modulo na estrutura da aplicação:
22
- * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
23
- * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-configurator.msg.ts"
24
- */
25
- getMessage(key) {
26
- return this._application.messagesBuilder.getMessage(key, {});
15
+ async open() {
16
+ this._opened = true;
17
+ this.configSelected.emit(this.getViewModeValue());
27
18
  }
28
- controlConfigModal(opened) {
29
- var _a;
30
- if (this._modal != undefined) {
31
- this._modal.opened = opened;
32
- if (this._configModal != undefined) {
33
- this._configModal.gridMode = ((_a = this._grid) === null || _a === void 0 ? void 0 : _a.offsetParent) != undefined;
34
- }
35
- }
19
+ async close() {
20
+ this.closeConfig();
36
21
  }
37
- changeConfigModal(evt) {
38
- const data = evt === null || evt === void 0 ? void 0 : evt.detail;
39
- if (data === null || data === void 0 ? void 0 : data.openConfig) {
40
- this.controlConfigModal(false);
41
- this.callShowConfig(data === null || data === void 0 ? void 0 : data.viewMode);
42
- }
43
- else if ((data === null || data === void 0 ? void 0 : data.viewMode) === GRID_MODE.index) {
44
- this.changeViewMode.emit(GRID_MODE.name);
45
- }
46
- else if ((data === null || data === void 0 ? void 0 : data.viewMode) === FORM_MODE.index) {
47
- this.changeViewMode.emit(FORM_MODE.name);
48
- }
22
+ closeConfig() {
23
+ this._opened = false;
49
24
  }
50
- callShowConfig(viewMode) {
51
- if (viewMode === GRID_MODE.index) {
52
- if (this._grid == undefined) {
53
- this.findGrid();
54
- }
55
- if (this._grid != undefined) {
56
- this._grid.setShowGridConfig(true);
57
- }
58
- }
59
- else if (viewMode === FORM_MODE.index) {
60
- if (this._form == undefined) {
61
- this.findForm();
62
- }
63
- if (this._form != undefined) {
64
- this._form.setShowFormConfig(true);
65
- }
66
- }
25
+ onViewModeChanged(evt) {
26
+ const value = evt === null || evt === void 0 ? void 0 : evt.detail;
27
+ this.viewMode = value;
28
+ this.configSelected.emit(value);
67
29
  }
68
- getConfigModal() {
69
- const modalContainer = document.createElement("ez-modal");
70
- modalContainer.modalSize = "small";
71
- modalContainer.opened = false;
72
- modalContainer.closeEsc = false;
73
- modalContainer.closeOutsideClick = false;
74
- modalContainer.dataset.configuratorModal = this.name;
75
- modalContainer.addEventListener(CONFIG_EVENTS.closeModal, () => {
76
- this.controlConfigModal(false);
77
- });
78
- const modalContent = document.createElement("snk-config-modal");
79
- modalContent.addEventListener(CONFIG_EVENTS.cancelConfig, () => {
80
- this.controlConfigModal(false);
81
- });
82
- modalContent.addEventListener(CONFIG_EVENTS.changeConfig, (evt) => {
83
- this.changeConfigModal(evt);
84
- });
85
- modalContent.configName = this.configName;
86
- modalContainer.append(modalContent);
87
- return modalContainer;
30
+ onClickOpenConfig() {
31
+ this.openConfig.emit(this.viewMode);
88
32
  }
89
- findConfigModal() {
90
- let modalContainer = document.body.querySelector(`[data-configurator-modal="${this.name}"]`);
91
- if (modalContainer == undefined) {
92
- modalContainer = this.getConfigModal();
93
- document.body.appendChild(modalContainer);
33
+ isAllowed(configName) {
34
+ if (AuthorizationConfig[configName]) {
35
+ return this._permissions ? this._permissions.isSup || this._permissions[configName] : false;
94
36
  }
95
- this._modal = modalContainer;
96
- this._configModal = modalContainer.querySelector("snk-config-modal");
37
+ return true;
97
38
  }
98
- findGrid() {
99
- if (this._grid != undefined) {
100
- return;
101
- }
102
- this._grid = ConfigurableElementsStorage.getGrid(this.configName);
103
- if (this._grid != undefined && this._grid.dataset.eventConfigChanged == undefined) {
104
- this._grid.dataset.eventConfigChanged = "true";
105
- this._grid.addEventListener(CONFIG_EVENTS.configChanged, (evt) => {
106
- this.saveConfig(evt);
107
- });
39
+ enableModeConfig() {
40
+ if (!this.isAllowed(AuthorizationConfig.CONFIG_GRID) || !this.isAllowed(AuthorizationConfig.CONFIG)) {
41
+ return false;
108
42
  }
43
+ return true;
109
44
  }
110
- findForm() {
111
- if (this._form != undefined) {
112
- return;
113
- }
114
- this._form = ConfigurableElementsStorage.getForm(this.configName);
115
- if (this._form != undefined && this._form.dataset.eventConfigChanged == undefined) {
116
- this._form.dataset.eventConfigChanged = "true";
117
- this._form.addEventListener(CONFIG_EVENTS.configChanged, (evt) => {
118
- this.saveConfig(evt);
119
- });
120
- }
121
- }
122
- saveConfig(evt) {
123
- const config = evt === null || evt === void 0 ? void 0 : evt.detail;
124
- if (this._application != undefined && config != undefined) {
125
- if ((config === null || config === void 0 ? void 0 : config.fields) != undefined) {
126
- this._application.saveFormConfig(config, this.configName)
127
- .then((response) => {
128
- if ((response === null || response === void 0 ? void 0 : response.resource) != undefined) {
129
- this.loadFormConfig(true);
130
- }
131
- });
45
+ getViewModeValue() {
46
+ if (this._permissions != undefined) {
47
+ if (!this.isAllowed(AuthorizationConfig.CONFIG_GRID)) {
48
+ this.viewMode = FORM_MODE.name;
132
49
  }
133
- else if ((config === null || config === void 0 ? void 0 : config.columns) != undefined) {
134
- this._application.saveGridConfig(config)
135
- .then((response) => {
136
- if ((response === null || response === void 0 ? void 0 : response.resource) != undefined) {
137
- this.setGridConfig(response.resource);
138
- }
139
- });
50
+ else if (!this.isAllowed(AuthorizationConfig.CONFIG)) {
51
+ this.viewMode = GRID_MODE.name;
140
52
  }
141
53
  }
54
+ return this.viewMode;
142
55
  }
143
- setGridConfig(strConfig) {
144
- if (this._grid != undefined) {
145
- const config = ObjectUtils.stringToObject(strConfig);
146
- this._grid.setConfig(config).then(() => {
147
- ApplicationUtils.info(this.getMessage("snkConfigurator.msgSaveSuccessfully"), { iconName: "check" });
148
- });
149
- }
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-configurator.msg.ts"
61
+ */
62
+ getMessage(key) {
63
+ var _a, _b;
64
+ return (_b = (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage(key, {});
150
65
  }
151
- loadGridConfig() {
152
- if (this._application != undefined && this.configName != undefined && this._grid != undefined) {
153
- this._application.loadGridConfig(this.configName).then((config) => {
154
- this._grid.setConfig(config);
155
- });
66
+ componentWillLoad() {
67
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
68
+ if (this._application) {
69
+ this._application.getAllAccess().then(access => this._permissions = access);
156
70
  }
157
- }
158
- loadFormConfig(showInfoSuccess = false) {
159
- if (this._application != undefined && this.configName != undefined && this._form != undefined) {
160
- this._application.loadFormConfig(this.configName).then((config) => {
161
- this._form.setConfig(config).then(() => {
162
- if (showInfoSuccess) {
163
- ApplicationUtils.info(this.getMessage("snkConfigurator.msgSaveSuccessfully"), { iconName: "check" });
164
- }
165
- });
166
- });
71
+ else {
72
+ this._permissions = {};
167
73
  }
168
74
  }
169
- loadConfig() {
170
- this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
171
- this.loadGridConfig();
172
- this.loadFormConfig();
173
- }
174
- componentDidLoad() {
175
- this.findConfigModal();
176
- this.findGrid();
177
- this.findForm();
178
- this.loadConfig();
179
- }
180
75
  render() {
181
- return (h("ez-button", { mode: "icon", iconName: "settings-inverted", size: "small", enabled: this.enabled, onClick: () => this.controlConfigModal(true) }));
76
+ return (h("ez-modal", { opened: this._opened, "close-esc": false, "close-outside-click": false, "modal-size": "small" }, h("div", { class: "snk-configurator" }, h("div", { class: "snk-configurator__header" }, h("label", { class: "snk-configurator__title" }, this.getMessage("snkConfigurator.titleConfigurations")), h("div", { class: "snk-configurator__button-close" }, h("ez-button", { mode: 'icon', iconName: "close", size: 'medium', onClick: () => this.closeConfig() }))), h("div", { class: "snk-configurator__main" }, h("ez-radio-button", { class: "ez-margin-top--medium", label: this.getMessage("snkConfigurator.subTitleModeConfig"), value: this.getViewModeValue(), onEzChange: (evt) => this.onViewModeChanged(evt), enabled: this.enableModeConfig() }, h("ez-radio-button-option", { label: this.getMessage("snkConfigurator.labelGrid"), value: GRID_MODE.name }), h("ez-radio-button-option", { label: this.getMessage("snkConfigurator.labelForm"), value: FORM_MODE.name })), h("ez-button", { mode: "slim", label: this.viewMode === GRID_MODE.name
77
+ ? this.getMessage("snkConfigurator.labelConfigGrid")
78
+ : this.getMessage("snkConfigurator.labelConfigForm"), class: "snk-configurator__button-config ez-button--primary", onClick: () => this.onClickOpenConfig() }), h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" })))));
182
79
  }
183
80
  static get is() { return "snk-configurator"; }
184
81
  static get encapsulation() { return "scoped"; }
82
+ static get originalStyleUrls() {
83
+ return {
84
+ "$": ["snk-configurator.css"]
85
+ };
86
+ }
87
+ static get styleUrls() {
88
+ return {
89
+ "$": ["snk-configurator.css"]
90
+ };
91
+ }
185
92
  static get properties() {
186
93
  return {
187
94
  "configName": {
@@ -201,7 +108,7 @@ export class SnkConfigurator {
201
108
  "attribute": "config-name",
202
109
  "reflect": false
203
110
  },
204
- "name": {
111
+ "viewMode": {
205
112
  "type": "string",
206
113
  "mutable": false,
207
114
  "complexType": {
@@ -213,42 +120,45 @@ export class SnkConfigurator {
213
120
  "optional": false,
214
121
  "docs": {
215
122
  "tags": [],
216
- "text": "Nome do componente que ser\u00E1 vinculado ao `data-configurator-parent` para controlar o modal de configura\u00E7\u00F5es."
217
- },
218
- "attribute": "name",
219
- "reflect": false,
220
- "defaultValue": "\"snkConfigurator\""
221
- },
222
- "enabled": {
223
- "type": "boolean",
224
- "mutable": false,
225
- "complexType": {
226
- "original": "boolean",
227
- "resolved": "boolean",
228
- "references": {}
229
- },
230
- "required": false,
231
- "optional": false,
232
- "docs": {
233
- "tags": [],
234
- "text": "Define se o campo est\u00E1 habilitado."
123
+ "text": "Define qual modo de visualiza\u00E7\u00E3o est\u00E1 ativo."
235
124
  },
236
- "attribute": "enabled",
125
+ "attribute": "view-mode",
237
126
  "reflect": false,
238
- "defaultValue": "true"
127
+ "defaultValue": "GRID_MODE.name"
239
128
  }
240
129
  };
241
130
  }
131
+ static get states() {
132
+ return {
133
+ "_opened": {},
134
+ "_permissions": {}
135
+ };
136
+ }
242
137
  static get events() {
243
138
  return [{
244
- "method": "changeViewMode",
245
- "name": "changeViewMode",
139
+ "method": "configSelected",
140
+ "name": "configSelected",
141
+ "bubbles": true,
142
+ "cancelable": true,
143
+ "composed": true,
144
+ "docs": {
145
+ "tags": [],
146
+ "text": "Evento disparado quando seleciona modo de visualiza\u00E7\u00E3o"
147
+ },
148
+ "complexType": {
149
+ "original": "string",
150
+ "resolved": "string",
151
+ "references": {}
152
+ }
153
+ }, {
154
+ "method": "openConfig",
155
+ "name": "openConfig",
246
156
  "bubbles": true,
247
157
  "cancelable": true,
248
158
  "composed": true,
249
159
  "docs": {
250
160
  "tags": [],
251
- "text": "Evento disparado quando h\u00E1 altera\u00E7\u00E3o no modo de visualiza\u00E7\u00E3o."
161
+ "text": "Evento disparado quando clicar para abrir uma configura\u00E7\u00E3o"
252
162
  },
253
163
  "complexType": {
254
164
  "original": "string",
@@ -257,5 +167,40 @@ export class SnkConfigurator {
257
167
  }
258
168
  }];
259
169
  }
260
- static get elementRef() { return "_element"; }
170
+ static get methods() {
171
+ return {
172
+ "open": {
173
+ "complexType": {
174
+ "signature": "() => Promise<void>",
175
+ "parameters": [],
176
+ "references": {
177
+ "Promise": {
178
+ "location": "global"
179
+ }
180
+ },
181
+ "return": "Promise<void>"
182
+ },
183
+ "docs": {
184
+ "text": "",
185
+ "tags": []
186
+ }
187
+ },
188
+ "close": {
189
+ "complexType": {
190
+ "signature": "() => Promise<void>",
191
+ "parameters": [],
192
+ "references": {
193
+ "Promise": {
194
+ "location": "global"
195
+ }
196
+ },
197
+ "return": "Promise<void>"
198
+ },
199
+ "docs": {
200
+ "text": "",
201
+ "tags": []
202
+ }
203
+ }
204
+ };
205
+ }
261
206
  }
@@ -11,6 +11,7 @@ const FORM_MODE = VIEW_MODE.form;
11
11
  */
12
12
  export class SnkCrud {
13
13
  constructor() {
14
+ this._viewMode = GRID_MODE.name;
14
15
  /**
15
16
  * Determina se pode haver mais de uma linha selecionada na grade
16
17
  */
@@ -24,22 +25,38 @@ export class SnkCrud {
24
25
  }
25
26
  async gridToForm(keepFormMode = false) {
26
27
  this._backToGrid = !keepFormMode && await this._viewStack.getSelectedIndex() === GRID_MODE.index;
27
- this._viewStack.show(FORM_MODE.index);
28
+ this.setViewMode(FORM_MODE);
28
29
  }
29
30
  async executeAction(act) {
30
31
  if (act === TaskbarElement.GRID_MODE) {
31
- this._viewStack.show(GRID_MODE.index);
32
+ this.setViewMode(GRID_MODE);
32
33
  }
33
34
  else if (act === TaskbarElement.FORM_MODE || act === TaskbarElement.UPDATE) {
34
35
  this.gridToForm(act !== TaskbarElement.UPDATE);
35
36
  }
37
+ else if (act === TaskbarElement.CONFIGURATOR) {
38
+ this._snkConfigurator.open();
39
+ }
40
+ }
41
+ setViewMode(viewMode) {
42
+ this._viewStack.show(viewMode.index);
43
+ this._viewMode = viewMode.name;
44
+ }
45
+ openConfig(viewMode) {
46
+ this._snkConfigurator.close();
47
+ if (viewMode === GRID_MODE.name) {
48
+ this._snkGrid.showConfig();
49
+ }
50
+ else if (viewMode === FORM_MODE.name) {
51
+ this._snkForm.showConfig();
52
+ }
36
53
  }
37
54
  insertionModeHandler() {
38
55
  this.gridToForm();
39
56
  }
40
57
  cancelHandler() {
41
58
  if (this._backToGrid) {
42
- this._viewStack.show(GRID_MODE.index);
59
+ this.setViewMode(GRID_MODE);
43
60
  }
44
61
  }
45
62
  componentWillLoad() {
@@ -69,7 +86,7 @@ export class SnkCrud {
69
86
  }
70
87
  }
71
88
  render() {
72
- return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-configurator-parent": "snkConfigurator" }, h("stack-item", null, h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection }, h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-form", { configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE.index), recordsValidator: this.recordsValidator, taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail) }, h("slot", { name: "SnkFormTaskBar" })))));
89
+ return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection }, h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-form", { ref: (ref) => this._snkForm = ref, configName: this.configName, actionsList: this.actionsList, onExit: () => this.setViewMode(GRID_MODE), recordsValidator: this.recordsValidator, taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail) }, h("slot", { name: "SnkFormTaskBar" }))), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._viewMode, onConfigSelected: (evt) => this.executeAction(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail) })));
73
90
  }
74
91
  static get is() { return "snk-crud"; }
75
92
  static get encapsulation() { return "scoped"; }
@@ -208,7 +225,8 @@ export class SnkCrud {
208
225
  static get states() {
209
226
  return {
210
227
  "_dataUnit": {},
211
- "_dataState": {}
228
+ "_dataState": {},
229
+ "_viewMode": {}
212
230
  };
213
231
  }
214
232
  static get events() {
@@ -1,7 +1,7 @@
1
1
  import { ApplicationContext, DateUtils, ObjectUtils } from '@sankhyalabs/core';
2
2
  import { h } from '@stencil/core';
3
- import ConfigurableElementsStorage from '../snk-configurator/subcomponents/configModalProvider/configurableElementsStorage';
4
3
  import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
4
+ import { ConfigStorage } from '../../lib/configs/ConfigStorage';
5
5
  export class SnkForm {
6
6
  constructor() {
7
7
  this._renderTimer = 500;
@@ -14,21 +14,30 @@ export class SnkForm {
14
14
  this._showFormConfig = false;
15
15
  }
16
16
  /**
17
- * Método responsável em abrir ou fechar o modal de configurações do form.
17
+ * Método responsável em abrir o modal de configurações do form.
18
18
  */
19
- async setShowFormConfig(value) {
20
- this._showFormConfig = value;
19
+ async showConfig() {
20
+ this._showFormConfig = true;
21
21
  }
22
22
  /**
23
- * Método responsável por setar as configurações do form.
23
+ * Método responsável em fechar o modal de configurações do form.
24
24
  */
25
- async setConfig(config) {
26
- this._editionFormConfig = {};
27
- if (!this.loadConfig(config)) {
28
- this.loadInsertionConfig();
29
- }
25
+ async hideConfig() {
26
+ this._showFormConfig = false;
30
27
  }
31
- loadConfig(config) {
28
+ loadConfig() {
29
+ ConfigStorage.get()
30
+ .loadFormConfig(this.configName)
31
+ .then((config) => {
32
+ if (!this.setConfig(config)) {
33
+ this.loadInsertionConfig();
34
+ }
35
+ })
36
+ .catch((error) => {
37
+ console.warn(error);
38
+ });
39
+ }
40
+ setConfig(config) {
32
41
  if ((config === null || config === void 0 ? void 0 : config.fields) == undefined) {
33
42
  return false;
34
43
  }
@@ -106,7 +115,13 @@ export class SnkForm {
106
115
  return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
107
116
  }
108
117
  changeConfig(config) {
109
- this.configChanged.emit(config);
118
+ this._editionFormConfig = {};
119
+ if (!this.setConfig(config)) {
120
+ this.loadInsertionConfig();
121
+ }
122
+ }
123
+ closeConfig() {
124
+ this.hideConfig();
110
125
  }
111
126
  getDisabledButtons() {
112
127
  const disabled = [];
@@ -118,9 +133,6 @@ export class SnkForm {
118
133
  }
119
134
  return disabled;
120
135
  }
121
- componentDidRender() {
122
- ConfigurableElementsStorage.setForm(this.configName, this._element);
123
- }
124
136
  componentWillLoad() {
125
137
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
126
138
  let parent = this._element.parentElement;
@@ -145,6 +157,7 @@ export class SnkForm {
145
157
  }
146
158
  parent = parent.parentElement;
147
159
  }
160
+ this.loadConfig();
148
161
  }
149
162
  componentWillRender() {
150
163
  var _a;
@@ -164,7 +177,7 @@ export class SnkForm {
164
177
  return undefined;
165
178
  }
166
179
  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", configName: this.configName, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, actionsList: this.actionsList, primaryButton: ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", 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, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
167
- h("snk-form-config", { dataUnit: this._dataUnit, formConfig: this.getFormConfig(), parentForm: this._element, onConfigChange: (evt) => { this.changeConfig(evt.detail); } }))))));
180
+ h("snk-form-config", { dataUnit: this._dataUnit, formConfig: this.getFormConfig(), configName: this.configName, onConfigChange: (evt) => this.changeConfig(evt.detail), onConfigClose: () => this.closeConfig() }))))));
168
181
  }
169
182
  static get is() { return "snk-form"; }
170
183
  static get encapsulation() { return "scoped"; }
@@ -302,37 +315,14 @@ export class SnkForm {
302
315
  "resolved": "string",
303
316
  "references": {}
304
317
  }
305
- }, {
306
- "method": "configChanged",
307
- "name": "configChanged",
308
- "bubbles": true,
309
- "cancelable": true,
310
- "composed": true,
311
- "docs": {
312
- "tags": [],
313
- "text": "Evento disparado quando as configura\u00E7\u00F5es s\u00E3o alteradas."
314
- },
315
- "complexType": {
316
- "original": "IFormConfig",
317
- "resolved": "IFormConfig",
318
- "references": {
319
- "IFormConfig": {
320
- "location": "import",
321
- "path": "@sankhyalabs/ezui/dist/types/components/ez-form/ez-form"
322
- }
323
- }
324
- }
325
318
  }];
326
319
  }
327
320
  static get methods() {
328
321
  return {
329
- "setShowFormConfig": {
322
+ "showConfig": {
330
323
  "complexType": {
331
- "signature": "(value: boolean) => Promise<void>",
332
- "parameters": [{
333
- "tags": [],
334
- "text": ""
335
- }],
324
+ "signature": "() => Promise<void>",
325
+ "parameters": [],
336
326
  "references": {
337
327
  "Promise": {
338
328
  "location": "global"
@@ -341,30 +331,23 @@ export class SnkForm {
341
331
  "return": "Promise<void>"
342
332
  },
343
333
  "docs": {
344
- "text": "M\u00E9todo respons\u00E1vel em abrir ou fechar o modal de configura\u00E7\u00F5es do form.",
334
+ "text": "M\u00E9todo respons\u00E1vel em abrir o modal de configura\u00E7\u00F5es do form.",
345
335
  "tags": []
346
336
  }
347
337
  },
348
- "setConfig": {
338
+ "hideConfig": {
349
339
  "complexType": {
350
- "signature": "(config: IFormConfig) => Promise<void>",
351
- "parameters": [{
352
- "tags": [],
353
- "text": ""
354
- }],
340
+ "signature": "() => Promise<void>",
341
+ "parameters": [],
355
342
  "references": {
356
343
  "Promise": {
357
344
  "location": "global"
358
- },
359
- "IFormConfig": {
360
- "location": "import",
361
- "path": "@sankhyalabs/ezui/dist/types/components/ez-form/ez-form"
362
345
  }
363
346
  },
364
347
  "return": "Promise<void>"
365
348
  },
366
349
  "docs": {
367
- "text": "M\u00E9todo respons\u00E1vel por setar as configura\u00E7\u00F5es do form.",
350
+ "text": "M\u00E9todo respons\u00E1vel em fechar o modal de configura\u00E7\u00F5es do form.",
368
351
  "tags": []
369
352
  }
370
353
  }