@sankhyalabs/sankhyablocks 8.1.0-dev.10 → 8.1.0-dev.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 (209) hide show
  1. package/dist/cjs/{ConfigStorage-e32e1391.js → ConfigStorage-42601579.js} +163 -51
  2. package/dist/cjs/{DataFetcher-d2c6ae38.js → DataFetcher-370cc8f2.js} +38 -29
  3. package/dist/cjs/ISave-d68ce3cd.js +8 -0
  4. package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
  5. package/dist/cjs/{SnkFormConfigManager-5e61b0a9.js → SnkFormConfigManager-e5a28b2e.js} +19 -21
  6. package/dist/cjs/{auth-fetcher-da975ac5.js → auth-fetcher-c42326e9.js} +2 -2
  7. package/dist/cjs/{dataunit-fetcher-58ad78a7.js → dataunit-fetcher-eab8050e.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-761994b9.js → form-config-fetcher-6704319c.js} +66 -3
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-bb0bb679.js → pesquisa-fetcher-84d392c7.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button.cjs.entry.js +18 -11
  13. package/dist/cjs/snk-application.cjs.entry.js +49 -44
  14. package/dist/cjs/snk-attach.cjs.entry.js +7 -13
  15. package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
  16. package/dist/cjs/snk-crud.cjs.entry.js +24 -10
  17. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  18. package/dist/cjs/{snk-data-unit-e89e07bd.js → snk-data-unit-80a00ae4.js} +4 -3
  19. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  20. package/dist/cjs/snk-detail-view.cjs.entry.js +13 -12
  21. package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
  22. package/dist/cjs/snk-filter-bar.cjs.entry.js +13 -16
  23. package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -15
  24. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -19
  25. package/dist/cjs/snk-form-config.cjs.entry.js +6 -17
  26. package/dist/cjs/snk-form.cjs.entry.js +11 -8
  27. package/dist/cjs/snk-grid-config.cjs.entry.js +5 -6
  28. package/dist/cjs/snk-grid.cjs.entry.js +13 -17
  29. package/dist/cjs/{snk-guides-viewer-eb0a79a4.js → snk-guides-viewer-fd785f55.js} +16 -7
  30. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  31. package/dist/cjs/snk-personalized-filter.cjs.entry.js +13 -16
  32. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-simple-crud.cjs.entry.js +7 -3
  34. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
  35. package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
  36. package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
  37. package/dist/collection/components/snk-application/snk-application.js +60 -65
  38. package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
  39. package/dist/collection/components/snk-crud/snk-crud.js +18 -6
  40. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +20 -2
  41. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +25 -28
  42. package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -4
  43. package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
  44. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +2 -12
  45. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
  46. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
  47. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +27 -11
  48. package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
  49. package/dist/collection/components/snk-form/snk-form.js +24 -2
  50. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
  51. package/dist/collection/components/snk-grid/snk-grid.js +27 -12
  52. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
  53. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
  54. package/dist/collection/components/snk-taskbar/snk-taskbar.js +19 -1
  55. package/dist/collection/lib/configs/ConfigStorage.js +33 -44
  56. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +38 -29
  57. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
  58. package/dist/collection/lib/index.js +10 -0
  59. package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
  60. package/dist/components/ConfigStorage.js +161 -48
  61. package/dist/components/DataFetcher.js +38 -29
  62. package/dist/components/ResourceIDUtils.js +10 -0
  63. package/dist/components/SnkFormConfigManager.js +17 -19
  64. package/dist/components/auth-fetcher.js +1 -1
  65. package/dist/components/form-config-fetcher.js +64 -2
  66. package/dist/components/snk-actions-button2.js +23 -9
  67. package/dist/components/snk-application2.js +134 -128
  68. package/dist/components/snk-attach2.js +1 -8
  69. package/dist/components/snk-configurator2.js +3 -1
  70. package/dist/components/snk-crud.js +22 -6
  71. package/dist/components/snk-data-unit2.js +5 -3
  72. package/dist/components/snk-detail-view2.js +18 -8
  73. package/dist/components/snk-entity-list.js +0 -4
  74. package/dist/components/snk-filter-bar2.js +11 -11
  75. package/dist/components/snk-filter-detail2.js +2 -12
  76. package/dist/components/snk-filter-modal-item2.js +5 -16
  77. package/dist/components/snk-form-config2.js +5 -15
  78. package/dist/components/snk-form.js +8 -2
  79. package/dist/components/snk-grid-config2.js +4 -2
  80. package/dist/components/snk-grid2.js +11 -12
  81. package/dist/components/snk-personalized-filter2.js +11 -11
  82. package/dist/components/snk-simple-crud2.js +5 -1
  83. package/dist/components/snk-taskbar2.js +3 -1
  84. package/dist/esm/{ConfigStorage-b6aefe42.js → ConfigStorage-2915a841.js} +162 -49
  85. package/dist/esm/{DataFetcher-aaaff866.js → DataFetcher-0b121ffb.js} +38 -29
  86. package/dist/esm/ISave-4412b20c.js +8 -0
  87. package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
  88. package/dist/esm/{SnkFormConfigManager-80901f2d.js → SnkFormConfigManager-8005340f.js} +19 -21
  89. package/dist/esm/{auth-fetcher-7860d777.js → auth-fetcher-643f240e.js} +1 -1
  90. package/dist/esm/{dataunit-fetcher-9dfcdb1d.js → dataunit-fetcher-6423d6eb.js} +1 -1
  91. package/dist/esm/{form-config-fetcher-4a34b86a.js → form-config-fetcher-77cdb26c.js} +65 -3
  92. package/dist/esm/loader.js +1 -1
  93. package/dist/esm/{pesquisa-fetcher-01d058e6.js → pesquisa-fetcher-c5a3c564.js} +1 -1
  94. package/dist/esm/sankhyablocks.js +1 -1
  95. package/dist/esm/snk-actions-button.entry.js +18 -11
  96. package/dist/esm/snk-application.entry.js +49 -44
  97. package/dist/esm/snk-attach.entry.js +3 -9
  98. package/dist/esm/snk-configurator.entry.js +2 -1
  99. package/dist/esm/snk-crud.entry.js +24 -10
  100. package/dist/esm/snk-data-exporter.entry.js +2 -2
  101. package/dist/esm/{snk-data-unit-8c4d944d.js → snk-data-unit-3ab57d1a.js} +4 -3
  102. package/dist/esm/snk-data-unit.entry.js +1 -1
  103. package/dist/esm/snk-detail-view.entry.js +13 -12
  104. package/dist/esm/snk-entity-list.entry.js +0 -4
  105. package/dist/esm/snk-filter-bar.entry.js +13 -16
  106. package/dist/esm/snk-filter-detail.entry.js +2 -16
  107. package/dist/esm/snk-filter-modal-item.entry.js +6 -20
  108. package/dist/esm/snk-form-config.entry.js +7 -18
  109. package/dist/esm/snk-form.entry.js +11 -8
  110. package/dist/esm/snk-grid-config.entry.js +5 -6
  111. package/dist/esm/snk-grid.entry.js +13 -17
  112. package/dist/esm/{snk-guides-viewer-ee42eb53.js → snk-guides-viewer-43b550a2.js} +16 -7
  113. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  114. package/dist/esm/snk-personalized-filter.entry.js +13 -16
  115. package/dist/esm/snk-print-selector.entry.js +1 -1
  116. package/dist/esm/snk-simple-crud.entry.js +7 -3
  117. package/dist/esm/snk-taskbar.entry.js +2 -1
  118. package/dist/sankhyablocks/p-1108ed0e.entry.js +1 -0
  119. package/dist/sankhyablocks/p-18ead46b.entry.js +1 -0
  120. package/dist/sankhyablocks/p-1986cfa4.js +26 -0
  121. package/dist/sankhyablocks/p-1c7b4bad.entry.js +1 -0
  122. package/dist/sankhyablocks/p-48a40939.js +1 -0
  123. package/dist/sankhyablocks/p-508822c3.entry.js +1 -0
  124. package/dist/sankhyablocks/{p-85affa29.js → p-53a7ab6c.js} +1 -1
  125. package/dist/sankhyablocks/{p-77ecc583.entry.js → p-58b84e45.entry.js} +1 -1
  126. package/dist/sankhyablocks/p-688dcb4c.js +1 -0
  127. package/dist/sankhyablocks/{p-05bcad8a.entry.js → p-774afde8.entry.js} +1 -1
  128. package/dist/sankhyablocks/p-84b9208d.entry.js +1 -0
  129. package/dist/sankhyablocks/p-85dfb90b.entry.js +1 -0
  130. package/dist/sankhyablocks/p-86dda34d.js +1 -0
  131. package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
  132. package/dist/sankhyablocks/{p-bee6b5d7.js → p-9bfc7124.js} +1 -1
  133. package/dist/sankhyablocks/p-9d81ad53.entry.js +1 -0
  134. package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
  135. package/dist/sankhyablocks/p-a107474c.js +56 -0
  136. package/dist/sankhyablocks/p-a28470ae.entry.js +1 -0
  137. package/dist/sankhyablocks/p-b9376677.entry.js +1 -0
  138. package/dist/sankhyablocks/p-c7c035eb.js +1 -0
  139. package/dist/sankhyablocks/p-caaef934.js +1 -0
  140. package/dist/sankhyablocks/p-cf65dbb2.entry.js +1 -0
  141. package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
  142. package/dist/sankhyablocks/p-da2422ef.entry.js +11 -0
  143. package/dist/sankhyablocks/p-e086cc2a.entry.js +1 -0
  144. package/dist/sankhyablocks/p-ed705cbb.entry.js +1 -0
  145. package/dist/sankhyablocks/p-f1f5232d.entry.js +1 -0
  146. package/dist/sankhyablocks/{p-60791bb6.js → p-f88bdc84.js} +1 -1
  147. package/dist/sankhyablocks/p-fa523d6b.entry.js +1 -0
  148. package/dist/sankhyablocks/p-fcdd5761.entry.js +1 -0
  149. package/dist/sankhyablocks/p-fdf6b377.entry.js +1 -0
  150. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  151. package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
  152. package/dist/types/components/snk-application/snk-application.d.ts +8 -13
  153. package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
  154. package/dist/types/components/snk-crud/snk-crud.d.ts +1 -0
  155. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +4 -0
  156. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -2
  157. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
  158. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
  159. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
  160. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
  161. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
  162. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  163. package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
  164. package/dist/types/components/snk-form/snk-form.d.ts +5 -1
  165. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
  166. package/dist/types/components/snk-grid/snk-grid.d.ts +4 -0
  167. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
  168. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
  169. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +4 -0
  170. package/dist/types/components.d.ts +99 -21
  171. package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
  172. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  173. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
  174. package/dist/types/lib/index.d.ts +11 -0
  175. package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
  176. package/package.json +1 -1
  177. package/dist/cjs/filter-bar-config-fetcher-80b033ce.js +0 -155
  178. package/dist/cjs/resource-fetcher-95d24dff.js +0 -68
  179. package/dist/components/filter-bar-config-fetcher.js +0 -153
  180. package/dist/components/resource-fetcher.js +0 -66
  181. package/dist/esm/filter-bar-config-fetcher-317cb6bf.js +0 -153
  182. package/dist/esm/resource-fetcher-b36ac145.js +0 -66
  183. package/dist/sankhyablocks/p-0b64f036.entry.js +0 -1
  184. package/dist/sankhyablocks/p-0e97ec46.entry.js +0 -1
  185. package/dist/sankhyablocks/p-1b81c379.entry.js +0 -1
  186. package/dist/sankhyablocks/p-2dd0f891.js +0 -17
  187. package/dist/sankhyablocks/p-330f584a.entry.js +0 -1
  188. package/dist/sankhyablocks/p-35ecafcb.entry.js +0 -1
  189. package/dist/sankhyablocks/p-42843f0e.js +0 -1
  190. package/dist/sankhyablocks/p-459d4267.entry.js +0 -1
  191. package/dist/sankhyablocks/p-557affc8.entry.js +0 -1
  192. package/dist/sankhyablocks/p-564efc43.js +0 -1
  193. package/dist/sankhyablocks/p-6295424d.entry.js +0 -1
  194. package/dist/sankhyablocks/p-64c2cec3.js +0 -1
  195. package/dist/sankhyablocks/p-803b79d6.js +0 -1
  196. package/dist/sankhyablocks/p-80729c9b.entry.js +0 -11
  197. package/dist/sankhyablocks/p-95fa8af6.entry.js +0 -1
  198. package/dist/sankhyablocks/p-96c1ae78.entry.js +0 -1
  199. package/dist/sankhyablocks/p-b556fadc.entry.js +0 -1
  200. package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
  201. package/dist/sankhyablocks/p-bf3bd954.entry.js +0 -1
  202. package/dist/sankhyablocks/p-c32b9d7c.entry.js +0 -1
  203. package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
  204. package/dist/sankhyablocks/p-dd1fa35d.js +0 -56
  205. package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
  206. package/dist/sankhyablocks/p-e42f1f2a.js +0 -1
  207. package/dist/sankhyablocks/p-f24c4bc7.entry.js +0 -1
  208. package/dist/sankhyablocks/p-f737f7e1.js +0 -10
  209. package/dist/sankhyablocks/p-fd69eab9.entry.js +0 -1
@@ -23,6 +23,7 @@ export class SnkTaskbar {
23
23
  };
24
24
  this._permissions = undefined;
25
25
  this.configName = undefined;
26
+ this.resourceID = undefined;
26
27
  this.buttons = undefined;
27
28
  this.customButtons = undefined;
28
29
  this.actionsList = undefined;
@@ -164,7 +165,7 @@ export class SnkTaskbar {
164
165
  componentWillLoad() {
165
166
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
166
167
  if (this._application) {
167
- this._application.getAllAccess().then(access => this._permissions = access);
168
+ this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
168
169
  }
169
170
  else {
170
171
  this._permissions = {};
@@ -232,6 +233,23 @@ export class SnkTaskbar {
232
233
  "attribute": "config-name",
233
234
  "reflect": false
234
235
  },
236
+ "resourceID": {
237
+ "type": "string",
238
+ "mutable": false,
239
+ "complexType": {
240
+ "original": "string",
241
+ "resolved": "string",
242
+ "references": {}
243
+ },
244
+ "required": false,
245
+ "optional": false,
246
+ "docs": {
247
+ "tags": [],
248
+ "text": "Identificador de recursos como configura\u00E7\u00F5es e acesso."
249
+ },
250
+ "attribute": "resource-i-d",
251
+ "reflect": false
252
+ },
235
253
  "buttons": {
236
254
  "type": "string",
237
255
  "mutable": false,
@@ -1,4 +1,3 @@
1
- import { ApplicationContext } from "@sankhyalabs/core";
2
1
  import { FormConfigFetcher } from "../http/data-fetcher/fetchers/form-config-fetcher";
3
2
  import GridConfigFetcher from "../http/data-fetcher/fetchers/grid-config-fetcher";
4
3
  import FilterBarConfigFetcher from "../http/data-fetcher/fetchers/filter-bar-config-fetcher";
@@ -9,83 +8,73 @@ const CONFIG_SOURCE = {
9
8
  filterBar: "filterBar"
10
9
  };
11
10
  export class ConfigStorage {
12
- static async get() {
13
- if (!ConfigStorage.instance) {
14
- const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
15
- if (application != undefined) {
16
- const configName = application.configName;
17
- const resourceID = await application.getResourceID();
18
- ConfigStorage.instance = new ConfigStorage();
19
- ConfigStorage.resourceID = resourceID;
20
- ConfigStorage.instance.loadFormConfig(configName);
21
- ConfigStorage.instance.loadGridConfig(configName);
22
- }
23
- }
24
- return this.instance;
11
+ static preload(resourceID, configName) {
12
+ ConfigStorage.loadFormConfig(configName, resourceID);
13
+ ConfigStorage.loadGridConfig(configName, resourceID);
25
14
  }
26
- async loadFilterBarConfig(name, urlParams) {
27
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar);
15
+ static async loadFilterBarConfig(name, resourceID, urlParams) {
16
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
28
17
  if (!ConfigStorage.configById.has(cacheID)) {
29
- ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(ConfigStorage.resourceID, name, urlParams));
18
+ ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
30
19
  }
31
20
  return ConfigStorage.configById.get(cacheID);
32
21
  }
33
- async loadFormConfig(name) {
34
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form);
22
+ static async loadFormConfig(name, resourceID) {
23
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
35
24
  if (!ConfigStorage.configById.has(cacheID)) {
36
- ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, ConfigStorage.resourceID));
25
+ ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
37
26
  }
38
27
  return ConfigStorage.configById.get(cacheID);
39
28
  }
40
- async loadGridConfig(name) {
41
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid);
29
+ static async loadGridConfig(name, resourceID) {
30
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
42
31
  if (!ConfigStorage.configById.has(cacheID)) {
43
- ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, ConfigStorage.resourceID));
32
+ ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
44
33
  }
45
34
  return ConfigStorage.configById.get(cacheID);
46
35
  }
47
- static async saveFilterBarConfig(config, name) {
48
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar);
36
+ static async saveFilterBarConfig(config, name, resourceID) {
37
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
49
38
  this.configById.delete(cacheID);
50
- return this.filterBarConfigFetcher.saveConfig(config, this.resourceID, name);
39
+ return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
51
40
  }
52
- static async saveFormConfig(config, name) {
53
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form);
41
+ static async saveFormConfig(config, name, resourceID) {
42
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
54
43
  this.configById.delete(cacheID);
55
- return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
44
+ return this.formConfigFetcher.saveConfig(config, name, resourceID);
56
45
  }
57
- static async saveCardState(config, name) {
58
- return this.formConfigFetcher.saveCardState(config, name, this.resourceID);
46
+ static async saveCardState(config, name, resourceID) {
47
+ return this.formConfigFetcher.saveCardState(config, name, resourceID);
59
48
  }
60
- static async saveGridConfig(config, name) {
49
+ static async saveGridConfig(config, name, resourceID) {
61
50
  if (config == undefined) {
62
51
  return;
63
52
  }
64
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid);
53
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
65
54
  this.configById.delete(cacheID);
66
- return this.gridConfigFetcher.saveConfig(config, name, this.resourceID);
55
+ return this.gridConfigFetcher.saveConfig(config, name, resourceID);
67
56
  }
68
- static async loadPersonalizedFilter(filterId, configName) {
69
- return this.personalizedFilterFetcher.loadPersonalizedFilter(this.resourceID, filterId, configName);
57
+ static async loadPersonalizedFilter(filterId, resourceID, configName) {
58
+ return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName);
70
59
  }
71
- static async savePersonalizedFilter(personalizedFilter, configName) {
60
+ static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
72
61
  //Ao criar ou alterar um filtro personalizado,
73
62
  //precisamos remover o cache do status da filterbar.
74
- const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar);
63
+ const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar, resourceID);
75
64
  this.configById.delete(cacheID);
76
- return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, this.resourceID, configName);
65
+ return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, resourceID, configName);
77
66
  }
78
- static async removePersonalizedFilter(personalizedFilter, configName) {
79
- return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, this.resourceID, configName);
67
+ static async removePersonalizedFilter(personalizedFilter, resourceID, configName) {
68
+ return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, resourceID, configName);
80
69
  }
81
70
  static async validatePersonalizedFilter(dataUnitName, expression) {
82
71
  return this.personalizedFilterFetcher.validatePersonalizedFilter(dataUnitName, expression);
83
72
  }
84
- static buildCacheID(name, source) {
73
+ static buildCacheID(name, source, resourceID) {
85
74
  if (name == undefined) {
86
- return `req_${source}_${this.resourceID}`;
75
+ return `req_${source}_${resourceID}`;
87
76
  }
88
- return `req_${source}_${name}_${this.resourceID}`;
77
+ return `req_${source}_${name}_${resourceID}`;
89
78
  }
90
79
  }
91
80
  ConfigStorage.configById = new Map();
@@ -8,6 +8,7 @@ import { PrintUtils } from '../../utils/PrintUtils';
8
8
  export class DataFetcher {
9
9
  constructor() {
10
10
  this.GRAPHQL_PATH = "/mgefin-bff/graphql";
11
+ this.ready = true;
11
12
  this.watingRequestsById = new Map();
12
13
  }
13
14
  static get() {
@@ -18,6 +19,9 @@ export class DataFetcher {
18
19
  DataFetcher.instance.resume();
19
20
  }
20
21
  else {
22
+ if (ApplicationContext.getContextValue("__SNK__APPLICATION__LOADING__") === true) {
23
+ DataFetcher.instance.pause();
24
+ }
21
25
  application.addEventListener('applicationLoading', () => DataFetcher.instance.pause());
22
26
  application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
23
27
  }
@@ -76,6 +80,10 @@ export class DataFetcher {
76
80
  }
77
81
  async callGraphQL(req) {
78
82
  var _a;
83
+ if (this.ready) {
84
+ this.pause();
85
+ window.requestAnimationFrame(() => this.resume());
86
+ }
79
87
  const reqKey = this.getReqKey(req);
80
88
  req.queryID = reqKey;
81
89
  req.values.queryID = reqKey;
@@ -105,7 +113,7 @@ export class DataFetcher {
105
113
  if (!this.watingRequestsById.has(reqKey)) {
106
114
  this.watingRequestsById.set(reqKey, new WaitingRequest(req));
107
115
  }
108
- return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
116
+ return (_a = this.watingRequestsById.get(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
109
117
  }
110
118
  }
111
119
  resolveURL() {
@@ -253,42 +261,43 @@ export class DataFetcher {
253
261
  getQueryTemplate(re) {
254
262
  return (re.query || "").replaceAll("$queryAlias$", re.queryID);
255
263
  }
256
- getWatingRequest(reqID) {
257
- return this.watingRequestsById.get(reqID);
258
- }
259
264
  pause() {
260
265
  this.ready = false;
261
266
  }
262
267
  async resume() {
263
268
  this.ready = true;
264
269
  if (this.watingRequestsById.size > 0) {
265
- const requestsBatch = [];
266
- this.watingRequestsById.forEach(async (waitingReq) => {
267
- let query = this.getQueryTemplate(waitingReq.request);
268
- requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
269
- });
270
- let res = undefined;
271
- let dataResponse = [];
272
- let errorsResponse = [];
273
- res = await this.fecthGrapql(requestsBatch);
274
- dataResponse = res.data;
275
- errorsResponse = res.errors;
276
- //Reject promises with errors from query
277
- errorsResponse.forEach((errorResponse) => {
278
- Object.entries(errorResponse).forEach(([_key, val]) => {
279
- var _a;
280
- (((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ErrorException("Falha detectada", val.message));
281
- });
270
+ const waitinRequests = this.watingRequestsById;
271
+ this.watingRequestsById = new Map();
272
+ this.executePendingRequest(waitinRequests);
273
+ }
274
+ }
275
+ async executePendingRequest(watingRequestsById) {
276
+ const requestsBatch = [];
277
+ watingRequestsById.forEach(async (waitingReq) => {
278
+ let query = this.getQueryTemplate(waitingReq.request);
279
+ requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
280
+ });
281
+ let res = undefined;
282
+ let dataResponse = [];
283
+ let errorsResponse = [];
284
+ res = await this.fecthGrapql(requestsBatch);
285
+ dataResponse = res.data;
286
+ errorsResponse = res.errors;
287
+ //Reject promises with errors from query
288
+ errorsResponse.forEach((errorResponse) => {
289
+ Object.entries(errorResponse).forEach(([_key, val]) => {
290
+ var _a;
291
+ (((_a = watingRequestsById.get(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ErrorException("Falha detectada", val.message));
282
292
  });
283
- //Resolve promises with data from query
284
- dataResponse.forEach((data) => {
285
- Object.entries(data).forEach(([key, val]) => {
286
- var _a;
287
- (((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
288
- });
293
+ });
294
+ //Resolve promises with data from query
295
+ dataResponse.forEach((data) => {
296
+ Object.entries(data).forEach(([key, val]) => {
297
+ var _a;
298
+ (((_a = watingRequestsById.get(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
289
299
  });
290
- this.watingRequestsById.clear();
291
- }
300
+ });
292
301
  }
293
302
  async fecthGrapql(request) {
294
303
  let res = undefined;
@@ -91,30 +91,6 @@ export default class FilterBarConfigFetcher extends ResourceFetcher {
91
91
  });
92
92
  });
93
93
  }
94
- saveEntityListConfig(item, resourceID, configName) {
95
- return new Promise((accept, reject) => {
96
- this.getConfig(resourceID, configName).then(config => {
97
- const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
98
- return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
99
- });
100
- const index = state.findIndex(({ id }) => id === item.id);
101
- const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
102
- if (index > -1) {
103
- state[index] = newItem;
104
- }
105
- else {
106
- state.push(newItem);
107
- }
108
- this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
109
- accept(resp);
110
- }).catch(exception => {
111
- reject(exception);
112
- });
113
- }).catch(exception => {
114
- reject(exception);
115
- });
116
- });
117
- }
118
94
  buildFieldList(items) {
119
95
  return items.map(item => {
120
96
  var _a, _b;
@@ -2,3 +2,13 @@ export { DataFetcher } from './http/data-fetcher/DataFetcher';
2
2
  export { PesquisaFetcher } from './http/data-fetcher/fetchers/pesquisa-fetcher';
3
3
  export { CrudUtils } from './utils/CrudUtils';
4
4
  export { PresentationMode } from "./@types";
5
+ export { TotalsFetcher } from './http/data-fetcher/fetchers/totals-fetcher';
6
+ export { default as ApplicationConfigFetcher } from './http/data-fetcher/fetchers/application-config-fetcher';
7
+ export { AttachFetcher } from './http/data-fetcher/fetchers/attach-fetcher';
8
+ export { default as DataUnitFetcher } from './http/data-fetcher/fetchers/dataunit-fetcher';
9
+ export { default as FilterBarConfigFetcher } from './http/data-fetcher/fetchers/filter-bar-config-fetcher';
10
+ export { FormConfigFetcher } from './http/data-fetcher/fetchers/form-config-fetcher';
11
+ export { default as GridConfigFetcher } from './http/data-fetcher/fetchers/grid-config-fetcher';
12
+ export { default as ParametersFetcher } from './http/data-fetcher/fetchers/parameters-fecher';
13
+ export { default as PersonalizedFilterFetcher } from './http/data-fetcher/fetchers/personalized-filter-fetcher';
14
+ export { ResourceFetcher } from './http/data-fetcher/fetchers/resource-fetcher';
@@ -0,0 +1,7 @@
1
+ import { ApplicationContext } from "@sankhyalabs/core";
2
+ export default class ResourceIDUtils {
3
+ static async getResourceID() {
4
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
5
+ return application.getResourceID();
6
+ }
7
+ }
@@ -1,9 +1,132 @@
1
- import { ApplicationContext } from '@sankhyalabs/core';
2
- import { F as FormConfigFetcher } from './form-config-fetcher.js';
3
- import { R as ResourceFetcher } from './resource-fetcher.js';
4
- import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher.js';
2
+ import { F as FilterItemType } from './filter-item-type.enum.js';
5
3
  import { d as dist, D as DataFetcher } from './DataFetcher.js';
6
4
 
5
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
6
+ var t = {};
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
8
+ t[p] = s[p];
9
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
10
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
12
+ t[p[i]] = s[p[i]];
13
+ }
14
+ return t;
15
+ };
16
+ function normalizeValue(value, type) {
17
+ if (value == undefined) {
18
+ return value;
19
+ }
20
+ if (value instanceof Date) {
21
+ return value.toISOString();
22
+ }
23
+ if (typeof value === "object") {
24
+ if (value instanceof Array) {
25
+ return value.map(item => {
26
+ if (FilterItemType.MULTI_LIST === type) {
27
+ const values = __rest(item, ["label"]);
28
+ return normalizeValue(values);
29
+ }
30
+ return normalizeValue(item);
31
+ });
32
+ }
33
+ else {
34
+ const normalized = Object.assign({}, value);
35
+ Object.keys(value).forEach(prop => {
36
+ if (value[prop] !== undefined) {
37
+ normalized[prop] = normalizeValue(value[prop], type);
38
+ }
39
+ else {
40
+ delete normalized[prop];
41
+ }
42
+ });
43
+ return normalized;
44
+ }
45
+ }
46
+ return value;
47
+ }
48
+ class FilterBarConfigFetcher extends ResourceFetcher {
49
+ normalize(items) {
50
+ return items.map(item => {
51
+ const { id, value, fixed, visible, type, groupedItems } = item;
52
+ const stateItem = { id };
53
+ if (value) {
54
+ stateItem["value"] = normalizeValue(value, type);
55
+ }
56
+ if (fixed) {
57
+ stateItem["fixed"] = fixed;
58
+ }
59
+ if (groupedItems) {
60
+ if (groupedItems.length === 0) {
61
+ return;
62
+ }
63
+ if (groupedItems.filter(item => item.visible).length > 0) {
64
+ stateItem["visible"] = true;
65
+ }
66
+ stateItem["groupedItems"] = this.normalize(groupedItems);
67
+ }
68
+ else {
69
+ if (visible) {
70
+ stateItem["visible"] = true;
71
+ }
72
+ }
73
+ return stateItem;
74
+ }).filter(item => item != undefined);
75
+ }
76
+ saveConfig(items, resourceID, configName) {
77
+ return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
78
+ }
79
+ getConfig(resourceID, configName, urlParams) {
80
+ return new Promise((accept, reject) => {
81
+ this.loadResource(this.getPath(resourceID, configName, urlParams))
82
+ .then((configAsString) => {
83
+ let fieldsList;
84
+ if (configAsString) {
85
+ const filterBarConfig = JSON.parse(configAsString);
86
+ fieldsList = this.buildFieldList(filterBarConfig.items);
87
+ }
88
+ accept(fieldsList || []);
89
+ })
90
+ .catch((error) => {
91
+ reject(error);
92
+ });
93
+ });
94
+ }
95
+ buildFieldList(items) {
96
+ return items.map(item => {
97
+ var _a, _b;
98
+ if (item.type === FilterItemType.MULTI_LIST) {
99
+ const multiListValue = item.value;
100
+ item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
101
+ }
102
+ return item;
103
+ });
104
+ }
105
+ getPath(resourceID, name, urlParams) {
106
+ let path = `cfg://filter/FilterBarState:${resourceID}`;
107
+ if (name) {
108
+ path += `.${name}`;
109
+ }
110
+ if (urlParams) {
111
+ path += this.buildQueryString(urlParams);
112
+ }
113
+ return path;
114
+ }
115
+ buildQueryString(urlParams) {
116
+ let queryString = '?';
117
+ for (let key in urlParams) {
118
+ if (!urlParams.hasOwnProperty(key)) {
119
+ continue;
120
+ }
121
+ if (queryString.length > 1) {
122
+ queryString += '&';
123
+ }
124
+ queryString += key + '=' + urlParams[key];
125
+ }
126
+ return queryString;
127
+ }
128
+ }
129
+
7
130
  class GridConfigFetcher extends ResourceFetcher {
8
131
  constructor() {
9
132
  super(...arguments);
@@ -218,83 +341,73 @@ const CONFIG_SOURCE = {
218
341
  filterBar: "filterBar"
219
342
  };
220
343
  class ConfigStorage {
221
- static async get() {
222
- if (!ConfigStorage.instance) {
223
- const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
224
- if (application != undefined) {
225
- const configName = application.configName;
226
- const resourceID = await application.getResourceID();
227
- ConfigStorage.instance = new ConfigStorage();
228
- ConfigStorage.resourceID = resourceID;
229
- ConfigStorage.instance.loadFormConfig(configName);
230
- ConfigStorage.instance.loadGridConfig(configName);
231
- }
232
- }
233
- return this.instance;
344
+ static preload(resourceID, configName) {
345
+ ConfigStorage.loadFormConfig(configName, resourceID);
346
+ ConfigStorage.loadGridConfig(configName, resourceID);
234
347
  }
235
- async loadFilterBarConfig(name, urlParams) {
236
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar);
348
+ static async loadFilterBarConfig(name, resourceID, urlParams) {
349
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
237
350
  if (!ConfigStorage.configById.has(cacheID)) {
238
- ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(ConfigStorage.resourceID, name, urlParams));
351
+ ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
239
352
  }
240
353
  return ConfigStorage.configById.get(cacheID);
241
354
  }
242
- async loadFormConfig(name) {
243
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form);
355
+ static async loadFormConfig(name, resourceID) {
356
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
244
357
  if (!ConfigStorage.configById.has(cacheID)) {
245
- ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, ConfigStorage.resourceID));
358
+ ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
246
359
  }
247
360
  return ConfigStorage.configById.get(cacheID);
248
361
  }
249
- async loadGridConfig(name) {
250
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid);
362
+ static async loadGridConfig(name, resourceID) {
363
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
251
364
  if (!ConfigStorage.configById.has(cacheID)) {
252
- ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, ConfigStorage.resourceID));
365
+ ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
253
366
  }
254
367
  return ConfigStorage.configById.get(cacheID);
255
368
  }
256
- static async saveFilterBarConfig(config, name) {
257
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar);
369
+ static async saveFilterBarConfig(config, name, resourceID) {
370
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
258
371
  this.configById.delete(cacheID);
259
- return this.filterBarConfigFetcher.saveConfig(config, this.resourceID, name);
372
+ return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
260
373
  }
261
- static async saveFormConfig(config, name) {
262
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form);
374
+ static async saveFormConfig(config, name, resourceID) {
375
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
263
376
  this.configById.delete(cacheID);
264
- return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
377
+ return this.formConfigFetcher.saveConfig(config, name, resourceID);
265
378
  }
266
- static async saveCardState(config, name) {
267
- return this.formConfigFetcher.saveCardState(config, name, this.resourceID);
379
+ static async saveCardState(config, name, resourceID) {
380
+ return this.formConfigFetcher.saveCardState(config, name, resourceID);
268
381
  }
269
- static async saveGridConfig(config, name) {
382
+ static async saveGridConfig(config, name, resourceID) {
270
383
  if (config == undefined) {
271
384
  return;
272
385
  }
273
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid);
386
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
274
387
  this.configById.delete(cacheID);
275
- return this.gridConfigFetcher.saveConfig(config, name, this.resourceID);
388
+ return this.gridConfigFetcher.saveConfig(config, name, resourceID);
276
389
  }
277
- static async loadPersonalizedFilter(filterId, configName) {
278
- return this.personalizedFilterFetcher.loadPersonalizedFilter(this.resourceID, filterId, configName);
390
+ static async loadPersonalizedFilter(filterId, resourceID, configName) {
391
+ return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName);
279
392
  }
280
- static async savePersonalizedFilter(personalizedFilter, configName) {
393
+ static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
281
394
  //Ao criar ou alterar um filtro personalizado,
282
395
  //precisamos remover o cache do status da filterbar.
283
- const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar);
396
+ const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar, resourceID);
284
397
  this.configById.delete(cacheID);
285
- return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, this.resourceID, configName);
398
+ return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, resourceID, configName);
286
399
  }
287
- static async removePersonalizedFilter(personalizedFilter, configName) {
288
- return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, this.resourceID, configName);
400
+ static async removePersonalizedFilter(personalizedFilter, resourceID, configName) {
401
+ return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, resourceID, configName);
289
402
  }
290
403
  static async validatePersonalizedFilter(dataUnitName, expression) {
291
404
  return this.personalizedFilterFetcher.validatePersonalizedFilter(dataUnitName, expression);
292
405
  }
293
- static buildCacheID(name, source) {
406
+ static buildCacheID(name, source, resourceID) {
294
407
  if (name == undefined) {
295
- return `req_${source}_${this.resourceID}`;
408
+ return `req_${source}_${resourceID}`;
296
409
  }
297
- return `req_${source}_${name}_${this.resourceID}`;
410
+ return `req_${source}_${name}_${resourceID}`;
298
411
  }
299
412
  }
300
413
  ConfigStorage.configById = new Map();
@@ -303,4 +416,4 @@ ConfigStorage.formConfigFetcher = new FormConfigFetcher();
303
416
  ConfigStorage.gridConfigFetcher = new GridConfigFetcher();
304
417
  ConfigStorage.personalizedFilterFetcher = new PersonalizedFilterFetcher();
305
418
 
306
- export { ConfigStorage as C, GridConfigFetcher as G, PersonalizedFilterFetcher as P };
419
+ export { ConfigStorage as C, PersonalizedFilterFetcher as P };