@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-50737.1 → 0.0.0-bugfix-dev-KB-53946.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/cjs/{ConfigStorage-8d4e9d53.js → ConfigStorage-085c7117.js} +11 -12
  2. package/dist/cjs/{SnkMultiSelectionListDataSource-1438f8f2.js → IExporterProvider-f50b6846.js} +52 -5
  3. package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
  4. package/dist/cjs/{SnkFormConfigManager-33995e92.js → SnkFormConfigManager-8986431f.js} +2 -2
  5. package/dist/cjs/{SnkMessageBuilder-141aa18d.js → SnkMessageBuilder-66aa2557.js} +4 -0
  6. package/dist/cjs/{auth-fetcher-bb8e9ae4.js → auth-fetcher-eddaf17f.js} +1 -1
  7. package/dist/cjs/{DataFetcher-99f0f6ed.js → form-config-fetcher-cdd644a7.js} +251 -0
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/{pesquisa-fetcher-94f6b316.js → pesquisa-fetcher-90b801fb.js} +79 -55
  10. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  11. package/dist/cjs/snk-actions-button_4.cjs.entry.js +9 -9
  12. package/dist/cjs/snk-application.cjs.entry.js +24 -24
  13. package/dist/cjs/snk-attach.cjs.entry.js +73 -52
  14. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  15. package/dist/cjs/snk-data-exporter.cjs.entry.js +199 -81
  16. package/dist/cjs/{snk-data-unit-6026a9f7.js → snk-data-unit-abd2113f.js} +3 -38
  17. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -2
  18. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -8
  19. package/dist/cjs/snk-filter-bar.cjs.entry.js +7 -3
  20. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +2 -3
  21. package/dist/cjs/snk-form-config.cjs.entry.js +1 -2
  22. package/dist/cjs/snk-form.cjs.entry.js +3 -4
  23. package/dist/cjs/snk-grid.cjs.entry.js +66 -102
  24. package/dist/cjs/{snk-guides-viewer-25721856.js → snk-guides-viewer-e4c8ee66.js} +4 -5
  25. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  26. package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -3
  27. package/dist/cjs/snk-simple-crud.cjs.entry.js +144 -36
  28. package/dist/cjs/snk-taskbar.cjs.entry.js +27 -4
  29. package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-d9392685.js} +2 -2
  30. package/dist/collection/components/snk-attach/snk-attach.js +39 -24
  31. package/dist/collection/components/snk-attach/structure/builder/attach-crud-config.builder.js +1 -1
  32. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +29 -22
  33. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +90 -0
  34. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +68 -0
  35. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +48 -1
  36. package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
  37. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +53 -0
  38. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
  39. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +37 -47
  40. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
  41. package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
  42. package/dist/collection/components/snk-data-unit/snk-data-unit.js +3 -42
  43. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +5 -0
  44. package/dist/collection/components/snk-grid/snk-grid.js +3 -94
  45. package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +5 -2
  46. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +126 -14
  47. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
  48. package/dist/collection/components/snk-taskbar/snk-taskbar.js +30 -3
  49. package/dist/collection/lib/dataUnit/InMemoryLoader.js +10 -41
  50. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +33 -0
  51. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
  52. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
  53. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +10 -2
  54. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
  55. package/dist/collection/lib/message/resources/snk-simple-crud.msg.js +4 -0
  56. package/dist/components/ConfigStorage.js +1 -2
  57. package/dist/components/{field-search.js → IExporterProvider.js} +52 -7
  58. package/dist/components/ISave.js +42 -0
  59. package/dist/components/SnkMessageBuilder.js +4 -0
  60. package/dist/components/dataunit-fetcher.js +61 -44
  61. package/dist/components/form-config-fetcher.js +7022 -3
  62. package/dist/components/index2.js +198 -33
  63. package/dist/components/snk-actions-button2.js +3 -12
  64. package/dist/components/snk-application2.js +1 -1
  65. package/dist/components/snk-attach2.js +64 -44
  66. package/dist/components/snk-crud.js +3 -4
  67. package/dist/components/snk-data-exporter2.js +194 -81
  68. package/dist/components/snk-data-unit2.js +41 -39
  69. package/dist/components/snk-detail-view2.js +4 -5
  70. package/dist/components/snk-expression-item2.js +1 -1
  71. package/dist/components/snk-filter-bar2.js +5 -0
  72. package/dist/components/snk-form-config2.js +1 -1
  73. package/dist/components/snk-grid2.js +63 -100
  74. package/dist/components/snk-personalized-filter2.js +1 -1
  75. package/dist/components/snk-simple-crud2.js +133 -23
  76. package/dist/components/snk-taskbar2.js +33 -8
  77. package/dist/esm/{ConfigStorage-6e241cd7.js → ConfigStorage-cc3f3dd3.js} +1 -2
  78. package/dist/esm/{SnkMultiSelectionListDataSource-aad5d4ff.js → IExporterProvider-9e6e0071.js} +52 -6
  79. package/dist/esm/RecordIDUtils-87d02110.js +41 -0
  80. package/dist/esm/{SnkFormConfigManager-7a4e678f.js → SnkFormConfigManager-7edda7eb.js} +2 -2
  81. package/dist/esm/{SnkMessageBuilder-9747ddd2.js → SnkMessageBuilder-0a4becdd.js} +4 -0
  82. package/dist/esm/{auth-fetcher-8ec448b0.js → auth-fetcher-11dd9cae.js} +1 -1
  83. package/dist/esm/{DataFetcher-a650ae58.js → form-config-fetcher-13cd3285.js} +250 -1
  84. package/dist/esm/loader.js +1 -1
  85. package/dist/esm/{pesquisa-fetcher-f05a12ca.js → pesquisa-fetcher-d785663b.js} +61 -44
  86. package/dist/esm/sankhyablocks.js +1 -1
  87. package/dist/esm/snk-actions-button_4.entry.js +4 -4
  88. package/dist/esm/snk-application.entry.js +6 -6
  89. package/dist/esm/snk-attach.entry.js +65 -44
  90. package/dist/esm/snk-crud.entry.js +5 -5
  91. package/dist/esm/snk-data-exporter.entry.js +199 -81
  92. package/dist/esm/{snk-data-unit-4c343635.js → snk-data-unit-29eba11a.js} +4 -39
  93. package/dist/esm/snk-data-unit.entry.js +3 -2
  94. package/dist/esm/snk-detail-view.entry.js +8 -8
  95. package/dist/esm/snk-filter-bar.entry.js +7 -3
  96. package/dist/esm/snk-filter-modal-item.entry.js +2 -3
  97. package/dist/esm/snk-form-config.entry.js +1 -2
  98. package/dist/esm/snk-form.entry.js +3 -4
  99. package/dist/esm/snk-grid.entry.js +64 -100
  100. package/dist/esm/{snk-guides-viewer-b94752f2.js → snk-guides-viewer-8fc16590.js} +4 -5
  101. package/dist/esm/snk-guides-viewer.entry.js +7 -7
  102. package/dist/esm/snk-personalized-filter.entry.js +2 -3
  103. package/dist/esm/snk-simple-crud.entry.js +132 -24
  104. package/dist/esm/snk-taskbar.entry.js +27 -4
  105. package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-ad766858.js} +2 -2
  106. package/dist/sankhyablocks/p-07825198.js +1 -0
  107. package/dist/sankhyablocks/p-0ba97458.js +65 -0
  108. package/dist/sankhyablocks/p-1650f66b.entry.js +1 -0
  109. package/dist/sankhyablocks/p-1d1aa052.js +1 -0
  110. package/dist/sankhyablocks/p-1d9d07b4.entry.js +1 -0
  111. package/dist/sankhyablocks/p-250149af.entry.js +1 -0
  112. package/dist/sankhyablocks/p-2cfa05b0.entry.js +1 -0
  113. package/dist/sankhyablocks/{p-400097f2.entry.js → p-2daa70f9.entry.js} +3 -3
  114. package/dist/sankhyablocks/p-32556aa6.js +1 -0
  115. package/dist/sankhyablocks/p-33a6728e.js +26 -0
  116. package/dist/sankhyablocks/p-5b6c4f46.entry.js +1 -0
  117. package/dist/sankhyablocks/p-5d9456dc.js +1 -0
  118. package/dist/sankhyablocks/{p-0624f62d.js → p-8a4c4b54.js} +6 -6
  119. package/dist/sankhyablocks/p-9863d682.js +1 -0
  120. package/dist/sankhyablocks/{p-125bb902.js → p-99b51d06.js} +1 -1
  121. package/dist/sankhyablocks/p-9c283890.entry.js +1 -0
  122. package/dist/sankhyablocks/p-9ee96756.entry.js +1 -0
  123. package/dist/sankhyablocks/p-a4c94582.entry.js +1 -0
  124. package/dist/sankhyablocks/p-c2e3a71c.entry.js +1 -0
  125. package/dist/sankhyablocks/p-c2f3ebf3.entry.js +1 -0
  126. package/dist/sankhyablocks/p-ce37e3d3.entry.js +1 -0
  127. package/dist/sankhyablocks/p-cfb98f51.entry.js +1 -0
  128. package/dist/sankhyablocks/{p-efeca7ba.js → p-d24c9dc6.js} +1 -1
  129. package/dist/sankhyablocks/p-edd9dd1c.entry.js +1 -0
  130. package/dist/sankhyablocks/p-f51af6dd.entry.js +1 -0
  131. package/dist/sankhyablocks/p-fa84e72f.entry.js +1 -0
  132. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  133. package/dist/types/components/snk-attach/snk-attach.d.ts +2 -1
  134. package/dist/types/components/snk-attach/structure/builder/attach-crud-config.builder.d.ts +10 -1
  135. package/dist/types/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.d.ts +5 -4
  136. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +13 -0
  137. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +11 -0
  138. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +21 -4
  139. package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
  140. package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
  141. package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
  142. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +3 -1
  143. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
  144. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
  145. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +1 -0
  146. package/dist/types/components/snk-grid/snk-grid.d.ts +0 -3
  147. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +17 -2
  148. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
  149. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +6 -0
  150. package/dist/types/components.d.ts +17 -0
  151. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +0 -2
  152. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +4 -0
  153. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
  154. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
  155. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
  156. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +1 -0
  157. package/package.json +1 -1
  158. package/dist/cjs/form-config-fetcher-d73f4449.js +0 -256
  159. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
  160. package/dist/components/DataFetcher.js +0 -7023
  161. package/dist/components/index3.js +0 -199
  162. package/dist/esm/form-config-fetcher-765b8498.js +0 -253
  163. package/dist/sankhyablocks/p-004c356e.js +0 -26
  164. package/dist/sankhyablocks/p-0bba5c9f.entry.js +0 -1
  165. package/dist/sankhyablocks/p-1048bd26.entry.js +0 -1
  166. package/dist/sankhyablocks/p-20b46647.entry.js +0 -1
  167. package/dist/sankhyablocks/p-24ed6ad6.entry.js +0 -1
  168. package/dist/sankhyablocks/p-2936303b.js +0 -1
  169. package/dist/sankhyablocks/p-6c9adfca.js +0 -1
  170. package/dist/sankhyablocks/p-85af23fe.entry.js +0 -1
  171. package/dist/sankhyablocks/p-85ba3d6b.entry.js +0 -1
  172. package/dist/sankhyablocks/p-88b29791.js +0 -1
  173. package/dist/sankhyablocks/p-9a5d1b39.js +0 -1
  174. package/dist/sankhyablocks/p-9e8618ec.entry.js +0 -1
  175. package/dist/sankhyablocks/p-a043314f.entry.js +0 -1
  176. package/dist/sankhyablocks/p-a1642e7c.entry.js +0 -1
  177. package/dist/sankhyablocks/p-ac77949b.entry.js +0 -1
  178. package/dist/sankhyablocks/p-b47c2963.entry.js +0 -1
  179. package/dist/sankhyablocks/p-be75153c.js +0 -1
  180. package/dist/sankhyablocks/p-bf39bdb8.entry.js +0 -1
  181. package/dist/sankhyablocks/p-d304659d.entry.js +0 -1
  182. package/dist/sankhyablocks/p-d5cb4b5a.entry.js +0 -1
  183. package/dist/sankhyablocks/p-d78d4062.js +0 -65
  184. package/dist/sankhyablocks/p-e7dbe53a.entry.js +0 -1
  185. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
  186. /package/dist/sankhyablocks/{p-ae4fc9a9.js → p-61dd89eb.js} +0 -0
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-f9e81701.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const AuthorizationConfig = require('./AuthorizationConfig-79ffae4b.js');
8
- const taskbarElements = require('./taskbar-elements-3ecd1278.js');
8
+ const taskbarElements = require('./taskbar-elements-d9392685.js');
9
9
  const index$1 = require('./index-0922807b.js');
10
10
  require('./index-102ba62d.js');
11
11
 
@@ -41,6 +41,8 @@ const SnkTaskbar = class {
41
41
  this._customElementsId = undefined;
42
42
  this._slotContainer = undefined;
43
43
  this._hiddenActionsList = [];
44
+ this._lastWidth = undefined;
45
+ this._hasToUpdateOverFlow = false;
44
46
  this.alignRigth = false;
45
47
  this.customSlotId = "TASKBAR_CUSTOM_ELEMENTS";
46
48
  this.customContainerId = undefined;
@@ -66,6 +68,11 @@ const SnkTaskbar = class {
66
68
  var _a;
67
69
  (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.forceUpdate();
68
70
  }
71
+ observeLastWidth(newValue, oldValue) {
72
+ if (oldValue === 0 && newValue !== 0) {
73
+ this._hasToUpdateOverFlow = true;
74
+ }
75
+ }
69
76
  // Internal methods
70
77
  elementsFromString(strButtons) {
71
78
  const elements = [];
@@ -159,8 +166,9 @@ const SnkTaskbar = class {
159
166
  className += "ez-padding-left--medium";
160
167
  }
161
168
  const taskbarElement = taskbarElements.TaskbarElement[def.toString()];
169
+ const dataExporterStoreKey = this._element.dataset.exporterStoreKey || this.configName;
162
170
  if (taskbarElement) {
163
- return taskbarElements.buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), this.configName, this.presentationMode);
171
+ return taskbarElements.buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), dataExporterStoreKey, this.presentationMode);
164
172
  }
165
173
  else {
166
174
  return taskbarElements.buildCustomButton(def, className, this.getIdElemBtnCustom(def), elem => this.elementClick(elem), elem => this.isEnabled(elem));
@@ -249,10 +257,20 @@ const SnkTaskbar = class {
249
257
  this.getCustomElements();
250
258
  }
251
259
  componentWillRender() {
260
+ this.handleDefinitions();
261
+ this.validatePresentationMode();
262
+ this.updateOverFlowIfNeeded();
263
+ }
264
+ handleDefinitions() {
252
265
  if (this._definitions == undefined && this._permissions) {
253
266
  this._definitions = this.elementsFromString(this.buttons);
254
267
  }
255
- this.validatePresentationMode();
268
+ }
269
+ updateOverFlowIfNeeded() {
270
+ if (this._hasToUpdateOverFlow) {
271
+ requestAnimationFrame(() => { var _a; return (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.forceUpdate(); });
272
+ this._hasToUpdateOverFlow = false;
273
+ }
256
274
  }
257
275
  handleOverFlow(overFlowingElements) {
258
276
  const elementsToHandle = overFlowingElements.filter(element => !this.hasToIgnoreOverFlow(element));
@@ -319,6 +337,10 @@ const SnkTaskbar = class {
319
337
  }
320
338
  componentDidRender() {
321
339
  this.appendCustomElementsInTaskbar();
340
+ this.updateLastWidth();
341
+ }
342
+ updateLastWidth() {
343
+ this._lastWidth = this._element.getBoundingClientRect().width;
322
344
  }
323
345
  disconnectedCallback() {
324
346
  var _a;
@@ -365,7 +387,8 @@ const SnkTaskbar = class {
365
387
  get _element() { return index.getElement(this); }
366
388
  static get watchers() { return {
367
389
  "buttons": ["observeButtons"],
368
- "disabledButtons": ["observeDisabledButtons"]
390
+ "disabledButtons": ["observeDisabledButtons"],
391
+ "_lastWidth": ["observeLastWidth"]
369
392
  }; }
370
393
  };
371
394
  SnkTaskbar.style = snkTaskbarCss;
@@ -50,7 +50,7 @@ const buildCustomButton = (def, className, dataElementId, action, isEnabled) =>
50
50
  return textButton(def.name, className, dataElementId, text, hint, action, isEnabled);
51
51
  }
52
52
  };
53
- const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, configName, presentationMode) => {
53
+ const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, dataExporterStoreKey, presentationMode) => {
54
54
  var _a;
55
55
  const title = getTitle(element);
56
56
  switch (element) {
@@ -93,7 +93,7 @@ const buildElem = (element, className, dataElementId, getTitle, action, isEnable
93
93
  case exports.TaskbarElement.DIVIDER:
94
94
  return index.h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium", "data-taskbar-divider": true });
95
95
  case exports.TaskbarElement.DATA_EXPORTER:
96
- const provider = (_a = index$1.store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[configName];
96
+ const provider = (_a = index$1.store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[dataExporterStoreKey];
97
97
  return index.h("snk-data-exporter", { class: className, provider: provider, "data-element-id": dataElementId, "data-taskbar-element": element });
98
98
  case exports.TaskbarElement.ATTACH:
99
99
  return iconButton("anexo", element, className, dataElementId, title, action, isEnabled);
@@ -1,8 +1,9 @@
1
1
  import { h } from "@stencil/core";
2
- import { DataUnit, ApplicationContext } from "@sankhyalabs/core";
2
+ import { DataUnit, ApplicationContext, Action } from "@sankhyalabs/core";
3
3
  import { AnexoSistemaFetcher, AttachFetcher, DataUnitFetcher } from "../../lib";
4
4
  import { VIEW_MODE } from "../../lib/utils/constants";
5
5
  import { AnexoSistemaDataUnitFactory, AttachFetcherDataUnitFactory, buildTaskBarManager, anexoSistemaCrudConfig, attachCrudConfig } from "./structure";
6
+ import InMemoryLoader from "../../lib/dataUnit/InMemoryLoader";
6
7
  const RESOURCE_ID = 'AnexoSistema';
7
8
  const DATA_UNIT_NAME = 'br.com.sankhya.core.v3.anexoSistema';
8
9
  export class SnkAttach {
@@ -28,7 +29,7 @@ export class SnkAttach {
28
29
  this.back.emit();
29
30
  });
30
31
  };
31
- this.fetcherType = "AnexoSistema";
32
+ this.fetcherType = undefined;
32
33
  this.fetcher = undefined;
33
34
  this.dataUnit = undefined;
34
35
  this.dataUnitBuilder = undefined;
@@ -40,8 +41,8 @@ export class SnkAttach {
40
41
  this.crudConfig = undefined;
41
42
  }
42
43
  registerKeyWatcher(newRegisterKey, oldRegisterKey) {
43
- var _a, _b, _c, _d;
44
- if (this._currentDataUnit == null) {
44
+ var _a, _b, _c, _d, _e, _f;
45
+ if (!this._currentDataUnit) {
45
46
  this.loadAttachmentDataUnit();
46
47
  }
47
48
  if (oldRegisterKey !== newRegisterKey) {
@@ -56,11 +57,7 @@ export class SnkAttach {
56
57
  if (hasMoreOneItem)
57
58
  return;
58
59
  }
59
- return this._currentDataUnit
60
- .loadMetadata()
61
- .then(() => {
62
- this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
63
- });
60
+ return (_f = (_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata()) === null || _f === void 0 ? void 0 : _f.then(this._currentDataUnit.loadData.bind(undefined, undefined, true, this.registerKey));
64
61
  }
65
62
  }
66
63
  /**
@@ -126,7 +123,7 @@ export class SnkAttach {
126
123
  if (!this._currentDataUnit.metadata) {
127
124
  this._currentDataUnit
128
125
  .loadMetadata()
129
- .then(() => this.crudConfig = anexoSistemaCrudConfig);
126
+ .then(() => this.crudConfig = Object.assign({}, anexoSistemaCrudConfig));
130
127
  }
131
128
  this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
132
129
  this._currentDataUnit.addFilterProvider({
@@ -138,25 +135,29 @@ export class SnkAttach {
138
135
  this._currentDataUnit.loadData().then(this.disableEditFieldsNotInForm.bind(this));
139
136
  }
140
137
  loadAttach() {
141
- var _a;
138
+ var _a, _b, _c;
142
139
  this._currentFetcher = new AttachFetcher();
143
- this._currentDataUnit = new DataUnit();
140
+ this._currentDataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
144
141
  this._currentDataUnit.addInterceptor({
145
- interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
142
+ interceptAction: (action) => {
143
+ var _a;
144
+ if (action.type === Action.METADATA_LOADED) {
145
+ this.crudConfig = Object.assign({}, attachCrudConfig);
146
+ (_a = this._crudElement) === null || _a === void 0 ? void 0 : _a.updateConfig();
147
+ }
148
+ return this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement);
149
+ }
146
150
  });
147
151
  this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
148
152
  (_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
149
- await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
150
153
  this.returnToGridMode();
154
+ await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
151
155
  });
152
156
  if (!this._currentDataUnit.metadata) {
153
- this._currentDataUnit
154
- .loadMetadata()
155
- .then(() => {
156
- this.crudConfig = attachCrudConfig;
157
- this._currentDataUnit
158
- .loadData(undefined, undefined, true, this.registerKey)
159
- .then(this.disableEditFieldsNotInForm.bind(this));
157
+ (_c = (_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadMetadata()) === null || _c === void 0 ? void 0 : _c.then(() => {
158
+ var _a, _b;
159
+ this.crudConfig = Object.assign({}, attachCrudConfig);
160
+ (_b = (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadData(undefined, undefined, true, this.registerKey)) === null || _b === void 0 ? void 0 : _b.then(this.disableEditFieldsNotInForm.bind(this));
160
161
  });
161
162
  }
162
163
  }
@@ -174,15 +175,30 @@ export class SnkAttach {
174
175
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
175
176
  }
176
177
  componentWillRender() {
178
+ if (!this.fetcherType) {
179
+ this.fetcherType = "AnexoSistema";
180
+ }
177
181
  if (this._currentDataUnit == null) {
178
182
  this.loadAttachmentDataUnit();
179
183
  }
180
184
  }
185
+ async handleOnDataStateChange({ detail }) {
186
+ if (this.fetcherType !== 'Attach')
187
+ return;
188
+ if (!detail.insertionMode) {
189
+ this._currentDataUnit.disableField('DESCRICAO');
190
+ }
191
+ else {
192
+ this._currentDataUnit.enableField('DESCRICAO');
193
+ }
194
+ await this._currentDataUnit.loadMetadata();
195
+ }
196
+ ;
181
197
  render() {
182
198
  var _a, _b;
183
199
  if (!this._currentDataUnit)
184
200
  return null;
185
- return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this._currentDataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
201
+ return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this._currentDataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder, onDataStateChange: this.handleOnDataStateChange.bind(this) }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
186
202
  }
187
203
  static get is() { return "snk-attach"; }
188
204
  static get encapsulation() { return "scoped"; }
@@ -218,8 +234,7 @@ export class SnkAttach {
218
234
  "text": "FetcherType define o tipo de fetcher respons\u00E1vel por carregar os dados do DataUnit."
219
235
  },
220
236
  "attribute": "fetcher-type",
221
- "reflect": false,
222
- "defaultValue": "\"AnexoSistema\""
237
+ "reflect": false
223
238
  },
224
239
  "fetcher": {
225
240
  "type": "unknown",
@@ -39,7 +39,7 @@ export const attachFetcherMetadataBuilder = {
39
39
  label: "Attach List",
40
40
  fields: [
41
41
  { name: "CODATA", label: getMessage("snkAttach.attachMetadata.lblCode"), dataType: DataType.TEXT },
42
- { name: "DESCRICAO", label: getMessage("snkAttach.attachMetadata.lblDescription"), dataType: DataType.TEXT },
42
+ { name: "DESCRICAO", label: getMessage("snkAttach.attachMetadata.lblDescription"), dataType: DataType.TEXT, readOnly: false },
43
43
  { name: "ARQUIVO", label: getMessage("snkAttach.attachMetadata.lblFileOrLink"), dataType: DataType.TEXT },
44
44
  { name: "USUARIO", label: getMessage("snkAttach.attachMetadata.lblUser"), dataType: DataType.TEXT },
45
45
  { name: "DTALTER", label: getMessage("snkAttach.attachMetadata.lblDate"), dataType: DataType.TEXT },
@@ -1,12 +1,14 @@
1
- import { Action, ApplicationContext, StringUtils } from "@sankhyalabs/core";
2
- import { SaveErrorsEnum } from "../../../../../lib/http/data-fetcher/fetchers/AttachFetcher/interfaces";
3
- import { AutorizationType } from "../../../../../lib/http/data-fetcher/fetchers/auth-fetcher";
4
- import { attachFetcherMetadataBuilder } from "../../builder/attach-crud-config.builder";
5
- import { VIEW_MODE } from "../../../../../lib/utils/constants";
1
+ import { Action, ApplicationContext, StringUtils, } from '@sankhyalabs/core';
2
+ import { SaveErrorsEnum } from '../../../../../lib/http/data-fetcher/fetchers/AttachFetcher/interfaces';
3
+ import { AutorizationType } from '../../../../../lib/http/data-fetcher/fetchers/auth-fetcher';
4
+ import { attachFetcherMetadataBuilder } from '../../builder/attach-crud-config.builder';
5
+ import { VIEW_MODE } from '../../../../../lib/utils/constants';
6
+ import { applyFilter, applySorting, buildPaginationInfo } from '../../../../../lib/dataUnit/dataUnitInMemoryUtils';
6
7
  const SERVICE_LOAD = "Attach.load";
7
8
  export class AttachFetcherDataUnitFactory {
8
9
  constructor(getMessage) {
9
10
  this.getMessage = getMessage;
11
+ this._records = [];
10
12
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
11
13
  }
12
14
  initLoaders(dataUnit, fetcher, onSuccess) {
@@ -26,25 +28,30 @@ export class AttachFetcherDataUnitFactory {
26
28
  metadataLoader(_) {
27
29
  return Promise.resolve(attachFetcherMetadataBuilder);
28
30
  }
29
- async dataLoader(_, request) {
31
+ async dataLoader(dataUnit, request) {
30
32
  if (!request.source) {
31
- return Promise.resolve({ records: [] });
33
+ return Promise.resolve({ records: this._records });
32
34
  }
33
- const criteria = {
34
- criteria: {
35
- codata: request.source,
36
- tipoAnexo: "N"
37
- }
38
- };
39
- const applicationDataFetcher = await this._application.getDataFetcher();
40
- const { anexos: { anexo = [] } } = await applicationDataFetcher.callServiceBroker(SERVICE_LOAD, JSON.stringify(criteria));
41
- const records = [];
42
- anexo.forEach((param) => {
43
- records.push(Object.assign({ __record__id__: StringUtils.generateUUID(), CAMINHO_ARQUIVO: [{
44
- name: param === null || param === void 0 ? void 0 : param.ARQUIVO,
45
- }] }, param));
46
- });
47
- return Promise.resolve({ records });
35
+ if (!Number.isNaN(Number(request.source))) {
36
+ const criteria = {
37
+ criteria: {
38
+ codata: request.source,
39
+ tipoAnexo: "N"
40
+ }
41
+ };
42
+ const applicationDataFetcher = await this._application.getDataFetcher();
43
+ const { anexos: { anexo = [] } } = await applicationDataFetcher.callServiceBroker(SERVICE_LOAD, JSON.stringify(criteria));
44
+ const records = [];
45
+ anexo.forEach((param) => {
46
+ records.push(Object.assign({ __record__id__: StringUtils.generateUUID(), CAMINHO_ARQUIVO: [{
47
+ name: param === null || param === void 0 ? void 0 : param.ARQUIVO,
48
+ }] }, param));
49
+ });
50
+ this._records = records;
51
+ }
52
+ let records = applyFilter(this._records, dataUnit, request.filters);
53
+ records = applySorting(records, dataUnit, request.sort);
54
+ return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
48
55
  }
49
56
  saveLoader(changes, fetcher) {
50
57
  return new Promise((resolve) => {
@@ -0,0 +1,90 @@
1
+ import { UserInterface } from "@sankhyalabs/core";
2
+ import { DataFetcher } from "../../../lib";
3
+ export default class ClientSideExporterStrategy {
4
+ constructor(provider) {
5
+ this._provider = provider;
6
+ }
7
+ async executeExport(resolveProps) {
8
+ const { methodName, titleGrid } = resolveProps;
9
+ const records = await this._provider.getRecords();
10
+ const columns = await this._provider.getColumnsMetadata();
11
+ const [serviceName, processor] = this.getExecutor(methodName);
12
+ const payload = {
13
+ serviceName,
14
+ requestBody: {
15
+ grid: {
16
+ titleGrid,
17
+ columns: this.buildColumnsObject(columns),
18
+ rows: this.buildRowsObject(columns, records),
19
+ customOptions: { xlsxExtension: false }
20
+ }
21
+ }
22
+ };
23
+ return new Promise((resolve, reject) => {
24
+ DataFetcher.get()
25
+ .callServiceBroker(serviceName, payload)
26
+ .then(result => resolve(processor(result)))
27
+ .catch(error => reject(error));
28
+ });
29
+ }
30
+ getExecutor(methodName) {
31
+ if (methodName === "exportToPDF") {
32
+ return [
33
+ "GridPDFBuilderSP.buildPDFFromJson",
34
+ responseBody => ({
35
+ fileSessionKey: responseBody.chavePDF.valor,
36
+ canPrint: responseBody.permiteImprimir.valor === "S",
37
+ canExport: responseBody.permiteExportar.valor === "S",
38
+ canSendEmail: responseBody.canSendEmail.valor === "S",
39
+ useAppPrint: true
40
+ })
41
+ ];
42
+ }
43
+ return [
44
+ "GridXLSBuilderSP.buildXLSFromJson",
45
+ responseBody => ({
46
+ fileSessionKey: responseBody.chaveXLS.valor,
47
+ canPrint: false,
48
+ canExport: false,
49
+ useAppPrint: false,
50
+ canSendEmail: false
51
+ })
52
+ ];
53
+ }
54
+ buildColumnsObject(columns) {
55
+ return {
56
+ column: columns.map((column, index) => {
57
+ const { label, id, width, userInterface } = column;
58
+ return Object.assign({ index: index + 1, id,
59
+ label,
60
+ width, presentationType: "P" }, (TYPE_MAP[userInterface] || { type: "S", align: "left" }));
61
+ })
62
+ };
63
+ }
64
+ buildRowsObject(columns, records) {
65
+ return {
66
+ row: records.map(rawRecord => {
67
+ const record = {};
68
+ columns.forEach((column, index) => record["c" + (index + 1)] = { $: this.formatValue(rawRecord, column) });
69
+ return record;
70
+ })
71
+ };
72
+ }
73
+ formatValue(record, column) {
74
+ if (this._provider.formatValue != undefined) {
75
+ return this._provider.formatValue(record, column);
76
+ }
77
+ return record[column.id] || "";
78
+ }
79
+ }
80
+ class FormatedRecord {
81
+ }
82
+ const TYPE_MAP = {
83
+ [UserInterface.DATE]: { type: "D", align: "center" },
84
+ [UserInterface.DATETIME]: { type: "H", align: "center" },
85
+ [UserInterface.TIME]: { type: "I", align: "right" },
86
+ [UserInterface.ELAPSEDTIME]: { type: "I", align: "right" },
87
+ [UserInterface.DECIMALNUMBER]: { type: "F", align: "right" },
88
+ [UserInterface.INTEGERNUMBER]: { type: "I", align: "right" },
89
+ [UserInterface.SEARCH]: { type: "S", align: "right" }
90
+ };
@@ -0,0 +1,68 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s)
4
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { ApplicationContext, ObjectUtils } from "@sankhyalabs/core";
14
+ import { DataFetcher } from '../../../lib/http/data-fetcher/DataFetcher';
15
+ import { DataExporterOption } from "../../../lib/@types";
16
+ export default class ServerSideExporterStrategy {
17
+ constructor(provider) {
18
+ this._provider = provider;
19
+ }
20
+ async getParams(resolveProps) {
21
+ var _a, _b, _c, _d, _e, _f;
22
+ const filters = (_b = (_a = this._provider).getFilters) === null || _b === void 0 ? void 0 : _b.call(_a);
23
+ const columns = await this._provider.getColumnsMetadata();
24
+ const sort = (_d = (_c = this._provider).getOrders) === null || _d === void 0 ? void 0 : _d.call(_c);
25
+ const resourceURI = (_f = (_e = this._provider).getResourceURI) === null || _f === void 0 ? void 0 : _f.call(_e);
26
+ const selectedIDs = this._provider.getSelectedIDs();
27
+ const option = resolveProps.exportOption;
28
+ const currentPageOptions = [
29
+ DataExporterOption.EXPORT_PAGE_TO_PDF,
30
+ DataExporterOption.EXPORT_PAGE_TO_XLS
31
+ ];
32
+ delete resolveProps.exportOption;
33
+ let params = Object.assign({ filters,
34
+ columns,
35
+ sort,
36
+ resourceURI, selectedIDs: selectedIDs.slice(0, this._provider.getExportLimit()) }, resolveProps);
37
+ if (currentPageOptions.includes(option) || resolveProps.type == "page") {
38
+ const offset = this._provider.getOffset();
39
+ const limit = this._provider.getPageSize();
40
+ params = Object.assign(Object.assign({}, params), { offset,
41
+ limit, selectedIDs: [] });
42
+ }
43
+ else if (resolveProps.type == "all") {
44
+ params = Object.assign(Object.assign({}, params), { offset: 0, limit: this._provider.getExportLimit(), selectedIDs: [] });
45
+ }
46
+ return Promise.resolve(params);
47
+ }
48
+ async executeExport(resolveProps) {
49
+ const _a = await this.getParams(resolveProps), { methodName } = _a, requestBody = __rest(_a, ["methodName"]);
50
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
51
+ const serviceName = `${application.getModuleName()}@DataExporterSPBean.${methodName}`;
52
+ const payload = { serviceName, requestBody };
53
+ return new Promise((resolve, reject) => {
54
+ DataFetcher.get()
55
+ .callServiceBroker(serviceName, ObjectUtils.objectToString(payload))
56
+ .then(result => resolve(this.getFormatResponse(result)))
57
+ .catch(error => reject(error));
58
+ });
59
+ }
60
+ getFormatResponse(result) {
61
+ var _a;
62
+ const response = (_a = result === null || result === void 0 ? void 0 : result.json) === null || _a === void 0 ? void 0 : _a.$;
63
+ if (response == undefined) {
64
+ return;
65
+ }
66
+ return ObjectUtils.stringToObject(response);
67
+ }
68
+ }
@@ -1 +1,48 @@
1
- export {};
1
+ import { UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
2
+ import { DataType } from '@sankhyalabs/core';
3
+ export class CommonsExporter {
4
+ constructor(dataUnit, grid) {
5
+ this.dataUnit = dataUnit;
6
+ this.grid = grid;
7
+ }
8
+ async getColumnsMetadata() {
9
+ var _a;
10
+ const columnsState = await ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getColumnsState());
11
+ return this.buildColumnsMetadata(columnsState);
12
+ }
13
+ buildColumnsMetadata(gridColumns) {
14
+ const columnsMetadata = [];
15
+ gridColumns === null || gridColumns === void 0 ? void 0 : gridColumns.forEach((column) => {
16
+ var _a, _b;
17
+ /**
18
+ * TODO: Analisar e criar uma melhor forma de tratar essa validação do "RECDESP".
19
+ */
20
+ if (column.hidden && column.name !== "RECDESP") {
21
+ return;
22
+ }
23
+ const fieldData = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(column.name);
24
+ const columnData = {
25
+ label: column.label,
26
+ id: column.name,
27
+ width: (fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface) === UserInterface.SEARCH ? 30 : column.width,
28
+ type: fieldData === null || fieldData === void 0 ? void 0 : fieldData.dataType,
29
+ userInterface: fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface
30
+ };
31
+ columnsMetadata.push(columnData);
32
+ if (((_b = fieldData === null || fieldData === void 0 ? void 0 : fieldData.properties) === null || _b === void 0 ? void 0 : _b.DESCRIPTIONFIELD) != undefined) {
33
+ const mergedFrom = fieldData.properties.mergedFrom;
34
+ const descriptionField = `${fieldData.properties.ENTITYNAME}.${fieldData.properties.DESCRIPTIONFIELD}`;
35
+ const descriptionColumn = {
36
+ label: fieldData.properties.DESCRIPTIONENTITY,
37
+ id: `${mergedFrom ? (mergedFrom + ".") : ""}${descriptionField}`,
38
+ width: 200,
39
+ type: DataType.TEXT,
40
+ userInterface: UserInterface.LONGTEXT,
41
+ descriptionFrom: fieldData.name
42
+ };
43
+ columnsMetadata.push(descriptionColumn);
44
+ }
45
+ });
46
+ return columnsMetadata || [];
47
+ }
48
+ }
@@ -0,0 +1,53 @@
1
+ import { CommonsExporter } from "../interfaces/IExporterProvider";
2
+ import { UserInterface } from "@sankhyalabs/core";
3
+ import { getSelectedIDs } from "../utils/RecordIDUtils";
4
+ import { DataExporterOption } from "../../../lib/@types";
5
+ export default class ClientSideExporterProvider extends CommonsExporter {
6
+ getSelectedNumber() {
7
+ return this.dataUnit.getSelectionInfo().length;
8
+ }
9
+ getTotalRecords() {
10
+ var _a, _b, _c;
11
+ const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
12
+ return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
13
+ }
14
+ getSelectedIDs() {
15
+ return getSelectedIDs(this.dataUnit);
16
+ }
17
+ getRecordID() {
18
+ var _a, _b, _c;
19
+ return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
20
+ }
21
+ async getRecords() {
22
+ if (this.dataUnit.records.length === 0) {
23
+ return Promise.resolve([]);
24
+ }
25
+ const selectionInfo = this.dataUnit.getSelectionInfo();
26
+ const records = selectionInfo.isEmpty() || selectionInfo.isAllRecords() ? await selectionInfo.getAllRecords() : selectionInfo.records;
27
+ return Promise.resolve(records == undefined ? [] : records);
28
+ }
29
+ getHiddenOptions() {
30
+ return [
31
+ DataExporterOption.EXPORT_BY_EMAIL,
32
+ DataExporterOption.EXPORT_PDF_TO_EMAIL,
33
+ DataExporterOption.EXPORT_XLS_TO_EMAIL,
34
+ DataExporterOption.EXPORT_PAGE_TO_PDF,
35
+ DataExporterOption.EXPORT_PAGE_TO_XLS
36
+ ];
37
+ }
38
+ formatValue(record, column) {
39
+ const { id, descriptionFrom } = column;
40
+ const value = record[descriptionFrom || id];
41
+ if (value == undefined) {
42
+ return "";
43
+ }
44
+ if (descriptionFrom != undefined) {
45
+ return value.label;
46
+ }
47
+ const fieldDescriptor = this.dataUnit.getField(id);
48
+ if (fieldDescriptor.userInterface === UserInterface.SEARCH) {
49
+ return value.value;
50
+ }
51
+ return this.dataUnit.getFormattedValue(id, value);
52
+ }
53
+ }
@@ -0,0 +1,55 @@
1
+ import { CommonsExporter } from "../interfaces/IExporterProvider";
2
+ import { getSelectedIDs } from "../utils/RecordIDUtils";
3
+ export default class ServerSideExporterProvider extends CommonsExporter {
4
+ getFilters() {
5
+ var _a;
6
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getAppliedFilters();
7
+ }
8
+ getOrders() {
9
+ var _a;
10
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSort();
11
+ }
12
+ getResourceURI() {
13
+ var _a;
14
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name;
15
+ }
16
+ getSelectedNumber() {
17
+ return this.dataUnit.getSelectionInfo().length;
18
+ }
19
+ getTotalRecords() {
20
+ var _a, _b, _c;
21
+ const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
22
+ return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
23
+ }
24
+ getSelectedIDs() {
25
+ return getSelectedIDs(this.dataUnit);
26
+ }
27
+ getOffset() {
28
+ return this.getExporterOffset(this.getPaginationInfo());
29
+ }
30
+ getPageSize() {
31
+ var _a;
32
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.pageSize;
33
+ }
34
+ getExportLimit() {
35
+ return 5000;
36
+ }
37
+ getRecordID() {
38
+ var _a, _b, _c;
39
+ return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
40
+ }
41
+ getPaginationInfo() {
42
+ var _a;
43
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo();
44
+ }
45
+ getExporterOffset(paginationInfo) {
46
+ if (paginationInfo == undefined) {
47
+ return;
48
+ }
49
+ const offset = paginationInfo.firstRecord;
50
+ if (offset > 0) {
51
+ return (offset - 1);
52
+ }
53
+ return offset;
54
+ }
55
+ }