@sankhyalabs/sankhyablocks 8.15.1 → 8.16.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 (216) hide show
  1. package/dist/cjs/{SnkMultiSelectionListDataSource-303e85d1.js → IExporterProvider-c78cb1b8.js} +94 -4
  2. package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
  3. package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-1b13bacd.js} +6 -3
  4. package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-722b104e.js} +8 -12
  5. package/dist/cjs/{pesquisa-fetcher-213797ec.js → dataunit-fetcher-620b29a1.js} +87 -180
  6. package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/pesquisa-fetcher-680e198f.js +166 -0
  9. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  10. package/dist/cjs/snk-actions-button_4.cjs.entry.js +4 -2
  11. package/dist/cjs/snk-application.cjs.entry.js +34 -11
  12. package/dist/cjs/snk-attach.cjs.entry.js +71 -46
  13. package/dist/cjs/snk-crud.cjs.entry.js +96 -10
  14. package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
  15. package/dist/cjs/snk-data-unit-82dea87e.js +679 -0
  16. package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
  17. package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
  18. package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
  19. package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
  20. package/dist/cjs/snk-form.cjs.entry.js +51 -6
  21. package/dist/cjs/snk-grid.cjs.entry.js +164 -107
  22. package/dist/cjs/{snk-guides-viewer-4b6ecda8.js → snk-guides-viewer-05a1ba27.js} +36 -8
  23. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
  24. package/dist/cjs/snk-simple-crud.cjs.entry.js +264 -37
  25. package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
  26. package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
  27. package/dist/collection/collection-manifest.json +1 -1
  28. package/dist/collection/components/snk-application/snk-application.js +35 -11
  29. package/dist/collection/components/snk-attach/snk-attach.js +67 -44
  30. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  31. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  32. package/dist/collection/components/snk-crud/snk-crud.js +249 -7
  33. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  34. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
  35. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +112 -5
  36. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +97 -0
  37. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
  38. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
  39. package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
  40. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
  41. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
  42. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
  43. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
  44. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
  45. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
  46. package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
  47. package/dist/collection/components/snk-data-unit/snk-data-unit.js +507 -214
  48. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  49. package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
  50. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  51. package/dist/collection/components/snk-form/snk-form.js +102 -5
  52. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -3
  53. package/dist/collection/components/snk-grid/snk-grid.js +240 -101
  54. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +386 -18
  55. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
  56. package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
  57. package/dist/collection/lib/@types/index.js +5 -0
  58. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  59. package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
  60. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  61. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  62. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
  63. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
  64. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
  65. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
  66. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  67. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  68. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +53 -4
  69. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  70. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
  71. package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
  72. package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
  73. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  74. package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
  75. package/dist/components/ISave.js +47 -0
  76. package/dist/components/SnkFormConfigManager.js +6 -3
  77. package/dist/components/SnkMessageBuilder.js +8 -12
  78. package/dist/components/dataunit-fetcher.js +84 -182
  79. package/dist/components/index2.js +198 -33
  80. package/dist/components/pesquisa-fetcher.js +164 -0
  81. package/dist/components/snk-actions-button2.js +4 -11
  82. package/dist/components/snk-application2.js +31 -9
  83. package/dist/components/snk-attach2.js +65 -41
  84. package/dist/components/snk-crud.js +103 -11
  85. package/dist/components/snk-data-exporter2.js +309 -85
  86. package/dist/components/snk-data-unit2.js +470 -212
  87. package/dist/components/snk-detail-view2.js +87 -10
  88. package/dist/components/snk-expression-item2.js +1 -1
  89. package/dist/components/snk-filter-bar2.js +6 -1
  90. package/dist/components/snk-form-view2.js +72 -1
  91. package/dist/components/snk-form.js +53 -6
  92. package/dist/components/snk-grid2.js +168 -106
  93. package/dist/components/snk-personalized-filter2.js +1 -1
  94. package/dist/components/snk-simple-crud2.js +259 -23
  95. package/dist/components/snk-taskbar2.js +6 -5
  96. package/dist/esm/{SnkMultiSelectionListDataSource-36918dbf.js → IExporterProvider-343272b3.js} +93 -5
  97. package/dist/esm/RecordIDUtils-87d02110.js +41 -0
  98. package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-d4554df9.js} +6 -3
  99. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-89925609.js} +8 -12
  100. package/dist/esm/{pesquisa-fetcher-fe6f3826.js → dataunit-fetcher-3fbf9d12.js} +83 -181
  101. package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
  102. package/dist/esm/loader.js +1 -1
  103. package/dist/esm/pesquisa-fetcher-03c8f919.js +164 -0
  104. package/dist/esm/sankhyablocks.js +1 -1
  105. package/dist/esm/snk-actions-button_4.entry.js +4 -2
  106. package/dist/esm/snk-application.entry.js +33 -10
  107. package/dist/esm/snk-attach.entry.js +66 -41
  108. package/dist/esm/snk-crud.entry.js +96 -10
  109. package/dist/esm/snk-data-exporter.entry.js +316 -86
  110. package/dist/esm/snk-data-unit-8f98b45f.js +677 -0
  111. package/dist/esm/snk-data-unit.entry.js +12 -2
  112. package/dist/esm/snk-detail-view.entry.js +48 -7
  113. package/dist/esm/snk-filter-bar.entry.js +5 -1
  114. package/dist/esm/snk-form-view.entry.js +67 -0
  115. package/dist/esm/snk-form.entry.js +51 -6
  116. package/dist/esm/snk-grid.entry.js +162 -105
  117. package/dist/esm/{snk-guides-viewer-113be3fd.js → snk-guides-viewer-aee2cafe.js} +36 -8
  118. package/dist/esm/snk-guides-viewer.entry.js +8 -6
  119. package/dist/esm/snk-simple-crud.entry.js +252 -25
  120. package/dist/esm/snk-taskbar.entry.js +4 -3
  121. package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
  122. package/dist/sankhyablocks/p-0d91b10f.entry.js +1 -0
  123. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  124. package/dist/sankhyablocks/p-26394a01.entry.js +1 -0
  125. package/dist/sankhyablocks/p-2d649237.entry.js +1 -0
  126. package/dist/sankhyablocks/p-30cf616e.js +1 -0
  127. package/dist/sankhyablocks/p-44767378.entry.js +1 -0
  128. package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
  129. package/dist/sankhyablocks/p-4f72727a.entry.js +1 -0
  130. package/dist/sankhyablocks/p-550fee49.entry.js +1 -0
  131. package/dist/sankhyablocks/p-5539ecb4.entry.js +1 -0
  132. package/dist/sankhyablocks/p-672302c3.js +60 -0
  133. package/dist/sankhyablocks/p-7a337364.js +1 -0
  134. package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
  135. package/dist/sankhyablocks/p-829d4045.js +1 -0
  136. package/dist/sankhyablocks/p-8a5910a7.entry.js +1 -0
  137. package/dist/sankhyablocks/p-8cc64963.entry.js +1 -0
  138. package/dist/sankhyablocks/p-8fc470e5.entry.js +1 -0
  139. package/dist/sankhyablocks/p-9863d682.js +1 -0
  140. package/dist/sankhyablocks/p-9e99a92a.js +1 -0
  141. package/dist/sankhyablocks/p-af8efd95.js +6 -0
  142. package/dist/sankhyablocks/p-be603a24.js +1 -0
  143. package/dist/sankhyablocks/p-d09feef1.js +1 -0
  144. package/dist/sankhyablocks/p-e95b3b93.entry.js +11 -0
  145. package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
  146. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  147. package/dist/types/components/snk-application/snk-application.d.ts +7 -3
  148. package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
  149. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  150. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  151. package/dist/types/components/snk-crud/snk-crud.d.ts +36 -1
  152. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  153. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
  154. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +19 -0
  155. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
  156. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
  157. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
  158. package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
  159. package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
  160. package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
  161. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
  162. package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
  163. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
  164. package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
  165. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
  166. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +61 -2
  167. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  168. package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +3 -0
  169. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  170. package/dist/types/components/snk-form/snk-form.d.ts +14 -0
  171. package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
  172. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +58 -4
  173. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
  174. package/dist/types/components.d.ts +220 -4
  175. package/dist/types/lib/@types/index.d.ts +5 -0
  176. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  177. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  178. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  179. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  180. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
  181. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
  182. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
  183. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  184. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  185. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  186. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  187. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +3 -0
  188. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
  189. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
  190. package/package.json +1 -1
  191. package/dist/cjs/snk-data-unit-41c29713.js +0 -462
  192. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
  193. package/dist/components/index3.js +0 -199
  194. package/dist/esm/snk-data-unit-de1d140d.js +0 -460
  195. package/dist/sankhyablocks/p-032fe52e.js +0 -1
  196. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  197. package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
  198. package/dist/sankhyablocks/p-0899e0b5.entry.js +0 -1
  199. package/dist/sankhyablocks/p-154a7f33.entry.js +0 -1
  200. package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
  201. package/dist/sankhyablocks/p-164666b1.js +0 -65
  202. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  203. package/dist/sankhyablocks/p-328585d0.entry.js +0 -1
  204. package/dist/sankhyablocks/p-38289a55.js +0 -1
  205. package/dist/sankhyablocks/p-52c8e589.js +0 -1
  206. package/dist/sankhyablocks/p-5cb07080.js +0 -1
  207. package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
  208. package/dist/sankhyablocks/p-7fe120b8.entry.js +0 -11
  209. package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
  210. package/dist/sankhyablocks/p-af1ac81f.entry.js +0 -1
  211. package/dist/sankhyablocks/p-b4525fc0.entry.js +0 -1
  212. package/dist/sankhyablocks/p-cce0865d.js +0 -1
  213. package/dist/sankhyablocks/p-dec65f6c.entry.js +0 -1
  214. package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
  215. package/dist/sankhyablocks/p-f13f7616.entry.js +0 -1
  216. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -1,462 +0,0 @@
1
- 'use strict';
2
-
3
- const index = require('./index-f9e81701.js');
4
- const core = require('@sankhyalabs/core');
5
- const utils = require('@sankhyalabs/ezui/dist/collection/utils');
6
- const SnkMessageBuilder = require('./SnkMessageBuilder-66aa2557.js');
7
-
8
- const SnkDataUnit = class {
9
- constructor(hostRef) {
10
- index.registerInstance(this, hostRef);
11
- this.dataStateChange = index.createEvent(this, "dataStateChange", 3);
12
- this.dataUnitReady = index.createEvent(this, "dataUnitReady", 3);
13
- this.messagesBuilderUpdated = index.createEvent(this, "messagesBuilderUpdated", 3);
14
- this.insertionMode = index.createEvent(this, "insertionMode", 3);
15
- this.cancelEdition = index.createEvent(this, "cancelEdition", 3);
16
- this._onDataUnitResolve = [];
17
- this._openedAlert = false;
18
- this._dataUnitObserver = (action) => {
19
- var _a, _b;
20
- const duState = this.buildDataState();
21
- this.dataState = duState;
22
- if (action.type === core.Action.DATA_SAVED) {
23
- if (this.ignoreSaveMessage) {
24
- return;
25
- }
26
- const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
27
- if (msg != undefined) {
28
- this.showSuccessMessage(msg);
29
- }
30
- }
31
- if (action.type === core.Action.RECORDS_ADDED || action.type === core.Action.RECORDS_COPIED) {
32
- this.insertionMode.emit();
33
- }
34
- if (action.type === core.Action.EDITION_CANCELED) {
35
- this.cancelEdition.emit();
36
- }
37
- if (action.type === core.Action.RECORDS_REMOVED) {
38
- const cachedRecords = action.payload.cachedRecords;
39
- let removeFinishMsg;
40
- if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
41
- removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
42
- }
43
- else {
44
- removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
45
- }
46
- if (removeFinishMsg != undefined) {
47
- this.showSuccessMessage(removeFinishMsg);
48
- }
49
- const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
50
- const paginationInfo = this.dataUnit.getPaginationInfo();
51
- if (paginationInfo) {
52
- if (recordsCount > 0 || paginationInfo.hasMore) {
53
- this.dataUnit.gotoPage(paginationInfo.currentPage);
54
- }
55
- else {
56
- this.dataUnit.gotoPage(0);
57
- }
58
- }
59
- }
60
- this.messagesBuilder.currentOperation = this.getMessageOperation();
61
- };
62
- this.dataState = undefined;
63
- this.messagesBuilder = undefined;
64
- this.dataUnitName = undefined;
65
- this.entityName = undefined;
66
- this.pageSize = 150;
67
- this.dataUnit = undefined;
68
- this.beforeSave = undefined;
69
- this.afterSave = undefined;
70
- this.useCancelConfirm = true;
71
- this.ignoreSaveMessage = undefined;
72
- this.configName = undefined;
73
- this.resourceID = undefined;
74
- }
75
- observePageSize() {
76
- if (this.dataUnit) {
77
- this.dataUnit.pageSize = this.pageSize;
78
- }
79
- }
80
- observeDataUnitName(newValue, oldValue) {
81
- if (oldValue != newValue) {
82
- if (this.dataUnit) {
83
- this._application.updateDataunitCache(oldValue, this.dataUnitName, this.dataUnit);
84
- }
85
- else {
86
- this.loadDataUnit();
87
- }
88
- }
89
- }
90
- observeEntityName(newValue, oldValue) {
91
- if (oldValue != newValue) {
92
- this.dataUnit = undefined;
93
- this.entityName = newValue;
94
- this.loadDataUnit();
95
- }
96
- }
97
- observeDataState(newValue, oldValue) {
98
- if (core.ObjectUtils.objectToString(oldValue) != core.ObjectUtils.objectToString(newValue)) {
99
- this.dataStateChange.emit(newValue);
100
- }
101
- }
102
- observeDataUnit() {
103
- this.handlerLinkFields();
104
- this.dataUnitReady.emit(this.dataUnit);
105
- }
106
- observeMessagesBuilder(newValue) {
107
- if (newValue) {
108
- this.messagesBuilderUpdated.emit(newValue);
109
- }
110
- }
111
- /**
112
- * Obtém o dataUnit.
113
- */
114
- async getDataUnit() {
115
- return new Promise((resolve) => {
116
- if (this.dataUnit) {
117
- resolve(this.dataUnit);
118
- }
119
- else {
120
- this._onDataUnitResolve.push(resolve);
121
- }
122
- });
123
- }
124
- /**
125
- * Método que retorna a lista de IDs dos registros selecionados.
126
- * @returns Retorna a lista de IDs dos registros selecionados.
127
- */
128
- async getSelectedRecordsIDsInfo() {
129
- var _a;
130
- const selectionInfo = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
131
- if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
132
- return [];
133
- }
134
- const selectedRecordsIDsInfo = [];
135
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
136
- if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
137
- selectedRecords.forEach(({ __record__id__ }) => {
138
- if (!this.dataUnit.isNewRecord(__record__id__)) {
139
- /*
140
- Esse if foi necessário para tratar corretamente o ID
141
- do record quando está sendo utilizado no modo standAlone
142
- isso não faz a exportação da grid funcionar no modo standAlone
143
- mas deixa de causar erro nas oprações de CRUD.
144
- */
145
- if (!core.JSUtils.isBase64(__record__id__)) {
146
- selectedRecordsIDsInfo.push({
147
- name: "__record__id__",
148
- type: core.DataType.TEXT,
149
- value: __record__id__
150
- });
151
- return;
152
- }
153
- const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
154
- Object.entries(revertBase64ToObject).forEach(([name, value]) => {
155
- var _a;
156
- const metadataField = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
157
- if (metadataField == undefined) {
158
- return;
159
- }
160
- selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
161
- });
162
- }
163
- });
164
- }
165
- return selectedRecordsIDsInfo;
166
- }
167
- getCleanOnCopyFields() {
168
- var _a;
169
- 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);
170
- }
171
- async interceptAction(action) {
172
- return new Promise(resolve => {
173
- var _a, _b, _c, _d, _e;
174
- switch (action.type) {
175
- case core.Action.RECORDS_ADDED:
176
- if (this.isAllowed("INSERT")) {
177
- resolve(action);
178
- }
179
- else {
180
- utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
181
- }
182
- break;
183
- case core.Action.RECORDS_COPIED:
184
- if (this.isAllowed("CLONE")) {
185
- const cleanFields = this.getCleanOnCopyFields();
186
- if (cleanFields.length > 0) {
187
- const records = action.payload;
188
- action = new core.DataUnitAction(core.Action.RECORDS_COPIED, records.map(record => {
189
- const newRecord = Object.assign({}, record);
190
- cleanFields.forEach(fieldName => delete newRecord[fieldName]);
191
- return newRecord;
192
- }));
193
- }
194
- resolve(action);
195
- }
196
- else {
197
- utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
198
- }
199
- break;
200
- case core.Action.DATA_CHANGED:
201
- case core.Action.CHANGING_DATA:
202
- if (this.isAllowed("UPDATE"))
203
- return resolve(action);
204
- if (this._openedAlert)
205
- return this.dataUnit.cancelEdition();
206
- this._openedAlert = true;
207
- this.dataUnit.cancelEdition();
208
- utils.ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
209
- this._openedAlert = false;
210
- });
211
- break;
212
- case core.Action.SAVING_DATA:
213
- if (this.beforeSave) {
214
- const continueAction = this.beforeSave(this.dataUnit);
215
- if (continueAction instanceof Promise) {
216
- continueAction.then(result => resolve(result ? action : undefined));
217
- }
218
- else {
219
- resolve(continueAction ? action : undefined);
220
- }
221
- }
222
- else {
223
- resolve(action);
224
- }
225
- break;
226
- case core.Action.DATA_SAVED:
227
- if (this.afterSave) {
228
- this.afterSave(this.dataUnit);
229
- }
230
- else {
231
- resolve(action);
232
- }
233
- break;
234
- case core.Action.EDITION_CANCELED:
235
- if (!this.useCancelConfirm)
236
- return resolve(action);
237
- if (this.dataState.hasDirtyRecords) {
238
- const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
239
- if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
240
- resolve(action);
241
- return;
242
- }
243
- if (cancelConfirmation == undefined) {
244
- this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
245
- resolve(action);
246
- }
247
- else {
248
- const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
249
- utils.ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
250
- .then((result) => {
251
- result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
252
- resolve(result ? action : undefined);
253
- });
254
- }
255
- }
256
- else {
257
- resolve(action);
258
- }
259
- break;
260
- case core.Action.REMOVING_RECORDS:
261
- if (this.isAllowed("REMOVE")) {
262
- let multipleSelection = false;
263
- let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
264
- const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
265
- if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
266
- removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
267
- multipleSelection = true;
268
- }
269
- if (!removeConfirmation) {
270
- resolve(action);
271
- }
272
- else {
273
- const options = {
274
- canClose: false,
275
- labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
276
- labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
277
- btnConfirmDanger: false
278
- };
279
- const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
280
- utils.ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, utils.DialogType.WARN, options)
281
- .then((result) => resolve(result ? action : undefined));
282
- }
283
- }
284
- else {
285
- utils.ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
286
- }
287
- break;
288
- default:
289
- resolve(action);
290
- }
291
- });
292
- }
293
- showSuccessMessage(message) {
294
- utils.ApplicationUtils.info(message, { iconName: "check" });
295
- }
296
- isAllowed(flag) {
297
- return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
298
- }
299
- buildDataState() {
300
- const selectionInfo = this.dataUnit.getSelectionInfo();
301
- const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
302
- return new DataStateImpl({
303
- insertionMode: this.dataUnit.hasNewRecord(),
304
- isStartingInsertionMode,
305
- hasNext: this.dataUnit.hasNext(),
306
- hasPrevious: this.dataUnit.hasPrevious(),
307
- copyMode: this.dataUnit.hasCopiedRecord(),
308
- isDirty: this.dataUnit.isDirty(),
309
- hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
310
- selectedRecords: undefined,
311
- selectionInfo,
312
- selectedRecord: this.dataUnit.getSelectedRecord(),
313
- recordsIsEmpty: this.dataUnit.records.length === 0
314
- });
315
- }
316
- /**
317
- * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
318
- * através de um pequeno modulo na estrutura da aplicação:
319
- * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
320
- * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
321
- */
322
- getMessage(key, params = undefined) {
323
- if (!params) {
324
- params = this.getMessageParams();
325
- }
326
- return this.messagesBuilder.getMessage(key, params);
327
- }
328
- getMessageParams() {
329
- //FIXME: Devido ao recurso de multiseleção do dataunit, precisaremos criar um mecanismo para
330
- //oferecer todos os registros selecionados para a mensagem, pois mensagens podem ficar incorretas.
331
- return this.dataState.selectedRecord;
332
- }
333
- getMessageOperation() {
334
- if (this.dataState.copyMode) {
335
- return SnkMessageBuilder.OperationMap.CLONE;
336
- }
337
- if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
338
- return SnkMessageBuilder.OperationMap.INSERT;
339
- }
340
- if (this.dataState.isDirty) {
341
- return SnkMessageBuilder.OperationMap.UPDATE;
342
- }
343
- return SnkMessageBuilder.OperationMap.CLEAN;
344
- }
345
- async getDataUnitParentOrChild() {
346
- var _a;
347
- const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
348
- if (this._parentSnkDataUnit) {
349
- this._parentDataUnit = await ((_a = this._parentSnkDataUnit) === null || _a === void 0 ? void 0 : _a.getDataUnit());
350
- return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID);
351
- }
352
- else {
353
- return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
354
- }
355
- }
356
- async loadDataUnit() {
357
- if (this.dataUnit == null && this._application && this.entityName) {
358
- this.dataUnit = await this.getDataUnitParentOrChild();
359
- }
360
- if (this.dataUnit) {
361
- this.dataUnit.pageSize = this.pageSize;
362
- this.dataUnit.unsubscribe(this._dataUnitObserver);
363
- this.dataUnit.addInterceptor(this);
364
- this.dataUnit.subscribe(this._dataUnitObserver);
365
- this.dataState = this.buildDataState();
366
- let resolver;
367
- while (resolver = this._onDataUnitResolve.pop()) {
368
- resolver(this.dataUnit);
369
- }
370
- }
371
- }
372
- getParentSnkDataUnit() {
373
- let currentElement = this.element;
374
- while (currentElement.parentNode) {
375
- if (currentElement.parentNode.nodeName === 'SNK-DATA-UNIT') {
376
- return currentElement.parentNode;
377
- }
378
- currentElement = currentElement.parentNode;
379
- }
380
- return;
381
- }
382
- handlerLinkFields() {
383
- var _a, _b;
384
- const metadata = Object.assign({}, this.dataUnit.metadata);
385
- if (!this._parentDataUnit)
386
- return;
387
- const child = this._parentDataUnit.getChildInfo(this.entityName);
388
- if (!child)
389
- return;
390
- const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
391
- (_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
392
- if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
393
- field.visible = false;
394
- }
395
- });
396
- this.dataUnit.metadata = metadata;
397
- }
398
- static getNearestInstance(element) {
399
- let parent = element.parentElement;
400
- while (parent) {
401
- if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
402
- return parent;
403
- }
404
- parent = parent.parentElement;
405
- }
406
- }
407
- //---------------------------------------------
408
- // Lifecycle web component
409
- //---------------------------------------------
410
- componentWillLoad() {
411
- this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
412
- this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
413
- this._parentSnkDataUnit = this.getParentSnkDataUnit();
414
- if (this.messagesBuilder == undefined) {
415
- this.messagesBuilder = new SnkMessageBuilder.SnkMessageBuilder(this.entityName);
416
- }
417
- }
418
- disconnectedCallback() {
419
- if (this.dataUnit) {
420
- this.dataUnit.releaseCallbacks();
421
- }
422
- }
423
- componentDidLoad() {
424
- this.loadDataUnit();
425
- }
426
- render() {
427
- return (index.h(index.Host, null));
428
- }
429
- get element() { return index.getElement(this); }
430
- static get watchers() { return {
431
- "pageSize": ["observePageSize"],
432
- "dataUnitName": ["observeDataUnitName"],
433
- "entityName": ["observeEntityName"],
434
- "dataState": ["observeDataState"],
435
- "dataUnit": ["observeDataUnit"],
436
- "messagesBuilder": ["observeMessagesBuilder"]
437
- }; }
438
- };
439
- class DataStateImpl {
440
- constructor(datastate) {
441
- this.copyMode = datastate.copyMode;
442
- this.insertionMode = datastate.insertionMode;
443
- this.isStartingInsertionMode = datastate.isStartingInsertionMode;
444
- this.isDirty = datastate.isDirty;
445
- this.hasDirtyRecords = datastate.hasDirtyRecords;
446
- this.hasNext = datastate.hasNext;
447
- this.hasPrevious = datastate.hasPrevious;
448
- this.selectionInfo = datastate.selectionInfo;
449
- this.selectedRecord = datastate.selectedRecord;
450
- this.recordsIsEmpty = datastate.recordsIsEmpty;
451
- }
452
- get selectedRecords() {
453
- var _a;
454
- console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`.");
455
- if ((_a = this.selectionInfo) === null || _a === void 0 ? void 0 : _a.isAllRecords()) {
456
- throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");
457
- }
458
- return this.selectionInfo.records;
459
- }
460
- }
461
-
462
- exports.SnkDataUnit = SnkDataUnit;
@@ -1,34 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s)
4
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import { ApplicationContext, ObjectUtils } from "@sankhyalabs/core";
14
- import { DataFetcher } from '../../DataFetcher';
15
- export default function fetchDataExporter(_a) {
16
- var { methodName } = _a, requestBody = __rest(_a, ["methodName"]);
17
- const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
18
- const serviceName = `${application.getModuleName()}@DataExporterSPBean.${methodName}`;
19
- const payload = { serviceName, requestBody };
20
- return new Promise((resolve, reject) => {
21
- DataFetcher.get()
22
- .callServiceBroker(serviceName, ObjectUtils.objectToString(payload))
23
- .then(result => resolve(getFormatResponse(result)))
24
- .catch(error => reject(error));
25
- });
26
- }
27
- function getFormatResponse(result) {
28
- var _a;
29
- const response = (_a = result === null || result === void 0 ? void 0 : result.json) === null || _a === void 0 ? void 0 : _a.$;
30
- if (response == undefined) {
31
- return;
32
- }
33
- return ObjectUtils.stringToObject(response);
34
- }
@@ -1,199 +0,0 @@
1
- import { getRenderingRef, forceUpdate } from '@stencil/core/internal/client';
2
-
3
- const appendToMap = (map, propName, value) => {
4
- const items = map.get(propName);
5
- if (!items) {
6
- map.set(propName, [value]);
7
- }
8
- else if (!items.includes(value)) {
9
- items.push(value);
10
- }
11
- };
12
- const debounce = (fn, ms) => {
13
- let timeoutId;
14
- return (...args) => {
15
- if (timeoutId) {
16
- clearTimeout(timeoutId);
17
- }
18
- timeoutId = setTimeout(() => {
19
- timeoutId = 0;
20
- fn(...args);
21
- }, ms);
22
- };
23
- };
24
-
25
- /**
26
- * Check if a possible element isConnected.
27
- * The property might not be there, so we check for it.
28
- *
29
- * We want it to return true if isConnected is not a property,
30
- * otherwise we would remove these elements and would not update.
31
- *
32
- * Better leak in Edge than to be useless.
33
- */
34
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
35
- const cleanupElements = debounce((map) => {
36
- for (let key of map.keys()) {
37
- map.set(key, map.get(key).filter(isConnected));
38
- }
39
- }, 2000);
40
- const stencilSubscription = () => {
41
- if (typeof getRenderingRef !== 'function') {
42
- // If we are not in a stencil project, we do nothing.
43
- // This function is not really exported by @stencil/core.
44
- return {};
45
- }
46
- const elmsToUpdate = new Map();
47
- return {
48
- dispose: () => elmsToUpdate.clear(),
49
- get: (propName) => {
50
- const elm = getRenderingRef();
51
- if (elm) {
52
- appendToMap(elmsToUpdate, propName, elm);
53
- }
54
- },
55
- set: (propName) => {
56
- const elements = elmsToUpdate.get(propName);
57
- if (elements) {
58
- elmsToUpdate.set(propName, elements.filter(forceUpdate));
59
- }
60
- cleanupElements(elmsToUpdate);
61
- },
62
- reset: () => {
63
- elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
64
- cleanupElements(elmsToUpdate);
65
- },
66
- };
67
- };
68
-
69
- const unwrap = (val) => (typeof val === 'function' ? val() : val);
70
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
- const unwrappedState = unwrap(defaultState);
72
- let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
73
- const handlers = {
74
- dispose: [],
75
- get: [],
76
- set: [],
77
- reset: [],
78
- };
79
- const reset = () => {
80
- var _a;
81
- // When resetting the state, the default state may be a function - unwrap it to invoke it.
82
- // otherwise, the state won't be properly reset
83
- states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
84
- handlers.reset.forEach((cb) => cb());
85
- };
86
- const dispose = () => {
87
- // Call first dispose as resetting the state would
88
- // cause less updates ;)
89
- handlers.dispose.forEach((cb) => cb());
90
- reset();
91
- };
92
- const get = (propName) => {
93
- handlers.get.forEach((cb) => cb(propName));
94
- return states.get(propName);
95
- };
96
- const set = (propName, value) => {
97
- const oldValue = states.get(propName);
98
- if (shouldUpdate(value, oldValue, propName)) {
99
- states.set(propName, value);
100
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
101
- }
102
- };
103
- const state = (typeof Proxy === 'undefined'
104
- ? {}
105
- : new Proxy(unwrappedState, {
106
- get(_, propName) {
107
- return get(propName);
108
- },
109
- ownKeys(_) {
110
- return Array.from(states.keys());
111
- },
112
- getOwnPropertyDescriptor() {
113
- return {
114
- enumerable: true,
115
- configurable: true,
116
- };
117
- },
118
- has(_, propName) {
119
- return states.has(propName);
120
- },
121
- set(_, propName, value) {
122
- set(propName, value);
123
- return true;
124
- },
125
- }));
126
- const on = (eventName, callback) => {
127
- handlers[eventName].push(callback);
128
- return () => {
129
- removeFromArray(handlers[eventName], callback);
130
- };
131
- };
132
- const onChange = (propName, cb) => {
133
- const unSet = on('set', (key, newValue) => {
134
- if (key === propName) {
135
- cb(newValue);
136
- }
137
- });
138
- // We need to unwrap the defaultState because it might be a function.
139
- // Otherwise we might not be sending the right reset value.
140
- const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
141
- return () => {
142
- unSet();
143
- unReset();
144
- };
145
- };
146
- const use = (...subscriptions) => {
147
- const unsubs = subscriptions.reduce((unsubs, subscription) => {
148
- if (subscription.set) {
149
- unsubs.push(on('set', subscription.set));
150
- }
151
- if (subscription.get) {
152
- unsubs.push(on('get', subscription.get));
153
- }
154
- if (subscription.reset) {
155
- unsubs.push(on('reset', subscription.reset));
156
- }
157
- if (subscription.dispose) {
158
- unsubs.push(on('dispose', subscription.dispose));
159
- }
160
- return unsubs;
161
- }, []);
162
- return () => unsubs.forEach((unsub) => unsub());
163
- };
164
- const forceUpdate = (key) => {
165
- const oldValue = states.get(key);
166
- handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
167
- };
168
- return {
169
- state,
170
- get,
171
- set,
172
- on,
173
- onChange,
174
- use,
175
- dispose,
176
- reset,
177
- forceUpdate,
178
- };
179
- };
180
- const removeFromArray = (array, item) => {
181
- const index = array.indexOf(item);
182
- if (index >= 0) {
183
- array[index] = array[array.length - 1];
184
- array.length--;
185
- }
186
- };
187
-
188
- const createStore = (defaultState, shouldUpdate) => {
189
- const map = createObservableMap(defaultState, shouldUpdate);
190
- map.use(stencilSubscription());
191
- return map;
192
- };
193
-
194
- const store = createStore({
195
- exporterProviders: {},
196
- filterFieldsDataSource: undefined
197
- });
198
-
199
- export { store as s };