@sankhyalabs/sankhyablocks 8.1.0-dev.1 → 8.1.0-dev.11

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 (212) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/{ConfigStorage-73e7afff.js → ConfigStorage-d688c739.js} +163 -50
  3. package/dist/cjs/{DataFetcher-004811c6.js → DataFetcher-d2c6ae38.js} +29 -0
  4. package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
  5. package/dist/cjs/{SnkFormConfigManager-d1f1a222.js → SnkFormConfigManager-29b73c81.js} +19 -21
  6. package/dist/cjs/{auth-fetcher-58237931.js → auth-fetcher-da975ac5.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-029eafbd.js → dataunit-fetcher-58ad78a7.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-181767c9.js → form-config-fetcher-761994b9.js} +2 -2
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-9a97994a.js → pesquisa-fetcher-bb0bb679.js} +1 -1
  11. package/dist/cjs/{resource-fetcher-c0332609.js → resource-fetcher-95d24dff.js} +1 -1
  12. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  13. package/dist/cjs/snk-actions-button.cjs.entry.js +13 -10
  14. package/dist/cjs/snk-application.cjs.entry.js +48 -44
  15. package/dist/cjs/snk-attach.cjs.entry.js +2 -2
  16. package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
  17. package/dist/cjs/snk-crud.cjs.entry.js +21 -9
  18. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  19. package/dist/cjs/{snk-data-unit-cc7a7ed0.js → snk-data-unit-80a00ae4.js} +4 -4
  20. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-detail-view.cjs.entry.js +11 -10
  22. package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
  23. package/dist/cjs/snk-filter-bar.cjs.entry.js +15 -17
  24. package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -15
  25. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +6 -19
  26. package/dist/cjs/snk-form-config.cjs.entry.js +7 -17
  27. package/dist/cjs/snk-form-view.cjs.entry.js +6 -1
  28. package/dist/cjs/snk-form.cjs.entry.js +13 -8
  29. package/dist/cjs/snk-grid-config.cjs.entry.js +6 -6
  30. package/dist/cjs/snk-grid.cjs.entry.js +18 -20
  31. package/dist/cjs/{snk-guides-viewer-27f87d90.js → snk-guides-viewer-f67f9cea.js} +12 -7
  32. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -8
  33. package/dist/cjs/snk-personalized-filter.cjs.entry.js +14 -16
  34. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  35. package/dist/cjs/snk-simple-crud.cjs.entry.js +15 -71
  36. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
  37. package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
  38. package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
  39. package/dist/collection/components/snk-application/snk-application.js +58 -65
  40. package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
  41. package/dist/collection/components/snk-crud/snk-crud.js +40 -6
  42. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +42 -2
  43. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +27 -1
  44. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +47 -28
  45. package/dist/collection/components/snk-data-unit/snk-data-unit.js +7 -8
  46. package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
  47. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +2 -12
  48. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
  49. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
  50. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +28 -12
  51. package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
  52. package/dist/collection/components/snk-form/snk-form.js +46 -2
  53. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
  54. package/dist/collection/components/snk-grid/snk-grid.js +51 -15
  55. package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
  56. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
  57. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +22 -0
  58. package/dist/collection/components/snk-taskbar/snk-taskbar.js +19 -1
  59. package/dist/collection/components/teste-pesquisa/teste-pesquisa.css +1 -1
  60. package/dist/collection/lib/configs/ConfigStorage.js +33 -44
  61. package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -59
  62. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
  63. package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
  64. package/dist/collection/lib/utils/urlutils.js +29 -0
  65. package/dist/components/ConfigStorage.js +161 -48
  66. package/dist/components/DataFetcher.js +29 -0
  67. package/dist/components/ResourceIDUtils.js +10 -0
  68. package/dist/components/SnkFormConfigManager.js +17 -19
  69. package/dist/components/auth-fetcher.js +1 -1
  70. package/dist/components/form-config-fetcher.js +64 -2
  71. package/dist/components/snk-actions-button2.js +11 -8
  72. package/dist/components/snk-application2.js +42 -38
  73. package/dist/components/snk-configurator2.js +3 -1
  74. package/dist/components/snk-crud.js +18 -5
  75. package/dist/components/snk-data-unit2.js +5 -4
  76. package/dist/components/snk-detail-view2.js +15 -7
  77. package/dist/components/snk-entity-list.js +0 -4
  78. package/dist/components/snk-filter-bar2.js +12 -12
  79. package/dist/components/snk-filter-detail2.js +2 -12
  80. package/dist/components/snk-filter-modal-item2.js +5 -16
  81. package/dist/components/snk-form-config2.js +5 -15
  82. package/dist/components/snk-form-view2.js +6 -1
  83. package/dist/components/snk-form.js +9 -2
  84. package/dist/components/snk-grid-config2.js +4 -2
  85. package/dist/components/snk-grid2.js +17 -16
  86. package/dist/components/snk-personalized-filter2.js +11 -11
  87. package/dist/components/snk-simple-crud2.js +3 -59
  88. package/dist/components/snk-taskbar2.js +3 -1
  89. package/dist/esm/{ConfigStorage-19a7260b.js → ConfigStorage-cfe03e99.js} +163 -49
  90. package/dist/esm/{DataFetcher-e0fc5549.js → DataFetcher-aaaff866.js} +29 -0
  91. package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
  92. package/dist/esm/{SnkFormConfigManager-1a42eb02.js → SnkFormConfigManager-bfd8eabd.js} +19 -21
  93. package/dist/esm/{auth-fetcher-83a946f8.js → auth-fetcher-7860d777.js} +1 -1
  94. package/dist/esm/{dataunit-fetcher-6a695723.js → dataunit-fetcher-9dfcdb1d.js} +1 -1
  95. package/dist/esm/{form-config-fetcher-9e167008.js → form-config-fetcher-4a34b86a.js} +2 -2
  96. package/dist/esm/loader.js +1 -1
  97. package/dist/esm/{pesquisa-fetcher-9118eb7a.js → pesquisa-fetcher-01d058e6.js} +1 -1
  98. package/dist/{components/resource-fetcher.js → esm/resource-fetcher-b36ac145.js} +1 -1
  99. package/dist/esm/sankhyablocks.js +1 -1
  100. package/dist/esm/snk-actions-button.entry.js +13 -10
  101. package/dist/esm/snk-application.entry.js +48 -44
  102. package/dist/esm/snk-attach.entry.js +2 -2
  103. package/dist/esm/snk-configurator.entry.js +2 -1
  104. package/dist/esm/snk-crud.entry.js +21 -9
  105. package/dist/esm/snk-data-exporter.entry.js +2 -2
  106. package/dist/esm/{snk-data-unit-77508763.js → snk-data-unit-3ab57d1a.js} +4 -4
  107. package/dist/esm/snk-data-unit.entry.js +1 -1
  108. package/dist/esm/snk-detail-view.entry.js +11 -10
  109. package/dist/esm/snk-entity-list.entry.js +0 -4
  110. package/dist/esm/snk-filter-bar.entry.js +15 -17
  111. package/dist/esm/snk-filter-detail.entry.js +2 -16
  112. package/dist/esm/snk-filter-modal-item.entry.js +7 -20
  113. package/dist/esm/snk-form-config.entry.js +8 -18
  114. package/dist/esm/snk-form-view.entry.js +6 -1
  115. package/dist/esm/snk-form.entry.js +13 -8
  116. package/dist/esm/snk-grid-config.entry.js +6 -6
  117. package/dist/esm/snk-grid.entry.js +18 -20
  118. package/dist/esm/{snk-guides-viewer-c47cd45e.js → snk-guides-viewer-3ea14ab4.js} +12 -7
  119. package/dist/esm/snk-guides-viewer.entry.js +7 -8
  120. package/dist/esm/snk-personalized-filter.entry.js +14 -16
  121. package/dist/esm/snk-print-selector.entry.js +1 -1
  122. package/dist/esm/snk-simple-crud.entry.js +5 -61
  123. package/dist/esm/snk-taskbar.entry.js +2 -1
  124. package/dist/sankhyablocks/{p-e7e54737.entry.js → p-05bcad8a.entry.js} +1 -1
  125. package/dist/sankhyablocks/p-0ae5b923.entry.js +1 -0
  126. package/dist/sankhyablocks/p-15230263.js +1 -0
  127. package/dist/sankhyablocks/p-18fa618e.entry.js +1 -0
  128. package/dist/sankhyablocks/{p-0ed0fc02.entry.js → p-1b81c379.entry.js} +1 -1
  129. package/dist/sankhyablocks/{p-98f9d076.js → p-2dd0f891.js} +2 -2
  130. package/dist/sankhyablocks/p-330f584a.entry.js +1 -0
  131. package/dist/sankhyablocks/{p-968741cc.js → p-48a40939.js} +1 -1
  132. package/dist/sankhyablocks/p-4c33a77c.entry.js +1 -0
  133. package/dist/sankhyablocks/p-53884b5f.entry.js +1 -0
  134. package/dist/sankhyablocks/{p-df8621b4.js → p-60791bb6.js} +1 -1
  135. package/dist/sankhyablocks/{p-f88c45bf.js → p-64c2cec3.js} +1 -1
  136. package/dist/sankhyablocks/p-688dcb4c.js +1 -0
  137. package/dist/sankhyablocks/p-70e785db.entry.js +1 -0
  138. package/dist/sankhyablocks/{p-0a4c753d.js → p-85affa29.js} +1 -1
  139. package/dist/sankhyablocks/p-861a3495.entry.js +1 -0
  140. package/dist/sankhyablocks/p-878b0dd3.entry.js +1 -0
  141. package/dist/sankhyablocks/p-97d2fbd9.entry.js +1 -0
  142. package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
  143. package/dist/sankhyablocks/p-9d591463.js +1 -0
  144. package/dist/sankhyablocks/p-9d93da18.js +56 -0
  145. package/dist/sankhyablocks/{p-34085ced.entry.js → p-9f387187.entry.js} +1 -1
  146. package/dist/sankhyablocks/p-aa4c112f.entry.js +11 -0
  147. package/dist/sankhyablocks/p-bae87498.entry.js +1 -0
  148. package/dist/sankhyablocks/{p-2ac9c585.js → p-bee6b5d7.js} +1 -1
  149. package/dist/sankhyablocks/p-c555075c.entry.js +1 -0
  150. package/dist/sankhyablocks/p-cc67bd06.entry.js +1 -0
  151. package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
  152. package/dist/sankhyablocks/p-e070d7a3.entry.js +1 -0
  153. package/dist/sankhyablocks/p-e086cc2a.entry.js +1 -0
  154. package/dist/sankhyablocks/p-ed705cbb.entry.js +1 -0
  155. package/dist/sankhyablocks/{p-7b8b8ae9.js → p-f737f7e1.js} +1 -1
  156. package/dist/sankhyablocks/p-fa523d6b.entry.js +1 -0
  157. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  158. package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
  159. package/dist/types/components/snk-application/snk-application.d.ts +8 -13
  160. package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
  161. package/dist/types/components/snk-crud/snk-crud.d.ts +5 -0
  162. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +8 -0
  163. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +5 -0
  164. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +9 -2
  165. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +2 -2
  166. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
  167. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
  168. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
  169. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
  170. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  171. package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
  172. package/dist/types/components/snk-form/snk-form.d.ts +9 -1
  173. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
  174. package/dist/types/components/snk-grid/snk-grid.d.ts +5 -1
  175. package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
  176. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
  177. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
  178. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +4 -0
  179. package/dist/types/components.d.ts +125 -21
  180. package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
  181. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +0 -7
  182. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
  183. package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
  184. package/dist/types/lib/utils/urlutils.d.ts +14 -0
  185. package/package.json +3 -3
  186. package/dist/cjs/filter-bar-config-fetcher-2b8ed9d0.js +0 -155
  187. package/dist/components/filter-bar-config-fetcher.js +0 -153
  188. package/dist/esm/filter-bar-config-fetcher-06e02851.js +0 -153
  189. package/dist/esm/resource-fetcher-768d5556.js +0 -66
  190. package/dist/sankhyablocks/p-216f081a.entry.js +0 -1
  191. package/dist/sankhyablocks/p-22c6fe1a.entry.js +0 -1
  192. package/dist/sankhyablocks/p-34a1357a.entry.js +0 -1
  193. package/dist/sankhyablocks/p-4721c3db.js +0 -1
  194. package/dist/sankhyablocks/p-6759adae.entry.js +0 -1
  195. package/dist/sankhyablocks/p-7e285d6c.entry.js +0 -11
  196. package/dist/sankhyablocks/p-815a42c0.entry.js +0 -1
  197. package/dist/sankhyablocks/p-8a41172a.entry.js +0 -1
  198. package/dist/sankhyablocks/p-8f8184ff.js +0 -56
  199. package/dist/sankhyablocks/p-976e56e9.js +0 -1
  200. package/dist/sankhyablocks/p-bc735728.entry.js +0 -1
  201. package/dist/sankhyablocks/p-be684b38.entry.js +0 -1
  202. package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
  203. package/dist/sankhyablocks/p-c0f656af.entry.js +0 -1
  204. package/dist/sankhyablocks/p-c44f6aaf.entry.js +0 -1
  205. package/dist/sankhyablocks/p-c57bd935.entry.js +0 -1
  206. package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
  207. package/dist/sankhyablocks/p-cfd7da4a.entry.js +0 -1
  208. package/dist/sankhyablocks/p-d1b89765.js +0 -1
  209. package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
  210. package/dist/sankhyablocks/p-e28129aa.entry.js +0 -1
  211. package/dist/sankhyablocks/p-f31bfdee.entry.js +0 -1
  212. package/dist/sankhyablocks/p-fe010e54.entry.js +0 -1
@@ -1,155 +0,0 @@
1
- 'use strict';
2
-
3
- const filterItemType_enum = require('./filter-item-type.enum-aa823a00.js');
4
- const resourceFetcher = require('./resource-fetcher-c0332609.js');
5
-
6
- var __rest = (undefined && undefined.__rest) || function (s, e) {
7
- var t = {};
8
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
9
- t[p] = s[p];
10
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
11
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
12
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
13
- t[p[i]] = s[p[i]];
14
- }
15
- return t;
16
- };
17
- function normalizeValue(value, type) {
18
- if (value == undefined) {
19
- return value;
20
- }
21
- if (value instanceof Date) {
22
- return value.toISOString();
23
- }
24
- if (typeof value === "object") {
25
- if (value instanceof Array) {
26
- return value.map(item => {
27
- if (filterItemType_enum.FilterItemType.MULTI_LIST === type) {
28
- const values = __rest(item, ["label"]);
29
- return normalizeValue(values);
30
- }
31
- return normalizeValue(item);
32
- });
33
- }
34
- else {
35
- const normalized = Object.assign({}, value);
36
- Object.keys(value).forEach(prop => {
37
- if (value[prop] !== undefined) {
38
- normalized[prop] = normalizeValue(value[prop], type);
39
- }
40
- else {
41
- delete normalized[prop];
42
- }
43
- });
44
- return normalized;
45
- }
46
- }
47
- return value;
48
- }
49
- class FilterBarConfigFetcher extends resourceFetcher.ResourceFetcher {
50
- normalize(items) {
51
- return items.map(item => {
52
- const { id, value, fixed, visible, type, groupedItems } = item;
53
- const stateItem = { id };
54
- if (value) {
55
- stateItem["value"] = normalizeValue(value, type);
56
- }
57
- if (fixed) {
58
- stateItem["fixed"] = fixed;
59
- }
60
- if (groupedItems) {
61
- if (groupedItems.length === 0) {
62
- return;
63
- }
64
- if (groupedItems.filter(item => item.visible).length > 0) {
65
- stateItem["visible"] = true;
66
- }
67
- stateItem["groupedItems"] = this.normalize(groupedItems);
68
- }
69
- else {
70
- if (visible) {
71
- stateItem["visible"] = true;
72
- }
73
- }
74
- return stateItem;
75
- }).filter(item => item != undefined);
76
- }
77
- saveConfig(items, resourceID, configName) {
78
- return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
79
- }
80
- getConfig(resourceID, configName, urlParams) {
81
- return new Promise((accept, reject) => {
82
- this.loadResource(this.getPath(resourceID, configName, urlParams))
83
- .then((configAsString) => {
84
- let fieldsList;
85
- if (configAsString) {
86
- const filterBarConfig = JSON.parse(configAsString);
87
- fieldsList = this.buildFieldList(filterBarConfig.items);
88
- }
89
- accept(fieldsList || []);
90
- })
91
- .catch((error) => {
92
- reject(error);
93
- });
94
- });
95
- }
96
- saveEntityListConfig(item, resourceID, configName) {
97
- return new Promise((accept, reject) => {
98
- this.getConfig(resourceID, configName).then(config => {
99
- const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
100
- return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
101
- });
102
- const index = state.findIndex(({ id }) => id === item.id);
103
- const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
104
- if (index > -1) {
105
- state[index] = newItem;
106
- }
107
- else {
108
- state.push(newItem);
109
- }
110
- this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
111
- accept(resp);
112
- }).catch(exception => {
113
- reject(exception);
114
- });
115
- }).catch(exception => {
116
- reject(exception);
117
- });
118
- });
119
- }
120
- buildFieldList(items) {
121
- return items.map(item => {
122
- var _a, _b;
123
- if (item.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
124
- const multiListValue = item.value;
125
- 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;
126
- }
127
- return item;
128
- });
129
- }
130
- getPath(resourceID, name, urlParams) {
131
- let path = `cfg://filter/FilterBarState:${resourceID}`;
132
- if (name) {
133
- path += `.${name}`;
134
- }
135
- if (urlParams) {
136
- path += this.buildQueryString(urlParams);
137
- }
138
- return path;
139
- }
140
- buildQueryString(urlParams) {
141
- let queryString = '?';
142
- for (let key in urlParams) {
143
- if (!urlParams.hasOwnProperty(key)) {
144
- continue;
145
- }
146
- if (queryString.length > 1) {
147
- queryString += '&';
148
- }
149
- queryString += key + '=' + urlParams[key];
150
- }
151
- return queryString;
152
- }
153
- }
154
-
155
- exports.FilterBarConfigFetcher = FilterBarConfigFetcher;
@@ -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,153 +0,0 @@
1
- import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
2
- import { R as ResourceFetcher } from './resource-fetcher-768d5556.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-e0fc5549.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 e,H as s}from"./p-d2d301a6.js";import{ElementIDUtils as r}from"@sankhyalabs/core";import{DataBinder as a}from"@sankhyalabs/ezui/dist/collection/utils/form";const o=class{constructor(e){i(this,e),this.snkContentCardChanged=t(this,"snkContentCardChanged",7),this.levelPath=void 0,this.label=void 0,this.name=void 0,this.fields=void 0,this.formMetadata=void 0,this.dataUnit=void 0,this.contracted=void 0,this.fixed=!1,this.summaryFields=void 0,this.canExpand=!0,this.canFix=!0,this.recordsValidator=void 0}async showUp(){this._formView&&this._formView.showUp()}changeFix(){this.fixed=!this.fixed,this.emitEvent("fixed")}changeContracted(){this.contracted=!this.contracted,this.emitEvent("presentation")}emitEvent(i){this.snkContentCardChanged.emit({formName:this.name,cardConfig:{fixed:this.fixed,presentation:this.contracted?"CONTRACTED":"EXPANDED"},propertyChanged:i})}getCardSummary(){const i={};return this.getSummaryFields().forEach((({field:t,label:e})=>{var s;const r=this.dataUnit.getFormattedValue(t);""!==r&&(null==e&&(e=null===(s=this.dataUnit.getField(t))||void 0===s?void 0:s.label),i[e]=r)})),i}getSummaryFields(){return null==this.summaryFields?this.fields.map((i=>{const t=this.dataUnit.getField(i.name);return{field:i.name,label:i.label||(null==t?void 0:t.label)}})):this.summaryFields}bindFields(i){null==this._dataBinder&&null!=this.dataUnit&&(this._dataBinder=new a(this.dataUnit)),this._dataBinder&&this._dataBinder.bind(i,this.dataUnit.dataUnitId,this.formMetadata,this.recordsValidator)}disconnectedCallback(){null!=this._dataBinder&&this._dataBinder.onDisconnectedCallback()}render(){return e(s,{class:"ez-box__container"},e("div",{class:"summary-header ez-flex ez-size-width--full"},e("div",{class:"ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9"},this.levelPath?e("span",{class:"level-path"},this.levelPath+" /"):void 0,this.label),e("div",{class:"ez-flex ez-flex--justify-end ez-col--sd-3"},this.canFix&&e("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.fixed?"un-pin":"push-pin","data-element-id":r.getInternalIDInfo("toggleFixed_ezFormCard"),onClick:()=>this.changeFix(),title:this.fixed?"Desafixar":"Fixar"}),this.canExpand&&e("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.contracted?"chevron-down":"chevron-up","data-element-id":r.getInternalIDInfo("toggleExpand_ezFormCard"),onClick:()=>this.changeContracted(),title:this.contracted?"Expandir":"Resumir"}))),e("slot",null),this.contracted?e("snk-form-summary",{summary:this.getCardSummary()}):e("ez-form-view",{ref:i=>this._formView=i,fields:this.fields,onEzContentReady:i=>this.bindFields(i.detail)}))}};o.style=".sc-snk-form-view-h{display:flex;width:100%;--ez-form-card-summary-field-content-weight:700}.level-path.sc-snk-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-form-view{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";export{o as snk_form_view}
@@ -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 h}from"./p-8f8184ff.js";import{P as l}from"./p-5534e08c.js";import{T as c}from"./p-c2beb95c.js";import{s as u}from"./p-6dc031de.js";import{S as v}from"./p-fa9d3f73.js";import{SelectionMode as g}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-98f9d076.js";import"./p-df8621b4.js";import"./p-112455b1.js";import"./p-7b8b8ae9.js";import"./p-976e56e9.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._multiSelectionListDataSource=new v,this._topTaskbarProcessor=new c({"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 c({"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.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=l.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(){h.get().then((i=>{i.loadGridConfig(this.configName).then((i=>{this.setGridConfig(i)})).catch((i=>{console.warn(i)}))}))}gridConfigChangeHandler(i){h.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__}};u.set("exporterProviders",Object.assign(Object.assign({},u.get("exporterProviders")),{[this.configName]:s}))}addElementID(){d.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}finshLoading(){this._dataUnitLoadLockerResolver=this._dataUnit.addLoadingLocker(),this.addElementID(),this._multiSelectionListDataSource.setApplication(this._application),this._multiSelectionListDataSource.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===l.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===l.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===l.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._multiSelectionListDataSource,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{DataUnit as r,StringUtils as a,SortMode as n,DataType as o,ChangeOperation as h,ObjectUtils as d,ApplicationContext as l,UserInterface as u}from"@sankhyalabs/core";import{c,S as m}from"./p-4a78e118.js";import{T as p}from"./p-a2493d11.js";import"./p-df8621b4.js";import"./p-0a4c753d.js";import{P as v}from"./p-5534e08c.js";import{T as g}from"./p-c2beb95c.js";import{DISTINCT_FILTER_NAME_PREFIX as b}from"@sankhyalabs/ezui/dist/collection/utils/constants";import{S as k}from"./p-fa9d3f73.js";import"./p-6dc031de.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";class f{constructor(t,i){this.records=i||[],this.metadata=t,this._dataUnit=new r(f.IN_MEMORY_DATA_UNIT_NAME),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,i)=>this.dataLoader(t,i),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 a.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}dataLoader(t,i){const s=this.getColumnFilters(t);let e=this.applyFilters(s);return i.sort&&i.sort.forEach((t=>{e=e.sort(((i,s)=>{const e=i[t.field],r=s[t.field];return this.getSortFn(t.dataType)(e,r)*(t.mode==n.ASC?1:-1)}))})),Promise.resolve({records:e})}applyFilters(t){let i=[...this._records];return t.forEach((t=>{i=i.filter((i=>{var s;return t.values.includes(null===(s=i[t.column])||void 0===s?void 0:s.toString())}))})),i}getColumnFilters(t){var i,s;const e=null!==(s=(null!==(i=t.getFilters())&&void 0!==i?i:[]).filter((t=>{var i;return null===(i=t.name)||void 0===i?void 0:i.includes(b)})))&&void 0!==s?s:[];return e.map((t=>{var i,s;return{column:null!==(s=null===(i=t.name)||void 0===i?void 0:i.replace(b,""))&&void 0!==s?s:"",values:t.params.map((t=>t.value))}}))}getSortFn(t){switch(t){case o.NUMBER:return this.sortNumber;case o.DATE:return this.sortDate;case o.OBJECT:return this.sortObject;default:return a.compare}}sortObject(t,i){return a.compare(null==t?void 0:t.label,null==i?void 0:i.label)}sortNumber(t,i){return t-i}sortDate(t,i){let s=t.getTime(),e=i.getTime();return s===e?0:s<e?-1:1}saveLoader(t,i){return new Promise((t=>{let s=[];i.forEach((t=>{let{record:i,updatingFields:e,operation:r}=t,a=!1;r!==h.INSERT&&r!==h.COPY||(i.__old__id__=i.__record__id__,i.__record__id__=this.generateUniqueId(),a=!0);const n=Object.assign(Object.assign({},i),e);if(a)this.records.push(n);else{const t=this.records.findIndex((t=>t.__record__id__==n.__record__id__));this.records[t]=n}s.push(n)})),t(s)}))}removeLoader(t,i){return new Promise((t=>{this._records=this._records.filter((t=>!i.includes(t.__record__id__))),t(i)}))}}f.IN_MEMORY_DATA_UNIT_NAME="InMemoryDataUnit";const S=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.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._multiSelectionListDataSource=new k,this._taskbarProcessor=new g({"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=c.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=m.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===m.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(c.GRID):i===p.FORM_MODE&&this.goToView(c.FORM),t.stopPropagation()}onModeChange(){this.mode==m.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,i){d.objectToString(i)!=d.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=l.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===c.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===c.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new f(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:o[t.getAttribute("dataType")]||o.TEXT,userInterface:u[t.getAttribute("userInterface")]||u.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 r=[];return(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||r.push(p.NEXT),(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||r.push(p.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&r.push(p.FORM_MODE),r}handleCancelEdit(){var t;(null===(t=this.dataState)||void 0===t?void 0:t.recordsIsEmpty)&&(this.goToView(c.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(c.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail),ignoreSaveMessage:this._currentViewMode===c.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:v.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(c.FORM),columnfilterDataSource:this.dataUnit.name.includes(f.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"]}}};S.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{S as snk_simple_crud}
@@ -1 +0,0 @@
1
- import{r as i,c as e,h as s,F as t}from"./p-d2d301a6.js";import{ElementIDUtils as a}from"@sankhyalabs/core";import{S as r}from"./p-d1b89765.js";import{buildFormMetadata as n,FormMetadata as d}from"@sankhyalabs/ezui/dist/collection/utils/form";import{T as o}from"./p-c2beb95c.js";import{T as h}from"./p-a2493d11.js";import{c as l}from"./p-4a78e118.js";import"./p-df8621b4.js";import"./p-0a4c753d.js";import{P as u}from"./p-5534e08c.js";import{SelectionMode as v}from"@sankhyalabs/core/dist/dataunit/DataUnit";const c="__FORM:",g=class{constructor(s){i(this,s),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0}observeDataUnit(){this.loadGuides(!0)}observeDataState(i,e){const s=null==i?void 0:i.selectedRecord,t=null==e?void 0:e.selectedRecord;(null==s?void 0:s.__record__id__)!==(null==t?void 0:t.__record__id__)&&this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected())}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}exitViewer(){this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===h.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){g.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataState.insertionMode,this.dataUnit)))}getMessage(i){return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=n(this.masterFormConfig,this.dataUnit,!0);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=!s||this.dataUnit.isNewRecord(s.__record__id__),a=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip="Para alterar detalhes é necessário estar com um registro selecionado.",e.disabled=!0),a.push(e)})),this._guides=a,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}isDetail(i){return null!=d.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))}))}loadTaskbarProcessor(){var i,e;const s=(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkGuideViewer.finish_edition":"snkGuideViewer.regular",t=[];this.dataState&&this.dataState.hasPrevious||t.push("PREVIOUS"),this.dataState&&this.dataState.hasNext||t.push("NEXT"),(null===(e=this.dataState)||void 0===e?void 0:e.selectionInfo)&&(this.dataState.selectionInfo.length>1&&t.push("CLONE"),this.dataState.selectionInfo.isAllRecords()&&t.push("REMOVE"));const a=["PREVIOUS","NEXT","DIVIDER","ATTACH","CLONE","REMOVE","MORE_OPTIONS","ACTIONS_BUTTON","DIVIDER","GRID_MODE","CONFIGURATOR"];this.presentationMode==u.SECONDARY?a.unshift("INSERT"):a.push("INSERT");const r=this.getInvisibleButtons();this._taskbarProcessor=new o({"snkGuideViewer.regular":a,"snkGuideViewer.finish_edition":["CANCEL","SAVE"]}),this._taskbarProcessor.process(s,this.taskbarManager,this.dataState,t,r)}getInvisibleButtons(){const i=[];return this.dataState&&this.dataState.selectionInfo.mode===v.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i,e,a,r,n,d){const o=null==i?void 0:i.cardsState;if(null!=o)return s(t,null,Array.from(o.entries()).filter((([i,e])=>(null==e?void 0:e.fixed)&&i!=a)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([t,a])=>{var o;const h=e.getSheet(t);if(null!=h)return s("snk-form-view",{levelPath:d,label:h.label,name:t,fields:h.fields,formMetadata:e,dataUnit:r,recordsValidator:n,contracted:"CONTRACTED"===(null==a?void 0:a.presentation),fixed:null==a?void 0:a.fixed,summaryFields:null===(o=null==i?void 0:i.summary)||void 0===o?void 0:o.get(t),key:t})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),a=d.getDetailName(t);return a?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,a)}`,entityName:a},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>d.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){var i,e,t,a,r;if(!this.selectedGuide)return;const n=this.selectedGuide.id;let o;const h=n.split("::"),l=h.pop(),v=d.getDetailName(l);let g=n;if(v||h.length>0){let e,t;if(n.includes(c)){[g,e]=n.split(c);const s=(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)||0;t=s>1?this._breadcrumbItems[s-2]:this.selectedGuide}else t=this.selectedGuide;o=this.wrapDetail(h,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(h,v),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:v,selectedForm:e,branchGuide:t,guideItemPath:this._breadcrumbItems,key:`detail${g}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail)}))}else{const i=this.selectedGuide.id,d=this._masterFormMetadata.getSheet(i);if(d){const h=null===(t=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===t?void 0:t.get(i);o=s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==h?void 0:h.fixed,summaryFields:null===(r=null===(a=this.masterFormConfig)||void 0===a?void 0:a.summary)||void 0===r?void 0:r.get(i),name:i,label:d.label,fields:d.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,key:n},this.presentationMode==u.SECONDARY&&this.buildTaskBar())}}return o}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))}getConfigViewMode(){return l.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===l.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}componentWillLoad(){this._configManager=new r(this.configName,(i=>this.masterFormConfig=i)),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}buildTaskBar(){var i;return s("div",{class:"ez-col ez-flex-item--align-center ez-col--sd-6 ez-col--tb-6 "+(this.presentationMode!=u.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},s("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,messagesBuilder:this.messagesBuilder,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-taskbar-owner":"master",dataUnit:this.dataUnit}))}render(){var i,e;if(null!=this._formEditorConfigManager)return s("snk-form-config",{dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null});if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this.loadTaskbarProcessor();const t=this._guides&&this._guides.length>1;return s("section",{class:"snk-guides-viewer"},s("div",{class:"ez-row snk-guides-viewer__header"},s("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6 ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},s("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),s("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},s("h1",{class:"ez-title ez-title--primary ez-title--xlarge"},this.getMessage("snkCrud.title")),(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)>1&&s("div",{class:"ez-margin-top--extra-small"},s("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=u.SECONDARY&&this.buildTaskBar()),s("div",{class:"snk-guides-viewer__container"},t?s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):s("div",null),s("div",{class:"snk-guides-viewer__detail-container"},g.buildFixedForms(this.masterFormConfig,this._masterFormMetadata,null===(e=this.selectedGuide)||void 0===e?void 0:e.id,this.dataUnit,this.recordsValidator),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail)}))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};g.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{g as S}
@@ -1 +0,0 @@
1
- import{r as i,c as s,h as t,g as o}from"./p-d2d301a6.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{S as a}from"./p-d1b89765.js";import"./p-8f8184ff.js";import"./p-98f9d076.js";import"./p-df8621b4.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7b8b8ae9.js";import"./p-976e56e9.js";import"./p-584d7212.js";const e=class{constructor(t){i(this,t),this.exit=s(this,"exit",7),this.actionClick=s(this,"actionClick",7),this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}closeConfig(){this.hideConfig()}dataunitReady(){h.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",(i=>{this._dataState=i.detail}));break}i=i.parentElement}this._configManager=new a(this.configName),this._configManager.loadConfig()}render(){if(this._dataUnit&&this._dataState)return t("section",null,t("div",{class:"ez-row"},t("div",{class:"ez-col ez-col--sd-12"},t("ez-form",{key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataState.insertionMode,this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&t("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return o(this)}};e.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";export{e as snk_form}