@sankhyalabs/sankhyablocks 8.1.0-rc.3 → 8.2.0-dev.1

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 (222) hide show
  1. package/dist/cjs/{ConfigStorage-73e7afff.js → ConfigStorage-12397f18.js} +163 -51
  2. package/dist/cjs/{DataFetcher-004811c6.js → DataFetcher-f2da1f79.js} +68 -30
  3. package/dist/cjs/ISave-d68ce3cd.js +8 -0
  4. package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
  5. package/dist/cjs/{SnkFormConfigManager-d1f1a222.js → SnkFormConfigManager-13f79e37.js} +19 -21
  6. package/dist/cjs/{auth-fetcher-58237931.js → auth-fetcher-319a4cb2.js} +2 -2
  7. package/dist/cjs/{dataunit-fetcher-029eafbd.js → dataunit-fetcher-e72068c1.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-181767c9.js → form-config-fetcher-5d62ab62.js} +66 -3
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-9a97994a.js → pesquisa-fetcher-8c363096.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 +25 -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 +14 -12
  21. package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
  22. package/dist/cjs/snk-filter-bar.cjs.entry.js +14 -17
  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-view.cjs.entry.js +6 -1
  27. package/dist/cjs/snk-form.cjs.entry.js +12 -8
  28. package/dist/cjs/snk-grid-config.cjs.entry.js +5 -6
  29. package/dist/cjs/snk-grid.cjs.entry.js +17 -20
  30. package/dist/cjs/{snk-guides-viewer-27f87d90.js → snk-guides-viewer-a7cd6fda.js} +17 -7
  31. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  32. package/dist/cjs/snk-personalized-filter.cjs.entry.js +13 -16
  33. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  34. package/dist/cjs/snk-simple-crud.cjs.entry.js +20 -72
  35. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
  36. package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
  37. package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
  38. package/dist/collection/components/snk-application/snk-application.js +60 -65
  39. package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
  40. package/dist/collection/components/snk-crud/snk-crud.js +40 -6
  41. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +42 -2
  42. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +27 -1
  43. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +47 -28
  44. package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -4
  45. package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
  46. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +2 -12
  47. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
  48. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
  49. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +28 -12
  50. package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
  51. package/dist/collection/components/snk-form/snk-form.js +46 -2
  52. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
  53. package/dist/collection/components/snk-grid/snk-grid.js +51 -15
  54. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
  55. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
  56. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +22 -0
  57. package/dist/collection/components/snk-taskbar/snk-taskbar.js +19 -1
  58. package/dist/collection/lib/configs/ConfigStorage.js +33 -44
  59. package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -59
  60. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +39 -30
  61. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
  62. package/dist/collection/lib/index.js +10 -0
  63. package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
  64. package/dist/collection/lib/utils/urlutils.js +29 -0
  65. package/dist/components/ConfigStorage.js +161 -48
  66. package/dist/components/DataFetcher.js +68 -30
  67. package/dist/components/ResourceIDUtils.js +10 -0
  68. package/dist/components/SnkFormConfigManager.js +17 -19
  69. package/dist/components/auth-fetcher.js +1 -1
  70. package/dist/components/form-config-fetcher.js +64 -2
  71. package/dist/components/snk-actions-button2.js +23 -9
  72. package/dist/components/snk-application2.js +134 -128
  73. package/dist/components/snk-attach2.js +1 -8
  74. package/dist/components/snk-configurator2.js +3 -1
  75. package/dist/components/snk-crud.js +23 -6
  76. package/dist/components/snk-data-unit2.js +5 -3
  77. package/dist/components/snk-detail-view2.js +20 -8
  78. package/dist/components/snk-entity-list.js +0 -4
  79. package/dist/components/snk-filter-bar2.js +12 -12
  80. package/dist/components/snk-filter-detail2.js +2 -12
  81. package/dist/components/snk-filter-modal-item2.js +5 -16
  82. package/dist/components/snk-form-config2.js +5 -15
  83. package/dist/components/snk-form-view2.js +6 -1
  84. package/dist/components/snk-form.js +9 -2
  85. package/dist/components/snk-grid-config2.js +4 -2
  86. package/dist/components/snk-grid2.js +17 -16
  87. package/dist/components/snk-personalized-filter2.js +11 -11
  88. package/dist/components/snk-simple-crud2.js +8 -60
  89. package/dist/components/snk-taskbar2.js +3 -1
  90. package/dist/esm/{ConfigStorage-19a7260b.js → ConfigStorage-932ab366.js} +162 -49
  91. package/dist/esm/{DataFetcher-e0fc5549.js → DataFetcher-7e18aa30.js} +68 -30
  92. package/dist/esm/ISave-4412b20c.js +8 -0
  93. package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
  94. package/dist/esm/{SnkFormConfigManager-1a42eb02.js → SnkFormConfigManager-bb9afc3f.js} +19 -21
  95. package/dist/esm/{auth-fetcher-83a946f8.js → auth-fetcher-6d9664b7.js} +1 -1
  96. package/dist/esm/{dataunit-fetcher-6a695723.js → dataunit-fetcher-91a4eb82.js} +1 -1
  97. package/dist/esm/{form-config-fetcher-9e167008.js → form-config-fetcher-aaaa79a6.js} +65 -3
  98. package/dist/esm/loader.js +1 -1
  99. package/dist/esm/{pesquisa-fetcher-9118eb7a.js → pesquisa-fetcher-56b30fb4.js} +1 -1
  100. package/dist/esm/sankhyablocks.js +1 -1
  101. package/dist/esm/snk-actions-button.entry.js +18 -11
  102. package/dist/esm/snk-application.entry.js +49 -44
  103. package/dist/esm/snk-attach.entry.js +3 -9
  104. package/dist/esm/snk-configurator.entry.js +2 -1
  105. package/dist/esm/snk-crud.entry.js +25 -10
  106. package/dist/esm/snk-data-exporter.entry.js +2 -2
  107. package/dist/esm/{snk-data-unit-8c4d944d.js → snk-data-unit-3ab57d1a.js} +4 -3
  108. package/dist/esm/snk-data-unit.entry.js +1 -1
  109. package/dist/esm/snk-detail-view.entry.js +14 -12
  110. package/dist/esm/snk-entity-list.entry.js +0 -4
  111. package/dist/esm/snk-filter-bar.entry.js +14 -17
  112. package/dist/esm/snk-filter-detail.entry.js +2 -16
  113. package/dist/esm/snk-filter-modal-item.entry.js +6 -20
  114. package/dist/esm/snk-form-config.entry.js +7 -18
  115. package/dist/esm/snk-form-view.entry.js +6 -1
  116. package/dist/esm/snk-form.entry.js +12 -8
  117. package/dist/esm/snk-grid-config.entry.js +5 -6
  118. package/dist/esm/snk-grid.entry.js +17 -20
  119. package/dist/esm/{snk-guides-viewer-c47cd45e.js → snk-guides-viewer-cc709b5f.js} +17 -7
  120. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  121. package/dist/esm/snk-personalized-filter.entry.js +13 -16
  122. package/dist/esm/snk-print-selector.entry.js +1 -1
  123. package/dist/esm/snk-simple-crud.entry.js +10 -62
  124. package/dist/esm/snk-taskbar.entry.js +2 -1
  125. package/dist/sankhyablocks/p-01739b21.entry.js +1 -0
  126. package/dist/sankhyablocks/{p-e7e54737.entry.js → p-03bb1aea.entry.js} +1 -1
  127. package/dist/sankhyablocks/p-05dbc70e.entry.js +1 -0
  128. package/dist/sankhyablocks/{p-0a4c753d.js → p-14eac6fe.js} +1 -1
  129. package/dist/sankhyablocks/{p-2ac9c585.js → p-2d333d22.js} +1 -1
  130. package/dist/sankhyablocks/p-41e897f1.js +56 -0
  131. package/dist/sankhyablocks/p-48a40939.js +1 -0
  132. package/dist/sankhyablocks/p-611aa624.entry.js +1 -0
  133. package/dist/sankhyablocks/p-66bb8c20.entry.js +1 -0
  134. package/dist/sankhyablocks/p-688dcb4c.js +1 -0
  135. package/dist/sankhyablocks/p-6f154396.entry.js +1 -0
  136. package/dist/sankhyablocks/p-787071a8.js +1 -0
  137. package/dist/sankhyablocks/p-8481bb59.entry.js +1 -0
  138. package/dist/sankhyablocks/p-8818d8f6.entry.js +1 -0
  139. package/dist/sankhyablocks/p-93f6ca04.entry.js +1 -0
  140. package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
  141. package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
  142. package/dist/sankhyablocks/p-a52a6c9d.js +26 -0
  143. package/dist/sankhyablocks/p-b6003974.entry.js +1 -0
  144. package/dist/sankhyablocks/p-c555075c.entry.js +1 -0
  145. package/dist/sankhyablocks/{p-e5845241.entry.js → p-d13c00b6.entry.js} +1 -1
  146. package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
  147. package/dist/sankhyablocks/p-d53a9169.entry.js +1 -0
  148. package/dist/sankhyablocks/p-d7638f45.entry.js +11 -0
  149. package/dist/sankhyablocks/p-e086cc2a.entry.js +1 -0
  150. package/dist/sankhyablocks/p-e64f3e17.entry.js +1 -0
  151. package/dist/sankhyablocks/p-ed41b38c.js +1 -0
  152. package/dist/sankhyablocks/p-ed705cbb.entry.js +1 -0
  153. package/dist/sankhyablocks/p-efc10705.entry.js +1 -0
  154. package/dist/sankhyablocks/p-f74fe358.js +1 -0
  155. package/dist/sankhyablocks/{p-df8621b4.js → p-f8e6b97e.js} +1 -1
  156. package/dist/sankhyablocks/p-f91e0c5d.entry.js +1 -0
  157. package/dist/sankhyablocks/p-fa523d6b.entry.js +1 -0
  158. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  159. package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
  160. package/dist/types/components/snk-application/snk-application.d.ts +8 -13
  161. package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
  162. package/dist/types/components/snk-crud/snk-crud.d.ts +5 -0
  163. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +8 -0
  164. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +5 -0
  165. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +9 -2
  166. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
  167. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
  168. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
  169. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
  170. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
  171. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  172. package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
  173. package/dist/types/components/snk-form/snk-form.d.ts +9 -1
  174. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
  175. package/dist/types/components/snk-grid/snk-grid.d.ts +5 -1
  176. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
  177. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
  178. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
  179. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +4 -0
  180. package/dist/types/components.d.ts +125 -21
  181. package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
  182. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +0 -7
  183. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  184. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
  185. package/dist/types/lib/index.d.ts +11 -0
  186. package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
  187. package/dist/types/lib/utils/urlutils.d.ts +14 -0
  188. package/package.json +2 -2
  189. package/dist/cjs/filter-bar-config-fetcher-2b8ed9d0.js +0 -155
  190. package/dist/cjs/resource-fetcher-c0332609.js +0 -68
  191. package/dist/components/filter-bar-config-fetcher.js +0 -153
  192. package/dist/components/resource-fetcher.js +0 -66
  193. package/dist/esm/filter-bar-config-fetcher-06e02851.js +0 -153
  194. package/dist/esm/resource-fetcher-768d5556.js +0 -66
  195. package/dist/sankhyablocks/p-0ed0fc02.entry.js +0 -1
  196. package/dist/sankhyablocks/p-216f081a.entry.js +0 -1
  197. package/dist/sankhyablocks/p-22c6fe1a.entry.js +0 -1
  198. package/dist/sankhyablocks/p-34a1357a.entry.js +0 -1
  199. package/dist/sankhyablocks/p-4721c3db.js +0 -1
  200. package/dist/sankhyablocks/p-564efc43.js +0 -1
  201. package/dist/sankhyablocks/p-6759adae.entry.js +0 -1
  202. package/dist/sankhyablocks/p-7b8b8ae9.js +0 -10
  203. package/dist/sankhyablocks/p-7e285d6c.entry.js +0 -11
  204. package/dist/sankhyablocks/p-815a42c0.entry.js +0 -1
  205. package/dist/sankhyablocks/p-8a41172a.entry.js +0 -1
  206. package/dist/sankhyablocks/p-8f8184ff.js +0 -56
  207. package/dist/sankhyablocks/p-976e56e9.js +0 -1
  208. package/dist/sankhyablocks/p-98f9d076.js +0 -17
  209. package/dist/sankhyablocks/p-bc735728.entry.js +0 -1
  210. package/dist/sankhyablocks/p-be684b38.entry.js +0 -1
  211. package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
  212. package/dist/sankhyablocks/p-c0f656af.entry.js +0 -1
  213. package/dist/sankhyablocks/p-c32b9d7c.entry.js +0 -1
  214. package/dist/sankhyablocks/p-c57bd935.entry.js +0 -1
  215. package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
  216. package/dist/sankhyablocks/p-cfd7da4a.entry.js +0 -1
  217. package/dist/sankhyablocks/p-d1b89765.js +0 -1
  218. package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
  219. package/dist/sankhyablocks/p-e28129aa.entry.js +0 -1
  220. package/dist/sankhyablocks/p-f31bfdee.entry.js +0 -1
  221. package/dist/sankhyablocks/p-f88c45bf.js +0 -1
  222. package/dist/sankhyablocks/p-fe010e54.entry.js +0 -1
@@ -1,6 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { S as SnkFormConfigManager } from './SnkFormConfigManager.js';
4
+ import { R as ResourceIDUtils } from './ResourceIDUtils.js';
4
5
  import { d as defineCustomElement$5 } from './snk-config-options2.js';
5
6
  import { d as defineCustomElement$4 } from './snk-field-config2.js';
6
7
  import { d as defineCustomElement$3 } from './snk-form-config2.js';
@@ -14,6 +15,7 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14
15
  this.__registerHost();
15
16
  this.exit = createEvent(this, "exit", 7);
16
17
  this.actionClick = createEvent(this, "actionClick", 7);
18
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
17
19
  this._dataUnit = undefined;
18
20
  this._dataState = undefined;
19
21
  this._showFormConfig = false;
@@ -21,6 +23,7 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
21
23
  this.configName = undefined;
22
24
  this.recordsValidator = undefined;
23
25
  this.messagesBuilder = undefined;
26
+ this.resourceID = undefined;
24
27
  }
25
28
  /**
26
29
  * Exibe a janela de configurações do formulário.
@@ -41,7 +44,7 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
41
44
  const dataInfo = { dataUnit: this._dataUnit };
42
45
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
43
46
  }
44
- componentWillLoad() {
47
+ async componentWillLoad() {
45
48
  let parent = this._element.parentElement;
46
49
  while (parent) {
47
50
  if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
@@ -63,7 +66,10 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
63
66
  }
64
67
  parent = parent.parentElement;
65
68
  }
66
- this._configManager = new SnkFormConfigManager(this.configName);
69
+ if (this.resourceID == undefined) {
70
+ this.resourceID = await ResourceIDUtils.getResourceID();
71
+ }
72
+ this._configManager = new SnkFormConfigManager(this.configName, this.resourceID);
67
73
  this._configManager.loadConfig();
68
74
  }
69
75
  render() {
@@ -79,6 +85,7 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
79
85
  "configName": [1, "config-name"],
80
86
  "recordsValidator": [16],
81
87
  "messagesBuilder": [1040],
88
+ "resourceID": [1, "resource-i-d"],
82
89
  "_dataUnit": [32],
83
90
  "_dataState": [32],
84
91
  "_showFormConfig": [32],
@@ -25,6 +25,7 @@ const SnkGridConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
25
25
  this.columns = undefined;
26
26
  this.config = undefined;
27
27
  this.configName = undefined;
28
+ this.resourceID = undefined;
28
29
  }
29
30
  /* Creation Methods */
30
31
  /**
@@ -248,7 +249,7 @@ const SnkGridConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
248
249
  }
249
250
  }
250
251
  _newConfig.columns = _newColumnConfigList;
251
- ConfigStorage.saveGridConfig(_newConfig, this.configName)
252
+ ConfigStorage.saveGridConfig(_newConfig, this.configName, this.resourceID)
252
253
  .then((savedConfig) => {
253
254
  this.configChange.emit(savedConfig);
254
255
  this._orderList.clearHistory();
@@ -475,7 +476,8 @@ const SnkGridConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
475
476
  "application": [16],
476
477
  "columns": [1040],
477
478
  "config": [1040],
478
- "configName": [1, "config-name"]
479
+ "configName": [1, "config-name"],
480
+ "resourceID": [1, "resource-i-d"]
479
481
  }]);
480
482
  function defineCustomElement() {
481
483
  if (typeof customElements === "undefined") {
@@ -4,7 +4,7 @@ import { UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMeta
4
4
  import { d as defineCustomElement$1, T as TaskbarElement } from './snk-taskbar2.js';
5
5
  import { C as ConfigStorage } from './ConfigStorage.js';
6
6
  import { P as PresentationMode } from './index2.js';
7
- import { S as SnkMultiSelectionListDataSource, T as TaskbarProcessor } from './SnkMultiSelectionListDataSource.js';
7
+ import { T as TaskbarProcessor, S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource.js';
8
8
  import { s as store } from './index3.js';
9
9
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
10
10
  import { d as defineCustomElement$h } from './snk-actions-button2.js';
@@ -32,7 +32,6 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
32
32
  this.__registerHost();
33
33
  this.actionClick = createEvent(this, "actionClick", 7);
34
34
  this.gridDoubleClick = createEvent(this, "gridDoubleClick", 7);
35
- this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
36
35
  this._topTaskbarProcessor = new TaskbarProcessor({
37
36
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
38
37
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
@@ -49,7 +48,9 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
49
48
  this._dataState = undefined;
50
49
  this._gridConfig = undefined;
51
50
  this._popUpGridConfig = false;
51
+ this.columnFilterDataSource = new SnkMultiSelectionListDataSource();
52
52
  this.configName = undefined;
53
+ this.resourceID = undefined;
53
54
  this.selectionToastConfig = undefined;
54
55
  this.actionsList = undefined;
55
56
  this.isDetail = undefined;
@@ -108,20 +109,17 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
108
109
  this._gridConfig = config;
109
110
  }
110
111
  loadConfig() {
111
- ConfigStorage.get()
112
- .then((instance) => {
113
- instance.loadGridConfig(this.configName)
114
- .then((config) => {
115
- this.setGridConfig(config);
116
- })
117
- .catch((error) => {
118
- console.warn(error);
119
- });
112
+ ConfigStorage.loadGridConfig(this.configName, this.resourceID)
113
+ .then((config) => {
114
+ this.setGridConfig(config);
115
+ })
116
+ .catch((error) => {
117
+ console.warn(error);
120
118
  });
121
119
  }
122
120
  gridConfigChangeHandler(evt) {
123
121
  const config = evt.detail;
124
- ConfigStorage.saveGridConfig(config, this.configName);
122
+ ConfigStorage.saveGridConfig(config, this.configName, this.resourceID);
125
123
  evt.stopPropagation();
126
124
  }
127
125
  modalConfigChangeHandler(evt) {
@@ -234,10 +232,11 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
234
232
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
235
233
  }
236
234
  finshLoading() {
235
+ var _a, _b;
237
236
  this._dataUnitLoadLockerResolver = this._dataUnit.addLoadingLocker();
238
237
  this.addElementID();
239
- this._multiSelectionListDataSource.setApplication(this._application);
240
- this._multiSelectionListDataSource.setDataUnit(this._dataUnit);
238
+ (_a = this.columnFilterDataSource) === null || _a === void 0 ? void 0 : _a.setApplication(this._application);
239
+ (_b = this.columnFilterDataSource) === null || _b === void 0 ? void 0 : _b.setDataUnit(this._dataUnit);
241
240
  }
242
241
  componentWillLoad() {
243
242
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
@@ -328,13 +327,15 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
328
327
  if (!this._dataUnit) {
329
328
  return undefined;
330
329
  }
331
- return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder }), ((_b = (_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.filterConfig) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
332
- h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" }), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton() })), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: () => this.gridDoubleClick.emit(), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, onComponentReady: () => this.onEzGridReady(), columnfilterDataSource: this._multiSelectionListDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.actionsList })), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), application: this._application, selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig() }))));
330
+ return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID }), ((_b = (_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.filterConfig) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
331
+ h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" }), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID })), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: () => this.gridDoubleClick.emit(), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, onComponentReady: () => this.onEzGridReady(), columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.actionsList, resourceID: this.resourceID })), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), application: this._application, selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
333
332
  }
334
333
  get _element() { return this; }
335
334
  static get style() { return snkGridCss; }
336
335
  }, [6, "snk-grid", {
336
+ "columnFilterDataSource": [1040],
337
337
  "configName": [1, "config-name"],
338
+ "resourceID": [1, "resource-i-d"],
338
339
  "selectionToastConfig": [16],
339
340
  "actionsList": [16],
340
341
  "isDetail": [4, "is-detail"],
@@ -41,6 +41,7 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
41
41
  this.entityUri = undefined;
42
42
  this.filterId = undefined;
43
43
  this.configName = undefined;
44
+ this.resourceID = undefined;
44
45
  }
45
46
  /*
46
47
  * Cria um novo filtro se não houver nenhum filtro existente
@@ -77,17 +78,15 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
77
78
  this._filterAssistent = ObjectUtils.copy(newPersonalizedFilter);
78
79
  }
79
80
  loadFilter(newValue, oldValue) {
80
- if (newValue == null || oldValue == newValue) {
81
+ if (newValue == null || oldValue == newValue || this.resourceID == undefined) {
81
82
  return;
82
83
  }
83
- ConfigStorage.get().then((_instance) => {
84
- ConfigStorage.loadPersonalizedFilter(newValue, this.configName)
85
- .then((resp) => {
86
- const personalizedFilter = this.addLabelToItems(resp);
87
- this._filterAssistent = personalizedFilter;
88
- this._originalFilterAssistent = ObjectUtils.copy(personalizedFilter);
89
- this._filterAssistentMode = this._filterAssistent.hasOwnProperty("assistent") && this._filterAssistent.assistent != undefined;
90
- });
84
+ ConfigStorage.loadPersonalizedFilter(newValue, this.resourceID, this.configName)
85
+ .then((resp) => {
86
+ const personalizedFilter = this.addLabelToItems(resp);
87
+ this._filterAssistent = personalizedFilter;
88
+ this._originalFilterAssistent = ObjectUtils.copy(personalizedFilter);
89
+ this._filterAssistentMode = this._filterAssistent.hasOwnProperty("assistent") && this._filterAssistent.assistent != undefined;
91
90
  });
92
91
  }
93
92
  componentWillLoad() {
@@ -112,7 +111,7 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
112
111
  return this._application.messagesBuilder.getMessage(key, params);
113
112
  }
114
113
  saveFilter() {
115
- ConfigStorage.savePersonalizedFilter(this._filterAssistent, this.configName).then((personalizedFilter) => {
114
+ ConfigStorage.savePersonalizedFilter(this._filterAssistent, this.resourceID, this.configName).then((personalizedFilter) => {
116
115
  this._elButtonSave.enabled = false;
117
116
  const messageToken = !!this._filterAssistent.id ? 'confirmEdit' : 'confirmSave';
118
117
  ApplicationUtils.info(this.getMessage(`snkPersonalizedFilter.${messageToken}.title`), { iconName: "check" });
@@ -123,7 +122,7 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
123
122
  });
124
123
  }
125
124
  removeFilter() {
126
- ConfigStorage.removePersonalizedFilter(this._filterAssistent, this.configName);
125
+ ConfigStorage.removePersonalizedFilter(this._filterAssistent, this.resourceID, this.configName);
127
126
  }
128
127
  hasChangesToSave() {
129
128
  return JSON.stringify(this._filterAssistent) === JSON.stringify(this._originalFilterAssistent);
@@ -301,6 +300,7 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
301
300
  "entityUri": [1025, "entity-uri"],
302
301
  "filterId": [1025, "filter-id"],
303
302
  "configName": [1025, "config-name"],
303
+ "resourceID": [1, "resource-i-d"],
304
304
  "_filterAssistentMode": [32],
305
305
  "_filterAssistent": [32],
306
306
  "createPersonalizedFilter": [64]
@@ -1,13 +1,16 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, ObjectUtils, ApplicationContext, UserInterface } from '@sankhyalabs/core';
2
+ import { DataUnit, defaultDataLoader, StringUtils, ChangeOperation, ObjectUtils, ApplicationContext, DataType, UserInterface } from '@sankhyalabs/core';
3
3
  import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants.js';
4
4
  import { T as TaskbarElement, d as defineCustomElement$1 } from './snk-taskbar2.js';
5
5
  import './DataFetcher.js';
6
6
  import './pesquisa-fetcher.js';
7
7
  import { P as PresentationMode } from './index2.js';
8
- import { S as SnkMultiSelectionListDataSource, T as TaskbarProcessor } from './SnkMultiSelectionListDataSource.js';
9
- import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
10
8
  import { d as defineCustomElement$5 } from './snk-actions-button2.js';
9
+ import '@sankhyalabs/ezui/dist/collection/utils/constants';
10
+ import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
11
+ import './filter-item-type.enum.js';
12
+ import './form-config-fetcher.js';
13
+ import { S as SnkMultiSelectionListDataSource, T as TaskbarProcessor } from './SnkMultiSelectionListDataSource.js';
11
14
  import { d as defineCustomElement$4 } from './snk-data-exporter2.js';
12
15
  import { d as defineCustomElement$3 } from './snk-data-unit2.js';
13
16
  import { d as defineCustomElement$2 } from './snk-exporter-email-sender2.js';
@@ -18,7 +21,7 @@ class InMemoryLoader {
18
21
  this.metadata = metadata;
19
22
  this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
20
23
  this._dataUnit.metadataLoader = () => this.metadaLoader();
21
- this._dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
24
+ this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this._records);
22
25
  this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
23
26
  this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
24
27
  this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
@@ -55,62 +58,6 @@ class InMemoryLoader {
55
58
  metadaLoader() {
56
59
  return Promise.resolve(this._metadata);
57
60
  }
58
- dataLoader(dataUnit, request) {
59
- const filters = this.getColumnFilters(dataUnit);
60
- let records = this.applyFilters(filters);
61
- if (request.sort) {
62
- request.sort.forEach(sort => {
63
- records = records.sort((recordA, recordB) => {
64
- const fieldA = recordA[sort.field];
65
- const fieldB = recordB[sort.field];
66
- const sortFn = this.getSortFn(sort.dataType);
67
- return sortFn(fieldA, fieldB) * (sort.mode == SortMode.ASC ? 1 : -1);
68
- });
69
- });
70
- }
71
- return Promise.resolve({ records: records });
72
- }
73
- applyFilters(filters) {
74
- let records = [...this._records];
75
- filters.forEach(filter => {
76
- records = records.filter(record => { var _a; return filter.values.includes((_a = record[filter.column]) === null || _a === void 0 ? void 0 : _a.toString()); });
77
- });
78
- return records;
79
- }
80
- getColumnFilters(dataUnit) {
81
- var _a, _b;
82
- const allFilters = (_a = dataUnit.getFilters()) !== null && _a !== void 0 ? _a : [];
83
- const columnFilters = (_b = allFilters.filter(filter => { var _a; return (_a = filter.name) === null || _a === void 0 ? void 0 : _a.includes(DISTINCT_FILTER_NAME_PREFIX); })) !== null && _b !== void 0 ? _b : [];
84
- return columnFilters.map(filter => {
85
- var _a, _b;
86
- return {
87
- column: (_b = (_a = filter.name) === null || _a === void 0 ? void 0 : _a.replace(DISTINCT_FILTER_NAME_PREFIX, "")) !== null && _b !== void 0 ? _b : "",
88
- values: filter.params.map(param => param.value),
89
- };
90
- });
91
- }
92
- getSortFn(type) {
93
- switch (type) {
94
- case DataType.NUMBER:
95
- return this.sortNumber;
96
- case DataType.DATE:
97
- return this.sortDate;
98
- case DataType.OBJECT:
99
- return this.sortObject;
100
- default:
101
- return StringUtils.compare;
102
- }
103
- }
104
- sortObject(a, b) {
105
- return StringUtils.compare(a === null || a === void 0 ? void 0 : a["label"], b === null || b === void 0 ? void 0 : b["label"]);
106
- }
107
- sortNumber(a, b) {
108
- return a - b;
109
- }
110
- sortDate(a, b) {
111
- let timeA = a.getTime(), timeB = b.getTime();
112
- return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
113
- }
114
61
  saveLoader(_dataUnit, changes) {
115
62
  return new Promise((resolve) => {
116
63
  let dataUnitRecords = [];
@@ -154,6 +101,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
154
101
  this.dataStateChange = createEvent(this, "dataStateChange", 3);
155
102
  this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
156
103
  this.actionClick = createEvent(this, "actionClick", 7);
104
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
157
105
  this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER"];
158
106
  this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
159
107
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
@@ -145,6 +145,7 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
145
145
  };
146
146
  this._permissions = undefined;
147
147
  this.configName = undefined;
148
+ this.resourceID = undefined;
148
149
  this.buttons = undefined;
149
150
  this.customButtons = undefined;
150
151
  this.actionsList = undefined;
@@ -286,7 +287,7 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
286
287
  componentWillLoad() {
287
288
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
288
289
  if (this._application) {
289
- this._application.getAllAccess().then(access => this._permissions = access);
290
+ this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
290
291
  }
291
292
  else {
292
293
  this._permissions = {};
@@ -330,6 +331,7 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
330
331
  static get style() { return snkTaskbarCss; }
331
332
  }, [6, "snk-taskbar", {
332
333
  "configName": [1, "config-name"],
334
+ "resourceID": [1, "resource-i-d"],
333
335
  "buttons": [1],
334
336
  "customButtons": [16],
335
337
  "actionsList": [16],
@@ -1,8 +1,6 @@
1
- import { ApplicationContext } from '@sankhyalabs/core';
2
- import { F as FormConfigFetcher } from './form-config-fetcher-9e167008.js';
3
- import { R as ResourceFetcher } from './resource-fetcher-768d5556.js';
4
- import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher-06e02851.js';
5
- import { d as dist, D as DataFetcher } from './DataFetcher-e0fc5549.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-aaaa79a6.js';
2
+ import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
3
+ import { d as dist, D as DataFetcher } from './DataFetcher-7e18aa30.js';
6
4
 
7
5
  class GridConfigFetcher extends ResourceFetcher {
8
6
  constructor() {
@@ -44,6 +42,131 @@ class GridConfigFetcher extends ResourceFetcher {
44
42
  }
45
43
  }
46
44
 
45
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
46
+ var t = {};
47
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
48
+ t[p] = s[p];
49
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
50
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
51
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
52
+ t[p[i]] = s[p[i]];
53
+ }
54
+ return t;
55
+ };
56
+ function normalizeValue(value, type) {
57
+ if (value == undefined) {
58
+ return value;
59
+ }
60
+ if (value instanceof Date) {
61
+ return value.toISOString();
62
+ }
63
+ if (typeof value === "object") {
64
+ if (value instanceof Array) {
65
+ return value.map(item => {
66
+ if (FilterItemType.MULTI_LIST === type) {
67
+ const values = __rest(item, ["label"]);
68
+ return normalizeValue(values);
69
+ }
70
+ return normalizeValue(item);
71
+ });
72
+ }
73
+ else {
74
+ const normalized = Object.assign({}, value);
75
+ Object.keys(value).forEach(prop => {
76
+ if (value[prop] !== undefined) {
77
+ normalized[prop] = normalizeValue(value[prop], type);
78
+ }
79
+ else {
80
+ delete normalized[prop];
81
+ }
82
+ });
83
+ return normalized;
84
+ }
85
+ }
86
+ return value;
87
+ }
88
+ class FilterBarConfigFetcher extends ResourceFetcher {
89
+ normalize(items) {
90
+ return items.map(item => {
91
+ const { id, value, fixed, visible, type, groupedItems } = item;
92
+ const stateItem = { id };
93
+ if (value) {
94
+ stateItem["value"] = normalizeValue(value, type);
95
+ }
96
+ if (fixed) {
97
+ stateItem["fixed"] = fixed;
98
+ }
99
+ if (groupedItems) {
100
+ if (groupedItems.length === 0) {
101
+ return;
102
+ }
103
+ if (groupedItems.filter(item => item.visible).length > 0) {
104
+ stateItem["visible"] = true;
105
+ }
106
+ stateItem["groupedItems"] = this.normalize(groupedItems);
107
+ }
108
+ else {
109
+ if (visible) {
110
+ stateItem["visible"] = true;
111
+ }
112
+ }
113
+ return stateItem;
114
+ }).filter(item => item != undefined);
115
+ }
116
+ saveConfig(items, resourceID, configName) {
117
+ return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
118
+ }
119
+ getConfig(resourceID, configName, urlParams) {
120
+ return new Promise((accept, reject) => {
121
+ this.loadResource(this.getPath(resourceID, configName, urlParams))
122
+ .then((configAsString) => {
123
+ let fieldsList;
124
+ if (configAsString) {
125
+ const filterBarConfig = JSON.parse(configAsString);
126
+ fieldsList = this.buildFieldList(filterBarConfig.items);
127
+ }
128
+ accept(fieldsList || []);
129
+ })
130
+ .catch((error) => {
131
+ reject(error);
132
+ });
133
+ });
134
+ }
135
+ buildFieldList(items) {
136
+ return items.map(item => {
137
+ var _a, _b;
138
+ if (item.type === FilterItemType.MULTI_LIST) {
139
+ const multiListValue = item.value;
140
+ 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;
141
+ }
142
+ return item;
143
+ });
144
+ }
145
+ getPath(resourceID, name, urlParams) {
146
+ let path = `cfg://filter/FilterBarState:${resourceID}`;
147
+ if (name) {
148
+ path += `.${name}`;
149
+ }
150
+ if (urlParams) {
151
+ path += this.buildQueryString(urlParams);
152
+ }
153
+ return path;
154
+ }
155
+ buildQueryString(urlParams) {
156
+ let queryString = '?';
157
+ for (let key in urlParams) {
158
+ if (!urlParams.hasOwnProperty(key)) {
159
+ continue;
160
+ }
161
+ if (queryString.length > 1) {
162
+ queryString += '&';
163
+ }
164
+ queryString += key + '=' + urlParams[key];
165
+ }
166
+ return queryString;
167
+ }
168
+ }
169
+
47
170
  class PersonalizedFilterFetcher {
48
171
  constructor() {
49
172
  this.templateByQuery = new Map();
@@ -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 };