@sankhyalabs/sankhyablocks 8.2.0-dev.1 → 8.2.0

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 (221) hide show
  1. package/dist/cjs/{ConfigStorage-12397f18.js → ConfigStorage-e9d7fa82.js} +51 -163
  2. package/dist/cjs/{DataFetcher-f2da1f79.js → DataFetcher-39b63a1e.js} +29 -67
  3. package/dist/cjs/{SnkFormConfigManager-13f79e37.js → SnkFormConfigManager-2f8eccd9.js} +21 -19
  4. package/dist/cjs/{dataunit-fetcher-e72068c1.js → dataunit-fetcher-15a7cc88.js} +1 -1
  5. package/dist/cjs/filter-bar-config-fetcher-24548cec.js +155 -0
  6. package/dist/cjs/{form-config-fetcher-5d62ab62.js → form-config-fetcher-ab3ce222.js} +3 -66
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/{pesquisa-fetcher-8c363096.js → pesquisa-fetcher-96c042aa.js} +1 -1
  9. package/dist/cjs/resource-fetcher-64102551.js +68 -0
  10. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  11. package/dist/cjs/snk-actions-button.cjs.entry.js +11 -18
  12. package/dist/cjs/snk-application.cjs.entry.js +73 -51
  13. package/dist/cjs/snk-attach.cjs.entry.js +13 -7
  14. package/dist/cjs/snk-configurator.cjs.entry.js +1 -2
  15. package/dist/cjs/snk-crud.cjs.entry.js +9 -28
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  17. package/dist/cjs/{snk-data-unit-80a00ae4.js → snk-data-unit-d5109a08.js} +6 -8
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +25 -18
  20. package/dist/cjs/snk-entity-list.cjs.entry.js +4 -0
  21. package/dist/cjs/snk-filter-bar.cjs.entry.js +17 -14
  22. package/dist/cjs/snk-filter-detail.cjs.entry.js +15 -1
  23. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +19 -5
  24. package/dist/cjs/snk-form-config.cjs.entry.js +17 -6
  25. package/dist/cjs/snk-form-view.cjs.entry.js +1 -6
  26. package/dist/cjs/snk-form.cjs.entry.js +8 -12
  27. package/dist/cjs/snk-grid-config.cjs.entry.js +6 -5
  28. package/dist/cjs/snk-grid.cjs.entry.js +20 -20
  29. package/dist/cjs/{snk-guides-viewer-a7cd6fda.js → snk-guides-viewer-8c9693aa.js} +9 -18
  30. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  31. package/dist/cjs/snk-personalized-filter.cjs.entry.js +16 -13
  32. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-simple-crud.cjs.entry.js +80 -22
  34. package/dist/cjs/snk-taskbar.cjs.entry.js +1 -2
  35. package/dist/collection/components/snk-actions-button/actions/index.js +4 -3
  36. package/dist/collection/components/snk-actions-button/snk-actions-button.js +4 -8
  37. package/dist/collection/components/snk-application/snk-application.js +65 -60
  38. package/dist/collection/components/snk-configurator/snk-configurator.js +1 -19
  39. package/dist/collection/components/snk-crud/snk-crud.js +8 -63
  40. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +15 -65
  41. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +1 -27
  42. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +30 -66
  43. package/dist/collection/components/snk-data-unit/snk-data-unit.js +7 -42
  44. package/dist/collection/components/snk-entity-list/snk-entity-list.js +23 -0
  45. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +12 -2
  46. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
  47. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +16 -21
  48. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +12 -28
  49. package/dist/collection/components/snk-form/SnkFormConfigManager.js +19 -17
  50. package/dist/collection/components/snk-form/snk-form.js +2 -46
  51. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +15 -5
  52. package/dist/collection/components/snk-grid/snk-grid.js +16 -110
  53. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +1 -19
  54. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +12 -28
  55. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +9 -43
  56. package/dist/collection/components/snk-taskbar/snk-taskbar.js +1 -19
  57. package/dist/collection/lib/configs/ConfigStorage.js +44 -33
  58. package/dist/collection/lib/dataUnit/InMemoryLoader.js +59 -2
  59. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +29 -38
  60. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +24 -0
  61. package/dist/collection/lib/index.js +0 -10
  62. package/dist/collection/lib/utils/urlutils.js +0 -29
  63. package/dist/components/ConfigStorage.js +48 -161
  64. package/dist/components/DataFetcher.js +29 -67
  65. package/dist/components/SnkFormConfigManager.js +19 -17
  66. package/dist/components/filter-bar-config-fetcher.js +153 -0
  67. package/dist/components/form-config-fetcher.js +2 -64
  68. package/dist/components/resource-fetcher.js +66 -0
  69. package/dist/components/snk-actions-button2.js +9 -23
  70. package/dist/components/snk-application2.js +154 -132
  71. package/dist/components/snk-attach2.js +8 -1
  72. package/dist/components/snk-configurator2.js +1 -3
  73. package/dist/components/snk-crud.js +7 -29
  74. package/dist/components/snk-data-unit2.js +6 -10
  75. package/dist/components/snk-detail-view2.js +23 -28
  76. package/dist/components/snk-entity-list.js +4 -0
  77. package/dist/components/snk-filter-bar2.js +12 -12
  78. package/dist/components/snk-filter-detail2.js +12 -2
  79. package/dist/components/snk-filter-modal-item2.js +16 -5
  80. package/dist/components/snk-form-config2.js +15 -5
  81. package/dist/components/snk-form-view2.js +1 -6
  82. package/dist/components/snk-form.js +2 -9
  83. package/dist/components/snk-grid-config2.js +2 -4
  84. package/dist/components/snk-grid2.js +16 -23
  85. package/dist/components/snk-personalized-filter2.js +11 -11
  86. package/dist/components/snk-simple-crud2.js +69 -12
  87. package/dist/components/snk-taskbar2.js +1 -3
  88. package/dist/esm/{ConfigStorage-932ab366.js → ConfigStorage-1090289a.js} +49 -162
  89. package/dist/esm/{DataFetcher-7e18aa30.js → DataFetcher-a4ed43e7.js} +29 -67
  90. package/dist/esm/{SnkFormConfigManager-bb9afc3f.js → SnkFormConfigManager-de537eca.js} +21 -19
  91. package/dist/esm/{dataunit-fetcher-91a4eb82.js → dataunit-fetcher-8d0bfa4a.js} +1 -1
  92. package/dist/esm/filter-bar-config-fetcher-2417b8cf.js +153 -0
  93. package/dist/esm/{form-config-fetcher-aaaa79a6.js → form-config-fetcher-4065db9a.js} +3 -65
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/esm/{pesquisa-fetcher-56b30fb4.js → pesquisa-fetcher-7460b876.js} +1 -1
  96. package/dist/esm/resource-fetcher-45a70066.js +66 -0
  97. package/dist/esm/sankhyablocks.js +1 -1
  98. package/dist/esm/snk-actions-button.entry.js +11 -18
  99. package/dist/esm/snk-application.entry.js +71 -49
  100. package/dist/esm/snk-attach.entry.js +9 -3
  101. package/dist/esm/snk-configurator.entry.js +1 -2
  102. package/dist/esm/snk-crud.entry.js +9 -28
  103. package/dist/esm/snk-data-exporter.entry.js +2 -2
  104. package/dist/esm/{snk-data-unit-3ab57d1a.js → snk-data-unit-3a0bbfcb.js} +6 -8
  105. package/dist/esm/snk-data-unit.entry.js +1 -1
  106. package/dist/esm/snk-detail-view.entry.js +25 -18
  107. package/dist/esm/snk-entity-list.entry.js +4 -0
  108. package/dist/esm/snk-filter-bar.entry.js +17 -14
  109. package/dist/esm/snk-filter-detail.entry.js +16 -2
  110. package/dist/esm/snk-filter-modal-item.entry.js +20 -6
  111. package/dist/esm/snk-form-config.entry.js +18 -7
  112. package/dist/esm/snk-form-view.entry.js +1 -6
  113. package/dist/esm/snk-form.entry.js +8 -12
  114. package/dist/esm/snk-grid-config.entry.js +6 -5
  115. package/dist/esm/snk-grid.entry.js +20 -20
  116. package/dist/esm/{snk-guides-viewer-cc709b5f.js → snk-guides-viewer-a6d39c18.js} +9 -18
  117. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  118. package/dist/esm/snk-personalized-filter.entry.js +16 -13
  119. package/dist/esm/snk-print-selector.entry.js +1 -1
  120. package/dist/esm/snk-simple-crud.entry.js +71 -13
  121. package/dist/esm/snk-taskbar.entry.js +1 -2
  122. package/dist/sankhyablocks/p-0fb83448.js +1 -0
  123. package/dist/sankhyablocks/p-15aba6fb.entry.js +11 -0
  124. package/dist/sankhyablocks/p-216f081a.entry.js +1 -0
  125. package/dist/sankhyablocks/p-21e7c08e.entry.js +1 -0
  126. package/dist/sankhyablocks/p-2861d44f.entry.js +1 -0
  127. package/dist/sankhyablocks/p-2d883fe9.entry.js +1 -0
  128. package/dist/sankhyablocks/{p-d13c00b6.entry.js → p-3d6f91c2.entry.js} +1 -1
  129. package/dist/sankhyablocks/{p-f8e6b97e.js → p-44e66c8d.js} +1 -1
  130. package/dist/sankhyablocks/p-4514fc6a.entry.js +1 -0
  131. package/dist/sankhyablocks/p-4f4cd005.entry.js +1 -0
  132. package/dist/sankhyablocks/p-50c13cc8.entry.js +1 -0
  133. package/dist/sankhyablocks/p-52c6b2e7.js +1 -0
  134. package/dist/sankhyablocks/p-5994af77.js +56 -0
  135. package/dist/sankhyablocks/p-5df17074.js +1 -0
  136. package/dist/sankhyablocks/p-6bb904bb.entry.js +1 -0
  137. package/dist/sankhyablocks/p-6f0795c8.entry.js +1 -0
  138. package/dist/sankhyablocks/p-7588f006.entry.js +1 -0
  139. package/dist/sankhyablocks/p-847e6c20.js +17 -0
  140. package/dist/sankhyablocks/p-9471cbc9.entry.js +1 -0
  141. package/dist/sankhyablocks/{p-14eac6fe.js → p-9d18017a.js} +1 -1
  142. package/dist/sankhyablocks/p-9edad923.js +1 -0
  143. package/dist/sankhyablocks/p-a42dd503.entry.js +1 -0
  144. package/dist/sankhyablocks/{p-2d333d22.js → p-b978da60.js} +1 -1
  145. package/dist/sankhyablocks/p-befbc9ee.entry.js +1 -0
  146. package/dist/sankhyablocks/p-c6380ea2.entry.js +1 -0
  147. package/dist/sankhyablocks/{p-03bb1aea.entry.js → p-c6feb995.entry.js} +1 -1
  148. package/dist/sankhyablocks/p-c945318c.entry.js +1 -0
  149. package/dist/sankhyablocks/p-ccbfb1cf.entry.js +1 -0
  150. package/dist/sankhyablocks/p-d7c7a289.entry.js +1 -0
  151. package/dist/sankhyablocks/p-de69b4b0.entry.js +1 -0
  152. package/dist/sankhyablocks/p-f3b7b69e.js +10 -0
  153. package/dist/sankhyablocks/p-f7eded3a.entry.js +1 -0
  154. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  155. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -2
  156. package/dist/types/components/snk-application/snk-application.d.ts +13 -8
  157. package/dist/types/components/snk-configurator/snk-configurator.d.ts +0 -4
  158. package/dist/types/components/snk-crud/snk-crud.d.ts +0 -10
  159. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +0 -13
  160. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +0 -5
  161. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +2 -13
  162. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +0 -8
  163. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +4 -0
  164. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +3 -0
  165. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
  166. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +4 -5
  167. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -4
  168. package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +4 -5
  169. package/dist/types/components/snk-form/snk-form.d.ts +1 -9
  170. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +2 -0
  171. package/dist/types/components/snk-grid/snk-grid.d.ts +1 -18
  172. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +0 -4
  173. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +1 -5
  174. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -8
  175. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +0 -4
  176. package/dist/types/components.d.ts +21 -189
  177. package/dist/types/lib/configs/ConfigStorage.d.ts +13 -11
  178. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +7 -0
  179. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  180. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +1 -0
  181. package/dist/types/lib/index.d.ts +0 -11
  182. package/dist/types/lib/utils/urlutils.d.ts +0 -14
  183. package/package.json +2 -2
  184. package/dist/cjs/ISave-d68ce3cd.js +0 -8
  185. package/dist/cjs/ResourceIDUtils-5ff86aa7.js +0 -12
  186. package/dist/cjs/auth-fetcher-319a4cb2.js +0 -34
  187. package/dist/collection/lib/resourceid/ResourceIDUtils.js +0 -7
  188. package/dist/components/ResourceIDUtils.js +0 -10
  189. package/dist/components/auth-fetcher.js +0 -32
  190. package/dist/esm/ISave-4412b20c.js +0 -8
  191. package/dist/esm/ResourceIDUtils-a114189a.js +0 -10
  192. package/dist/esm/auth-fetcher-6d9664b7.js +0 -32
  193. package/dist/sankhyablocks/p-01739b21.entry.js +0 -1
  194. package/dist/sankhyablocks/p-05dbc70e.entry.js +0 -1
  195. package/dist/sankhyablocks/p-41e897f1.js +0 -56
  196. package/dist/sankhyablocks/p-48a40939.js +0 -1
  197. package/dist/sankhyablocks/p-611aa624.entry.js +0 -1
  198. package/dist/sankhyablocks/p-66bb8c20.entry.js +0 -1
  199. package/dist/sankhyablocks/p-688dcb4c.js +0 -1
  200. package/dist/sankhyablocks/p-6f154396.entry.js +0 -1
  201. package/dist/sankhyablocks/p-787071a8.js +0 -1
  202. package/dist/sankhyablocks/p-8481bb59.entry.js +0 -1
  203. package/dist/sankhyablocks/p-8818d8f6.entry.js +0 -1
  204. package/dist/sankhyablocks/p-93f6ca04.entry.js +0 -1
  205. package/dist/sankhyablocks/p-9a270401.entry.js +0 -1
  206. package/dist/sankhyablocks/p-9e7d65a4.js +0 -1
  207. package/dist/sankhyablocks/p-a52a6c9d.js +0 -26
  208. package/dist/sankhyablocks/p-b6003974.entry.js +0 -1
  209. package/dist/sankhyablocks/p-c555075c.entry.js +0 -1
  210. package/dist/sankhyablocks/p-d4f9ee17.entry.js +0 -1
  211. package/dist/sankhyablocks/p-d53a9169.entry.js +0 -1
  212. package/dist/sankhyablocks/p-d7638f45.entry.js +0 -11
  213. package/dist/sankhyablocks/p-e086cc2a.entry.js +0 -1
  214. package/dist/sankhyablocks/p-e64f3e17.entry.js +0 -1
  215. package/dist/sankhyablocks/p-ed41b38c.js +0 -1
  216. package/dist/sankhyablocks/p-ed705cbb.entry.js +0 -1
  217. package/dist/sankhyablocks/p-efc10705.entry.js +0 -1
  218. package/dist/sankhyablocks/p-f74fe358.js +0 -1
  219. package/dist/sankhyablocks/p-f91e0c5d.entry.js +0 -1
  220. package/dist/sankhyablocks/p-fa523d6b.entry.js +0 -1
  221. package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +0 -3
@@ -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 { T as TaskbarProcessor, S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource.js';
7
+ import { S as SnkMultiSelectionListDataSource, T as TaskbarProcessor } 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,6 +32,7 @@ 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();
35
36
  this._topTaskbarProcessor = new TaskbarProcessor({
36
37
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
37
38
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
@@ -48,9 +49,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
48
49
  this._dataState = undefined;
49
50
  this._gridConfig = undefined;
50
51
  this._popUpGridConfig = false;
51
- this.columnFilterDataSource = new SnkMultiSelectionListDataSource();
52
52
  this.configName = undefined;
53
- this.resourceID = undefined;
54
53
  this.selectionToastConfig = undefined;
55
54
  this.actionsList = undefined;
56
55
  this.isDetail = undefined;
@@ -59,9 +58,6 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
59
58
  this.multipleSelection = undefined;
60
59
  this.presentationMode = PresentationMode.PRIMARY;
61
60
  this.messagesBuilder = undefined;
62
- this.useEnterLikeTab = false;
63
- this.recordsValidator = undefined;
64
- this.canEdit = true;
65
61
  }
66
62
  /**
67
63
  * Exibe a janela de configurações da grade.
@@ -109,17 +105,20 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
109
105
  this._gridConfig = config;
110
106
  }
111
107
  loadConfig() {
112
- ConfigStorage.loadGridConfig(this.configName, this.resourceID)
113
- .then((config) => {
114
- this.setGridConfig(config);
115
- })
116
- .catch((error) => {
117
- console.warn(error);
108
+ ConfigStorage.get()
109
+ .then((instance) => {
110
+ instance.loadGridConfig(this.configName)
111
+ .then((config) => {
112
+ this.setGridConfig(config);
113
+ })
114
+ .catch((error) => {
115
+ console.warn(error);
116
+ });
118
117
  });
119
118
  }
120
119
  gridConfigChangeHandler(evt) {
121
120
  const config = evt.detail;
122
- ConfigStorage.saveGridConfig(config, this.configName, this.resourceID);
121
+ ConfigStorage.saveGridConfig(config, this.configName);
123
122
  evt.stopPropagation();
124
123
  }
125
124
  modalConfigChangeHandler(evt) {
@@ -232,11 +231,10 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
232
231
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
233
232
  }
234
233
  finshLoading() {
235
- var _a, _b;
236
234
  this._dataUnitLoadLockerResolver = this._dataUnit.addLoadingLocker();
237
235
  this.addElementID();
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);
236
+ this._multiSelectionListDataSource.setApplication(this._application);
237
+ this._multiSelectionListDataSource.setDataUnit(this._dataUnit);
240
238
  }
241
239
  componentWillLoad() {
242
240
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
@@ -327,15 +325,13 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
327
325
  if (!this._dataUnit) {
328
326
  return undefined;
329
327
  }
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 }))));
328
+ 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 &&
329
+ 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 }, 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() }))));
332
330
  }
333
331
  get _element() { return this; }
334
332
  static get style() { return snkGridCss; }
335
333
  }, [6, "snk-grid", {
336
- "columnFilterDataSource": [1040],
337
334
  "configName": [1, "config-name"],
338
- "resourceID": [1, "resource-i-d"],
339
335
  "selectionToastConfig": [16],
340
336
  "actionsList": [16],
341
337
  "isDetail": [4, "is-detail"],
@@ -344,9 +340,6 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
344
340
  "multipleSelection": [4, "multiple-selection"],
345
341
  "presentationMode": [1, "presentation-mode"],
346
342
  "messagesBuilder": [1040],
347
- "useEnterLikeTab": [4, "use-enter-like-tab"],
348
- "recordsValidator": [16],
349
- "canEdit": [4, "can-edit"],
350
343
  "_dataUnit": [32],
351
344
  "_dataState": [32],
352
345
  "_gridConfig": [32],
@@ -41,7 +41,6 @@ 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;
45
44
  }
46
45
  /*
47
46
  * Cria um novo filtro se não houver nenhum filtro existente
@@ -78,15 +77,17 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
78
77
  this._filterAssistent = ObjectUtils.copy(newPersonalizedFilter);
79
78
  }
80
79
  loadFilter(newValue, oldValue) {
81
- if (newValue == null || oldValue == newValue || this.resourceID == undefined) {
80
+ if (newValue == null || oldValue == newValue) {
82
81
  return;
83
82
  }
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;
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
+ });
90
91
  });
91
92
  }
92
93
  componentWillLoad() {
@@ -111,7 +112,7 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
111
112
  return this._application.messagesBuilder.getMessage(key, params);
112
113
  }
113
114
  saveFilter() {
114
- ConfigStorage.savePersonalizedFilter(this._filterAssistent, this.resourceID, this.configName).then((personalizedFilter) => {
115
+ ConfigStorage.savePersonalizedFilter(this._filterAssistent, this.configName).then((personalizedFilter) => {
115
116
  this._elButtonSave.enabled = false;
116
117
  const messageToken = !!this._filterAssistent.id ? 'confirmEdit' : 'confirmSave';
117
118
  ApplicationUtils.info(this.getMessage(`snkPersonalizedFilter.${messageToken}.title`), { iconName: "check" });
@@ -122,7 +123,7 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
122
123
  });
123
124
  }
124
125
  removeFilter() {
125
- ConfigStorage.removePersonalizedFilter(this._filterAssistent, this.resourceID, this.configName);
126
+ ConfigStorage.removePersonalizedFilter(this._filterAssistent, this.configName);
126
127
  }
127
128
  hasChangesToSave() {
128
129
  return JSON.stringify(this._filterAssistent) === JSON.stringify(this._originalFilterAssistent);
@@ -300,7 +301,6 @@ const SnkPersonalizedFilter = /*@__PURE__*/ proxyCustomElement(class extends HTM
300
301
  "entityUri": [1025, "entity-uri"],
301
302
  "filterId": [1025, "filter-id"],
302
303
  "configName": [1025, "config-name"],
303
- "resourceID": [1, "resource-i-d"],
304
304
  "_filterAssistentMode": [32],
305
305
  "_filterAssistent": [32],
306
306
  "createPersonalizedFilter": [64]
@@ -1,16 +1,13 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { DataUnit, defaultDataLoader, StringUtils, ChangeOperation, ObjectUtils, ApplicationContext, DataType, UserInterface } from '@sankhyalabs/core';
2
+ import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, ObjectUtils, ApplicationContext, 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 { 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
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
+ import { d as defineCustomElement$5 } from './snk-actions-button2.js';
14
11
  import { d as defineCustomElement$4 } from './snk-data-exporter2.js';
15
12
  import { d as defineCustomElement$3 } from './snk-data-unit2.js';
16
13
  import { d as defineCustomElement$2 } from './snk-exporter-email-sender2.js';
@@ -21,7 +18,7 @@ class InMemoryLoader {
21
18
  this.metadata = metadata;
22
19
  this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
23
20
  this._dataUnit.metadataLoader = () => this.metadaLoader();
24
- this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this._records);
21
+ this._dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
25
22
  this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
26
23
  this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
27
24
  this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
@@ -58,6 +55,62 @@ class InMemoryLoader {
58
55
  metadaLoader() {
59
56
  return Promise.resolve(this._metadata);
60
57
  }
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
+ }
61
114
  saveLoader(_dataUnit, changes) {
62
115
  return new Promise((resolve) => {
63
116
  let dataUnitRecords = [];
@@ -101,10 +154,14 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
101
154
  this.dataStateChange = createEvent(this, "dataStateChange", 3);
102
155
  this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
103
156
  this.actionClick = createEvent(this, "actionClick", 7);
104
- this.formItemsReady = createEvent(this, "formItemsReady", 7);
105
157
  this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER"];
106
158
  this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
107
159
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
160
+ // /**
161
+ // * Quando verdadeiro, o ENTER fará a navegação como se fosse a tecla TAB na grade.
162
+ // */
163
+ // @Prop()
164
+ // useEnterLikeTab: boolean = false;
108
165
  this._taskbarProcessor = new TaskbarProcessor({
109
166
  "snkSimpleCrudTaskbar.form_regular": this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(TaskbarElement.GRID_MODE),
110
167
  "snkSimpleCrudTaskbar.grid_regular": this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(TaskbarElement.FORM_MODE),
@@ -123,7 +180,6 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
123
180
  this.useCancelConfirm = true;
124
181
  this.taskbarManager = undefined;
125
182
  this.messagesBuilder = undefined;
126
- this.useEnterLikeTab = false;
127
183
  }
128
184
  resolveInMemoryBtns(taskbarButtons) {
129
185
  const newTaskBarConfig = [...taskbarButtons];
@@ -268,9 +324,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
268
324
  }
269
325
  render() {
270
326
  var _a;
271
- return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
327
+ return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail),
328
+ // ignoreSaveMessage={this._currentViewMode === VIEW_MODE.GRID}
329
+ onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
272
330
  ? undefined
273
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig }))))));
331
+ : this._multiSelectionListDataSource }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig }))))));
274
332
  }
275
333
  get _element() { return this; }
276
334
  static get watchers() { return {
@@ -288,7 +346,6 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
288
346
  "useCancelConfirm": [4, "use-cancel-confirm"],
289
347
  "taskbarManager": [16],
290
348
  "messagesBuilder": [1040],
291
- "useEnterLikeTab": [4, "use-enter-like-tab"],
292
349
  "_currentViewMode": [32],
293
350
  "_config": [32],
294
351
  "goToView": [64],
@@ -145,7 +145,6 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
145
145
  };
146
146
  this._permissions = undefined;
147
147
  this.configName = undefined;
148
- this.resourceID = undefined;
149
148
  this.buttons = undefined;
150
149
  this.customButtons = undefined;
151
150
  this.actionsList = undefined;
@@ -287,7 +286,7 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
287
286
  componentWillLoad() {
288
287
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
289
288
  if (this._application) {
290
- this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
289
+ this._application.getAllAccess().then(access => this._permissions = access);
291
290
  }
292
291
  else {
293
292
  this._permissions = {};
@@ -331,7 +330,6 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
331
330
  static get style() { return snkTaskbarCss; }
332
331
  }, [6, "snk-taskbar", {
333
332
  "configName": [1, "config-name"],
334
- "resourceID": [1, "resource-i-d"],
335
333
  "buttons": [1],
336
334
  "customButtons": [16],
337
335
  "actionsList": [16],
@@ -1,6 +1,8 @@
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';
1
+ import { ApplicationContext } from '@sankhyalabs/core';
2
+ import { F as FormConfigFetcher } from './form-config-fetcher-4065db9a.js';
3
+ import { R as ResourceFetcher } from './resource-fetcher-45a70066.js';
4
+ import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher-2417b8cf.js';
5
+ import { d as dist, D as DataFetcher } from './DataFetcher-a4ed43e7.js';
4
6
 
5
7
  class GridConfigFetcher extends ResourceFetcher {
6
8
  constructor() {
@@ -42,131 +44,6 @@ class GridConfigFetcher extends ResourceFetcher {
42
44
  }
43
45
  }
44
46
 
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
-
170
47
  class PersonalizedFilterFetcher {
171
48
  constructor() {
172
49
  this.templateByQuery = new Map();
@@ -341,73 +218,83 @@ const CONFIG_SOURCE = {
341
218
  filterBar: "filterBar"
342
219
  };
343
220
  class ConfigStorage {
344
- static preload(resourceID, configName) {
345
- ConfigStorage.loadFormConfig(configName, resourceID);
346
- ConfigStorage.loadGridConfig(configName, resourceID);
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;
347
234
  }
348
- static async loadFilterBarConfig(name, resourceID, urlParams) {
349
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
235
+ async loadFilterBarConfig(name, urlParams) {
236
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar);
350
237
  if (!ConfigStorage.configById.has(cacheID)) {
351
- ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
238
+ ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(ConfigStorage.resourceID, name, urlParams));
352
239
  }
353
240
  return ConfigStorage.configById.get(cacheID);
354
241
  }
355
- static async loadFormConfig(name, resourceID) {
356
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
242
+ async loadFormConfig(name) {
243
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form);
357
244
  if (!ConfigStorage.configById.has(cacheID)) {
358
- ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
245
+ ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, ConfigStorage.resourceID));
359
246
  }
360
247
  return ConfigStorage.configById.get(cacheID);
361
248
  }
362
- static async loadGridConfig(name, resourceID) {
363
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
249
+ async loadGridConfig(name) {
250
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid);
364
251
  if (!ConfigStorage.configById.has(cacheID)) {
365
- ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
252
+ ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, ConfigStorage.resourceID));
366
253
  }
367
254
  return ConfigStorage.configById.get(cacheID);
368
255
  }
369
- static async saveFilterBarConfig(config, name, resourceID) {
370
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
256
+ static async saveFilterBarConfig(config, name) {
257
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar);
371
258
  this.configById.delete(cacheID);
372
- return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
259
+ return this.filterBarConfigFetcher.saveConfig(config, this.resourceID, name);
373
260
  }
374
- static async saveFormConfig(config, name, resourceID) {
375
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
261
+ static async saveFormConfig(config, name) {
262
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form);
376
263
  this.configById.delete(cacheID);
377
- return this.formConfigFetcher.saveConfig(config, name, resourceID);
264
+ return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
378
265
  }
379
- static async saveCardState(config, name, resourceID) {
380
- return this.formConfigFetcher.saveCardState(config, name, resourceID);
266
+ static async saveCardState(config, name) {
267
+ return this.formConfigFetcher.saveCardState(config, name, this.resourceID);
381
268
  }
382
- static async saveGridConfig(config, name, resourceID) {
269
+ static async saveGridConfig(config, name) {
383
270
  if (config == undefined) {
384
271
  return;
385
272
  }
386
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
273
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid);
387
274
  this.configById.delete(cacheID);
388
- return this.gridConfigFetcher.saveConfig(config, name, resourceID);
275
+ return this.gridConfigFetcher.saveConfig(config, name, this.resourceID);
389
276
  }
390
- static async loadPersonalizedFilter(filterId, resourceID, configName) {
391
- return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName);
277
+ static async loadPersonalizedFilter(filterId, configName) {
278
+ return this.personalizedFilterFetcher.loadPersonalizedFilter(this.resourceID, filterId, configName);
392
279
  }
393
- static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
280
+ static async savePersonalizedFilter(personalizedFilter, configName) {
394
281
  //Ao criar ou alterar um filtro personalizado,
395
282
  //precisamos remover o cache do status da filterbar.
396
- const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar, resourceID);
283
+ const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar);
397
284
  this.configById.delete(cacheID);
398
- return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, resourceID, configName);
285
+ return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, this.resourceID, configName);
399
286
  }
400
- static async removePersonalizedFilter(personalizedFilter, resourceID, configName) {
401
- return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, resourceID, configName);
287
+ static async removePersonalizedFilter(personalizedFilter, configName) {
288
+ return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, this.resourceID, configName);
402
289
  }
403
290
  static async validatePersonalizedFilter(dataUnitName, expression) {
404
291
  return this.personalizedFilterFetcher.validatePersonalizedFilter(dataUnitName, expression);
405
292
  }
406
- static buildCacheID(name, source, resourceID) {
293
+ static buildCacheID(name, source) {
407
294
  if (name == undefined) {
408
- return `req_${source}_${resourceID}`;
295
+ return `req_${source}_${this.resourceID}`;
409
296
  }
410
- return `req_${source}_${name}_${resourceID}`;
297
+ return `req_${source}_${name}_${this.resourceID}`;
411
298
  }
412
299
  }
413
300
  ConfigStorage.configById = new Map();
@@ -416,4 +303,4 @@ ConfigStorage.formConfigFetcher = new FormConfigFetcher();
416
303
  ConfigStorage.gridConfigFetcher = new GridConfigFetcher();
417
304
  ConfigStorage.personalizedFilterFetcher = new PersonalizedFilterFetcher();
418
305
 
419
- export { ConfigStorage as C, PersonalizedFilterFetcher as P };
306
+ export { ConfigStorage as C, GridConfigFetcher as G, PersonalizedFilterFetcher as P };