@sankhyalabs/sankhyablocks 5.4.3 → 5.6.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 (223) hide show
  1. package/dist/cjs/{SnkMessageBuilder-115e8a80.js → SnkMessageBuilder-e64dce7f.js} +49 -1
  2. package/dist/cjs/{constants-ae0ed870.js → constants-3787fa32.js} +1 -0
  3. package/dist/cjs/dataunit-fetcher-8f5ade55.js +319 -0
  4. package/dist/cjs/index-8d94b7e0.js +7 -0
  5. package/dist/cjs/{index-fc7ca86c.js → index-de79181a.js} +2 -1
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  8. package/dist/cjs/snk-application.cjs.entry.js +3 -315
  9. package/dist/cjs/snk-attach.cjs.entry.js +450 -0
  10. package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  12. package/dist/cjs/snk-crud.cjs.entry.js +23 -13
  13. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  14. package/dist/cjs/{snk-data-unit-aa613f3b.js → snk-data-unit-85d6565e.js} +4 -1
  15. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  16. package/dist/cjs/snk-detail-view.cjs.entry.js +5 -5
  17. package/dist/cjs/snk-expression-item.cjs.entry.js +213 -0
  18. package/dist/cjs/snk-field-config.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +435 -0
  20. package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-grid-config.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-grid.cjs.entry.js +11 -3
  23. package/dist/cjs/{snk-guides-viewer-7db960c2.js → snk-guides-viewer-9784c527.js} +2 -2
  24. package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
  25. package/dist/cjs/snk-personalized-filter.cjs.entry.js +126 -0
  26. package/dist/cjs/snk-select-box.cjs.entry.js +1 -1
  27. package/dist/cjs/{snk-simple-crud.cjs.entry.js → snk-simple-bar_2.cjs.entry.js} +48 -5
  28. package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
  29. package/dist/cjs/snk-taskbar.cjs.entry.js +6 -4
  30. package/dist/cjs/{taskbar-elements-5e87cf44.js → taskbar-elements-bc2598f9.js} +4 -1
  31. package/dist/collection/collection-manifest.json +4 -1
  32. package/dist/collection/components/snk-attach/interfaces/index.js +1 -0
  33. package/dist/collection/components/snk-attach/snk-attach.css +8 -0
  34. package/dist/collection/components/snk-attach/snk-attach.js +202 -0
  35. package/dist/collection/components/snk-attach/structure/crud-config-builder.js +37 -0
  36. package/dist/collection/components/snk-attach/structure/data-unit-builder.js +106 -0
  37. package/dist/collection/components/snk-attach/structure/index.js +3 -0
  38. package/dist/collection/components/snk-attach/structure/taskbar-builder.js +47 -0
  39. package/dist/collection/components/snk-configurator/snk-configurator.js +3 -3
  40. package/dist/collection/components/snk-crud/snk-crud.js +22 -11
  41. package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -0
  42. package/dist/collection/components/snk-filter-field-search/snk-filter-field-search.js +62 -69
  43. package/dist/collection/components/snk-grid/snk-grid.js +11 -3
  44. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.css +4 -0
  45. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +87 -0
  46. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.js +34 -0
  47. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.css +97 -0
  48. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.js +298 -0
  49. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/snk-filter-param-config.js +2 -2
  50. package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +37 -2
  51. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +65 -2
  52. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -0
  53. package/dist/collection/components/snk-taskbar/snk-taskbar.js +4 -2
  54. package/dist/collection/lib/http/data-fetcher/fetchers/attach-fetcher.js +136 -0
  55. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js +1 -0
  56. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js +1 -0
  57. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/ISave.js +6 -0
  58. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/index.js +3 -0
  59. package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +63 -0
  60. package/dist/collection/lib/message/SnkMessageBuilder.js +7 -1
  61. package/dist/collection/lib/message/resources/snk-attach.msg.js +27 -0
  62. package/dist/collection/lib/message/resources/snk-personalized-filter.msg.js +12 -0
  63. package/dist/collection/lib/message/resources/snk-simple-bar.msg.js +3 -0
  64. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -0
  65. package/dist/collection/lib/store/index.js +2 -1
  66. package/dist/collection/lib/utils/constants.js +1 -0
  67. package/dist/components/SnkMessageBuilder.js +49 -1
  68. package/dist/components/constants.js +1 -0
  69. package/dist/components/dataunit-fetcher.js +317 -0
  70. package/dist/components/index.d.ts +3 -0
  71. package/dist/components/index.js +3 -0
  72. package/dist/components/index2.js +1 -1
  73. package/dist/components/index3.js +199 -0
  74. package/dist/components/snk-application2.js +2 -314
  75. package/dist/components/snk-attach.d.ts +11 -0
  76. package/dist/components/snk-attach.js +6 -0
  77. package/dist/components/snk-attach2.js +498 -0
  78. package/dist/components/snk-crud.js +77 -48
  79. package/dist/components/snk-data-exporter2.js +1 -1
  80. package/dist/components/snk-data-unit2.js +4 -0
  81. package/dist/components/snk-expression-item.d.ts +11 -0
  82. package/dist/components/snk-expression-item.js +6 -0
  83. package/dist/components/snk-expression-item2.js +241 -0
  84. package/dist/components/snk-filter-field-search.js +1 -200
  85. package/dist/{esm/snk-filter-field-search.entry.js → components/snk-filter-field-search2.js} +65 -38
  86. package/dist/components/snk-filter-param-config.js +1 -273
  87. package/dist/{esm/snk-filter-param-config.entry.js → components/snk-filter-param-config2.js} +35 -11
  88. package/dist/components/snk-grid2.js +12 -4
  89. package/dist/components/snk-personalized-filter.d.ts +11 -0
  90. package/dist/components/snk-personalized-filter.js +158 -0
  91. package/dist/components/snk-simple-bar.js +1 -41
  92. package/dist/components/snk-simple-bar2.js +59 -0
  93. package/dist/components/snk-simple-crud.js +1 -328
  94. package/dist/{esm/snk-simple-crud.entry.js → components/snk-simple-crud2.js} +73 -18
  95. package/dist/components/snk-taskbar2.js +10 -199
  96. package/dist/esm/{SnkMessageBuilder-a15d22f8.js → SnkMessageBuilder-f3590f65.js} +49 -1
  97. package/dist/esm/{constants-15617e7d.js → constants-e916ccc3.js} +1 -0
  98. package/dist/esm/dataunit-fetcher-d32c6a47.js +317 -0
  99. package/dist/esm/{index-6519a79e.js → index-507e19ec.js} +1 -1
  100. package/dist/esm/index-620ac460.js +7 -0
  101. package/dist/esm/{index-e467ade5.js → index-8efbf198.js} +2 -1
  102. package/dist/esm/loader.js +1 -1
  103. package/dist/esm/sankhyablocks.js +1 -1
  104. package/dist/esm/snk-application.entry.js +3 -315
  105. package/dist/esm/snk-attach.entry.js +446 -0
  106. package/dist/esm/snk-config-options.entry.js +1 -1
  107. package/dist/esm/snk-configurator.entry.js +1 -1
  108. package/dist/esm/snk-crud.entry.js +25 -15
  109. package/dist/esm/snk-data-exporter.entry.js +4 -4
  110. package/dist/esm/{snk-data-unit-5ed93c0e.js → snk-data-unit-50b1660c.js} +4 -1
  111. package/dist/esm/snk-data-unit.entry.js +2 -2
  112. package/dist/esm/snk-detail-view.entry.js +6 -6
  113. package/dist/esm/snk-expression-item.entry.js +209 -0
  114. package/dist/esm/snk-field-config.entry.js +1 -1
  115. package/dist/esm/snk-filter-field-search_2.entry.js +430 -0
  116. package/dist/esm/snk-form-config.entry.js +1 -1
  117. package/dist/esm/snk-grid-config.entry.js +1 -1
  118. package/dist/esm/snk-grid.entry.js +13 -5
  119. package/dist/esm/{snk-guides-viewer-1e7c21f6.js → snk-guides-viewer-4d12f268.js} +3 -3
  120. package/dist/esm/snk-guides-viewer.entry.js +5 -5
  121. package/dist/esm/snk-personalized-filter.entry.js +122 -0
  122. package/dist/esm/snk-select-box.entry.js +1 -1
  123. package/dist/esm/snk-simple-bar_2.entry.js +325 -0
  124. package/dist/esm/snk-tab-config.entry.js +1 -1
  125. package/dist/esm/snk-taskbar.entry.js +7 -5
  126. package/dist/esm/{taskbar-elements-10d80c79.js → taskbar-elements-e6af3e93.js} +5 -2
  127. package/dist/sankhyablocks/p-17375123.js +1 -0
  128. package/dist/sankhyablocks/{p-b80cf644.entry.js → p-1c0ee011.entry.js} +1 -1
  129. package/dist/sankhyablocks/p-1dcfd32a.entry.js +1 -0
  130. package/dist/sankhyablocks/p-27e264d9.entry.js +1 -0
  131. package/dist/sankhyablocks/p-343699ad.entry.js +1 -0
  132. package/dist/sankhyablocks/p-3d3263b4.js +1 -0
  133. package/dist/sankhyablocks/p-3fbe2d69.entry.js +11 -0
  134. package/dist/sankhyablocks/p-433dfa63.entry.js +1 -0
  135. package/dist/sankhyablocks/{p-f132e371.js → p-4c2015a9.js} +1 -1
  136. package/dist/sankhyablocks/p-4eefe631.entry.js +1 -0
  137. package/dist/sankhyablocks/p-6a02e236.js +1 -0
  138. package/dist/sankhyablocks/{p-0a1e7f75.entry.js → p-6ac29569.entry.js} +1 -1
  139. package/dist/sankhyablocks/{p-f4d36823.entry.js → p-6f0b3cc0.entry.js} +1 -1
  140. package/dist/sankhyablocks/{p-6516f35a.entry.js → p-86f75e7a.entry.js} +1 -1
  141. package/dist/sankhyablocks/{p-32599159.entry.js → p-8b02b276.entry.js} +1 -1
  142. package/dist/sankhyablocks/p-8bdf5e57.entry.js +1 -0
  143. package/dist/sankhyablocks/{p-9bfa3cfb.entry.js → p-c4417efb.entry.js} +1 -1
  144. package/dist/sankhyablocks/p-c9477950.js +1 -0
  145. package/dist/sankhyablocks/{p-703dddb9.js → p-ccd26e3a.js} +1 -1
  146. package/dist/sankhyablocks/p-d410f45a.js +1 -0
  147. package/dist/sankhyablocks/p-df8f13b4.entry.js +1 -0
  148. package/dist/sankhyablocks/{p-3169584f.entry.js → p-e0b4aec3.entry.js} +1 -1
  149. package/dist/sankhyablocks/p-e9f42525.entry.js +1 -0
  150. package/dist/sankhyablocks/{p-1393dc00.entry.js → p-f344b811.entry.js} +1 -1
  151. package/dist/sankhyablocks/p-f4184ce7.js +1 -0
  152. package/dist/sankhyablocks/p-f821768b.js +74 -0
  153. package/dist/sankhyablocks/{p-f29caa0a.entry.js → p-f8c66aa3.entry.js} +1 -1
  154. package/dist/sankhyablocks/p-fd4ed40a.entry.js +1 -0
  155. package/dist/sankhyablocks/p-ff96b509.entry.js +27 -0
  156. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  157. package/dist/types/components/snk-attach/interfaces/index.d.ts +10 -0
  158. package/dist/types/components/snk-attach/snk-attach.d.ts +45 -0
  159. package/dist/types/components/snk-attach/structure/crud-config-builder.d.ts +7 -0
  160. package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +16 -0
  161. package/dist/types/components/snk-attach/structure/index.d.ts +3 -0
  162. package/dist/types/components/snk-attach/structure/taskbar-builder.d.ts +8 -0
  163. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +5 -0
  164. package/dist/types/components/snk-filter-field-search/interfaces/index.d.ts +14 -4
  165. package/dist/types/components/snk-filter-field-search/snk-filter-field-search.d.ts +13 -10
  166. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +20 -0
  167. package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.d.ts +9 -0
  168. package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.d.ts +54 -0
  169. package/dist/types/components/snk-personalized-filter/subcomponents/snk-filter-param-config/interfaces/IExpressionItem.d.ts +4 -2
  170. package/dist/types/components/snk-simple-bar/snk-simple-bar.d.ts +14 -0
  171. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
  172. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +1 -0
  173. package/dist/types/components.d.ts +150 -9
  174. package/dist/types/global.d.ts +9 -0
  175. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +8 -2
  176. package/dist/types/lib/http/data-fetcher/fetchers/attach-fetcher.d.ts +14 -0
  177. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.d.ts +9 -0
  178. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.d.ts +13 -0
  179. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/ISave.d.ts +26 -0
  180. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/index.d.ts +3 -0
  181. package/dist/types/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.d.ts +7 -0
  182. package/dist/types/lib/message/resources/snk-attach.msg.d.ts +2 -0
  183. package/dist/types/lib/message/resources/snk-personalized-filter.msg.d.ts +1 -0
  184. package/dist/types/lib/message/resources/snk-simple-bar.msg.d.ts +1 -0
  185. package/dist/types/lib/store/index.d.ts +1 -0
  186. package/dist/types/lib/utils/constants.d.ts +2 -1
  187. package/package.json +1 -1
  188. package/react/components.d.ts +3 -0
  189. package/react/components.js +3 -0
  190. package/react/components.js.map +1 -1
  191. package/dist/cjs/snk-filter-field-search.cjs.entry.js +0 -185
  192. package/dist/cjs/snk-filter-param-config.cjs.entry.js +0 -256
  193. package/dist/cjs/snk-simple-bar.cjs.entry.js +0 -30
  194. package/dist/esm/snk-simple-bar.entry.js +0 -26
  195. package/dist/sankhyablocks/p-1c17eecf.entry.js +0 -1
  196. package/dist/sankhyablocks/p-2ecf14ff.js +0 -1
  197. package/dist/sankhyablocks/p-340d6fb0.entry.js +0 -84
  198. package/dist/sankhyablocks/p-74724fa7.js +0 -1
  199. package/dist/sankhyablocks/p-79d22df0.entry.js +0 -1
  200. package/dist/sankhyablocks/p-79f01b63.entry.js +0 -1
  201. package/dist/sankhyablocks/p-81e85890.entry.js +0 -1
  202. package/dist/sankhyablocks/p-93d8fe00.entry.js +0 -1
  203. package/dist/sankhyablocks/p-94e6fc90.entry.js +0 -1
  204. package/dist/sankhyablocks/p-98f7f796.js +0 -1
  205. package/dist/sankhyablocks/p-b3e71248.entry.js +0 -1
  206. package/dist/sankhyablocks/p-bc281de0.js +0 -1
  207. package/dist/sankhyablocks/p-d61759a5.entry.js +0 -1
  208. package/dist/sankhyablocks/p-d65809d5.entry.js +0 -1
  209. package/dist/sankhyablocks/p-f587a454.js +0 -1
  210. package/dist/types/components/snk-application/snk-application.d.ts +0 -259
  211. package/dist/types/components/snk-crud/snk-crud.d.ts +0 -73
  212. package/dist/types/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender.d.ts +0 -40
  213. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +0 -27
  214. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +0 -23
  215. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +0 -23
  216. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +0 -29
  217. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +0 -25
  218. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +0 -19
  219. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -38
  220. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +0 -74
  221. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +0 -53
  222. package/dist/types/components/snk-grid/snk-grid.d.ts +0 -95
  223. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -59
@@ -0,0 +1,446 @@
1
+ import { r as registerInstance, c as createEvent, h } from './index-cfd4bb13.js';
2
+ import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
3
+ import { D as DataFetcher } from './DataFetcher-b3d8b2d5.js';
4
+ import { c as VIEW_MODE } from './constants-e916ccc3.js';
5
+ import { D as DataUnitFetcher } from './dataunit-fetcher-d32c6a47.js';
6
+ import { T as TaskbarElement } from './taskbar-elements-e6af3e93.js';
7
+ import './_commonjsHelpers-9943807e.js';
8
+ import './index-507e19ec.js';
9
+ import './index-8efbf198.js';
10
+
11
+ var SaveErrorsEnum;
12
+ (function (SaveErrorsEnum) {
13
+ SaveErrorsEnum["LINK_AND_FILE_AT_THE_SAME_TIME"] = "LINK_AND_FILE_AT_THE_SAME_TIME";
14
+ SaveErrorsEnum["ANY_LINK_OR_FILE_FILLED"] = "ANY_LINK_OR_FILE_FILLED";
15
+ SaveErrorsEnum["UNKNOWN"] = "UNKNOWN";
16
+ })(SaveErrorsEnum || (SaveErrorsEnum = {}));
17
+
18
+ class AttachFetcher {
19
+ constructor(entityName, registerKey, dataUnitName) {
20
+ var _a;
21
+ this.entityName = entityName;
22
+ this.registerKey = registerKey;
23
+ this.dataUnitName = dataUnitName;
24
+ this.validateFields = (fields) => {
25
+ if (!!fields.LINK && !!fields.NOMEARQUIVO)
26
+ throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
27
+ if (!fields.LINK && !fields.NOMEARQUIVO)
28
+ throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
29
+ if (!this.registerKey)
30
+ throw new Error('Register key can not be null');
31
+ };
32
+ this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
33
+ }
34
+ async save(change) {
35
+ var _a, _b;
36
+ const serviceName = "AnexoSistemaSP.salvar";
37
+ let { updatingFields: fields } = change;
38
+ fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
39
+ try {
40
+ this.validateFields(fields);
41
+ const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
42
+ const reqBody = {
43
+ serviceName,
44
+ requestBody: {
45
+ params: {
46
+ resourceID: this.resourceID,
47
+ description: fields.DESCRICAO,
48
+ fileSelect: fileInfo ? 1 : 0,
49
+ keySession: (_b = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.properties) === null || _b === void 0 ? void 0 : _b.fileNameTmp,
50
+ nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
51
+ link: fields.LINK,
52
+ nameEntity: this.entityName,
53
+ pkEntity: this.registerKey,
54
+ typeAcess: fields.TIPOACESSO,
55
+ typeApres: fields.TIPOAPRES,
56
+ }
57
+ }
58
+ };
59
+ const result = await DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody));
60
+ return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
61
+ }
62
+ catch (error) {
63
+ return Promise.reject(error);
64
+ }
65
+ }
66
+ async edit(change) {
67
+ var _a, _b, _c;
68
+ const serviceName = "AnexoSistemaSP.salvar";
69
+ let { updatingFields: fields, record } = change;
70
+ const getFieldValue = (fieldValue) => {
71
+ if (fields[fieldValue] !== undefined)
72
+ return fields[fieldValue];
73
+ return record[fieldValue];
74
+ };
75
+ const attachField = getFieldValue('NOMEARQUIVO');
76
+ const hasNewAttachment = (_b = (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.downloadURL;
77
+ fields = Object.assign(Object.assign({}, fields), { DESCRICAO: getFieldValue('DESCRICAO'), LINK: getFieldValue('LINK'), TIPOACESSO: getFieldValue('TIPOACESSO'), TIPOAPRES: getFieldValue('TIPOAPRES'), CHAVEARQUIVO: record.CHAVEARQUIVO, NOMEARQUIVO: attachField === null || attachField === void 0 ? void 0 : attachField[0] });
78
+ const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
79
+ try {
80
+ this.validateFields(fields);
81
+ const reqBody = {
82
+ serviceName,
83
+ requestBody: {
84
+ params: {
85
+ resourceID: this.resourceID,
86
+ nuAttach: record === null || record === void 0 ? void 0 : record.NUATTACH,
87
+ description: fields.DESCRICAO,
88
+ fileSelect: hasNewAttachment ? 1 : 0,
89
+ keySession: (_c = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.properties) === null || _c === void 0 ? void 0 : _c.fileNameTmp,
90
+ keyAttach: fields.CHAVEARQUIVO,
91
+ nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
92
+ link: fields.LINK,
93
+ nameEntity: this.entityName,
94
+ pkEntity: this.registerKey,
95
+ typeAcess: fields.TIPOACESSO,
96
+ typeApres: fields.TIPOAPRES,
97
+ }
98
+ }
99
+ };
100
+ const result = await DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody));
101
+ return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
102
+ }
103
+ catch (error) {
104
+ return Promise.reject(error);
105
+ }
106
+ }
107
+ delete(record) {
108
+ var _a;
109
+ const serviceName = "AnexoSistemaSP.excluir";
110
+ const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
111
+ const reqBody = {
112
+ serviceName,
113
+ requestBody: {
114
+ paramsDelete: {
115
+ keyAttach: record.CHAVEARQUIVO,
116
+ nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
117
+ nameEntity: record.NOMEINSTANCIA,
118
+ nuAttach: record.NUATTACH,
119
+ pkEntity: record.PKREGISTRO
120
+ }
121
+ }
122
+ };
123
+ return new Promise((resolve, reject) => {
124
+ DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody))
125
+ .then(result => resolve(result))
126
+ .catch(error => reject(error));
127
+ });
128
+ }
129
+ getDownloadKey(record) {
130
+ var _a;
131
+ const serviceName = "AnexoSistemaSP.baixar";
132
+ const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
133
+ const reqBody = {
134
+ serviceName,
135
+ requestBody: {
136
+ paramsDown: {
137
+ nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
138
+ nameEntity: record.NOMEINSTANCIA,
139
+ nuAttach: record.NUATTACH,
140
+ pkEntity: record.PKREGISTRO,
141
+ keyAttach: record.CHAVEARQUIVO,
142
+ }
143
+ }
144
+ };
145
+ return new Promise((resolve, reject) => {
146
+ DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody))
147
+ .then(result => resolve(result))
148
+ .catch(error => reject(error));
149
+ });
150
+ }
151
+ }
152
+
153
+ class AttachmentDataUnitBuilder {
154
+ constructor(entityName, getMessage) {
155
+ this.entityName = entityName;
156
+ this.getMessage = getMessage;
157
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
158
+ }
159
+ initLoaders(dataUnit, attachFetcher, onSuccess) {
160
+ if (!this.loader)
161
+ this.loader = dataUnit.dataLoader;
162
+ dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
163
+ dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, attachFetcher).then((recordIds) => {
164
+ if (recordIds.length)
165
+ onSuccess();
166
+ return recordIds;
167
+ });
168
+ dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, attachFetcher).then((recordIds) => {
169
+ if (recordIds.length)
170
+ onSuccess();
171
+ return recordIds;
172
+ });
173
+ }
174
+ dataLoader(dataUnit, request) {
175
+ return new Promise(resolve => {
176
+ this.loader(dataUnit, request).then(response => {
177
+ const records = ((response === null || response === void 0 ? void 0 : response.records) || []).map(record => {
178
+ let fileInfo;
179
+ if (!record.LINK)
180
+ fileInfo = [{
181
+ name: record.NOMEARQUIVO,
182
+ }];
183
+ return Object.assign(Object.assign({}, record), { ARQUIVOOULINK: !!record.LINK ? record.LINK : record.NOMEARQUIVO, NOMEARQUIVO: fileInfo });
184
+ });
185
+ resolve(Object.assign(Object.assign({}, response), { records }));
186
+ });
187
+ });
188
+ }
189
+ saveLoader(changes, attachFetcher) {
190
+ return new Promise((resolve) => {
191
+ var _a;
192
+ const change = Array.isArray(changes) ? changes[0] : {};
193
+ const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ? attachFetcher.edit.bind(attachFetcher) : attachFetcher.save.bind(attachFetcher);
194
+ savePromise(change).then((records) => {
195
+ resolve(records);
196
+ }).catch((error) => {
197
+ if (error.message === SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
198
+ this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
199
+ return resolve([]);
200
+ }
201
+ if (error.message === SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
202
+ this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
203
+ return resolve([]);
204
+ }
205
+ if (error.message) {
206
+ this._application.error((error.title || error.name), error.message);
207
+ return resolve([]);
208
+ }
209
+ resolve([]);
210
+ });
211
+ });
212
+ }
213
+ removeLoader(dataUnit, ids, attachFetcher) {
214
+ return new Promise((resolve) => {
215
+ const { records } = dataUnit.getSelectionInfo();
216
+ attachFetcher.delete(records[0]).then(() => {
217
+ resolve(ids);
218
+ });
219
+ resolve([]);
220
+ });
221
+ }
222
+ getFilters(registerKey) {
223
+ return [
224
+ {
225
+ name: 'AttachmentsByPK',
226
+ expression: 'this.PKREGISTRO = :PKREGISTRO',
227
+ params: [{
228
+ name: "PKREGISTRO",
229
+ dataType: DataType.TEXT,
230
+ value: `${registerKey}_${this.entityName}`
231
+ }]
232
+ }
233
+ ];
234
+ }
235
+ getInterceptions(dataUnit, action, crudRef) {
236
+ return new Promise((resolve) => {
237
+ if (action.type === Action.EDITION_CANCELED) {
238
+ if (!dataUnit.isDirty())
239
+ return resolve(action);
240
+ return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
241
+ if (cancellationConfirmed) {
242
+ crudRef.goToView(VIEW_MODE.GRID);
243
+ return resolve(action);
244
+ }
245
+ return resolve(undefined);
246
+ });
247
+ }
248
+ if (action.type === Action.DATA_SAVED) {
249
+ dataUnit.loadData();
250
+ return resolve(action);
251
+ }
252
+ resolve(action);
253
+ });
254
+ }
255
+ }
256
+
257
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
258
+ const getMessage = (key) => {
259
+ var _a, _b;
260
+ return (_b = (_a = application === null || application === void 0 ? void 0 : application.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage) === null || _b === void 0 ? void 0 : _b.call(_a, key, null);
261
+ };
262
+ const TaskbarAttachButtons = {
263
+ DOWNLOAD: {
264
+ hint: getMessage("snkAttach.taskbar.titleDownload"),
265
+ name: "DOWNLOAD",
266
+ iconName: 'file-download'
267
+ },
268
+ LINK: {
269
+ hint: getMessage("snkAttach.taskbar.titleLink"),
270
+ name: "LINK",
271
+ iconName: "launch"
272
+ }
273
+ };
274
+ const buildTaskBarManager = () => {
275
+ const disabledButtonsWithoutSelection = [
276
+ TaskbarElement.REMOVE,
277
+ "DOWNLOAD",
278
+ "LINK"
279
+ ];
280
+ return {
281
+ getButtons: (_, dataState, currentButtons) => {
282
+ if ((dataState === null || dataState === void 0 ? void 0 : dataState.insertionMode) || (dataState === null || dataState === void 0 ? void 0 : dataState.isDirty))
283
+ return currentButtons.reverse();
284
+ else
285
+ currentButtons.splice(currentButtons.indexOf(TaskbarElement.REFRESH), 1);
286
+ const { selectedRecord } = dataState || {};
287
+ const taskbarTobeAdded = !!(selectedRecord === null || selectedRecord === void 0 ? void 0 : selectedRecord.LINK) ? TaskbarAttachButtons.LINK : TaskbarAttachButtons.DOWNLOAD;
288
+ currentButtons.splice(currentButtons.indexOf(TaskbarElement.DIVIDER) + 1, 0, TaskbarElement.REMOVE, taskbarTobeAdded, TaskbarElement.DIVIDER);
289
+ const updatedButtons = Array.from(new Set(currentButtons.filter(button => button !== TaskbarElement.CLONE)));
290
+ updatedButtons.splice(updatedButtons.indexOf(taskbarTobeAdded) + 1, 0, TaskbarElement.DIVIDER);
291
+ return updatedButtons;
292
+ },
293
+ isEnabled: (_, dataState, currentButton) => {
294
+ const hasSelectedRecord = (dataState === null || dataState === void 0 ? void 0 : dataState.selectedRecord) !== undefined;
295
+ const disabledButton = disabledButtonsWithoutSelection.includes(currentButton);
296
+ if (disabledButton && !hasSelectedRecord)
297
+ return false;
298
+ return true;
299
+ }
300
+ };
301
+ };
302
+
303
+ const crudConfig = {
304
+ grid: {
305
+ columns: [
306
+ { name: "ARQUIVOOULINK", orderIndex: 0, width: 0 },
307
+ { name: "DESCRICAO", orderIndex: 1, width: 0 },
308
+ { name: "DHCAD", orderIndex: 2, width: 0 },
309
+ { name: "DHALTER", orderIndex: 3, width: 0 },
310
+ { name: "TIPOAPRES", orderIndex: 4, width: 0 },
311
+ { name: "TIPOACESSO", orderIndex: 5, width: 0 },
312
+ { name: "CODUSU", orderIndex: 6, width: 0 },
313
+ { name: "CODUSUALT", orderIndex: 7, width: 0 }
314
+ ]
315
+ },
316
+ form: {
317
+ emptyConfig: false,
318
+ fields: [
319
+ {
320
+ name: "DESCRICAO",
321
+ required: true
322
+ },
323
+ {
324
+ name: "TIPOAPRES",
325
+ required: true,
326
+ },
327
+ {
328
+ name: "TIPOACESSO",
329
+ required: true,
330
+ },
331
+ {
332
+ name: "LINK"
333
+ },
334
+ {
335
+ name: "NOMEARQUIVO"
336
+ }
337
+ ]
338
+ },
339
+ };
340
+
341
+ const snkAttachCss = ".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}";
342
+
343
+ const RESOURCE_ID = 'AnexoSistema';
344
+ const DATA_UNIT_NAME = 'br.com.sankhya.core.v3.anexoSistema';
345
+ const SnkAttach = class {
346
+ constructor(hostRef) {
347
+ registerInstance(this, hostRef);
348
+ this.back = createEvent(this, "back", 7);
349
+ this.handleTaskbarClick = ({ detail: taskbar }) => {
350
+ if (["DOWNLOAD", "LINK"].includes(taskbar))
351
+ return this.downloadAttachment(this.dataUnit.getSelectedRecord());
352
+ };
353
+ this.handleBack = () => {
354
+ this.dataUnit.cancelEdition().then((cancelationConfirmed) => {
355
+ if (cancelationConfirmed)
356
+ this.back.emit();
357
+ });
358
+ };
359
+ this.handleFinish = () => {
360
+ if (!this.dataUnit.isDirty())
361
+ return this.back.emit();
362
+ this.dataUnit.saveData().then(() => {
363
+ this.showFinishedToast();
364
+ this.back.emit();
365
+ });
366
+ };
367
+ this.registerKey = undefined;
368
+ this.entityName = undefined;
369
+ this.messagesBuilder = undefined;
370
+ this.dataUnit = undefined;
371
+ this.crudConfig = {};
372
+ }
373
+ registerKeyWatcher(newRegisterKey, oldRegisterKey) {
374
+ var _a;
375
+ if (oldRegisterKey !== newRegisterKey) {
376
+ this.returnToGridMode();
377
+ this._attachFetcher = new AttachFetcher(this.entityName, this.registerKey, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name);
378
+ this._dataUnitBuilder.initLoaders(this.dataUnit, this._attachFetcher, () => { this.returnToGridMode(); });
379
+ this.dataUnit.loadData();
380
+ }
381
+ }
382
+ /**
383
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
384
+ * através de um pequeno modulo na estrutura da aplicação:
385
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
386
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-attach.msg.ts"
387
+ */
388
+ getMessage(key, params) {
389
+ if (this.messagesBuilder)
390
+ return this.messagesBuilder.getMessage(key, params);
391
+ }
392
+ showFinishedToast() {
393
+ this._application.info(this.getMessage('snkAttach.finishedMessage'), { iconName: "check" });
394
+ }
395
+ downloadAttachment(selectedRecord) {
396
+ if (!selectedRecord)
397
+ throw new Error('Nenhum registro selecionado');
398
+ if (selectedRecord.LINK) {
399
+ window.open(`${selectedRecord.LINK}`);
400
+ return;
401
+ }
402
+ this._attachFetcher.getDownloadKey(selectedRecord).then(({ chave }) => {
403
+ window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${chave.valor}&forcarDownload=S`);
404
+ });
405
+ }
406
+ returnToGridMode() {
407
+ this.dataUnit.clearSelection();
408
+ if (this._crudElement)
409
+ this._crudElement.goToView(VIEW_MODE.GRID);
410
+ }
411
+ loadAttachmentDataUnit() {
412
+ var _a;
413
+ try {
414
+ const dataUnit = this.dataUnit || new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
415
+ this._attachFetcher = new AttachFetcher(this.entityName, this.registerKey, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name);
416
+ if (!dataUnit.metadata)
417
+ dataUnit.loadMetadata().then(() => {
418
+ this.crudConfig = crudConfig;
419
+ });
420
+ this._dataUnitBuilder = new AttachmentDataUnitBuilder(this.entityName, this.getMessage.bind(this));
421
+ dataUnit.addFilterProvider({ getFilter: () => this._dataUnitBuilder.getFilters(this.registerKey) });
422
+ dataUnit.addInterceptor({ interceptAction: (action) => this._dataUnitBuilder.getInterceptions(dataUnit, action, this._crudElement) });
423
+ this.dataUnit = dataUnit;
424
+ this.dataUnit.loadData();
425
+ return this.dataUnit;
426
+ }
427
+ catch (error) {
428
+ throw new Error('There was an error while creating the data unit');
429
+ }
430
+ }
431
+ componentWillLoad() {
432
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
433
+ this.loadAttachmentDataUnit();
434
+ }
435
+ render() {
436
+ if (!this.dataUnit)
437
+ return null;
438
+ return (h("main", null, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this.dataUnit, taskbarManager: buildTaskBarManager(), gridConfig: this.crudConfig.grid, formConfig: this.crudConfig.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
439
+ }
440
+ static get watchers() { return {
441
+ "registerKey": ["registerKeyWatcher"]
442
+ }; }
443
+ };
444
+ SnkAttach.style = snkAttachCss;
445
+
446
+ export { SnkAttach as snk_attach };
@@ -2,7 +2,7 @@ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement
2
2
  import { UserInterface, ObjectUtils, StringUtils, ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { DataType, getConvertedValue } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
4
4
  import { CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
5
- import { V as VARS_BY_TYPE, D as DEFAULT_TYPE, a as TAGS_BY_TYPE } from './constants-15617e7d.js';
5
+ import { V as VARS_BY_TYPE, D as DEFAULT_TYPE, a as TAGS_BY_TYPE } from './constants-e916ccc3.js';
6
6
 
7
7
  const snkConfigOptionsCss = ".sc-snk-config-options-h{--snk-config-options--border:2px solid var(--color--secondary-200, #D2D3DA);width:100%;border-radius:15px;border:var(--snk-config-options--border)}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";
8
8
 
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-cfd4bb13.js';
2
2
  import { ApplicationContext } from '@sankhyalabs/core';
3
3
  import { A as AuthorizationConfig } from './AuthorizationConfig-dcbd207a.js';
4
- import { c as VIEW_MODE } from './constants-15617e7d.js';
4
+ import { c as VIEW_MODE } from './constants-e916ccc3.js';
5
5
 
6
6
  const snkConfiguratorCss = ".sc-snk-configurator-h{--snk-configurator__button-close--padding-left:var(--space--medium, 12px);--snk-configurator__title--color:var(--title--primary, #2B3A54);--snk-configurator__title--font-family:var(--font-pattern, \"Roboto\");--snk-configurator__title--font-size:var(--title--large, 20px);--snk-configurator__title--font-weight:var(--text-weight--extra-large, 700);--snk-configurator__subtitle--color:var(--title--primary, #2B3A54);--snk-configurator__subtitle--font-family:var(--font-pattern, \"Roboto\");--snk-configurator__subtitle--font-size:var(--text--medium, 14px);--snk-configurator__subtitle--font-weight:var(--text-weight--large, 600);--snk-configurator__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-configurator__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-configurator__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-configurator__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-configurator__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-configurator__scrollbar--width:var(--space--medium, 12px)}.snk-configurator.sc-snk-configurator{display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.snk-configurator.sc-snk-configurator{width:359px;max-width:359px}}.snk-configurator__button-config.sc-snk-configurator{--ez-button--min-width:100%}.snk-configurator__header.sc-snk-configurator{display:flex;justify-content:space-between;align-items:center;width:100%}.snk-configurator__title.sc-snk-configurator{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-configurator__title--color);font-size:var(--snk-configurator__title--font-size);font-family:var(--snk-configurator__title--font-family);font-weight:var(--snk-configurator__title--font-weight)}.snk-configurator__subtitle.sc-snk-configurator{display:flex;margin:0;padding-top:var(--space--medium);padding-bottom:var(--space--small);color:var(--snk-configurator__subtitle--color);font-size:var(--snk-configurator__subtitle--font-size);font-family:var(--snk-configurator__subtitle--font-family);font-weight:var(--snk-configurator__subtitle--font-weight)}.snk-configurator__button-close.sc-snk-configurator{padding-left:var(--snk-configurator__button-close--padding-left)}.snk-configurator__main.sc-snk-configurator{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-configurator__scrollbar--color-clicked) var(--snk-configurator__scrollbar--color-background)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar{background-color:var(--snk-configurator__scrollbar--color-background);width:var(--snk-configurator__scrollbar--width);max-width:var(--snk-configurator__scrollbar--width);min-width:var(--snk-configurator__scrollbar--width)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-track{background-color:var(--snk-configurator__scrollbar--color-background);border-radius:var(--snk-configurator__scrollbar--border-radius)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb{background-color:var(--snk-configurator__scrollbar--color-default);border-radius:var(--snk-configurator__scrollbar--border-radius)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:vertical:hover,.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-configurator__scrollbar--color-hover)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:vertical:active,.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-configurator__scrollbar--color-clicked)}";
7
7
 
@@ -1,11 +1,11 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
2
- import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
- import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
2
+ import { ElementIDUtils, ApplicationContext, VersionUtils } from '@sankhyalabs/core';
3
+ import { T as TaskbarElement } from './taskbar-elements-e6af3e93.js';
4
4
  import './DataFetcher-b3d8b2d5.js';
5
5
  import './pesquisa-fetcher-bd6af0e3.js';
6
- import { P as PresentationMode } from './index-6519a79e.js';
7
- import { c as VIEW_MODE } from './constants-15617e7d.js';
8
- import './index-e467ade5.js';
6
+ import { P as PresentationMode } from './index-507e19ec.js';
7
+ import { c as VIEW_MODE } from './constants-e916ccc3.js';
8
+ import './index-8efbf198.js';
9
9
  import './_commonjsHelpers-9943807e.js';
10
10
 
11
11
  const snkCrudCss = ".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";
@@ -16,6 +16,7 @@ const SnkCrud = class {
16
16
  this.actionClick = createEvent(this, "actionClick", 7);
17
17
  this._dataUnit = undefined;
18
18
  this._dataState = undefined;
19
+ this.attachmentRegisterKey = undefined;
19
20
  this._currentViewMode = VIEW_MODE.GRID;
20
21
  this.configName = undefined;
21
22
  this.actionsList = undefined;
@@ -37,15 +38,17 @@ const SnkCrud = class {
37
38
  this.setViewMode(VIEW_MODE.FORM);
38
39
  }
39
40
  async executeAction(act) {
40
- if (act === TaskbarElement.GRID_MODE) {
41
- this.setViewMode(VIEW_MODE.GRID);
42
- }
43
- else if (act === TaskbarElement.FORM_MODE || act === TaskbarElement.UPDATE) {
44
- this.gridToForm(act !== TaskbarElement.UPDATE);
45
- }
46
- else if (act === TaskbarElement.CONFIGURATOR) {
47
- this._snkConfigurator.open();
48
- }
41
+ if (act === TaskbarElement.GRID_MODE)
42
+ return this.setViewMode(VIEW_MODE.GRID);
43
+ if (act === TaskbarElement.FORM_MODE || act === TaskbarElement.UPDATE)
44
+ return this.gridToForm(act !== TaskbarElement.UPDATE);
45
+ if (act === TaskbarElement.CONFIGURATOR)
46
+ return this._snkConfigurator.open();
47
+ if (act === "ATTACH")
48
+ return this.setViewMode(VIEW_MODE.ATTACHMENT);
49
+ }
50
+ handleAttachBack() {
51
+ this.setViewMode(VIEW_MODE.GRID);
49
52
  }
50
53
  setViewMode(viewMode) {
51
54
  this._viewStack.show(viewMode);
@@ -108,8 +111,15 @@ const SnkCrud = class {
108
111
  this.messagesBuilder = this._snkDataUnit.messagesBuilder;
109
112
  }
110
113
  }
114
+ async canRenderAttachment() {
115
+ var _a, _b, _c, _d, _e;
116
+ const isValidVersion = VersionUtils.isRequiredVersion((_a = window.envContext) === null || _a === void 0 ? void 0 : _a.sysVersion, '4.22');
117
+ const recordCriteria = await ((_c = (_b = this._snkDataUnit) === null || _b === void 0 ? void 0 : _b.getSelectedRecordsIDsInfo) === null || _c === void 0 ? void 0 : _c.call(_b));
118
+ this.attachmentRegisterKey = (_d = recordCriteria.find(criteria => !!criteria.value)) === null || _d === void 0 ? void 0 : _d.value;
119
+ return isValidVersion && ((_e = this._dataState) === null || _e === void 0 ? void 0 : _e.selectedRecord) !== undefined;
120
+ }
111
121
  render() {
112
- return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode }, h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form" }, h("slot", { name: "SnkFormTaskBar" }))), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail) })));
122
+ return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode }, h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form" }, h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, this.canRenderAttachment() && (h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.handleAttachBack.bind(this) }))), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail) })));
113
123
  }
114
124
  get _element() { return getElement(this); }
115
125
  };
@@ -1,12 +1,12 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement } from './index-cfd4bb13.js';
2
2
  import { ObjectUtils, ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { D as DataExporterOption, a as DataExporterFormat, b as DataExporterType } from './index-6519a79e.js';
5
- import { d as KEY_PORT_EXPORT, W as WEB_CONNECTION, R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-15617e7d.js';
4
+ import { D as DataExporterOption, a as DataExporterFormat, b as DataExporterType } from './index-507e19ec.js';
5
+ import { d as KEY_PORT_EXPORT, W as WEB_CONNECTION, R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-e916ccc3.js';
6
6
  import { D as DataFetcher } from './DataFetcher-b3d8b2d5.js';
7
- import { S as SnkDataUnit } from './snk-data-unit-5ed93c0e.js';
7
+ import { S as SnkDataUnit } from './snk-data-unit-50b1660c.js';
8
8
  import './_commonjsHelpers-9943807e.js';
9
- import './SnkMessageBuilder-a15d22f8.js';
9
+ import './SnkMessageBuilder-f3590f65.js';
10
10
 
11
11
  class ItemBuilder {
12
12
  constructor(getMessage, selectedNumber) {
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-cfd4bb13.js';
2
2
  import { Action, ObjectUtils, JSUtils, ApplicationContext, DataType } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-a15d22f8.js';
4
+ import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-f3590f65.js';
5
5
 
6
6
  const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%;width:100%}";
7
7
 
@@ -64,6 +64,7 @@ const SnkDataUnit = class {
64
64
  this.dataUnit = undefined;
65
65
  this.beforeSave = undefined;
66
66
  this.afterSave = undefined;
67
+ this.useCancelConfirm = true;
67
68
  }
68
69
  observePageSize() {
69
70
  if (this.dataUnit) {
@@ -212,6 +213,8 @@ const SnkDataUnit = class {
212
213
  }
213
214
  break;
214
215
  case Action.EDITION_CANCELED:
216
+ if (!this.useCancelConfirm)
217
+ return resolve(action);
215
218
  if (this.dataState.hasDirtyRecords) {
216
219
  const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
217
220
  if ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) {
@@ -1,5 +1,5 @@
1
- export { S as snk_data_unit } from './snk-data-unit-5ed93c0e.js';
1
+ export { S as snk_data_unit } from './snk-data-unit-50b1660c.js';
2
2
  import './index-cfd4bb13.js';
3
3
  import '@sankhyalabs/core';
4
4
  import '@sankhyalabs/ezui/dist/collection/utils';
5
- import './SnkMessageBuilder-a15d22f8.js';
5
+ import './SnkMessageBuilder-f3590f65.js';
@@ -4,15 +4,15 @@ import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collecti
4
4
  import './DataFetcher-b3d8b2d5.js';
5
5
  import './pesquisa-fetcher-bd6af0e3.js';
6
6
  import '@sankhyalabs/core';
7
- import { P as PresentationMode } from './index-6519a79e.js';
8
- import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
9
- import { c as VIEW_MODE } from './constants-15617e7d.js';
10
- import { S as SnkGuidesViewer } from './snk-guides-viewer-1e7c21f6.js';
11
- import { S as SnkMessageBuilder } from './SnkMessageBuilder-a15d22f8.js';
7
+ import { P as PresentationMode } from './index-507e19ec.js';
8
+ import { T as TaskbarElement } from './taskbar-elements-e6af3e93.js';
9
+ import { c as VIEW_MODE } from './constants-e916ccc3.js';
10
+ import { S as SnkGuidesViewer } from './snk-guides-viewer-4d12f268.js';
11
+ import { S as SnkMessageBuilder } from './SnkMessageBuilder-f3590f65.js';
12
12
  import './ConfigStorage-ac77ff39.js';
13
13
  import './form-config-fetcher-018e7e73.js';
14
14
  import './_commonjsHelpers-9943807e.js';
15
- import './index-e467ade5.js';
15
+ import './index-8efbf198.js';
16
16
  import './taskbar-processor-94402e6e.js';
17
17
 
18
18
  class GuideBuilder {