@sankhyalabs/sankhyablocks 8.1.0-dev.10 → 8.1.0-dev.12

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 (209) hide show
  1. package/dist/cjs/{ConfigStorage-e32e1391.js → ConfigStorage-42601579.js} +163 -51
  2. package/dist/cjs/{DataFetcher-d2c6ae38.js → DataFetcher-370cc8f2.js} +38 -29
  3. package/dist/cjs/ISave-d68ce3cd.js +8 -0
  4. package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
  5. package/dist/cjs/{SnkFormConfigManager-5e61b0a9.js → SnkFormConfigManager-e5a28b2e.js} +19 -21
  6. package/dist/cjs/{auth-fetcher-da975ac5.js → auth-fetcher-c42326e9.js} +2 -2
  7. package/dist/cjs/{dataunit-fetcher-58ad78a7.js → dataunit-fetcher-eab8050e.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-761994b9.js → form-config-fetcher-6704319c.js} +66 -3
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-bb0bb679.js → pesquisa-fetcher-84d392c7.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button.cjs.entry.js +18 -11
  13. package/dist/cjs/snk-application.cjs.entry.js +49 -44
  14. package/dist/cjs/snk-attach.cjs.entry.js +7 -13
  15. package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
  16. package/dist/cjs/snk-crud.cjs.entry.js +24 -10
  17. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  18. package/dist/cjs/{snk-data-unit-e89e07bd.js → snk-data-unit-80a00ae4.js} +4 -3
  19. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  20. package/dist/cjs/snk-detail-view.cjs.entry.js +13 -12
  21. package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
  22. package/dist/cjs/snk-filter-bar.cjs.entry.js +13 -16
  23. package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -15
  24. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -19
  25. package/dist/cjs/snk-form-config.cjs.entry.js +6 -17
  26. package/dist/cjs/snk-form.cjs.entry.js +11 -8
  27. package/dist/cjs/snk-grid-config.cjs.entry.js +5 -6
  28. package/dist/cjs/snk-grid.cjs.entry.js +13 -17
  29. package/dist/cjs/{snk-guides-viewer-eb0a79a4.js → snk-guides-viewer-fd785f55.js} +16 -7
  30. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  31. package/dist/cjs/snk-personalized-filter.cjs.entry.js +13 -16
  32. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-simple-crud.cjs.entry.js +7 -3
  34. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
  35. package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
  36. package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
  37. package/dist/collection/components/snk-application/snk-application.js +60 -65
  38. package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
  39. package/dist/collection/components/snk-crud/snk-crud.js +18 -6
  40. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +20 -2
  41. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +25 -28
  42. package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -4
  43. package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
  44. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +2 -12
  45. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
  46. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
  47. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +27 -11
  48. package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
  49. package/dist/collection/components/snk-form/snk-form.js +24 -2
  50. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
  51. package/dist/collection/components/snk-grid/snk-grid.js +27 -12
  52. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
  53. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
  54. package/dist/collection/components/snk-taskbar/snk-taskbar.js +19 -1
  55. package/dist/collection/lib/configs/ConfigStorage.js +33 -44
  56. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +38 -29
  57. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
  58. package/dist/collection/lib/index.js +10 -0
  59. package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
  60. package/dist/components/ConfigStorage.js +161 -48
  61. package/dist/components/DataFetcher.js +38 -29
  62. package/dist/components/ResourceIDUtils.js +10 -0
  63. package/dist/components/SnkFormConfigManager.js +17 -19
  64. package/dist/components/auth-fetcher.js +1 -1
  65. package/dist/components/form-config-fetcher.js +64 -2
  66. package/dist/components/snk-actions-button2.js +23 -9
  67. package/dist/components/snk-application2.js +134 -128
  68. package/dist/components/snk-attach2.js +1 -8
  69. package/dist/components/snk-configurator2.js +3 -1
  70. package/dist/components/snk-crud.js +22 -6
  71. package/dist/components/snk-data-unit2.js +5 -3
  72. package/dist/components/snk-detail-view2.js +18 -8
  73. package/dist/components/snk-entity-list.js +0 -4
  74. package/dist/components/snk-filter-bar2.js +11 -11
  75. package/dist/components/snk-filter-detail2.js +2 -12
  76. package/dist/components/snk-filter-modal-item2.js +5 -16
  77. package/dist/components/snk-form-config2.js +5 -15
  78. package/dist/components/snk-form.js +8 -2
  79. package/dist/components/snk-grid-config2.js +4 -2
  80. package/dist/components/snk-grid2.js +11 -12
  81. package/dist/components/snk-personalized-filter2.js +11 -11
  82. package/dist/components/snk-simple-crud2.js +5 -1
  83. package/dist/components/snk-taskbar2.js +3 -1
  84. package/dist/esm/{ConfigStorage-b6aefe42.js → ConfigStorage-2915a841.js} +162 -49
  85. package/dist/esm/{DataFetcher-aaaff866.js → DataFetcher-0b121ffb.js} +38 -29
  86. package/dist/esm/ISave-4412b20c.js +8 -0
  87. package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
  88. package/dist/esm/{SnkFormConfigManager-80901f2d.js → SnkFormConfigManager-8005340f.js} +19 -21
  89. package/dist/esm/{auth-fetcher-7860d777.js → auth-fetcher-643f240e.js} +1 -1
  90. package/dist/esm/{dataunit-fetcher-9dfcdb1d.js → dataunit-fetcher-6423d6eb.js} +1 -1
  91. package/dist/esm/{form-config-fetcher-4a34b86a.js → form-config-fetcher-77cdb26c.js} +65 -3
  92. package/dist/esm/loader.js +1 -1
  93. package/dist/esm/{pesquisa-fetcher-01d058e6.js → pesquisa-fetcher-c5a3c564.js} +1 -1
  94. package/dist/esm/sankhyablocks.js +1 -1
  95. package/dist/esm/snk-actions-button.entry.js +18 -11
  96. package/dist/esm/snk-application.entry.js +49 -44
  97. package/dist/esm/snk-attach.entry.js +3 -9
  98. package/dist/esm/snk-configurator.entry.js +2 -1
  99. package/dist/esm/snk-crud.entry.js +24 -10
  100. package/dist/esm/snk-data-exporter.entry.js +2 -2
  101. package/dist/esm/{snk-data-unit-8c4d944d.js → snk-data-unit-3ab57d1a.js} +4 -3
  102. package/dist/esm/snk-data-unit.entry.js +1 -1
  103. package/dist/esm/snk-detail-view.entry.js +13 -12
  104. package/dist/esm/snk-entity-list.entry.js +0 -4
  105. package/dist/esm/snk-filter-bar.entry.js +13 -16
  106. package/dist/esm/snk-filter-detail.entry.js +2 -16
  107. package/dist/esm/snk-filter-modal-item.entry.js +6 -20
  108. package/dist/esm/snk-form-config.entry.js +7 -18
  109. package/dist/esm/snk-form.entry.js +11 -8
  110. package/dist/esm/snk-grid-config.entry.js +5 -6
  111. package/dist/esm/snk-grid.entry.js +13 -17
  112. package/dist/esm/{snk-guides-viewer-ee42eb53.js → snk-guides-viewer-43b550a2.js} +16 -7
  113. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  114. package/dist/esm/snk-personalized-filter.entry.js +13 -16
  115. package/dist/esm/snk-print-selector.entry.js +1 -1
  116. package/dist/esm/snk-simple-crud.entry.js +7 -3
  117. package/dist/esm/snk-taskbar.entry.js +2 -1
  118. package/dist/sankhyablocks/p-1108ed0e.entry.js +1 -0
  119. package/dist/sankhyablocks/p-18ead46b.entry.js +1 -0
  120. package/dist/sankhyablocks/p-1986cfa4.js +26 -0
  121. package/dist/sankhyablocks/p-1c7b4bad.entry.js +1 -0
  122. package/dist/sankhyablocks/p-48a40939.js +1 -0
  123. package/dist/sankhyablocks/p-508822c3.entry.js +1 -0
  124. package/dist/sankhyablocks/{p-85affa29.js → p-53a7ab6c.js} +1 -1
  125. package/dist/sankhyablocks/{p-77ecc583.entry.js → p-58b84e45.entry.js} +1 -1
  126. package/dist/sankhyablocks/p-688dcb4c.js +1 -0
  127. package/dist/sankhyablocks/{p-05bcad8a.entry.js → p-774afde8.entry.js} +1 -1
  128. package/dist/sankhyablocks/p-84b9208d.entry.js +1 -0
  129. package/dist/sankhyablocks/p-85dfb90b.entry.js +1 -0
  130. package/dist/sankhyablocks/p-86dda34d.js +1 -0
  131. package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
  132. package/dist/sankhyablocks/{p-bee6b5d7.js → p-9bfc7124.js} +1 -1
  133. package/dist/sankhyablocks/p-9d81ad53.entry.js +1 -0
  134. package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
  135. package/dist/sankhyablocks/p-a107474c.js +56 -0
  136. package/dist/sankhyablocks/p-a28470ae.entry.js +1 -0
  137. package/dist/sankhyablocks/p-b9376677.entry.js +1 -0
  138. package/dist/sankhyablocks/p-c7c035eb.js +1 -0
  139. package/dist/sankhyablocks/p-caaef934.js +1 -0
  140. package/dist/sankhyablocks/p-cf65dbb2.entry.js +1 -0
  141. package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
  142. package/dist/sankhyablocks/p-da2422ef.entry.js +11 -0
  143. package/dist/sankhyablocks/p-e086cc2a.entry.js +1 -0
  144. package/dist/sankhyablocks/p-ed705cbb.entry.js +1 -0
  145. package/dist/sankhyablocks/p-f1f5232d.entry.js +1 -0
  146. package/dist/sankhyablocks/{p-60791bb6.js → p-f88bdc84.js} +1 -1
  147. package/dist/sankhyablocks/p-fa523d6b.entry.js +1 -0
  148. package/dist/sankhyablocks/p-fcdd5761.entry.js +1 -0
  149. package/dist/sankhyablocks/p-fdf6b377.entry.js +1 -0
  150. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  151. package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
  152. package/dist/types/components/snk-application/snk-application.d.ts +8 -13
  153. package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
  154. package/dist/types/components/snk-crud/snk-crud.d.ts +1 -0
  155. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +4 -0
  156. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -2
  157. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
  158. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
  159. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
  160. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
  161. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
  162. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  163. package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
  164. package/dist/types/components/snk-form/snk-form.d.ts +5 -1
  165. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
  166. package/dist/types/components/snk-grid/snk-grid.d.ts +4 -0
  167. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
  168. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
  169. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +4 -0
  170. package/dist/types/components.d.ts +99 -21
  171. package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
  172. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  173. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
  174. package/dist/types/lib/index.d.ts +11 -0
  175. package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
  176. package/package.json +1 -1
  177. package/dist/cjs/filter-bar-config-fetcher-80b033ce.js +0 -155
  178. package/dist/cjs/resource-fetcher-95d24dff.js +0 -68
  179. package/dist/components/filter-bar-config-fetcher.js +0 -153
  180. package/dist/components/resource-fetcher.js +0 -66
  181. package/dist/esm/filter-bar-config-fetcher-317cb6bf.js +0 -153
  182. package/dist/esm/resource-fetcher-b36ac145.js +0 -66
  183. package/dist/sankhyablocks/p-0b64f036.entry.js +0 -1
  184. package/dist/sankhyablocks/p-0e97ec46.entry.js +0 -1
  185. package/dist/sankhyablocks/p-1b81c379.entry.js +0 -1
  186. package/dist/sankhyablocks/p-2dd0f891.js +0 -17
  187. package/dist/sankhyablocks/p-330f584a.entry.js +0 -1
  188. package/dist/sankhyablocks/p-35ecafcb.entry.js +0 -1
  189. package/dist/sankhyablocks/p-42843f0e.js +0 -1
  190. package/dist/sankhyablocks/p-459d4267.entry.js +0 -1
  191. package/dist/sankhyablocks/p-557affc8.entry.js +0 -1
  192. package/dist/sankhyablocks/p-564efc43.js +0 -1
  193. package/dist/sankhyablocks/p-6295424d.entry.js +0 -1
  194. package/dist/sankhyablocks/p-64c2cec3.js +0 -1
  195. package/dist/sankhyablocks/p-803b79d6.js +0 -1
  196. package/dist/sankhyablocks/p-80729c9b.entry.js +0 -11
  197. package/dist/sankhyablocks/p-95fa8af6.entry.js +0 -1
  198. package/dist/sankhyablocks/p-96c1ae78.entry.js +0 -1
  199. package/dist/sankhyablocks/p-b556fadc.entry.js +0 -1
  200. package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
  201. package/dist/sankhyablocks/p-bf3bd954.entry.js +0 -1
  202. package/dist/sankhyablocks/p-c32b9d7c.entry.js +0 -1
  203. package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
  204. package/dist/sankhyablocks/p-dd1fa35d.js +0 -56
  205. package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
  206. package/dist/sankhyablocks/p-e42f1f2a.js +0 -1
  207. package/dist/sankhyablocks/p-f24c4bc7.entry.js +0 -1
  208. package/dist/sankhyablocks/p-f737f7e1.js +0 -10
  209. package/dist/sankhyablocks/p-fd69eab9.entry.js +0 -1
@@ -1,153 +0,0 @@
1
- import { F as FilterItemType } from './filter-item-type.enum.js';
2
- import { R as ResourceFetcher } from './resource-fetcher.js';
3
-
4
- var __rest = (undefined && undefined.__rest) || function (s, e) {
5
- var t = {};
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
7
- t[p] = s[p];
8
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
9
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
10
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
11
- t[p[i]] = s[p[i]];
12
- }
13
- return t;
14
- };
15
- function normalizeValue(value, type) {
16
- if (value == undefined) {
17
- return value;
18
- }
19
- if (value instanceof Date) {
20
- return value.toISOString();
21
- }
22
- if (typeof value === "object") {
23
- if (value instanceof Array) {
24
- return value.map(item => {
25
- if (FilterItemType.MULTI_LIST === type) {
26
- const values = __rest(item, ["label"]);
27
- return normalizeValue(values);
28
- }
29
- return normalizeValue(item);
30
- });
31
- }
32
- else {
33
- const normalized = Object.assign({}, value);
34
- Object.keys(value).forEach(prop => {
35
- if (value[prop] !== undefined) {
36
- normalized[prop] = normalizeValue(value[prop], type);
37
- }
38
- else {
39
- delete normalized[prop];
40
- }
41
- });
42
- return normalized;
43
- }
44
- }
45
- return value;
46
- }
47
- class FilterBarConfigFetcher extends ResourceFetcher {
48
- normalize(items) {
49
- return items.map(item => {
50
- const { id, value, fixed, visible, type, groupedItems } = item;
51
- const stateItem = { id };
52
- if (value) {
53
- stateItem["value"] = normalizeValue(value, type);
54
- }
55
- if (fixed) {
56
- stateItem["fixed"] = fixed;
57
- }
58
- if (groupedItems) {
59
- if (groupedItems.length === 0) {
60
- return;
61
- }
62
- if (groupedItems.filter(item => item.visible).length > 0) {
63
- stateItem["visible"] = true;
64
- }
65
- stateItem["groupedItems"] = this.normalize(groupedItems);
66
- }
67
- else {
68
- if (visible) {
69
- stateItem["visible"] = true;
70
- }
71
- }
72
- return stateItem;
73
- }).filter(item => item != undefined);
74
- }
75
- saveConfig(items, resourceID, configName) {
76
- return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
77
- }
78
- getConfig(resourceID, configName, urlParams) {
79
- return new Promise((accept, reject) => {
80
- this.loadResource(this.getPath(resourceID, configName, urlParams))
81
- .then((configAsString) => {
82
- let fieldsList;
83
- if (configAsString) {
84
- const filterBarConfig = JSON.parse(configAsString);
85
- fieldsList = this.buildFieldList(filterBarConfig.items);
86
- }
87
- accept(fieldsList || []);
88
- })
89
- .catch((error) => {
90
- reject(error);
91
- });
92
- });
93
- }
94
- saveEntityListConfig(item, resourceID, configName) {
95
- return new Promise((accept, reject) => {
96
- this.getConfig(resourceID, configName).then(config => {
97
- const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
98
- return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
99
- });
100
- const index = state.findIndex(({ id }) => id === item.id);
101
- const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
102
- if (index > -1) {
103
- state[index] = newItem;
104
- }
105
- else {
106
- state.push(newItem);
107
- }
108
- this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
109
- accept(resp);
110
- }).catch(exception => {
111
- reject(exception);
112
- });
113
- }).catch(exception => {
114
- reject(exception);
115
- });
116
- });
117
- }
118
- buildFieldList(items) {
119
- return items.map(item => {
120
- var _a, _b;
121
- if (item.type === FilterItemType.MULTI_LIST) {
122
- const multiListValue = item.value;
123
- item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
124
- }
125
- return item;
126
- });
127
- }
128
- getPath(resourceID, name, urlParams) {
129
- let path = `cfg://filter/FilterBarState:${resourceID}`;
130
- if (name) {
131
- path += `.${name}`;
132
- }
133
- if (urlParams) {
134
- path += this.buildQueryString(urlParams);
135
- }
136
- return path;
137
- }
138
- buildQueryString(urlParams) {
139
- let queryString = '?';
140
- for (let key in urlParams) {
141
- if (!urlParams.hasOwnProperty(key)) {
142
- continue;
143
- }
144
- if (queryString.length > 1) {
145
- queryString += '&';
146
- }
147
- queryString += key + '=' + urlParams[key];
148
- }
149
- return queryString;
150
- }
151
- }
152
-
153
- export { FilterBarConfigFetcher as F };
@@ -1,66 +0,0 @@
1
- import { d as dist, D as DataFetcher } from './DataFetcher.js';
2
-
3
- class ResourceFetcher {
4
- constructor() {
5
- this.templateByQuery = new Map();
6
- this.buldTemplates();
7
- }
8
- buldTemplates() {
9
- this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
10
- $queryAlias$: fetchResource(name: $name){
11
- resource
12
- }
13
- }`);
14
- this.templateByQuery.set("saveResource", dist.gql `mutation($resource: InputResource!) {
15
- $queryAlias$: saveResource(resource: $resource){
16
- name
17
- resource
18
- }
19
- }`);
20
- }
21
- loadResource(name) {
22
- if (ResourceFetcher._loadingResource.has(name)) {
23
- return ResourceFetcher._loadingResource.get(name);
24
- }
25
- const promiseLoadResource = new Promise((resolve, reject) => {
26
- DataFetcher.get()
27
- .callGraphQL({
28
- values: { name },
29
- query: this.templateByQuery.get("fetchResource"),
30
- })
31
- .then((result) => {
32
- resolve(result === null || result === void 0 ? void 0 : result.resource);
33
- ResourceFetcher._loadingResource.delete(name);
34
- })
35
- .catch((error) => {
36
- reject(error);
37
- ResourceFetcher._loadingResource.delete(name);
38
- });
39
- });
40
- ResourceFetcher._loadingResource.set(name, promiseLoadResource);
41
- return promiseLoadResource;
42
- }
43
- saveResource(resource, name) {
44
- return new Promise((resolve, reject) => {
45
- DataFetcher.get()
46
- .callGraphQL({
47
- values: {
48
- resource: {
49
- name: name,
50
- resource: JSON.stringify(resource)
51
- }
52
- },
53
- query: this.templateByQuery.get("saveResource")
54
- })
55
- .then((resp) => {
56
- resolve(resp);
57
- })
58
- .catch((error) => {
59
- reject(error);
60
- });
61
- });
62
- }
63
- }
64
- ResourceFetcher._loadingResource = new Map();
65
-
66
- export { ResourceFetcher as R };
@@ -1,153 +0,0 @@
1
- import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
2
- import { R as ResourceFetcher } from './resource-fetcher-b36ac145.js';
3
-
4
- var __rest = (undefined && undefined.__rest) || function (s, e) {
5
- var t = {};
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
7
- t[p] = s[p];
8
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
9
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
10
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
11
- t[p[i]] = s[p[i]];
12
- }
13
- return t;
14
- };
15
- function normalizeValue(value, type) {
16
- if (value == undefined) {
17
- return value;
18
- }
19
- if (value instanceof Date) {
20
- return value.toISOString();
21
- }
22
- if (typeof value === "object") {
23
- if (value instanceof Array) {
24
- return value.map(item => {
25
- if (FilterItemType.MULTI_LIST === type) {
26
- const values = __rest(item, ["label"]);
27
- return normalizeValue(values);
28
- }
29
- return normalizeValue(item);
30
- });
31
- }
32
- else {
33
- const normalized = Object.assign({}, value);
34
- Object.keys(value).forEach(prop => {
35
- if (value[prop] !== undefined) {
36
- normalized[prop] = normalizeValue(value[prop], type);
37
- }
38
- else {
39
- delete normalized[prop];
40
- }
41
- });
42
- return normalized;
43
- }
44
- }
45
- return value;
46
- }
47
- class FilterBarConfigFetcher extends ResourceFetcher {
48
- normalize(items) {
49
- return items.map(item => {
50
- const { id, value, fixed, visible, type, groupedItems } = item;
51
- const stateItem = { id };
52
- if (value) {
53
- stateItem["value"] = normalizeValue(value, type);
54
- }
55
- if (fixed) {
56
- stateItem["fixed"] = fixed;
57
- }
58
- if (groupedItems) {
59
- if (groupedItems.length === 0) {
60
- return;
61
- }
62
- if (groupedItems.filter(item => item.visible).length > 0) {
63
- stateItem["visible"] = true;
64
- }
65
- stateItem["groupedItems"] = this.normalize(groupedItems);
66
- }
67
- else {
68
- if (visible) {
69
- stateItem["visible"] = true;
70
- }
71
- }
72
- return stateItem;
73
- }).filter(item => item != undefined);
74
- }
75
- saveConfig(items, resourceID, configName) {
76
- return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
77
- }
78
- getConfig(resourceID, configName, urlParams) {
79
- return new Promise((accept, reject) => {
80
- this.loadResource(this.getPath(resourceID, configName, urlParams))
81
- .then((configAsString) => {
82
- let fieldsList;
83
- if (configAsString) {
84
- const filterBarConfig = JSON.parse(configAsString);
85
- fieldsList = this.buildFieldList(filterBarConfig.items);
86
- }
87
- accept(fieldsList || []);
88
- })
89
- .catch((error) => {
90
- reject(error);
91
- });
92
- });
93
- }
94
- saveEntityListConfig(item, resourceID, configName) {
95
- return new Promise((accept, reject) => {
96
- this.getConfig(resourceID, configName).then(config => {
97
- const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
98
- return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
99
- });
100
- const index = state.findIndex(({ id }) => id === item.id);
101
- const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
102
- if (index > -1) {
103
- state[index] = newItem;
104
- }
105
- else {
106
- state.push(newItem);
107
- }
108
- this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
109
- accept(resp);
110
- }).catch(exception => {
111
- reject(exception);
112
- });
113
- }).catch(exception => {
114
- reject(exception);
115
- });
116
- });
117
- }
118
- buildFieldList(items) {
119
- return items.map(item => {
120
- var _a, _b;
121
- if (item.type === FilterItemType.MULTI_LIST) {
122
- const multiListValue = item.value;
123
- item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
124
- }
125
- return item;
126
- });
127
- }
128
- getPath(resourceID, name, urlParams) {
129
- let path = `cfg://filter/FilterBarState:${resourceID}`;
130
- if (name) {
131
- path += `.${name}`;
132
- }
133
- if (urlParams) {
134
- path += this.buildQueryString(urlParams);
135
- }
136
- return path;
137
- }
138
- buildQueryString(urlParams) {
139
- let queryString = '?';
140
- for (let key in urlParams) {
141
- if (!urlParams.hasOwnProperty(key)) {
142
- continue;
143
- }
144
- if (queryString.length > 1) {
145
- queryString += '&';
146
- }
147
- queryString += key + '=' + urlParams[key];
148
- }
149
- return queryString;
150
- }
151
- }
152
-
153
- export { FilterBarConfigFetcher as F };
@@ -1,66 +0,0 @@
1
- import { d as dist, D as DataFetcher } from './DataFetcher-aaaff866.js';
2
-
3
- class ResourceFetcher {
4
- constructor() {
5
- this.templateByQuery = new Map();
6
- this.buldTemplates();
7
- }
8
- buldTemplates() {
9
- this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
10
- $queryAlias$: fetchResource(name: $name){
11
- resource
12
- }
13
- }`);
14
- this.templateByQuery.set("saveResource", dist.gql `mutation($resource: InputResource!) {
15
- $queryAlias$: saveResource(resource: $resource){
16
- name
17
- resource
18
- }
19
- }`);
20
- }
21
- loadResource(name) {
22
- if (ResourceFetcher._loadingResource.has(name)) {
23
- return ResourceFetcher._loadingResource.get(name);
24
- }
25
- const promiseLoadResource = new Promise((resolve, reject) => {
26
- DataFetcher.get()
27
- .callGraphQL({
28
- values: { name },
29
- query: this.templateByQuery.get("fetchResource"),
30
- })
31
- .then((result) => {
32
- resolve(result === null || result === void 0 ? void 0 : result.resource);
33
- ResourceFetcher._loadingResource.delete(name);
34
- })
35
- .catch((error) => {
36
- reject(error);
37
- ResourceFetcher._loadingResource.delete(name);
38
- });
39
- });
40
- ResourceFetcher._loadingResource.set(name, promiseLoadResource);
41
- return promiseLoadResource;
42
- }
43
- saveResource(resource, name) {
44
- return new Promise((resolve, reject) => {
45
- DataFetcher.get()
46
- .callGraphQL({
47
- values: {
48
- resource: {
49
- name: name,
50
- resource: JSON.stringify(resource)
51
- }
52
- },
53
- query: this.templateByQuery.get("saveResource")
54
- })
55
- .then((resp) => {
56
- resolve(resp);
57
- })
58
- .catch((error) => {
59
- reject(error);
60
- });
61
- });
62
- }
63
- }
64
- ResourceFetcher._loadingResource = new Map();
65
-
66
- export { ResourceFetcher as R };
@@ -1 +0,0 @@
1
- import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{ElementIDUtils as d,ApplicationContext as r,DataType as a}from"@sankhyalabs/core";import{UserInterface as n}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{T as o}from"./p-a2493d11.js";import{C as l}from"./p-dd1fa35d.js";import{P as h}from"./p-5534e08c.js";import{T as u}from"./p-c2beb95c.js";import{s as c}from"./p-6dc031de.js";import{S as v}from"./p-fa9d3f73.js";import{SelectionMode as g}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-2dd0f891.js";import"./p-60791bb6.js";import"./p-112455b1.js";import"./p-f737f7e1.js";import"./p-e42f1f2a.js";import"./p-584d7212.js";const m=class{constructor(s){i(this,s),this.actionClick=t(this,"actionClick",7),this.gridDoubleClick=t(this,"gridDoubleClick",7),this._topTaskbarProcessor=new u({"snkGridTopTaskbar.regular":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.secondary":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.finish_edition":["CANCEL","SAVE"],"snkGridTopTaskbar.finish_edition.secondary":[]}),this._headerTaskbarProcessor=new u({"snkGridHeaderTaskbar.unselected":["REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.detail.unselected":["REFRESH"],"snkGridHeaderTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","REFRESH"]}),this._dataUnit=void 0,this._dataState=void 0,this._gridConfig=void 0,this._popUpGridConfig=!1,this.columnFilterDataSource=new v,this.configName=void 0,this.selectionToastConfig=void 0,this.actionsList=void 0,this.isDetail=void 0,this.taskbarManager=void 0,this.statusResolver=void 0,this.multipleSelection=void 0,this.presentationMode=h.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.recordsValidator=void 0,this.canEdit=!0}async showConfig(){null!=this._grid&&this.openGridConfig()}async hideConfig(){null!=this._grid&&this.closeGridConfig()}async setConfig(i){this.setGridConfig(i)}async reloadFilterBar(){var i;null===(i=this._snkFilterBar)||void 0===i||i.reload()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._popUpGridConfig=!0}))}closeGridConfig(){this._popUpGridConfig=!1}setGridConfig(i){this._gridConfig=i}loadConfig(){l.get().then((i=>{i.loadGridConfig(this.configName).then((i=>{this.setGridConfig(i)})).catch((i=>{console.warn(i)}))}))}gridConfigChangeHandler(i){l.saveGridConfig(i.detail,this.configName),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}buildColumnsMetadata(i){const t=[];return null==i||i.forEach((i=>{var s,e;if(i.hidden&&"RECDESP"!==i.name)return;const d=null===(s=this._dataUnit)||void 0===s?void 0:s.getField(i.name);if(t.push({label:i.label,id:i.name,width:i.width,type:null==d?void 0:d.dataType,userInterface:null==d?void 0:d.userInterface}),null!=(null===(e=null==d?void 0:d.properties)||void 0===e?void 0:e.DESCRIPTIONFIELD)){const i=d.properties.mergedFrom;t.push({label:d.properties.DESCRIPTIONENTITY,id:`${i?i+".":""}${d.properties.ENTITYNAME}.${d.properties.DESCRIPTIONFIELD}`,width:200,type:a.TEXT,userInterface:n.LONGTEXT})}})),t||[]}getPaginationInfo(){var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getPaginationInfo()}getExporterOffset(i){if(null==i)return;const t=i.firstRecord;return t>0?t-1:t}async dataExporterProviderStore(){var i;const t=await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getSelectedRecordsIDsInfo()),s={getFilters:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},getColumnsMetadata:async()=>{var i;const t=await(null===(i=this._grid)||void 0===i?void 0:i.getColumnsState());return this.buildColumnsMetadata(t)},getOrders:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getSort()},getResourceURI:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.name},getSelectedNumber:()=>{var i,t;return null===(t=null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.length},getTotalRecords:()=>{var i,t,s;const{total:e}=(null===(i=this._dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length},getSelectedIDs:()=>t||[],getOffset:()=>this.getExporterOffset(this.getPaginationInfo()),getLimit:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.pageSize},getRecordID:()=>{var i,t,s;return null===(s=null===(t=null===(i=this._dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}};c.set("exporterProviders",Object.assign(Object.assign({},c.get("exporterProviders")),{[this.configName]:s}))}addElementID(){d.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}finshLoading(){var i,t;this._dataUnitLoadLockerResolver=this._dataUnit.addLoadingLocker(),this.addElementID(),null===(i=this.columnFilterDataSource)||void 0===i||i.setApplication(this._application),null===(t=this.columnFilterDataSource)||void 0===t||t.setDataUnit(this._dataUnit)}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataUnit?this.finshLoading():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.finshLoading()})),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),this._snkDataUnit.addEventListener("dataStateChange",(i=>{this._dataState=i.detail})),this._snkDataUnit.addEventListener("cancelEdition",(()=>{var i;(null===(i=this._dataState)||void 0===i?void 0:i.recordsIsEmpty)&&this._dataUnit.clearSelection()}));break}i=i.parentElement}this.loadConfig()}getHeaderDisabledButtons(){var i;const t=[];return(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)&&(this._dataState.selectionInfo.length>1&&t.push(o.CLONE,"ATTACH"),this._dataState.selectionInfo.isAllRecords()&&t.push("REMOVE")),t}getInvisibleButtons(){let i=[];return this._dataUnit&&0!==this._dataUnit.records.length||i.push("DATA_EXPORTER"),this._dataState&&this._dataState.selectionInfo.mode===g.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}componentWillRender(){var i;const t=this.getInvisibleButtons();let s;s=this._dataState&&(null===(i=this._dataState.selectionInfo)||void 0===i?void 0:i.length)?this.isDetail?"snkGridHeaderTaskbar.detail.selected":"snkGridHeaderTaskbar.selected":this.isDetail?"snkGridHeaderTaskbar.detail.unselected":"snkGridHeaderTaskbar.unselected",this._headerTaskbarProcessor.process(s,this.taskbarManager,this._dataState,this.getHeaderDisabledButtons(),t),this._topTaskbarProcessor.process(this.getTopTaskBarId(this.presentationMode===h.SECONDARY?".secondary":""),this.taskbarManager,this._dataState,void 0,t),this.dataExporterProviderStore()}getTopTaskBarId(i){var t;return(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)?`snkGridTopTaskbar.finish_edition${i}`:`snkGridTopTaskbar.regular${i}`}getPrimaryButton(){return this.presentationMode===h.PRIMARY?"INSERT":""}onEzGridReady(){var i;null===(i=this._dataUnitLoadLockerResolver)||void 0===i||i.call(this),this._dataUnitLoadLockerResolver=void 0}render(){var i,t;if(this._dataUnit)return s("div",{class:"snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large"},s("div",{class:"snk-grid__header ez-margin-bottom--medium"},s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder}),(null===(t=null===(i=this._snkFilterBar)||void 0===i?void 0:i.filterConfig)||void 0===t?void 0:t.length)>0&&s("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider"}),s("snk-taskbar",{class:"ez-padding-left--medium","data-element-id":"grid_top",key:"topTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._topTaskbarProcessor.buttons,disabledButtons:this._topTaskbarProcessor.disabledButtons,customButtons:this._topTaskbarProcessor.customButtons,primaryButton:this.getPrimaryButton()})),s("ez-grid",{ref:i=>this._grid=i,class:(this.presentationMode===h.SECONDARY?"snk-grid-container__without-shadow ":"")+"snk-grid__table","data-element-id":"embedded",dataUnit:this._dataUnit,key:"grid-"+this._snkDataUnit.entityName,config:this._gridConfig,onConfigChange:i=>{this.gridConfigChangeHandler(i)},onEzDoubleClick:()=>this.gridDoubleClick.emit(),statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,onComponentReady:()=>this.onEzGridReady(),columnfilterDataSource:this.columnFilterDataSource,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,recordsValidator:this.recordsValidator,canEdit:this.canEdit},s("snk-taskbar",{dataUnit:this._dataUnit,configName:this.configName,messagesBuilder:this.messagesBuilder,"data-element-id":"grid_left",buttons:this._headerTaskbarProcessor.buttons,disabledButtons:this._headerTaskbarProcessor.disabledButtons,customButtons:this._headerTaskbarProcessor.customButtons,slot:"leftButtons",actionsList:this.actionsList})),s("div",{class:"ez-col ez-col--sd-12"},s("slot",{name:"SnkGridFooter"})),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._popUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this._gridConfig,"data-element-id":this._element.getAttribute(d.DATA_ELEMENT_ID_ATTRIBUTE_NAME),application:this._application,selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig()})))}get _element(){return e(this)}};m.style=".snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%}.snk-grid__header.sc-snk-grid{display:flex;flex-wrap:nowrap;width:100%}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:300px}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}";export{m as snk_grid}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as s,g as e}from"./p-d2d301a6.js";import{ElementIDUtils as a,ApplicationContext as h}from"@sankhyalabs/core";import{T as n}from"./p-a2493d11.js";import"./p-60791bb6.js";import"./p-85affa29.js";import{P as o}from"./p-5534e08c.js";import{c as r}from"./p-4a78e118.js";import{A as d}from"./p-64c2cec3.js";import"./p-6dc031de.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-f737f7e1.js";const c=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this._viewHistory=[],this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=r.GRID,this._canEdit=void 0,this.configName=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=o.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===r.GRID,this.setViewMode(r.FORM)}async executeAction(t){return t===n.GRID_MODE?this.setViewMode(r.GRID):t===n.FORM_MODE||t===n.UPDATE?this.gridToForm(t!==n.UPDATE):t===n.CONFIGURATOR?this._snkConfigurator.open():"ATTACH"===t?this.setViewMode(r.ATTACHMENT):void 0}backView(){const t=this._viewHistory.at(-2)||r.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t}openConfig(t){this._snkConfigurator.close(),t===r.GRID?this._snkGrid.showConfig():t===r.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){a.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(r.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}componentWillLoad(){const t=h.getContextValue("__SNK__APPLICATION__");t.hasAccess(d.UPDATE).then((t=>this._canEdit=t));let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.initDataUnit()})),this._snkDataUnit.addEventListener("dataStateChange",(async({detail:t})=>{this._dataState=t,void 0!==t.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}));break}i=i.parentElement}this.configName||(this.configName=t.configName)}initDataUnit(){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder)}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}render(){return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===r.GRID,s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit},s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(r.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit},s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",null,s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL")},s("div",{slot:"SnkConfigContainerSlot"},s("slot",{name:"SnkConfigContainerSlot"}))))}get _element(){return e(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};c.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{c as snk_crud}
@@ -1 +0,0 @@
1
- import{r as t,c as e,h as i}from"./p-d2d301a6.js";import{ApplicationContext as s,DataType as n,Action as a}from"@sankhyalabs/core";import{D as r}from"./p-60791bb6.js";import{c as o}from"./p-4a78e118.js";import{D as h}from"./p-bee6b5d7.js";import{T as d}from"./p-a2493d11.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-5534e08c.js";import"./p-6dc031de.js";var l;!function(t){t.LINK_AND_FILE_AT_THE_SAME_TIME="LINK_AND_FILE_AT_THE_SAME_TIME",t.ANY_LINK_OR_FILE_FILLED="ANY_LINK_OR_FILE_FILLED",t.UNKNOWN="UNKNOWN"}(l||(l={}));class c{constructor(t,e,i){var s;this.entityName=t,this.registerKey=e,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(l.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(l.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}async save(t){var e,i;const s="AnexoSistemaSP.salvar";let{updatingFields:n}=t;n=Object.assign(Object.assign({},n),{NOMEARQUIVO:null===(e=n.NOMEARQUIVO)||void 0===e?void 0:e[0]});try{this.validateFields(n);const t=n.LINK?null:n.NOMEARQUIVO,e={serviceName:s,requestBody:{params:{resourceID:this.resourceID,description:n.DESCRICAO,fileSelect:t?1:0,keySession:null===(i=null==t?void 0:t.properties)||void 0===i?void 0:i.fileNameTmp,nameAttach:null==t?void 0:t.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},a=await r.get().callServiceBroker(s,JSON.stringify(e));return Promise.resolve([Object.assign(Object.assign(Object.assign({},a),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var e,i,s;const n="AnexoSistemaSP.salvar";let{updatingFields:a,record:o}=t;const h=t=>void 0!==a[t]?a[t]:o[t],d=h("NOMEARQUIVO"),l=null===(i=null===(e=a.NOMEARQUIVO)||void 0===e?void 0:e[0])||void 0===i?void 0:i.downloadURL;a=Object.assign(Object.assign({},a),{DESCRICAO:h("DESCRICAO"),LINK:h("LINK"),TIPOACESSO:h("TIPOACESSO"),TIPOAPRES:h("TIPOAPRES"),CHAVEARQUIVO:o.CHAVEARQUIVO,NOMEARQUIVO:null==d?void 0:d[0]});const c=a.LINK?null:a.NOMEARQUIVO;try{this.validateFields(a);const t={serviceName:n,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==o?void 0:o.NUATTACH,description:a.DESCRICAO,fileSelect:l?1:0,keySession:null===(s=null==c?void 0:c.properties)||void 0===s?void 0:s.fileNameTmp,keyAttach:a.CHAVEARQUIVO,nameAttach:null==c?void 0:c.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},e=await r.get().callServiceBroker(n,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},e),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==c?void 0:c.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var e;const i="AnexoSistemaSP.excluir",s=(null===(e=t.NOMEARQUIVO)||void 0===e?void 0:e[0])||{},n={serviceName:i,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,e)=>{r.get().callServiceBroker(i,JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}getDownloadKey(t){var e;const i="AnexoSistemaSP.baixar",s=(null===(e=t.NOMEARQUIVO)||void 0===e?void 0:e[0])||{},n={serviceName:i,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,e)=>{r.get().callServiceBroker(i,JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}class m{constructor(t,e){this.entityName=t,this.getMessage=e,this._application=s.getContextValue("__SNK__APPLICATION__")}initLoaders(t,e,i){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,e)=>this.dataLoader(t,e),t.saveLoader=(t,s)=>this.saveLoader(s,e).then((t=>(t.length&&i(),t))),t.removeLoader=(t,s)=>this.removeLoader(t,s,e).then((t=>(t.length&&i(),t)))}dataLoader(t,e){return new Promise((i=>{this.loader(t,e).then((t=>{const e=((null==t?void 0:t.records)||[]).map((t=>{let e;return t.LINK||(e=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:e})}));i(Object.assign(Object.assign({},t),{records:e}))}))}))}saveLoader(t,e){return new Promise((i=>{var s;const n=Array.isArray(t)?t[0]:{};((null===(s=null==n?void 0:n.record)||void 0===s?void 0:s.NUATTACH)>=0?e.edit.bind(e):e.save.bind(e))(n).then((t=>{i(t)})).catch((t=>t.message===l.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),i([])):t.message===l.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),i([])):t.message?(this._application.error(t.title||t.name,t.message),i([])):void i([])))}))}removeLoader(t,e,i){return new Promise((s=>{const{records:n}=t.getSelectionInfo();i.delete(n[0]).then((()=>s(e)))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:n.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,e,i){return new Promise((s=>e.type===a.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(i.goToView(o.GRID),s(e)):s(void 0))):s(e):e.type===a.DATA_SAVED?(t.loadData(),s(e)):void s(e)))}}const u=s.getContextValue("__SNK__APPLICATION__"),v=t=>{var e,i;return null===(i=null===(e=null==u?void 0:u.messagesBuilder)||void 0===e?void 0:e.getMessage)||void 0===i?void 0:i.call(e,t,null)},A={DOWNLOAD:{hint:v("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:v("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},O=()=>{const t=[d.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,e,i)=>{if((null==e?void 0:e.insertionMode)||(null==e?void 0:e.isDirty))return i.reverse();i.splice(i.indexOf(d.REFRESH),1);const{selectedRecord:s}=e||{},n=(null==s?void 0:s.LINK)?A.LINK:A.DOWNLOAD;i.splice(i.indexOf(d.DIVIDER)+1,0,d.REMOVE,n,d.DIVIDER);const a=Array.from(new Set(i.filter((t=>t!==d.CLONE))));return a.splice(a.indexOf(n)+1,0,d.DIVIDER),a},isEnabled:(e,i,s)=>{const n=void 0!==(null==i?void 0:i.selectedRecord);return!(t.includes(s)&&!n)}}},I={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},p=class{constructor(i){t(this,i),this.back=e(this,"back",7),this.handleTaskbarClick=({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this.dataUnit.getSelectedRecord())},this.handleBack=()=>{this.dataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this.dataUnit.isDirty())return this.back.emit();this.dataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this.dataUnit=void 0,this.crudConfig=void 0}registerKeyWatcher(t,e){var i;e!==t&&(this.returnToGridMode(),this._attachFetcher=new c(this.entityName,this.registerKey,null===(i=this.dataUnit)||void 0===i?void 0:i.name),this._dataUnitBuilder.initLoaders(this.dataUnit,this._attachFetcher,(()=>{this.returnToGridMode()})),this.dataUnit.loadData())}getMessage(t,e){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,e)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._attachFetcher.getDownloadKey(t).then((({chave:t})=>{window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${t.valor}&forcarDownload=S`)}))}returnToGridMode(){this.dataUnit.clearSelection(),this._crudElement&&this._crudElement.goToView(o.GRID)}loadAttachmentDataUnit(){var t;try{const e=this.dataUnit||(new h).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema");return this._attachFetcher=new c(this.entityName,this.registerKey,null===(t=this.dataUnit)||void 0===t?void 0:t.name),e.metadata||e.loadMetadata().then((()=>{this.crudConfig=I})),this._dataUnitBuilder=new m(this.entityName,this.getMessage.bind(this)),e.addFilterProvider({getFilter:()=>this._dataUnitBuilder.getFilters(this.registerKey)}),e.addInterceptor({interceptAction:t=>this._dataUnitBuilder.getInterceptions(e,t,this._crudElement)}),this.dataUnit=e,this.dataUnit.loadData(),this.dataUnit}catch(t){throw new Error("There was an error while creating the data unit")}}componentWillLoad(){this._application=s.getContextValue("__SNK__APPLICATION__"),this.loadAttachmentDataUnit()}render(){var t,e;return this.dataUnit?i("main",null,i("header",{class:"snk-attach__header"},i("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},i("div",{slot:"rightSlot"},i("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),i("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},i("div",{class:"ez-box__container"},i("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this.dataUnit,taskbarManager:O(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(e=this.crudConfig)||void 0===e?void 0:e.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick},i("div",{slot:"snkSimpleCrudHeader"},i("div",{class:"ez-flex ez-flex--column"},i("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),i("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};p.style=".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%}";export{p as snk_attach}
@@ -1,17 +0,0 @@
1
- import{d as e,D as t}from"./p-60791bb6.js";import{ObjectUtils as n}from"@sankhyalabs/core";import{R as i}from"./p-f737f7e1.js";class s extends i{constructor(){super(),this.queryConfig=new Map,this.buildTemplatesConfig()}buildTemplatesConfig(){this.queryConfig.set("fetchUserAvailableConfigs",e.gql`query($name: String!) {
2
- $queryAlias$: fetchUserAvailableConfigs(name: $name){
3
- name
4
- origin
5
- key
6
- }
7
- }`),this.queryConfig.set("fetchLegacyConfig",e.gql`query($name: String!) {
8
- $queryAlias$: fetchLegacyConfig(name: $name){
9
- name
10
- resource
11
- }
12
- }`),this.queryConfig.set("fetchDefaultConfig",e.gql`query($name: String!) {
13
- $queryAlias$: fetchDefaultConfig(name: $name){
14
- name
15
- resource
16
- }
17
- }`)}loadFormConfig(e,t){return new Promise(((n,i)=>{Promise.all([this.loadResource(this.getPath(t,e)),this.loadResource(this.getPath(`FormCardState:${t}`,e,"form-card")),this.loadResource(this.getPath(t,e,"summary")),this.loadResource(this.getPath(t,e,"defaultValues"))]).then((([e,t,i,s])=>{let r;if(null!=e){r=Object.assign(Object.assign({},JSON.parse(e)),{emptyConfig:!1});const{tabs:t,fields:n}=r;if(t){const e=new Map(t.map((e=>[e.label,e])));null==n||n.forEach((t=>{var n;return t.tab=(null===(n=e.get(this.getTabName(t.tab)))||void 0===n?void 0:n.label)||e.get(this.getTabName(t.tab))}))}r.fields=null==n?void 0:n.map((e=>{if("readonly"in e){const t=!0===e.readonly;delete e.readonly,e.readOnly=t}return e}))}null!=t&&(null==r&&(r={emptyConfig:!0,fields:[]}),r.cardsState=new Map(JSON.parse(t))),null!=i&&(null==r&&(r={emptyConfig:!0,fields:[]}),r.summary=new Map(Object.entries(JSON.parse(i)))),null!=s&&(null==r&&(r={emptyConfig:!0,fields:[]}),r.defaultVars=new Map(Object.entries(JSON.parse(s)))),n(r)})).catch((e=>{i(e)}))}))}getTabName(e){return"object"==typeof e?e.label:e}saveCardState(e,t,n){const i=this.getPath(`FormCardState:${n}`,t,"form-card");return new Promise(((t,n)=>{this.saveResource(Array.from(e.entries()),i).then((e=>{t(new Map(JSON.parse(e.resource)))})).catch((e=>{n(e)}))}))}saveConfig(e,t,n){delete e.cardsState,delete e.defaultVars,delete e.summary;const i=this.getPath(n,t);return new Promise(((t,n)=>{this.saveResource(e,i).then((e=>{t(JSON.parse(e.resource))})).catch((e=>{n(e)}))}))}fetchUserAvailableConfigs(e,n){const i=this.getPath(n,e);return new Promise(((e,n)=>{t.get().callGraphQL({values:{name:i},query:this.queryConfig.get("fetchUserAvailableConfigs")}).then((t=>{e(t)})).catch((e=>{n(e)}))}))}fetchLegacyConfig(e,i){const s=this.getPath(i,e);return new Promise(((e,i)=>{t.get().callGraphQL({values:{name:s},query:this.queryConfig.get("fetchLegacyConfig")}).then((t=>{e(n.stringToObject((null==t?void 0:t.resource)||""))})).catch((e=>{i(e)}))}))}fetchDefaultConfig(e,i){const s=this.getPath(i,e);return new Promise(((e,i)=>{t.get().callGraphQL({values:{name:s},query:this.queryConfig.get("fetchDefaultConfig")}).then((t=>{e(n.stringToObject((null==t?void 0:t.resource)||""))})).catch((e=>{i(e)}))}))}getPath(e,t,n="form"){return t?`cfg://${n}/${e}/${t}`:`cfg://${n}/${e}`}}var r;!function(e){e.USER="USER",e.DEFAULT="DEFAULT",e.SHARED="SHARED"}(r||(r={}));export{s as F,r as U}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as s,g as e}from"./p-d2d301a6.js";import{DataUnit as a,defaultDataLoader as r,StringUtils as h,ChangeOperation as n,ObjectUtils as o,ApplicationContext as d,DataType as l,UserInterface as m}from"@sankhyalabs/core";import{c as u,S as c}from"./p-4a78e118.js";import{T as p}from"./p-a2493d11.js";import"./p-60791bb6.js";import"./p-85affa29.js";import{P as g}from"./p-5534e08c.js";import{T as v}from"./p-c2beb95c.js";import{S as b}from"./p-fa9d3f73.js";import"./p-6dc031de.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";class k{constructor(t,i){this.records=i||[],this.metadata=t,this._dataUnit=new a(k.IN_MEMORY_DATA_UNIT_NAME),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,i)=>r(t,i,this._records),this._dataUnit.saveLoader=(t,i)=>this.saveLoader(t,i),this._dataUnit.removeLoader=(t,i)=>this.removeLoader(t,i),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}get dataUnit(){return this._dataUnit}get records(){return this._records}set records(t){this._records=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t))),this._dataUnit&&(this._dataUnit.records=[...this._records])}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return h.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}saveLoader(t,i){return new Promise((t=>{let s=[];i.forEach((t=>{let{record:i,updatingFields:e,operation:a}=t,r=!1;a!==n.INSERT&&a!==n.COPY||(i.__old__id__=i.__record__id__,i.__record__id__=this.generateUniqueId(),r=!0);const h=Object.assign(Object.assign({},i),e);if(r)this.records.push(h);else{const t=this.records.findIndex((t=>t.__record__id__==h.__record__id__));this.records[t]=h}s.push(h)})),t(s)}))}removeLoader(t,i){return new Promise((t=>{this._records=this._records.filter((t=>!i.includes(t.__record__id__))),t(i)}))}}k.IN_MEMORY_DATA_UNIT_NAME="InMemoryDataUnit";const f=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.actionClick=i(this,"actionClick",7),this.formItemsReady=i(this,"formItemsReady",7),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._multiSelectionListDataSource=new b,this._taskbarProcessor=new v({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(p.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(p.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(p.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(p.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=u.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=c.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1}resolveInMemoryBtns(t){const i=[...t];return this.mode===c.IN_MEMORY&&i.splice(1,1),i}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const i=t.detail;i===p.GRID_MODE?this.goToView(u.GRID):i===p.FORM_MODE&&this.goToView(u.FORM),t.stopPropagation()}onModeChange(){this.mode==c.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons())}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource()}configDatasource(){const t=d.getContextValue("__SNK__APPLICATION__");this._multiSelectionListDataSource.setApplication(t),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}getTaskBarId(){var t,i,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&(null===(s=this.dataState.selectionInfo.records)||void 0===s?void 0:s.length)>0?this._currentViewMode===u.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===u.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new k(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),i=[],s={fields:[],emptyConfig:!1};t.forEach((t=>{const e={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:l[t.getAttribute("dataType")]||l.TEXT,userInterface:m[t.getAttribute("userInterface")]||m.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),i.push(e)})),i.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:i})}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}getTaskBarDisabledButtons(){var t,i,s,e;const a=[];return(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||a.push(p.NEXT),(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||a.push(p.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&a.push(p.FORM_MODE),a}handleCancelEdit(){var t;(null===(t=this.dataState)||void 0===t?void 0:t.recordsIsEmpty)&&(this.goToView(u.GRID),this.dataUnit.clearSelection())}render(){var t;return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:t=>this.onDataStateChange(t),onCancelEdition:this.handleCancelEdit.bind(this),onInsertionMode:()=>this.goToView(u.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail),ignoreSaveMessage:this._currentViewMode===u.GRID,onMessagesBuilderUpdated:t=>this.messagesBuilder=t.detail},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-flex ez-box ez-box--shadow"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:g.SECONDARY}),s("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(u.FORM),columnfilterDataSource:this.dataUnit.name.includes(k.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{dataUnit:this.dataUnit,config:this.formConfig})))))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};f.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{f as snk_simple_crud}
@@ -1 +0,0 @@
1
- import{r as t,h as s,H as i,g as e}from"./p-d2d301a6.js";import{ApplicationContext as n,StringUtils as o,ErrorException as a,WarningException as c,ObjectUtils as r,DateUtils as l,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as d}from"./p-60791bb6.js";import{P as p}from"./p-eaad0aa8.js";import"./p-85affa29.js";import"./p-5534e08c.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";class m{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.javaCall)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecJava})}))}callExecJava(t){const s={requestBody:{javaCall:t}};d.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(s))}}class v{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.runScript)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecScript})}))}callExecScript(t){const s={runScript:t};d.get().callServiceBroker("ActionButtonsSP.executeScript",s)}}class b{constructor(){this._application=n.getContextValue("__SNK__APPLICATION__")}async execute(t,s){const i=t.resourceID;if(!i)return;let e=await this.buildLaunchObject(t,s);return this._application.openApp(i,e),null}buildLaunchObject(t,s){return new Promise((i=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},c=[];e.forEach((i=>{const e=i.localField;let r=s.getFieldValue(e);if(!r){let i=s.getField(e).label;throw i=o.isEmpty(s.getField(e).label)?e:i,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:i}))}r=o.isEmpty(r.toString())?void 0:r.toString(),n[i.targetField]=r,c.push({fieldName:i.targetField,value:r})})),n.ACTION_PARAMETERS=c,n.call_time=Date.now(),i(n)}i(null)}))}}class k{execute(t){var s,i,e;const n=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.name,o=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.rootEntity,a={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:a,callback:this.callExecProcedure})}))}callExecProcedure(t){const s={requestBody:{stpCall:t}};d.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(s))}}var w,f;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(w||(w={}));class _{constructor(t){this.actionType=t,this._application=n.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case w.LAUNCH_SCREEN:return new b;case w.JAVASCRIPT:return new v;case w.JAVA:return new m;case w.PROCEDURE:return new k;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(f||(f={}));const S="__MASTER_ROW__";class y{constructor(t,s){var i;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=s,this._selectedRows=(null===(i=null==s?void 0:s.getSelectionInfo())||void 0===i?void 0:i.isAllRecords())?[]:null==s?void 0:s.getSelectionInfo().records,this._application=n.getContextValue("__SNK__APPLICATION__")}apply(t,s){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:i,callback:e})=>{this.resolvePromptParams(t,i,s).then((()=>{this.actionExecute(i,e)}))}))}async execute(t){var s;if(!t.actionConfig)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(s=t.actionConfig.params)||void 0===s?void 0:s.promptParam){const s=t.actionConfig.params.promptParam;let i=!1;for(let t=0;t<s.length;t++)if(!i&&"true"===s[t].saveLast){i=!0;break}i&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=r.copy(t),e.applyParameters=t=>{this.apply(t,i)},e.openPopup()}else t.type!=w.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:s})=>{this.actionExecute(t,s)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((s=>{let i=t.actionConfig.params.promptParam;return s&&s.param.forEach((t=>{i=i.map((s=>s.name!==t.paramName?s:Object.assign(Object.assign({},s),"B"===s.paramType?{value:"S"===t.$}:{value:t.$})))})),i}))}actionExecute(t,s){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,s),this.recordsReloader(t.refreshType)}resolvePromptParams(t,s,i){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,s),i&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let s,i,e=t.paramType,n=!1,o=t.value;switch(e){case p.DATE:e="D";break;case p.DATETIME:e="H";break;case p.DECIMAL:e="F",s={"sk-precision":Number(t.precision)};break;case p.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case p.ENTITY:s={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(i=t.entityPK),o=t.value?Number(t.value):null;break;case p.OPTIONS:e="O";let a=t.options.split(";").map((function(t,s){let i,e;if(t.indexOf("=")>-1){let s=t.split("=");i=s[0],e=s[1]}else i=s+1,e=t;return{data:i,value:e}}));s={"sk-options":a}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:i,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:s,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,s){s.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));o.isEmpty(t.value)||s.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let s;switch(t){case"D":s="F";break;case"DT":case"DH":s="D";break;case"B":case"ENTITY":case"SO":s="S";break;default:s=t}return s}getParamValue(t){let s=t.value;return s?("DT"==t.paramType?s=l.formatDate(s):"DH"==t.paramType&&(s=l.formatDateTime(s)),s):s}async loadLastValues(t){const s=await this.buildResourceId(t.actionID);return new Promise(((t,i)=>{if(this._lastValuesCache[s])t(this._lastValuesCache[s]);else{const e={config:{chave:s,tipo:"T"}};d.get().callServiceBroker("SystemUtilsSP.getConf",e).then((i=>{var e,n;let o;(null===(n=null===(e=i.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=i.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[s]=o,t(o)})).catch((t=>{i(t)}))}}))}async saveLastValues(t,s){if(this._application){let i={params:{param:[]}};s.forEach((t=>{"true"==t.saveLast&&i.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=i.params,this._application.saveConfig(e,i)}}async buildResourceId(t){let s="";return s=await this._application.getResourceID(),s+".actionconfig."+t}prepareAndExecute(t,s){this.addRows(t),s(t)}addRows(t){const s={row:[]},i=this._selectedRows;for(const t in i){const e=i[t],n={};e.hasOwnProperty(S)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[S],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));s.row.push(n)}s.row.length>0&&(t.rows=s)}recordsReloader(t){switch(t){case f.NONE:break;case f.PARENT:case f.MASTER:case f.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,s,i,e;if(null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===s?void 0:s.isAllRecords())return{filters:{filters:null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class P{clientConfirm(t,s){const i=n.getContextValue("__SNK__APPLICATION__");let e="";t.content.event.hasOwnProperty("stpCall")?(s.requestBody=t.content.event.stpCall,e=w.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(s.requestBody=t.content.event.runScript,e=w.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(s.requestBody=t.content.event.javaCall,e=w.JAVA);let o={type:"S",sequence:t.content.event.sequence};s.requestBody.params?Array.isArray(s.requestBody.params.param)||(s.requestBody.params.param=[s.requestBody.params.param]):s.requestBody.params={param:[]},s.requestBody.params.param.push(o);const a=t.content.event.title.$,c=t.content.event.message.$;let r;switch(e){case w.JAVASCRIPT:r={runScript:s.requestBody};break;case w.PROCEDURE:r={requestBody:{stpCall:s.requestBody}};break;case w.JAVA:r={requestBody:{javaCall:s.requestBody}}}if("S"==t.content.event.showNoOption){o.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=a,t.message=c,t.accept=()=>{o.$="S",s.reCall(r)},t.cancel=()=>{o.$="N",s.reCall(r)},t.openPopup()}else i.confirm(a,c,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((t=>{t&&(o.paramName="__CONFIRMACAO__",o.$="S",s.reCall(r))}))}}const A=class{constructor(s){t(this,s),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const s=this._actions.find((s=>s.actionID==t.detail.id)),i=new _(s.type).executor;new y(i,this._dataUnit).execute(Object.assign({},s)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return d.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var s;(null===(s=t.actions)||void 0===s?void 0:s.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const s=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();s&&this._dropdownParent&&(this._dropdownParent.style.top=s.y+s.height+5+"px",this._dropdownParent.style.left=s.x+"px")}closeDropdown(t){const s=null==t?void 0:t.target;s&&(s.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){var t;this._application=n.getContextValue("__SNK__APPLICATION__"),this._resourceID=await this._application.getResourceID(),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas"),this._dataUnit=null===(t=this._element.parentElement)||void 0===t?void 0:t.dataUnit,this._entityName=this._dataUnit.name.split("/")[2],this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new P;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return s(i,null,this._actions&&this._actions.length>0&&s("div",{class:`ez-padding-left--medium snk-actions-button \n ${this.canShowDropdown()?" snk-actions-button--overlap":""}\n `},s("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),s("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&s("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&s("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};A.style=".sc-snk-actions-button-h{--snk-actions-button--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button--overlap.sc-snk-actions-button{z-index:var(--snk-actions-button--z-index)}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";export{A as snk_actions_button}
@@ -1 +0,0 @@
1
- import{C as t}from"./p-dd1fa35d.js";import{ObjectUtils as e}from"@sankhyalabs/core";import{F as s}from"./p-2dd0f891.js";class i{constructor(t,e){this._configName=t,this._onConfigChange=e}async loadConfig(){return new Promise((e=>{t.get().then((t=>{t.loadFormConfig(this._configName).then((t=>{this.setConfig(t),e(t)})).catch((t=>{console.warn(t)}))}))}))}saveConfig(s){const i=e.copy(s);return new Promise((e=>{t.saveFormConfig(s,this._configName).then((t=>{this.setConfig(Object.assign(Object.assign({},i),t)),e(Object.assign(Object.assign({},i),t))}))}))}saveCardState(e,s,i){return new Promise((r=>{var n;const h=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,o=h.get(e);h.set(e,"fixed"===i?this.updateFixSequence(Object.assign(Object.assign({},o),{fixed:s.fixed}),h):Object.assign(Object.assign({},o),{[i]:s[i]})),t.saveCardState(h,this._configName).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:h}),r(t)}))}))}updateFixSequence(t,e){let s=-1;return Array.from(e.values()).forEach((e=>{e.fixed||delete t.fixSequence,null!=e.fixSequence&&(s=Math.max(s,e.fixSequence))})),t.fixed?t.fixSequence=s+1:delete t.fixSequence,t}getFieldsList(t){var e;const s=null===(e=this._config)||void 0===e?void 0:e.fields;return null!=s&&s.length>0?[...s]:null!=t?t.metadata.fields.filter((t=>!1!==t.visible)).map((({name:t})=>({name:t}))):[]}getInsertionConfig(t){const e=this.getFieldsList(t).filter((e=>{if(t){const s=t.getField(e.name);if(s&&s.readOnly)return!1}return!e.readOnly}));return Object.assign(Object.assign({},this._config),{fields:e})}setConfig(t){this.isLoaded=!0;const{cardsState:e,summary:s,defaultVars:i}=this._config||{};this._config=Object.assign({},t),e&&(this._config.cardsState=e),s&&(this._config.summary=s),i&&(this._config.defaultVars=i),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,e){return t?this.getInsertionConfig(e):Object.assign({},this._config)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new s),this._formConfigFetcher}async fetchUserAvailableConfigs(t){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,t)}async fetchLegacyConfig(t){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,t)}async fetchDefaultConfig(t){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,t)}}export{i as S}
@@ -1 +0,0 @@
1
- import{r as t,c as i,f as s,h as e,H as a}from"./p-d2d301a6.js";import{S as h}from"./p-42843f0e.js";import{FormMetadata as o,buildFormMetadata as n}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-60791bb6.js";import"./p-85affa29.js";import"@sankhyalabs/core";import{P as r}from"./p-5534e08c.js";import{T as d}from"./p-a2493d11.js";import{c as l}from"./p-4a78e118.js";import{S as c}from"./p-803b79d6.js";import{S as m}from"./p-ae6aff81.js";import"./p-dd1fa35d.js";import"./p-2dd0f891.js";import"./p-f737f7e1.js";import"./p-e42f1f2a.js";import"./p-584d7212.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-6dc031de.js";import"./p-c2beb95c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";class u{constructor(t,i,s){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s}get id(){return this._parentGuide.id}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,h=null!=o.getDetailName(s.split("::").pop()),n=h&&e,r=this._parentGuide.id,d=h?`${r}::${s}`:`${r}__FORM:${s}`;return h&&t.has(d)&&!n?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:n,tooltip:n?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),h=a.shift();return h.label=e?"Novo Registro":s.__record__label__,h.children=a,i.children=[h],i}}const p=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formItemsReady=i(this,"formItemsReady",7),this._disabledButtons=void 0,this._currentView=void 0,this.attachmentRegisterKey=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0,this.canEdit=!0}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,h=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==h?void 0:h.__record__id__)&&this.snkDetailGuidesChange.emit(new u(this.branchGuide,this._formMetadata,this.dataUnit)),s&&setTimeout((()=>{this.changeViewMode(l.FORM)}),0),e&&this.changeViewMode(l.GRID);const o=[];this.dataState.hasPrevious||o.push(d.PREVIOUS),this.dataState.hasNext||o.push(d.NEXT),this._disabledButtons=o}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}onContentCardChanged(t){c.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(p.REGEX_FORM_ID,"")}loadMetadata(){var t;if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(null===(t=this.dataState)||void 0===t?void 0:t.insertionMode,this.dataUnit);this._formMetadata=n(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){var i,s;this._viewStack=t,this._currentView=this.selectedForm?1:0,null===(s=null===(i=this._viewStack)||void 0===i?void 0:i.show)||void 0===s||s.call(i,this._currentView)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===l.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}handleAttachBack(){this._viewStack.show(l.GRID)}executeActionHandler(t){t.detail===d.GRID_MODE&&(this.emitSwitchEvent(l.GRID),t.stopPropagation()),t.detail===d.FORM_MODE&&(this.emitSwitchEvent(l.FORM),t.stopPropagation()),t.detail===d.ATTACH&&(this._viewStack.show(l.ATTACHMENT),t.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}async handleDataStateChange({detail:t}){this.dataState=t,void 0!==t.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new h(this._configName,(()=>this.loadMetadata())),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new m(this.entityName))}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{ref:t=>this._snkDataUnit=t,dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===l.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-flex ez-title--primary ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:t=>this._snkGrid=t,configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.emitSwitchEvent(l.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:r.SECONDARY,canEdit:this.canEdit,isDetail:!0}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath,onFormItemsReady:({detail:t})=>this.formItemsReady.emit(t)},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,messagesBuilder:this.messagesBuilder,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:r.SECONDARY,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit}))),e("stack-item",null,e("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this.entityName,onBack:this.handleAttachBack.bind(this)})))))}static get watchers(){return{dataState:["observerDataState"]}}};p.REGEX_FORM_ID=/__FORM:[^:]+/g,p.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";export{p as snk_detail_view}