@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-38445.1 → 0.0.0-bugfix-dev-kb-67792.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 (248) hide show
  1. package/dist/cjs/{ConfigStorage-942ce74b.js → ConfigStorage-0a690675.js} +2 -2
  2. package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-77729a93.js} +7 -2
  3. package/dist/cjs/{SnkFormConfigManager-1b13bacd.js → SnkFormConfigManager-d6d5db6d.js} +5 -8
  4. package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-96b0f549.js} +13 -9
  5. package/dist/cjs/{IExporterProvider-597949f9.js → SnkMultiSelectionListDataSource-f79d220c.js} +6 -96
  6. package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-29bb791c.js} +1 -1
  7. package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-feb08214.js} +1 -1
  8. package/dist/cjs/{index-1dfc7a6e.js → index-0922807b.js} +0 -5
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{dataunit-fetcher-688d3f05.js → pesquisa-fetcher-cba1b3d0.js} +181 -88
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -7
  13. package/dist/cjs/snk-application.cjs.entry.js +15 -38
  14. package/dist/cjs/snk-attach.cjs.entry.js +49 -74
  15. package/dist/cjs/snk-crud.cjs.entry.js +13 -99
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +88 -318
  17. package/dist/cjs/snk-data-unit-559ac55c.js +462 -0
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -12
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +10 -51
  20. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-filter-bar.cjs.entry.js +14 -9
  22. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  23. package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
  24. package/dist/cjs/snk-form-view.cjs.entry.js +0 -67
  25. package/dist/cjs/snk-form.cjs.entry.js +9 -54
  26. package/dist/cjs/snk-grid.cjs.entry.js +112 -169
  27. package/dist/cjs/{snk-guides-viewer-67605336.js → snk-guides-viewer-bfcad2d6.js} +10 -38
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -11
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  30. package/dist/cjs/snk-simple-crud.cjs.entry.js +40 -267
  31. package/dist/cjs/snk-taskbar.cjs.entry.js +3 -4
  32. package/dist/cjs/{taskbar-elements-9ad1f9c0.js → taskbar-elements-3ecd1278.js} +3 -3
  33. package/dist/collection/collection-manifest.json +1 -1
  34. package/dist/collection/components/snk-application/snk-application.js +11 -35
  35. package/dist/collection/components/snk-attach/snk-attach.js +44 -67
  36. package/dist/collection/components/snk-crud/snk-crud.js +7 -249
  37. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +0 -135
  38. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +0 -161
  39. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +5 -112
  40. package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
  41. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -54
  42. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +52 -59
  43. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +2 -64
  44. package/dist/collection/components/snk-data-unit/snk-data-unit.js +214 -507
  45. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +11 -23
  46. package/dist/collection/components/snk-form/snk-form.js +5 -102
  47. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +3 -6
  48. package/dist/collection/components/snk-grid/snk-grid.css +0 -2
  49. package/dist/collection/components/snk-grid/snk-grid.js +102 -241
  50. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +18 -386
  51. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
  52. package/dist/collection/components/snk-taskbar/snk-taskbar.js +1 -2
  53. package/dist/collection/lib/@types/index.js +0 -5
  54. package/dist/collection/lib/dataUnit/InMemoryLoader.js +3 -7
  55. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -3
  56. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +0 -3
  57. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +0 -4
  58. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +13 -11
  59. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +0 -1
  60. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +4 -53
  61. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +34 -0
  62. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
  63. package/dist/collection/lib/message/SnkMessageBuilder.js +12 -5
  64. package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +0 -2
  65. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +0 -1
  66. package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
  67. package/dist/components/DataFetcher.js +8 -3
  68. package/dist/components/SnkFormConfigManager.js +3 -6
  69. package/dist/components/SnkMessageBuilder.js +13 -9
  70. package/dist/components/dataunit-fetcher.js +182 -84
  71. package/dist/components/{IExporterProvider.js → field-search.js} +6 -93
  72. package/dist/components/index2.js +33 -198
  73. package/dist/components/index3.js +199 -0
  74. package/dist/components/snk-actions-button2.js +11 -4
  75. package/dist/components/snk-application2.js +9 -31
  76. package/dist/components/snk-attach2.js +41 -65
  77. package/dist/components/snk-crud.js +11 -103
  78. package/dist/components/snk-data-exporter2.js +87 -311
  79. package/dist/components/snk-data-unit2.js +212 -470
  80. package/dist/components/snk-detail-view2.js +10 -87
  81. package/dist/components/snk-exporter-email-sender2.js +1 -1
  82. package/dist/components/snk-expression-item2.js +1 -1
  83. package/dist/components/snk-filter-bar2.js +11 -7
  84. package/dist/components/snk-form-view2.js +1 -72
  85. package/dist/components/snk-form.js +6 -53
  86. package/dist/components/snk-grid2.js +108 -170
  87. package/dist/components/snk-personalized-filter2.js +1 -1
  88. package/dist/components/snk-simple-crud2.js +23 -259
  89. package/dist/components/snk-taskbar2.js +5 -6
  90. package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-8c2ddac8.js} +2 -2
  91. package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-773a3e4b.js} +8 -3
  92. package/dist/esm/{SnkFormConfigManager-d4554df9.js → SnkFormConfigManager-c01b9d9d.js} +5 -8
  93. package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-72423074.js} +13 -9
  94. package/dist/esm/{IExporterProvider-63a188b6.js → SnkMultiSelectionListDataSource-a4805051.js} +7 -95
  95. package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-a411f73c.js} +1 -1
  96. package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-e0382e5a.js} +1 -1
  97. package/dist/esm/{index-3aa4977a.js → index-0ece87a6.js} +1 -6
  98. package/dist/esm/loader.js +1 -1
  99. package/dist/esm/{dataunit-fetcher-264191b2.js → pesquisa-fetcher-34a8b8be.js} +182 -84
  100. package/dist/esm/sankhyablocks.js +1 -1
  101. package/dist/esm/snk-actions-button_4.entry.js +5 -7
  102. package/dist/esm/snk-application.entry.js +14 -37
  103. package/dist/esm/snk-attach.entry.js +44 -69
  104. package/dist/esm/snk-crud.entry.js +13 -99
  105. package/dist/esm/snk-data-exporter.entry.js +89 -319
  106. package/dist/esm/snk-data-unit-44215df7.js +460 -0
  107. package/dist/esm/snk-data-unit.entry.js +2 -12
  108. package/dist/esm/snk-detail-view.entry.js +10 -51
  109. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  110. package/dist/esm/snk-filter-bar.entry.js +14 -9
  111. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  112. package/dist/esm/snk-form-config.entry.js +2 -2
  113. package/dist/esm/snk-form-view.entry.js +0 -67
  114. package/dist/esm/snk-form.entry.js +9 -54
  115. package/dist/esm/snk-grid.entry.js +110 -167
  116. package/dist/esm/{snk-guides-viewer-151f6091.js → snk-guides-viewer-edeac29f.js} +10 -38
  117. package/dist/esm/snk-guides-viewer.entry.js +9 -11
  118. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  119. package/dist/esm/snk-simple-crud.entry.js +28 -255
  120. package/dist/esm/snk-taskbar.entry.js +3 -4
  121. package/dist/esm/{taskbar-elements-d59867f1.js → taskbar-elements-2473c8ac.js} +3 -3
  122. package/dist/sankhyablocks/p-03dcc5ff.entry.js +1 -0
  123. package/dist/sankhyablocks/{p-913a9979.js → p-0cd3c0a9.js} +1 -1
  124. package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
  125. package/dist/sankhyablocks/p-176c3491.entry.js +1 -0
  126. package/dist/sankhyablocks/{p-df5451c7.js → p-181975f1.js} +1 -1
  127. package/dist/sankhyablocks/p-37e5d563.js +65 -0
  128. package/dist/sankhyablocks/p-38289a55.js +1 -0
  129. package/dist/sankhyablocks/{p-a1d72395.entry.js → p-41c2c191.entry.js} +1 -1
  130. package/dist/sankhyablocks/p-46e55a95.entry.js +1 -0
  131. package/dist/sankhyablocks/p-4e728357.entry.js +1 -0
  132. package/dist/sankhyablocks/p-5571bdfe.js +1 -0
  133. package/dist/sankhyablocks/p-5630574e.js +1 -0
  134. package/dist/sankhyablocks/p-594bc21d.js +1 -0
  135. package/dist/sankhyablocks/p-5f8c0426.entry.js +1 -0
  136. package/dist/sankhyablocks/p-80c64add.entry.js +1 -0
  137. package/dist/sankhyablocks/p-86af4cc2.js +1 -0
  138. package/dist/sankhyablocks/p-8b690717.js +1 -0
  139. package/dist/sankhyablocks/{p-aff76a53.js → p-96621231.js} +1 -1
  140. package/dist/sankhyablocks/p-a1832166.entry.js +1 -0
  141. package/dist/sankhyablocks/p-a809d944.entry.js +1 -0
  142. package/dist/sankhyablocks/p-a97226f6.entry.js +1 -0
  143. package/dist/sankhyablocks/p-add17f6a.entry.js +1 -0
  144. package/dist/sankhyablocks/{p-7e7a7473.js → p-ae4fc9a9.js} +1 -1
  145. package/dist/sankhyablocks/{p-eae7a817.entry.js → p-c2ae0fab.entry.js} +1 -1
  146. package/dist/sankhyablocks/p-c5a9a5d9.entry.js +1 -0
  147. package/dist/sankhyablocks/p-c5aa7d70.entry.js +11 -0
  148. package/dist/sankhyablocks/p-cb0147ab.entry.js +1 -0
  149. package/dist/sankhyablocks/p-f0145e3b.js +1 -0
  150. package/dist/sankhyablocks/{p-14a08904.entry.js → p-f03e4199.entry.js} +1 -1
  151. package/dist/sankhyablocks/p-f607db63.entry.js +1 -0
  152. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  153. package/dist/types/components/snk-application/snk-application.d.ts +3 -7
  154. package/dist/types/components/snk-attach/snk-attach.d.ts +9 -11
  155. package/dist/types/components/snk-crud/snk-crud.d.ts +1 -36
  156. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +0 -23
  157. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +3 -28
  158. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +0 -19
  159. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +4 -24
  160. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +1 -4
  161. package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +0 -21
  162. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +2 -61
  163. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +1 -4
  164. package/dist/types/components/snk-form/snk-form.d.ts +0 -14
  165. package/dist/types/components/snk-grid/snk-grid.d.ts +6 -46
  166. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -58
  167. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
  168. package/dist/types/components.d.ts +4 -220
  169. package/dist/types/lib/@types/index.d.ts +0 -5
  170. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +1 -2
  171. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +1 -2
  172. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +0 -1
  173. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +0 -1
  174. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +0 -6
  175. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +3 -0
  176. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +0 -3
  177. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +1 -2
  178. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +0 -1
  179. package/package.json +1 -1
  180. package/dist/cjs/RecordIDUtils-3735135c.js +0 -43
  181. package/dist/cjs/pesquisa-fetcher-680e198f.js +0 -166
  182. package/dist/cjs/snk-data-unit-685272e7.js +0 -679
  183. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +0 -1
  184. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +0 -1
  185. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +0 -97
  186. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +0 -74
  187. package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +0 -1
  188. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +0 -58
  189. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +0 -55
  190. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +0 -88
  191. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +0 -20
  192. package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +0 -38
  193. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +0 -24
  194. package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +0 -18
  195. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +0 -35
  196. package/dist/collection/lib/dataUnit/ValueFormatter.js +0 -4
  197. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +0 -1
  198. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +0 -1
  199. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +0 -1
  200. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +0 -22
  201. package/dist/components/ISave.js +0 -47
  202. package/dist/components/pesquisa-fetcher.js +0 -164
  203. package/dist/esm/RecordIDUtils-87d02110.js +0 -41
  204. package/dist/esm/pesquisa-fetcher-03c8f919.js +0 -164
  205. package/dist/esm/snk-data-unit-63f83504.js +0 -677
  206. package/dist/sankhyablocks/p-14b9f964.entry.js +0 -1
  207. package/dist/sankhyablocks/p-19c18d06.entry.js +0 -1
  208. package/dist/sankhyablocks/p-1db45d26.entry.js +0 -1
  209. package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
  210. package/dist/sankhyablocks/p-30cf616e.js +0 -1
  211. package/dist/sankhyablocks/p-3a212712.js +0 -1
  212. package/dist/sankhyablocks/p-47b60deb.entry.js +0 -1
  213. package/dist/sankhyablocks/p-7505da04.entry.js +0 -1
  214. package/dist/sankhyablocks/p-75f83d1d.entry.js +0 -1
  215. package/dist/sankhyablocks/p-7a337364.js +0 -1
  216. package/dist/sankhyablocks/p-829d4045.js +0 -1
  217. package/dist/sankhyablocks/p-82a0bfb0.entry.js +0 -11
  218. package/dist/sankhyablocks/p-8fc470e5.entry.js +0 -1
  219. package/dist/sankhyablocks/p-941bf3ef.entry.js +0 -1
  220. package/dist/sankhyablocks/p-9863d682.js +0 -1
  221. package/dist/sankhyablocks/p-af8efd95.js +0 -6
  222. package/dist/sankhyablocks/p-b4b21558.entry.js +0 -1
  223. package/dist/sankhyablocks/p-bad55caa.entry.js +0 -1
  224. package/dist/sankhyablocks/p-c053256c.entry.js +0 -1
  225. package/dist/sankhyablocks/p-c5268346.entry.js +0 -1
  226. package/dist/sankhyablocks/p-cefba299.js +0 -1
  227. package/dist/sankhyablocks/p-dc7c9047.js +0 -1
  228. package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
  229. package/dist/sankhyablocks/p-fcac4dfc.js +0 -1
  230. package/dist/sankhyablocks/p-fe79f83a.js +0 -60
  231. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +0 -4
  232. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +0 -4
  233. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +0 -14
  234. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +0 -12
  235. package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +0 -5
  236. package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +0 -17
  237. package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +0 -17
  238. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +0 -77
  239. package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +0 -4
  240. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
  241. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +0 -3
  242. package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +0 -3
  243. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +0 -11
  244. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +0 -2
  245. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +0 -3
  246. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +0 -10
  247. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +0 -7
  248. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +0 -20
@@ -1,47 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { JSUtils, DataType, Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
2
+ import { Action, ObjectUtils, JSUtils, DataUnitAction, ApplicationContext, DataType } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
5
- import { g as getRecordValue, d as DatasetStrategy } from './dataunit-fetcher.js';
6
- import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
7
-
8
- const getSelectedIDs = (dataUnit) => {
9
- const selectionInfo = dataUnit.getSelectionInfo();
10
- if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
11
- return [];
12
- }
13
- const selectedRecordsIDsInfo = [];
14
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
15
- if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
16
- selectedRecords.forEach(recordId => {
17
- if (!dataUnit.isNewRecord(recordId)) {
18
- /*
19
- Esse if foi necessário para tratar corretamente o ID
20
- do record quando está sendo utilizado no modo standAlone
21
- isso não faz a exportação da grid funcionar no modo standAlone
22
- mas deixa de causar erro nas oprações de CRUD.
23
- */
24
- if (!JSUtils.isBase64(recordId)) {
25
- selectedRecordsIDsInfo.push({
26
- name: "__record__id__",
27
- type: DataType.TEXT,
28
- value: recordId
29
- });
30
- return;
31
- }
32
- const revertBase64ToObject = JSON.parse(window.atob(recordId));
33
- Object.entries(revertBase64ToObject).forEach(([name, value]) => {
34
- const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
35
- if (metadataField == undefined) {
36
- return;
37
- }
38
- selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
39
- });
40
- }
41
- });
42
- }
43
- return selectedRecordsIDsInfo;
44
- };
45
5
 
46
6
  const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
47
7
  constructor() {
@@ -50,41 +10,54 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
50
10
  this.dataStateChange = createEvent(this, "dataStateChange", 3);
51
11
  this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
52
12
  this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
53
- this.dataUnitFieldsHidded = createEvent(this, "dataUnitFieldsHidded", 7);
54
13
  this.insertionMode = createEvent(this, "insertionMode", 3);
55
14
  this.cancelEdition = createEvent(this, "cancelEdition", 3);
56
15
  this._onDataUnitResolve = [];
57
16
  this._openedAlert = false;
58
- this._fieldsWithRmp = [];
59
- this._fieldsWithRmPrecision = [];
60
- this._metadataByRow = new Map();
61
- this._rowMetadataCache = new Map();
62
- this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
63
- this._dataUnitObserver = async (action) => {
64
- const duState = this.buildDataState(action.type);
17
+ this._dataUnitObserver = (action) => {
18
+ var _a, _b;
19
+ const duState = this.buildDataState();
65
20
  this.dataState = duState;
66
- this.messagesBuilder.currentOperation = this.getMessageOperation();
67
- switch (action.type) {
68
- case Action.DATA_SAVED:
69
- await this.handleDataSaved(action);
70
- break;
71
- case Action.RECORDS_ADDED:
72
- case Action.RECORDS_COPIED:
73
- this.insertionMode.emit();
74
- break;
75
- case Action.EDITION_CANCELED:
76
- this.cancelEdition.emit();
77
- break;
78
- case Action.RECORDS_REMOVED:
79
- this.handleRecordsRemoved(action);
80
- break;
81
- case Action.METADATA_LOADED:
82
- this.fillFieldsWithRmp(this.dataUnit.metadata);
83
- this.fillFieldsWithRmPrecision(this.dataUnit.metadata);
84
- break;
21
+ if (action.type === Action.DATA_SAVED) {
22
+ if (this.ignoreSaveMessage) {
23
+ return;
24
+ }
25
+ const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
26
+ if (msg != undefined) {
27
+ this.showSuccessMessage(msg);
28
+ }
29
+ }
30
+ if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
31
+ this.insertionMode.emit();
32
+ }
33
+ if (action.type === Action.EDITION_CANCELED) {
34
+ this.cancelEdition.emit();
85
35
  }
36
+ if (action.type === Action.RECORDS_REMOVED) {
37
+ const cachedRecords = action.payload.cachedRecords;
38
+ let removeFinishMsg;
39
+ if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
40
+ removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
41
+ }
42
+ else {
43
+ removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
44
+ }
45
+ if (removeFinishMsg != undefined) {
46
+ this.showSuccessMessage(removeFinishMsg);
47
+ }
48
+ const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
49
+ const paginationInfo = this.dataUnit.getPaginationInfo();
50
+ if (paginationInfo) {
51
+ if (recordsCount > 0 || paginationInfo.hasMore) {
52
+ this.dataUnit.gotoPage(paginationInfo.currentPage);
53
+ }
54
+ else {
55
+ this.dataUnit.gotoPage(0);
56
+ }
57
+ }
58
+ }
59
+ this.messagesBuilder.currentOperation = this.getMessageOperation();
86
60
  };
87
- this.fieldsToLink = [];
88
61
  this.dataState = undefined;
89
62
  this.messagesBuilder = undefined;
90
63
  this.dataUnitName = undefined;
@@ -152,320 +125,169 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
152
125
  * @returns Retorna a lista de IDs dos registros selecionados.
153
126
  */
154
127
  async getSelectedRecordsIDsInfo() {
155
- return Promise.resolve(getSelectedIDs(this.dataUnit));
156
- }
157
- /**
158
- * Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
159
- */
160
- async getFieldsWithRmp() {
161
- return this._fieldsWithRmp;
162
- }
163
- /**
164
- * Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
165
- */
166
- async getFieldsWithRmPrecision() {
167
- return this._fieldsWithRmPrecision;
168
- }
169
- /**
170
- * Busca os metadados da linha selecionada.
171
- */
172
- async getRowMetadata(record) {
173
- return this.doGetRowMetadata(record);
174
- }
175
- doGetRowMetadata(record) {
176
- const selectedRecord = this.dataUnit.getSelectedRecord();
177
- if (!record && !selectedRecord) {
178
- return;
179
- }
180
- const currentRecord = record || selectedRecord;
181
- const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
182
- const rowMetadata = this._metadataByRow.get(recordId);
183
- if (!rowMetadata) {
184
- return;
185
- }
186
- rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
187
- return Object.assign({}, rowMetadata);
188
- }
189
- buildGetPropRowMetadata(rowMetadata) {
190
- return (propPath, fieldName) => {
191
- if (propPath === "rm_precision") {
192
- propPath = this.resolvePrecisionFromMetadata(fieldName);
193
- }
194
- return ObjectUtils.getProp(rowMetadata, propPath);
195
- };
196
- }
197
- resolvePrecisionFromMetadata(fieldName) {
198
- var _a, _b;
199
- if (!fieldName) {
200
- ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
201
- return;
202
- }
203
- const rmPrecision = (_b = (_a = this.dataUnit.getField(fieldName)) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.rm_precision;
204
- if (!rmPrecision) {
205
- return '';
128
+ var _a;
129
+ const selectionInfo = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
130
+ if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
131
+ return [];
132
+ }
133
+ const selectedRecordsIDsInfo = [];
134
+ const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
135
+ if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
136
+ selectedRecords.forEach(({ __record__id__ }) => {
137
+ if (!this.dataUnit.isNewRecord(__record__id__)) {
138
+ /*
139
+ Esse if foi necessário para tratar corretamente o ID
140
+ do record quando está sendo utilizado no modo standAlone
141
+ isso não faz a exportação da grid funcionar no modo standAlone
142
+ mas deixa de causar erro nas oprações de CRUD.
143
+ */
144
+ if (!JSUtils.isBase64(__record__id__)) {
145
+ selectedRecordsIDsInfo.push({
146
+ name: "__record__id__",
147
+ type: DataType.TEXT,
148
+ value: __record__id__
149
+ });
150
+ return;
151
+ }
152
+ const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
153
+ Object.entries(revertBase64ToObject).forEach(([name, value]) => {
154
+ var _a;
155
+ const metadataField = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
156
+ if (metadataField == undefined) {
157
+ return;
158
+ }
159
+ selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
160
+ });
161
+ }
162
+ });
206
163
  }
207
- let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
208
- return rmPrecisionPath;
164
+ return selectedRecordsIDsInfo;
209
165
  }
210
166
  getCleanOnCopyFields() {
211
167
  var _a;
212
168
  return (_a = this.dataUnit.metadata) === null || _a === void 0 ? void 0 : _a.fields.filter(field => { var _a; return (_a = field.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; }).map(field => field.name);
213
169
  }
214
- fillFieldsWithRmp(payload) {
215
- payload.fields.forEach((field) => {
216
- var _a;
217
- if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
218
- this._fieldsWithRmp.push(field.name);
219
- }
220
- });
221
- }
222
- fillFieldsWithRmPrecision(payload) {
223
- payload.fields.forEach((field) => {
224
- var _a;
225
- if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
226
- this._fieldsWithRmPrecision.push(field.name);
227
- }
228
- });
229
- }
230
- getCacheName(fieldName, metadataName, fieldValue) {
231
- const cacheName = [fieldName, metadataName, fieldValue].join("_");
232
- return cacheName;
233
- }
234
- updateDataStateRmp(newValue) {
235
- const newRowMetadata = Object.assign({}, newValue);
236
- this.dataState.rowMetadata = newRowMetadata;
237
- }
238
- saveCacheRmd(record) {
239
- const rmd = record.__record__metadata__;
240
- const keysRmd = Object.keys(rmd);
241
- keysRmd.shift();
242
- keysRmd.forEach((fieldName) => {
243
- const fieldValue = getRecordValue(record, fieldName);
244
- const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
245
- this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
246
- });
247
- }
248
- getMetadataByRow(payload) {
249
- var _a;
250
- if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
251
- return payload;
252
- }
253
- if (!this._fieldsWithRmp.length) {
254
- const records = payload.records.map((record) => {
255
- delete record.__record__metadata__;
256
- return record;
257
- });
258
- return Object.assign(Object.assign({}, payload), { records });
259
- }
260
- const records = payload.records.map((record) => {
261
- if (!record.__record__metadata__) {
262
- return record;
263
- }
264
- this.saveCacheRmd(record);
265
- const rowMetadata = Object.assign({}, record.__record__metadata__);
266
- rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
267
- this._metadataByRow.set(record.__record__id__, rowMetadata);
268
- delete record.__record__metadata__;
269
- return record;
270
- });
271
- return Object.assign(Object.assign({}, payload), { records });
272
- }
273
- interceptRecordsAdded(action) {
274
- if (!this.isAllowed("INSERT")) {
275
- ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
276
- return;
277
- }
278
- return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
279
- }
280
- interceptRecordsCopied(action) {
281
- if (!this.isAllowed("CLONE")) {
282
- ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
283
- return;
284
- }
285
- return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
286
- }
287
- async interceptDataChange(action) {
288
- if (this.isAllowed("UPDATE")) {
289
- return action;
290
- }
291
- if (this._openedAlert) {
292
- await this.dataUnit.cancelEdition();
293
- return;
294
- }
295
- this._openedAlert = true;
296
- await this.dataUnit.cancelEdition();
297
- await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
298
- this._openedAlert = false;
299
- }
300
- async interceptSavingData(action) {
301
- if (!this.beforeSave) {
302
- return action;
303
- }
304
- const continueAction = this.beforeSave(this.dataUnit);
305
- if (continueAction instanceof Promise) {
306
- const result = await continueAction;
307
- return result ? action : undefined;
308
- }
309
- return continueAction ? action : undefined;
310
- }
311
- interceptDataSaved(action) {
312
- if (this.afterSave) {
313
- this.afterSave(this.dataUnit);
314
- return;
315
- }
316
- return action;
317
- }
318
- async interceptEditionCanceled(action) {
319
- var _a, _b;
320
- if (!this.useCancelConfirm || !this.dataState.hasDirtyRecords || ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
321
- return action;
322
- }
323
- const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
324
- if (cancelConfirmation == undefined) {
325
- this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
326
- return action;
327
- }
328
- const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
329
- const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
330
- confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
331
- return confirm ? action : undefined;
332
- }
333
- async interceptRemovingRecords(action) {
334
- var _a, _b, _c;
335
- if (!this.isAllowed("REMOVE")) {
336
- ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
337
- return;
338
- }
339
- let multipleSelection = false;
340
- let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
341
- const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
342
- if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
343
- removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
344
- multipleSelection = true;
345
- }
346
- if (!removeConfirmation) {
347
- return action;
348
- }
349
- const options = {
350
- canClose: false,
351
- labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
352
- labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
353
- btnConfirmDanger: false
354
- };
355
- const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
356
- const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
357
- return confirm ? action : undefined;
358
- }
359
- interceptDataLoaded(action) {
360
- const newPayload = this.getMetadataByRow(action.payload);
361
- action = new DataUnitAction(Action.DATA_LOADED, newPayload);
362
- return action;
363
- }
364
- interceptMetadataLoaded(action) {
365
- this.fillFieldsWithRmp(action.payload);
366
- this.fillFieldsWithRmPrecision(action.payload);
367
- return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
368
- }
369
170
  async interceptAction(action) {
370
- switch (action.type) {
371
- case Action.RECORDS_ADDED:
372
- return this.interceptRecordsAdded(action);
373
- case Action.RECORDS_COPIED:
374
- return this.interceptRecordsCopied(action);
375
- case Action.DATA_CHANGED:
376
- await this.handleLoadRowMetadata(action);
377
- return await this.interceptDataChange(action);
378
- case Action.CHANGING_DATA:
379
- return await this.interceptDataChange(action);
380
- case Action.SAVING_DATA:
381
- return await this.interceptSavingData(action);
382
- case Action.DATA_SAVED:
383
- return this.interceptDataSaved(action);
384
- case Action.EDITION_CANCELED:
385
- return await this.interceptEditionCanceled(action);
386
- case Action.REMOVING_RECORDS:
387
- return await this.interceptRemovingRecords(action);
388
- case Action.DATA_LOADED:
389
- return this.interceptDataLoaded(action);
390
- case Action.METADATA_LOADED:
391
- return this.interceptMetadataLoaded(action);
392
- default:
393
- return action;
394
- }
395
- }
396
- async handleLoadRowMetadata(action) {
397
- const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
398
- const keysPayload = Object.keys(record);
399
- const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
400
- if (rmpField) {
401
- const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
402
- const fieldValue = getRecordValue(record, rmpField);
403
- return await this.updateRowMetadata({
404
- fieldName: rmpField,
405
- fieldValue,
406
- metadataName,
407
- updatedFields: record,
408
- });
409
- }
410
- }
411
- async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
412
- const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
413
- const cacheValue = this._rowMetadataCache.get(cacheName);
414
- if (cacheValue) {
415
- this.updateDataStateRmp(cacheValue);
416
- return cacheValue;
417
- }
418
- else {
419
- const datasetStrategy = new DatasetStrategy();
420
- const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
421
- this.updateDataStateRmp(response._rmd);
422
- this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
423
- return Object.assign({}, response._rmd);
424
- }
425
- }
426
- handleDULinksOnMetadataLoaded(payload) {
427
- const metadata = Object.assign({}, payload);
428
- this.processLinks(metadata);
429
- return metadata;
430
- }
431
- handleRecordsCopied(initialRecords) {
432
- let records = [...initialRecords];
433
- records = this.handleCleanOnCopy(records);
434
- return this.handleLinksWithParent(records);
435
- }
436
- handleLinksWithParent(records) {
437
- var _a, _b;
438
- const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
439
- if (!parentDataUnit)
440
- return records;
441
- const parentSelectedRecord = parentDataUnit.getSelectedRecord();
442
- const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
443
- const { links } = selfInfo;
444
- if (!links || links.length === 0)
445
- return records;
446
- return records.map(record => {
447
- return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
448
- });
449
- }
450
- buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
451
- const newRecord = Object.assign({}, record);
452
- links.forEach(link => {
453
- const convertedParentSelectedRecord = convertType(this.dataUnit.getField(link.target).dataType, parentSelectedRecord[link.source]);
454
- newRecord[link.target] = convertedParentSelectedRecord;
171
+ return new Promise(resolve => {
172
+ var _a, _b, _c, _d, _e;
173
+ switch (action.type) {
174
+ case Action.RECORDS_ADDED:
175
+ if (this.isAllowed("INSERT")) {
176
+ resolve(action);
177
+ }
178
+ else {
179
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
180
+ }
181
+ break;
182
+ case Action.RECORDS_COPIED:
183
+ if (this.isAllowed("CLONE")) {
184
+ const cleanFields = this.getCleanOnCopyFields();
185
+ if (cleanFields.length > 0) {
186
+ const records = action.payload;
187
+ action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
188
+ const newRecord = Object.assign({}, record);
189
+ cleanFields.forEach(fieldName => delete newRecord[fieldName]);
190
+ return newRecord;
191
+ }));
192
+ }
193
+ resolve(action);
194
+ }
195
+ else {
196
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
197
+ }
198
+ break;
199
+ case Action.DATA_CHANGED:
200
+ case Action.CHANGING_DATA:
201
+ if (this.isAllowed("UPDATE"))
202
+ return resolve(action);
203
+ if (this._openedAlert)
204
+ return this.dataUnit.cancelEdition();
205
+ this._openedAlert = true;
206
+ this.dataUnit.cancelEdition();
207
+ ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
208
+ this._openedAlert = false;
209
+ });
210
+ break;
211
+ case Action.SAVING_DATA:
212
+ if (this.beforeSave) {
213
+ const continueAction = this.beforeSave(this.dataUnit);
214
+ if (continueAction instanceof Promise) {
215
+ continueAction.then(result => resolve(result ? action : undefined));
216
+ }
217
+ else {
218
+ resolve(continueAction ? action : undefined);
219
+ }
220
+ }
221
+ else {
222
+ resolve(action);
223
+ }
224
+ break;
225
+ case Action.DATA_SAVED:
226
+ if (this.afterSave) {
227
+ this.afterSave(this.dataUnit);
228
+ }
229
+ else {
230
+ resolve(action);
231
+ }
232
+ break;
233
+ case Action.EDITION_CANCELED:
234
+ if (!this.useCancelConfirm)
235
+ return resolve(action);
236
+ if (this.dataState.hasDirtyRecords) {
237
+ const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
238
+ if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
239
+ resolve(action);
240
+ return;
241
+ }
242
+ if (cancelConfirmation == undefined) {
243
+ this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
244
+ resolve(action);
245
+ }
246
+ else {
247
+ const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
248
+ ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
249
+ .then((result) => {
250
+ result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
251
+ resolve(result ? action : undefined);
252
+ });
253
+ }
254
+ }
255
+ else {
256
+ resolve(action);
257
+ }
258
+ break;
259
+ case Action.REMOVING_RECORDS:
260
+ if (this.isAllowed("REMOVE")) {
261
+ let multipleSelection = false;
262
+ let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
263
+ const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
264
+ if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
265
+ removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
266
+ multipleSelection = true;
267
+ }
268
+ if (!removeConfirmation) {
269
+ resolve(action);
270
+ }
271
+ else {
272
+ const options = {
273
+ canClose: false,
274
+ labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
275
+ labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
276
+ btnConfirmDanger: false
277
+ };
278
+ const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
279
+ ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
280
+ .then((result) => resolve(result ? action : undefined));
281
+ }
282
+ }
283
+ else {
284
+ ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
285
+ }
286
+ break;
287
+ default:
288
+ resolve(action);
289
+ }
455
290
  });
456
- return newRecord;
457
- }
458
- handleCleanOnCopy(records) {
459
- const cleanFields = this.getCleanOnCopyFields();
460
- if (cleanFields.length > 0) {
461
- records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
462
- }
463
- return records;
464
- }
465
- buildCopyWithCleanedFields(record, cleanFields) {
466
- const newRecord = Object.assign({}, record);
467
- cleanFields.forEach(fieldName => delete newRecord[fieldName]);
468
- return newRecord;
469
291
  }
470
292
  showSuccessMessage(message) {
471
293
  ApplicationUtils.info(message, { iconName: "check" });
@@ -473,19 +295,9 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
473
295
  isAllowed(flag) {
474
296
  return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
475
297
  }
476
- buildDataState(actionType) {
477
- var _a;
298
+ buildDataState() {
478
299
  const selectionInfo = this.dataUnit.getSelectionInfo();
479
300
  const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
480
- const selectedRecord = this.dataUnit.getSelectedRecord();
481
- let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
482
- const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
483
- if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
484
- rowMetadata = this.doGetRowMetadata(selectedRecord);
485
- }
486
- else if (rowMetadata) {
487
- rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
488
- }
489
301
  return new DataStateImpl({
490
302
  insertionMode: this.dataUnit.hasNewRecord(),
491
303
  isStartingInsertionMode,
@@ -496,48 +308,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
496
308
  hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
497
309
  selectedRecords: undefined,
498
310
  selectionInfo,
499
- selectedRecord,
500
- recordsIsEmpty: this.dataUnit.records.length === 0,
501
- metadataByRow: this._metadataByRow,
502
- rowMetadata
311
+ selectedRecord: this.dataUnit.getSelectedRecord(),
312
+ recordsIsEmpty: this.dataUnit.records.length === 0
503
313
  });
504
314
  }
505
- async handleDataSaved(action) {
506
- const newRowMetadata = await this.handleLoadRowMetadata(action);
507
- if (newRowMetadata) {
508
- newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
509
- }
510
- const recordId = action.payload.records[0].__record__id__;
511
- this._metadataByRow.set(recordId, newRowMetadata);
512
- this.dataState = this.buildDataState();
513
- if (this.ignoreSaveMessage) {
514
- return;
515
- }
516
- const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
517
- if (msg != undefined) {
518
- this.showSuccessMessage(msg);
519
- }
520
- }
521
- handleRecordsRemoved(action) {
522
- var _a, _b;
523
- const cachedRecords = action.payload.cachedRecords;
524
- let removeFinishMsg;
525
- if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
526
- removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
527
- }
528
- else {
529
- removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
530
- }
531
- if (removeFinishMsg != undefined) {
532
- this.showSuccessMessage(removeFinishMsg);
533
- }
534
- const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
535
- const paginationInfo = this.dataUnit.getPaginationInfo();
536
- if (paginationInfo) {
537
- const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
538
- this.dataUnit.gotoPage(page);
539
- }
540
- }
541
315
  /**
542
316
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
543
317
  * através de um pequeno modulo na estrutura da aplicação:
@@ -579,7 +353,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
579
353
  }
580
354
  }
581
355
  async loadDataUnit() {
582
- var _a;
583
356
  if (this.dataUnit == null && this._application && this.entityName) {
584
357
  this.dataUnit = await this.getDataUnitParentOrChild();
585
358
  }
@@ -588,10 +361,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
588
361
  this.dataUnit.unsubscribe(this._dataUnitObserver);
589
362
  this.dataUnit.addInterceptor(this);
590
363
  this.dataUnit.subscribe(this._dataUnitObserver);
591
- await this.dataUnit.loadMetadata();
592
- if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
593
- this.getMetadataByRow(this.dataUnit);
594
- }
595
364
  this.dataState = this.buildDataState();
596
365
  let resolver;
597
366
  while (resolver = this._onDataUnitResolve.pop()) {
@@ -610,40 +379,20 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
610
379
  return;
611
380
  }
612
381
  handlerLinkFields() {
613
- var _a, _b, _c, _d;
614
- const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
615
- if (!parentDU)
382
+ var _a, _b;
383
+ const metadata = Object.assign({}, this.dataUnit.metadata);
384
+ if (!this._parentDataUnit)
616
385
  return;
617
- const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
618
- const child = parentDU.getChildInfo(childName);
386
+ const child = this._parentDataUnit.getChildInfo(this.entityName);
619
387
  if (!child)
620
388
  return;
621
- const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
622
- this.handleDUWithLinks(links);
623
- }
624
- handleDUWithLinks(fieldsToLink) {
625
- this.fieldsToLink = fieldsToLink;
626
- const metadata = Object.assign({}, this.dataUnit.metadata);
627
- this.processLinks(metadata);
628
- this.dataUnit.metadata = metadata;
629
- this.dataUnitFieldsHidded.emit();
630
- }
631
- processLinks(metadata) {
632
- var _a;
633
- (_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
634
- var _a;
635
- if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
389
+ const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
390
+ (_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
391
+ if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
636
392
  field.visible = false;
637
393
  }
638
394
  });
639
- }
640
- getCleanDataUnitName() {
641
- var _a;
642
- const uri = this.dataUnit.name;
643
- if (StringUtils.isEmpty(uri))
644
- return uri;
645
- const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
646
- return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
395
+ this.dataUnit.metadata = metadata;
647
396
  }
648
397
  static getNearestInstance(element) {
649
398
  let parent = element.parentElement;
@@ -670,9 +419,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
670
419
  this.dataUnit.releaseCallbacks();
671
420
  }
672
421
  }
673
- async componentDidLoad() {
674
- await this.loadDataUnit();
675
- this.handlerLinkFields();
422
+ componentDidLoad() {
423
+ this.loadDataUnit();
676
424
  }
677
425
  render() {
678
426
  return (h(Host, null));
@@ -699,12 +447,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
699
447
  "ignoreSaveMessage": [4, "ignore-save-message"],
700
448
  "configName": [1, "config-name"],
701
449
  "resourceID": [1, "resource-i-d"],
702
- "fieldsToLink": [32],
703
450
  "getDataUnit": [64],
704
- "getSelectedRecordsIDsInfo": [64],
705
- "getFieldsWithRmp": [64],
706
- "getFieldsWithRmPrecision": [64],
707
- "getRowMetadata": [64]
451
+ "getSelectedRecordsIDsInfo": [64]
708
452
  }]);
709
453
  class DataStateImpl {
710
454
  constructor(datastate) {
@@ -718,8 +462,6 @@ class DataStateImpl {
718
462
  this.selectionInfo = datastate.selectionInfo;
719
463
  this.selectedRecord = datastate.selectedRecord;
720
464
  this.recordsIsEmpty = datastate.recordsIsEmpty;
721
- this.metadataByRow = datastate.metadataByRow;
722
- this.rowMetadata = datastate.rowMetadata;
723
465
  }
724
466
  get selectedRecords() {
725
467
  var _a;
@@ -744,4 +486,4 @@ function defineCustomElement() {
744
486
  } });
745
487
  }
746
488
 
747
- export { SnkDataUnit as S, defineCustomElement as d, getSelectedIDs as g };
489
+ export { SnkDataUnit as S, defineCustomElement as d };