@sankhyalabs/sankhyablocks 8.3.1 → 8.4.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 (253) hide show
  1. package/dist/cjs/{ConfigStorage-c9ca6658.js → ConfigStorage-f0f89379.js} +163 -51
  2. package/dist/cjs/{DataFetcher-7694daf2.js → DataFetcher-4798bac3.js} +78 -234
  3. package/dist/cjs/ISave-d68ce3cd.js +8 -0
  4. package/dist/cjs/PrintUtils-bcaeb82f.js +215 -0
  5. package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
  6. package/dist/cjs/{SnkFormConfigManager-fb684c0e.js → SnkFormConfigManager-d5fd8800.js} +19 -21
  7. package/dist/cjs/{auth-fetcher-80818a0f.js → auth-fetcher-f2967437.js} +2 -2
  8. package/dist/cjs/{dataunit-fetcher-1acab20d.js → dataunit-fetcher-959c9a00.js} +1 -1
  9. package/dist/cjs/{form-config-fetcher-f10017bf.js → form-config-fetcher-5e3d3b87.js} +66 -3
  10. package/dist/cjs/index-f9e81701.js +4 -0
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/{pesquisa-fetcher-c9d99342.js → pesquisa-fetcher-7973c081.js} +1 -1
  13. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  14. package/dist/cjs/snk-actions-button.cjs.entry.js +19 -11
  15. package/dist/cjs/snk-application.cjs.entry.js +60 -44
  16. package/dist/cjs/snk-attach.cjs.entry.js +9 -14
  17. package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
  18. package/dist/cjs/snk-crud.cjs.entry.js +28 -11
  19. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -2
  20. package/dist/cjs/{snk-data-unit-e89e07bd.js → snk-data-unit-7cc1846d.js} +5 -5
  21. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-detail-view.cjs.entry.js +17 -13
  23. package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
  24. package/dist/cjs/snk-filter-bar.cjs.entry.js +15 -17
  25. package/dist/cjs/snk-filter-detail.cjs.entry.js +7 -16
  26. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +6 -19
  27. package/dist/cjs/snk-form-config.cjs.entry.js +7 -17
  28. package/dist/cjs/snk-form-view.cjs.entry.js +6 -1
  29. package/dist/cjs/snk-form.cjs.entry.js +13 -8
  30. package/dist/cjs/snk-grid-config.cjs.entry.js +6 -6
  31. package/dist/cjs/snk-grid.cjs.entry.js +23 -22
  32. package/dist/cjs/{snk-guides-viewer-5da253af.js → snk-guides-viewer-b7b680d2.js} +19 -8
  33. package/dist/cjs/snk-guides-viewer.cjs.entry.js +10 -9
  34. package/dist/cjs/snk-personalized-filter.cjs.entry.js +14 -16
  35. package/dist/cjs/snk-print-selector.cjs.entry.js +2 -4
  36. package/dist/cjs/snk-simple-crud.cjs.entry.js +43 -85
  37. package/dist/cjs/snk-taskbar-custom-elements.cjs.entry.js +20 -0
  38. package/dist/cjs/snk-taskbar.cjs.entry.js +71 -5
  39. package/dist/cjs/{taskbar-elements-b98dd6e9.js → taskbar-elements-39949c7a.js} +4 -4
  40. package/dist/collection/collection-manifest.json +1 -0
  41. package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
  42. package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
  43. package/dist/collection/components/snk-application/snk-application.js +120 -65
  44. package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
  45. package/dist/collection/components/snk-crud/snk-crud.js +44 -8
  46. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +60 -2
  47. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +27 -1
  48. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +65 -28
  49. package/dist/collection/components/snk-data-unit/snk-data-unit.js +22 -6
  50. package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
  51. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +8 -13
  52. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
  53. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
  54. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +28 -12
  55. package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
  56. package/dist/collection/components/snk-form/snk-form.js +46 -2
  57. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
  58. package/dist/collection/components/snk-grid/snk-grid.js +108 -16
  59. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
  60. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
  61. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +23 -1
  62. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +4 -4
  63. package/dist/collection/components/snk-taskbar/snk-taskbar-custom-elements.js +43 -0
  64. package/dist/collection/components/snk-taskbar/snk-taskbar.css +4 -0
  65. package/dist/collection/components/snk-taskbar/snk-taskbar.js +126 -5
  66. package/dist/collection/lib/configs/ConfigStorage.js +33 -44
  67. package/dist/collection/lib/dataUnit/InMemoryLoader.js +23 -71
  68. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +47 -32
  69. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
  70. package/dist/collection/lib/index.js +10 -0
  71. package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
  72. package/dist/collection/lib/utils/PrintUtils.js +18 -9
  73. package/dist/collection/lib/utils/urlutils.js +29 -0
  74. package/dist/components/ConfigStorage.js +161 -48
  75. package/dist/components/DataFetcher.js +79 -234
  76. package/dist/components/PrintUtils.js +213 -0
  77. package/dist/components/ResourceIDUtils.js +10 -0
  78. package/dist/components/SnkFormConfigManager.js +17 -19
  79. package/dist/components/auth-fetcher.js +1 -1
  80. package/dist/components/form-config-fetcher.js +64 -2
  81. package/dist/components/index.d.ts +1 -0
  82. package/dist/components/index.js +1 -0
  83. package/dist/components/snk-actions-button2.js +23 -9
  84. package/dist/components/snk-application2.js +145 -129
  85. package/dist/components/snk-attach2.js +1 -8
  86. package/dist/components/snk-configurator2.js +3 -1
  87. package/dist/components/snk-crud.js +27 -8
  88. package/dist/components/snk-data-unit2.js +6 -5
  89. package/dist/components/snk-detail-view2.js +26 -10
  90. package/dist/components/snk-entity-list.js +0 -4
  91. package/dist/components/snk-filter-bar2.js +12 -12
  92. package/dist/components/snk-filter-detail2.js +8 -13
  93. package/dist/components/snk-filter-modal-item2.js +5 -16
  94. package/dist/components/snk-form-config2.js +5 -15
  95. package/dist/components/snk-form-view2.js +6 -1
  96. package/dist/components/snk-form.js +9 -2
  97. package/dist/components/snk-grid-config2.js +4 -2
  98. package/dist/components/snk-grid2.js +24 -17
  99. package/dist/components/snk-personalized-filter2.js +11 -11
  100. package/dist/components/snk-print-selector.js +1 -1
  101. package/dist/components/snk-simple-crud2.js +30 -73
  102. package/dist/components/snk-taskbar-custom-elements.d.ts +11 -0
  103. package/dist/components/snk-taskbar-custom-elements.js +35 -0
  104. package/dist/components/snk-taskbar2.js +81 -9
  105. package/dist/esm/{ConfigStorage-6887ede4.js → ConfigStorage-4441aa3d.js} +162 -49
  106. package/dist/esm/{DataFetcher-731430d9.js → DataFetcher-1618bffe.js} +79 -234
  107. package/dist/esm/ISave-4412b20c.js +8 -0
  108. package/dist/esm/PrintUtils-3e4ff0f5.js +213 -0
  109. package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
  110. package/dist/esm/{SnkFormConfigManager-6acecf9f.js → SnkFormConfigManager-5a5f85a3.js} +19 -21
  111. package/dist/esm/{auth-fetcher-82d89fe6.js → auth-fetcher-7861187e.js} +1 -1
  112. package/dist/esm/{dataunit-fetcher-ad7a1a3e.js → dataunit-fetcher-53c007be.js} +1 -1
  113. package/dist/esm/{form-config-fetcher-9560730a.js → form-config-fetcher-2fe67341.js} +65 -3
  114. package/dist/esm/index-a7d3d3f1.js +4 -0
  115. package/dist/esm/loader.js +1 -1
  116. package/dist/esm/{pesquisa-fetcher-27dc20ed.js → pesquisa-fetcher-19e81fc8.js} +1 -1
  117. package/dist/esm/sankhyablocks.js +1 -1
  118. package/dist/esm/snk-actions-button.entry.js +19 -11
  119. package/dist/esm/snk-application.entry.js +60 -44
  120. package/dist/esm/snk-attach.entry.js +5 -10
  121. package/dist/esm/snk-configurator.entry.js +2 -1
  122. package/dist/esm/snk-crud.entry.js +30 -13
  123. package/dist/esm/snk-data-exporter.entry.js +3 -2
  124. package/dist/esm/{snk-data-unit-8c4d944d.js → snk-data-unit-1715d2f1.js} +5 -5
  125. package/dist/esm/snk-data-unit.entry.js +1 -1
  126. package/dist/esm/snk-detail-view.entry.js +17 -13
  127. package/dist/esm/snk-entity-list.entry.js +0 -4
  128. package/dist/esm/snk-filter-bar.entry.js +15 -17
  129. package/dist/esm/snk-filter-detail.entry.js +8 -17
  130. package/dist/esm/snk-filter-modal-item.entry.js +7 -20
  131. package/dist/esm/snk-form-config.entry.js +8 -18
  132. package/dist/esm/snk-form-view.entry.js +6 -1
  133. package/dist/esm/snk-form.entry.js +13 -8
  134. package/dist/esm/snk-grid-config.entry.js +6 -6
  135. package/dist/esm/snk-grid.entry.js +23 -22
  136. package/dist/esm/{snk-guides-viewer-d3623a1f.js → snk-guides-viewer-e4fe884d.js} +19 -8
  137. package/dist/esm/snk-guides-viewer.entry.js +10 -9
  138. package/dist/esm/snk-personalized-filter.entry.js +14 -16
  139. package/dist/esm/snk-print-selector.entry.js +1 -3
  140. package/dist/esm/snk-simple-crud.entry.js +34 -76
  141. package/dist/esm/snk-taskbar-custom-elements.entry.js +16 -0
  142. package/dist/esm/snk-taskbar.entry.js +71 -5
  143. package/dist/esm/{taskbar-elements-2c761819.js → taskbar-elements-0a6b8b95.js} +4 -4
  144. package/dist/sankhyablocks/p-0b99a775.entry.js +1 -0
  145. package/dist/sankhyablocks/p-1e30c376.entry.js +1 -0
  146. package/dist/sankhyablocks/p-1fa3acbe.entry.js +1 -0
  147. package/dist/sankhyablocks/p-27dbbb3a.entry.js +1 -0
  148. package/dist/sankhyablocks/p-29b1d77b.entry.js +11 -0
  149. package/dist/sankhyablocks/p-324ce41e.entry.js +1 -0
  150. package/dist/sankhyablocks/p-34604220.entry.js +1 -0
  151. package/dist/sankhyablocks/p-41820e28.entry.js +1 -0
  152. package/dist/sankhyablocks/p-4352324d.entry.js +1 -0
  153. package/dist/sankhyablocks/{p-f6b98398.js → p-449d25e0.js} +2 -2
  154. package/dist/sankhyablocks/p-5051a23a.entry.js +1 -0
  155. package/dist/sankhyablocks/p-5526ab67.js +1 -0
  156. package/dist/sankhyablocks/p-5b2ee1d3.js +1 -0
  157. package/dist/sankhyablocks/p-5da848bb.js +26 -0
  158. package/dist/sankhyablocks/p-6098d844.entry.js +1 -0
  159. package/dist/sankhyablocks/p-648a7c72.entry.js +1 -0
  160. package/dist/sankhyablocks/p-688dcb4c.js +1 -0
  161. package/dist/sankhyablocks/p-72fc257b.entry.js +1 -0
  162. package/dist/sankhyablocks/p-7d6eca73.entry.js +1 -0
  163. package/dist/sankhyablocks/p-81a7f74c.js +1 -0
  164. package/dist/sankhyablocks/p-8d884fab.js +1 -0
  165. package/dist/sankhyablocks/p-90b5d1af.entry.js +1 -0
  166. package/dist/sankhyablocks/p-989937ee.entry.js +1 -0
  167. package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
  168. package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
  169. package/dist/sankhyablocks/{p-1bed2c42.js → p-a75e892a.js} +1 -1
  170. package/dist/sankhyablocks/p-a81996df.js +1 -0
  171. package/dist/sankhyablocks/p-c555075c.entry.js +1 -0
  172. package/dist/sankhyablocks/{p-a2493d11.js → p-c9841939.js} +1 -1
  173. package/dist/sankhyablocks/p-ca1522bc.entry.js +1 -0
  174. package/dist/sankhyablocks/p-cbed6235.entry.js +1 -0
  175. package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
  176. package/dist/sankhyablocks/p-daa687aa.js +56 -0
  177. package/dist/sankhyablocks/p-e1cb1f0b.js +1 -0
  178. package/dist/sankhyablocks/p-eb1a650a.entry.js +1 -0
  179. package/dist/sankhyablocks/p-f784010c.entry.js +1 -0
  180. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  181. package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
  182. package/dist/types/components/snk-application/snk-application.d.ts +9 -22
  183. package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
  184. package/dist/types/components/snk-crud/snk-crud.d.ts +6 -0
  185. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +12 -0
  186. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +5 -0
  187. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -2
  188. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
  189. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
  190. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
  191. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
  192. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
  193. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  194. package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
  195. package/dist/types/components/snk-form/snk-form.d.ts +9 -1
  196. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
  197. package/dist/types/components/snk-grid/snk-grid.d.ts +17 -1
  198. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
  199. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
  200. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
  201. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +2 -2
  202. package/dist/types/components/snk-taskbar/snk-taskbar-custom-elements.d.ts +7 -0
  203. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +27 -0
  204. package/dist/types/components.d.ts +203 -22
  205. package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
  206. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -8
  207. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  208. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
  209. package/dist/types/lib/index.d.ts +11 -0
  210. package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
  211. package/dist/types/lib/utils/PrintUtils.d.ts +1 -0
  212. package/dist/types/lib/utils/urlutils.d.ts +14 -0
  213. package/package.json +2 -2
  214. package/react/components.d.ts +1 -0
  215. package/react/components.js +1 -0
  216. package/react/components.js.map +1 -1
  217. package/dist/cjs/filter-bar-config-fetcher-f13a1aff.js +0 -155
  218. package/dist/cjs/resource-fetcher-a6e6c5fd.js +0 -68
  219. package/dist/components/filter-bar-config-fetcher.js +0 -153
  220. package/dist/components/resource-fetcher.js +0 -66
  221. package/dist/esm/filter-bar-config-fetcher-553c5463.js +0 -153
  222. package/dist/esm/resource-fetcher-0586b1fc.js +0 -66
  223. package/dist/sankhyablocks/p-000d073b.entry.js +0 -1
  224. package/dist/sankhyablocks/p-162f5d21.entry.js +0 -1
  225. package/dist/sankhyablocks/p-1dc76c50.js +0 -1
  226. package/dist/sankhyablocks/p-216f081a.entry.js +0 -1
  227. package/dist/sankhyablocks/p-24b18442.entry.js +0 -1
  228. package/dist/sankhyablocks/p-301d4e34.js +0 -1
  229. package/dist/sankhyablocks/p-4374bc89.entry.js +0 -1
  230. package/dist/sankhyablocks/p-564efc43.js +0 -1
  231. package/dist/sankhyablocks/p-5fe223c9.entry.js +0 -1
  232. package/dist/sankhyablocks/p-61651a40.entry.js +0 -1
  233. package/dist/sankhyablocks/p-70d4a90a.entry.js +0 -1
  234. package/dist/sankhyablocks/p-7bd353de.entry.js +0 -1
  235. package/dist/sankhyablocks/p-837831c2.js +0 -56
  236. package/dist/sankhyablocks/p-85ec10c9.entry.js +0 -1
  237. package/dist/sankhyablocks/p-89d46727.entry.js +0 -1
  238. package/dist/sankhyablocks/p-8e8b5fc7.js +0 -1
  239. package/dist/sankhyablocks/p-8e96581f.js +0 -17
  240. package/dist/sankhyablocks/p-9b2af526.entry.js +0 -1
  241. package/dist/sankhyablocks/p-9db7e50a.js +0 -10
  242. package/dist/sankhyablocks/p-a2f32d4e.entry.js +0 -1
  243. package/dist/sankhyablocks/p-a7eaea51.entry.js +0 -1
  244. package/dist/sankhyablocks/p-a84b1ca2.entry.js +0 -1
  245. package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
  246. package/dist/sankhyablocks/p-c32b9d7c.entry.js +0 -1
  247. package/dist/sankhyablocks/p-c3943e7e.entry.js +0 -11
  248. package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
  249. package/dist/sankhyablocks/p-c7d1e26a.js +0 -1
  250. package/dist/sankhyablocks/p-cd40ab53.entry.js +0 -1
  251. package/dist/sankhyablocks/p-d41198ff.js +0 -1
  252. package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
  253. package/dist/sankhyablocks/p-f9f385eb.entry.js +0 -1
@@ -174,7 +174,7 @@ export class SnkSimpleCrud {
174
174
  }
175
175
  render() {
176
176
  var _a;
177
- 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)
177
+ 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("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), 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)
178
178
  ? undefined
179
179
  : 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 }))))));
180
180
  }
@@ -452,6 +452,28 @@ export class SnkSimpleCrud {
452
452
  "resolved": "string",
453
453
  "references": {}
454
454
  }
455
+ }, {
456
+ "method": "formItemsReady",
457
+ "name": "formItemsReady",
458
+ "bubbles": true,
459
+ "cancelable": true,
460
+ "composed": true,
461
+ "docs": {
462
+ "tags": [],
463
+ "text": "Respons\u00E1vel por notificar quando ocorrer a renderiza\u00E7\u00E3o de itens do formul\u00E1rio."
464
+ },
465
+ "complexType": {
466
+ "original": "Array<HTMLElement>",
467
+ "resolved": "HTMLElement[]",
468
+ "references": {
469
+ "Array": {
470
+ "location": "global"
471
+ },
472
+ "HTMLElement": {
473
+ "location": "global"
474
+ }
475
+ }
476
+ }
455
477
  }];
456
478
  }
457
479
  static get methods() {
@@ -99,16 +99,16 @@ export const buildElem = (element, className, dataElementId, getTitle, action, i
99
99
  }
100
100
  };
101
101
  function textButton(name, className, dataElementId, text, title, action, isEnabled) {
102
- return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
102
+ return h("ez-button", { key: dataElementId, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
103
103
  }
104
104
  function iconButton(iconName, name, className, dataElementId, title, action, isEnabled) {
105
- return h("ez-button", { title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
105
+ return h("ez-button", { key: dataElementId, title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
106
106
  }
107
107
  function iconTextButton(iconName, name, className, dataElementId, text, title, action, isEnabled) {
108
- return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) }, h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
108
+ return h("ez-button", { key: dataElementId, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) }, h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
109
109
  }
110
110
  function actionButton(element, className, dataElementId, title, action, isEnabled, actions) {
111
111
  return actions && actions.length > 0
112
- ? h("ez-actions-button", { title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
112
+ ? h("ez-actions-button", { key: dataElementId, title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
113
113
  : undefined;
114
114
  }
@@ -0,0 +1,43 @@
1
+ import { h, Host } from '@stencil/core';
2
+ export class SnkTaskbarCustomElements {
3
+ constructor() {
4
+ this.slot = 'TASKBAR_CUSTOM_ELEMENTS';
5
+ }
6
+ render() {
7
+ return (h(Host, { slot: this.slot }, h("div", { id: this.slot, class: "taskbar-custom-elements-container" }, h("slot", null))));
8
+ }
9
+ static get is() { return "snk-taskbar-custom-elements"; }
10
+ static get encapsulation() { return "scoped"; }
11
+ static get originalStyleUrls() {
12
+ return {
13
+ "$": ["snk-taskbar.css"]
14
+ };
15
+ }
16
+ static get styleUrls() {
17
+ return {
18
+ "$": ["snk-taskbar.css"]
19
+ };
20
+ }
21
+ static get properties() {
22
+ return {
23
+ "slot": {
24
+ "type": "string",
25
+ "mutable": false,
26
+ "complexType": {
27
+ "original": "string",
28
+ "resolved": "string",
29
+ "references": {}
30
+ },
31
+ "required": false,
32
+ "optional": false,
33
+ "docs": {
34
+ "tags": [],
35
+ "text": "Nome do slot da Taskbar onde os elementos customizados dever\u00E3o aparecer."
36
+ },
37
+ "attribute": "slot",
38
+ "reflect": false,
39
+ "defaultValue": "'TASKBAR_CUSTOM_ELEMENTS'"
40
+ }
41
+ };
42
+ }
43
+ }
@@ -1,3 +1,7 @@
1
1
  :host {
2
2
  display: flex;
3
3
  }
4
+
5
+ .taskbar-custom-elements-container{
6
+ display: none;
7
+ }
@@ -1,10 +1,11 @@
1
1
  import { ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
2
2
  import { h, Host } from '@stencil/core';
3
3
  import { AuthorizationConfig } from '../snk-configurator/AuthorizationConfig';
4
- import { TaskbarElement, buildElem, AuthorizationElements, buildCustomButton, VisibleWhenForbidden } from './elements/taskbar-elements';
4
+ import { AuthorizationElements, buildCustomButton, buildElem, TaskbarElement, VisibleWhenForbidden, } from './elements/taskbar-elements';
5
5
  import { PresentationMode } from '../../lib/@types';
6
6
  export class SnkTaskbar {
7
7
  constructor() {
8
+ this.TASKBAR_ITEM_ID_PREFIX = 'TASKBAR_ITEM_';
8
9
  this._titleKeyByElement = {
9
10
  [TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
10
11
  [TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
@@ -22,7 +23,13 @@ export class SnkTaskbar {
22
23
  [TaskbarElement.ATTACH]: "snkTaskbar.titleAttach",
23
24
  };
24
25
  this._permissions = undefined;
26
+ this._customElements = undefined;
27
+ this._customElementsId = undefined;
28
+ this._slotContainer = undefined;
29
+ this.customSlotId = "TASKBAR_CUSTOM_ELEMENTS";
30
+ this.customContainerId = undefined;
25
31
  this.configName = undefined;
32
+ this.resourceID = undefined;
26
33
  this.buttons = undefined;
27
34
  this.customButtons = undefined;
28
35
  this.actionsList = undefined;
@@ -161,14 +168,52 @@ export class SnkTaskbar {
161
168
  return true;
162
169
  });
163
170
  }
171
+ appendCustomElementsInTaskbar() {
172
+ this._customElementsId.forEach(id => {
173
+ const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
174
+ const customElement = this._customElements.get(elementId);
175
+ const container = this._element.querySelector(`#${id}`);
176
+ if (container) {
177
+ container === null || container === void 0 ? void 0 : container.appendChild(customElement);
178
+ }
179
+ else {
180
+ this.unlinkCustomElementFromTaskbar(customElement);
181
+ }
182
+ });
183
+ }
184
+ addCustomElementContainer(elem) {
185
+ const elementId = `${this.TASKBAR_ITEM_ID_PREFIX}${elem}`;
186
+ if (!this._customElementsId.includes(elementId)) {
187
+ this._customElementsId.push(elementId);
188
+ }
189
+ return h("span", { key: elementId, id: elementId });
190
+ }
191
+ getCustomElements() {
192
+ var _a, _b;
193
+ this._customElementsId = [];
194
+ this._customElements = new Map();
195
+ this._slotContainer = this.buildSlotContainer();
196
+ const customElementsArray = Array.from((_b = (_a = this._slotContainer) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []);
197
+ customElementsArray.forEach(item => this._customElements.set(item.id, item));
198
+ }
199
+ buildSlotContainer() {
200
+ if (this.customContainerId) {
201
+ const container = document.querySelector(`#${this.customContainerId}`);
202
+ return container === null || container === void 0 ? void 0 : container.querySelector(`#${this.customSlotId}`);
203
+ }
204
+ else {
205
+ return this._element.querySelector(`#${this.customSlotId}`);
206
+ }
207
+ }
164
208
  componentWillLoad() {
165
209
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
166
210
  if (this._application) {
167
- this._application.getAllAccess().then(access => this._permissions = access);
211
+ this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
168
212
  }
169
213
  else {
170
214
  this._permissions = {};
171
215
  }
216
+ this.getCustomElements();
172
217
  }
173
218
  componentWillRender() {
174
219
  if (this._definitions == undefined && this._permissions) {
@@ -180,12 +225,30 @@ export class SnkTaskbar {
180
225
  const dataInfo = { dataUnit: this.dataUnit };
181
226
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
182
227
  }
228
+ componentDidRender() {
229
+ this.appendCustomElementsInTaskbar();
230
+ }
231
+ disconnectedCallback() {
232
+ this.unlinkAllCustomElements();
233
+ }
234
+ unlinkAllCustomElements() {
235
+ var _a;
236
+ (_a = this._customElementsId) === null || _a === void 0 ? void 0 : _a.forEach(id => {
237
+ const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
238
+ const customElement = this._customElements.get(elementId);
239
+ this.unlinkCustomElementFromTaskbar(customElement);
240
+ });
241
+ }
242
+ unlinkCustomElementFromTaskbar(customElement) {
243
+ this._slotContainer.appendChild(customElement);
244
+ }
183
245
  render() {
184
246
  if (this._definitions === undefined) {
185
247
  return undefined;
186
248
  }
187
249
  let index = 0;
188
250
  return (h(Host, null, this.removeEmpty(this._definitions.map((elem) => {
251
+ var _a;
189
252
  if (elem === TaskbarElement.DIVIDER) {
190
253
  index = 0;
191
254
  }
@@ -195,11 +258,14 @@ export class SnkTaskbar {
195
258
  if (TaskbarElement[elem]) {
196
259
  return this.getElement(index, TaskbarElement[elem]);
197
260
  }
198
- if (this.customButtons.has(elem)) {
261
+ if ((_a = this.customButtons) === null || _a === void 0 ? void 0 : _a.has(elem)) {
199
262
  return this.getElement(index, this.customButtons.get(elem));
200
263
  }
264
+ if (this._customElements.has(elem)) {
265
+ return this.addCustomElementContainer(elem);
266
+ }
201
267
  return h("slot", { name: elem });
202
- }))));
268
+ })), h("div", { class: "taskbar-custom-elements-container" }, h("slot", { name: this.customSlotId }))));
203
269
  }
204
270
  static get is() { return "snk-taskbar"; }
205
271
  static get encapsulation() { return "scoped"; }
@@ -215,6 +281,41 @@ export class SnkTaskbar {
215
281
  }
216
282
  static get properties() {
217
283
  return {
284
+ "customSlotId": {
285
+ "type": "string",
286
+ "mutable": false,
287
+ "complexType": {
288
+ "original": "string",
289
+ "resolved": "string",
290
+ "references": {}
291
+ },
292
+ "required": false,
293
+ "optional": false,
294
+ "docs": {
295
+ "tags": [],
296
+ "text": "Usado para determinar o identificador do slot que recebe elementos personalizados."
297
+ },
298
+ "attribute": "custom-slot-id",
299
+ "reflect": false,
300
+ "defaultValue": "\"TASKBAR_CUSTOM_ELEMENTS\""
301
+ },
302
+ "customContainerId": {
303
+ "type": "string",
304
+ "mutable": false,
305
+ "complexType": {
306
+ "original": "string",
307
+ "resolved": "string",
308
+ "references": {}
309
+ },
310
+ "required": false,
311
+ "optional": false,
312
+ "docs": {
313
+ "tags": [],
314
+ "text": "Usado para determinar o identificador do container na DOM que \u00E9 responsavel por guardar os elementos personalizados\nque n\u00E3o podem ser passados por slot.\n\nExemplo: Elementos customizados na Taskbar da aba de detalhes."
315
+ },
316
+ "attribute": "custom-container-id",
317
+ "reflect": false
318
+ },
218
319
  "configName": {
219
320
  "type": "string",
220
321
  "mutable": false,
@@ -232,6 +333,23 @@ export class SnkTaskbar {
232
333
  "attribute": "config-name",
233
334
  "reflect": false
234
335
  },
336
+ "resourceID": {
337
+ "type": "string",
338
+ "mutable": false,
339
+ "complexType": {
340
+ "original": "string",
341
+ "resolved": "string",
342
+ "references": {}
343
+ },
344
+ "required": false,
345
+ "optional": false,
346
+ "docs": {
347
+ "tags": [],
348
+ "text": "Identificador de recursos como configura\u00E7\u00F5es e acesso."
349
+ },
350
+ "attribute": "resource-i-d",
351
+ "reflect": false
352
+ },
235
353
  "buttons": {
236
354
  "type": "string",
237
355
  "mutable": false,
@@ -396,7 +514,10 @@ export class SnkTaskbar {
396
514
  }
397
515
  static get states() {
398
516
  return {
399
- "_permissions": {}
517
+ "_permissions": {},
518
+ "_customElements": {},
519
+ "_customElementsId": {},
520
+ "_slotContainer": {}
400
521
  };
401
522
  }
402
523
  static get events() {
@@ -1,4 +1,3 @@
1
- import { ApplicationContext } from "@sankhyalabs/core";
2
1
  import { FormConfigFetcher } from "../http/data-fetcher/fetchers/form-config-fetcher";
3
2
  import GridConfigFetcher from "../http/data-fetcher/fetchers/grid-config-fetcher";
4
3
  import FilterBarConfigFetcher from "../http/data-fetcher/fetchers/filter-bar-config-fetcher";
@@ -9,83 +8,73 @@ const CONFIG_SOURCE = {
9
8
  filterBar: "filterBar"
10
9
  };
11
10
  export class ConfigStorage {
12
- static async get() {
13
- if (!ConfigStorage.instance) {
14
- const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
15
- if (application != undefined) {
16
- const configName = application.configName;
17
- const resourceID = await application.getResourceID();
18
- ConfigStorage.instance = new ConfigStorage();
19
- ConfigStorage.resourceID = resourceID;
20
- ConfigStorage.instance.loadFormConfig(configName);
21
- ConfigStorage.instance.loadGridConfig(configName);
22
- }
23
- }
24
- return this.instance;
11
+ static preload(resourceID, configName) {
12
+ ConfigStorage.loadFormConfig(configName, resourceID);
13
+ ConfigStorage.loadGridConfig(configName, resourceID);
25
14
  }
26
- async loadFilterBarConfig(name, urlParams) {
27
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar);
15
+ static async loadFilterBarConfig(name, resourceID, urlParams) {
16
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
28
17
  if (!ConfigStorage.configById.has(cacheID)) {
29
- ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(ConfigStorage.resourceID, name, urlParams));
18
+ ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
30
19
  }
31
20
  return ConfigStorage.configById.get(cacheID);
32
21
  }
33
- async loadFormConfig(name) {
34
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form);
22
+ static async loadFormConfig(name, resourceID) {
23
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
35
24
  if (!ConfigStorage.configById.has(cacheID)) {
36
- ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, ConfigStorage.resourceID));
25
+ ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
37
26
  }
38
27
  return ConfigStorage.configById.get(cacheID);
39
28
  }
40
- async loadGridConfig(name) {
41
- const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid);
29
+ static async loadGridConfig(name, resourceID) {
30
+ const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
42
31
  if (!ConfigStorage.configById.has(cacheID)) {
43
- ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, ConfigStorage.resourceID));
32
+ ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
44
33
  }
45
34
  return ConfigStorage.configById.get(cacheID);
46
35
  }
47
- static async saveFilterBarConfig(config, name) {
48
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar);
36
+ static async saveFilterBarConfig(config, name, resourceID) {
37
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
49
38
  this.configById.delete(cacheID);
50
- return this.filterBarConfigFetcher.saveConfig(config, this.resourceID, name);
39
+ return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
51
40
  }
52
- static async saveFormConfig(config, name) {
53
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form);
41
+ static async saveFormConfig(config, name, resourceID) {
42
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
54
43
  this.configById.delete(cacheID);
55
- return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
44
+ return this.formConfigFetcher.saveConfig(config, name, resourceID);
56
45
  }
57
- static async saveCardState(config, name) {
58
- return this.formConfigFetcher.saveCardState(config, name, this.resourceID);
46
+ static async saveCardState(config, name, resourceID) {
47
+ return this.formConfigFetcher.saveCardState(config, name, resourceID);
59
48
  }
60
- static async saveGridConfig(config, name) {
49
+ static async saveGridConfig(config, name, resourceID) {
61
50
  if (config == undefined) {
62
51
  return;
63
52
  }
64
- const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid);
53
+ const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
65
54
  this.configById.delete(cacheID);
66
- return this.gridConfigFetcher.saveConfig(config, name, this.resourceID);
55
+ return this.gridConfigFetcher.saveConfig(config, name, resourceID);
67
56
  }
68
- static async loadPersonalizedFilter(filterId, configName) {
69
- return this.personalizedFilterFetcher.loadPersonalizedFilter(this.resourceID, filterId, configName);
57
+ static async loadPersonalizedFilter(filterId, resourceID, configName) {
58
+ return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName);
70
59
  }
71
- static async savePersonalizedFilter(personalizedFilter, configName) {
60
+ static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
72
61
  //Ao criar ou alterar um filtro personalizado,
73
62
  //precisamos remover o cache do status da filterbar.
74
- const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar);
63
+ const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar, resourceID);
75
64
  this.configById.delete(cacheID);
76
- return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, this.resourceID, configName);
65
+ return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, resourceID, configName);
77
66
  }
78
- static async removePersonalizedFilter(personalizedFilter, configName) {
79
- return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, this.resourceID, configName);
67
+ static async removePersonalizedFilter(personalizedFilter, resourceID, configName) {
68
+ return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, resourceID, configName);
80
69
  }
81
70
  static async validatePersonalizedFilter(dataUnitName, expression) {
82
71
  return this.personalizedFilterFetcher.validatePersonalizedFilter(dataUnitName, expression);
83
72
  }
84
- static buildCacheID(name, source) {
73
+ static buildCacheID(name, source, resourceID) {
85
74
  if (name == undefined) {
86
- return `req_${source}_${this.resourceID}`;
75
+ return `req_${source}_${resourceID}`;
87
76
  }
88
- return `req_${source}_${name}_${this.resourceID}`;
77
+ return `req_${source}_${name}_${resourceID}`;
89
78
  }
90
79
  }
91
80
  ConfigStorage.configById = new Map();
@@ -1,31 +1,44 @@
1
- import { ChangeOperation, DataType, DataUnit, SortMode, StringUtils, } from '@sankhyalabs/core';
2
- import { DISTINCT_FILTER_NAME_PREFIX } from "@sankhyalabs/ezui/dist/collection/utils/constants";
1
+ import { ChangeOperation, DataUnit, defaultDataLoader, StringUtils, } from '@sankhyalabs/core';
3
2
  export default class InMemoryLoader {
4
3
  constructor(metadata, records) {
5
- this.records = records || [];
4
+ this.records = records;
6
5
  this.metadata = metadata;
7
6
  this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
8
7
  this._dataUnit.metadataLoader = () => this.metadaLoader();
9
- this._dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
8
+ this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
10
9
  this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
11
10
  this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
12
11
  this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
13
12
  }
13
+ getRecordsToLoad() {
14
+ if (this._initialRecords) {
15
+ try {
16
+ return this._initialRecords;
17
+ }
18
+ finally {
19
+ this._initialRecords = undefined;
20
+ }
21
+ }
22
+ return this.dataUnit.records;
23
+ }
14
24
  get dataUnit() {
15
25
  return this._dataUnit;
16
26
  }
17
27
  get records() {
18
- return this._records;
28
+ return this.dataUnit.records;
19
29
  }
20
30
  set records(records) {
21
- this._records = records === null || records === void 0 ? void 0 : records.map(record => {
31
+ const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
22
32
  if (!record["__record__id__"]) {
23
33
  record["__record__id__"] = this.generateUniqueId();
24
34
  }
25
35
  return record;
26
36
  });
27
37
  if (this._dataUnit) {
28
- this._dataUnit.records = [...this._records];
38
+ this._dataUnit.records = newRecords;
39
+ }
40
+ else {
41
+ this._initialRecords = newRecords;
29
42
  }
30
43
  }
31
44
  get metadata() {
@@ -43,76 +56,16 @@ export default class InMemoryLoader {
43
56
  metadaLoader() {
44
57
  return Promise.resolve(this._metadata);
45
58
  }
46
- dataLoader(dataUnit, request) {
47
- const filters = this.getColumnFilters(dataUnit);
48
- let records = this.applyFilters(filters);
49
- if (request.sort) {
50
- request.sort.forEach(sort => {
51
- records = records.sort((recordA, recordB) => {
52
- const fieldA = recordA[sort.field];
53
- const fieldB = recordB[sort.field];
54
- const sortFn = this.getSortFn(sort.dataType);
55
- return sortFn(fieldA, fieldB) * (sort.mode == SortMode.ASC ? 1 : -1);
56
- });
57
- });
58
- }
59
- return Promise.resolve({ records: records });
60
- }
61
- applyFilters(filters) {
62
- let records = [...this._records];
63
- filters.forEach(filter => {
64
- records = records.filter(record => { var _a; return filter.values.includes((_a = record[filter.column]) === null || _a === void 0 ? void 0 : _a.toString()); });
65
- });
66
- return records;
67
- }
68
- getColumnFilters(dataUnit) {
69
- var _a, _b;
70
- const allFilters = (_a = dataUnit.getFilters()) !== null && _a !== void 0 ? _a : [];
71
- 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 : [];
72
- return columnFilters.map(filter => {
73
- var _a, _b;
74
- return {
75
- column: (_b = (_a = filter.name) === null || _a === void 0 ? void 0 : _a.replace(DISTINCT_FILTER_NAME_PREFIX, "")) !== null && _b !== void 0 ? _b : "",
76
- values: filter.params.map(param => param.value),
77
- };
78
- });
79
- }
80
- getSortFn(type) {
81
- switch (type) {
82
- case DataType.NUMBER:
83
- return this.sortNumber;
84
- case DataType.DATE:
85
- return this.sortDate;
86
- case DataType.OBJECT:
87
- return this.sortObject;
88
- default:
89
- return StringUtils.compare;
90
- }
91
- }
92
- sortObject(a, b) {
93
- return StringUtils.compare(a === null || a === void 0 ? void 0 : a["label"], b === null || b === void 0 ? void 0 : b["label"]);
94
- }
95
- sortNumber(a, b) {
96
- return a - b;
97
- }
98
- sortDate(a, b) {
99
- let timeA = a.getTime(), timeB = b.getTime();
100
- return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
101
- }
102
59
  saveLoader(_dataUnit, changes) {
103
60
  return new Promise((resolve) => {
104
61
  let dataUnitRecords = [];
105
62
  changes.forEach(change => {
106
63
  let { record, updatingFields, operation } = change;
107
- let isAdd = false;
64
+ const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
108
65
  if (operation === ChangeOperation.INSERT ||
109
66
  operation === ChangeOperation.COPY) {
110
- record["__old__id__"] = record["__record__id__"];
111
- record["__record__id__"] = this.generateUniqueId();
112
- isAdd = true;
113
- }
114
- const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
115
- if (isAdd) {
67
+ changedRecord["__old__id__"] = record["__record__id__"];
68
+ changedRecord["__record__id__"] = this.generateUniqueId();
116
69
  this.records.push(changedRecord);
117
70
  }
118
71
  else {
@@ -126,7 +79,6 @@ export default class InMemoryLoader {
126
79
  }
127
80
  removeLoader(_dataUnit, recordIds) {
128
81
  return new Promise((resolve) => {
129
- this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
130
82
  resolve(recordIds);
131
83
  });
132
84
  }