@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
@@ -1,4 +1,5 @@
1
1
  import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
+ import { CSSVarsUtils } from "@sankhyalabs/ezui/dist/collection/utils";
2
3
  import { h } from '@stencil/core';
3
4
  import { SIMPLE_CRUD_MODE, VIEW_MODE } from '../../lib/utils/constants';
4
5
  import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
@@ -10,16 +11,18 @@ import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/
10
11
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
11
12
  import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
12
13
  import { REGULAR_DEFAULT_BTNS, REGULAR_SELECTED_BTNS } from './regular-buttons';
14
+ import ClientSideExporterProvider from '../snk-data-exporter/providers/ClientSideExporterProvider';
15
+ import store from "../../lib/store";
13
16
  export class SnkSimpleCrud {
14
17
  constructor() {
15
18
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
16
19
  this._keyDownHandler = (event) => this.keyDownListener(event);
17
20
  this._formConfigFetcher = new FormConfigFetcher();
18
21
  this._taskbarProcessor = new TaskbarProcessor({
19
- "snkSimpleCrudTaskbar.form_regular": this.getButtons(false, TaskbarElement.GRID_MODE),
20
- "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, TaskbarElement.FORM_MODE),
21
- "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, TaskbarElement.GRID_MODE),
22
- "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, TaskbarElement.FORM_MODE),
22
+ "snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
23
+ "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
24
+ "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
25
+ "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
23
26
  "snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
24
27
  });
25
28
  this._showPopUpGridConfig = false;
@@ -30,12 +33,14 @@ export class SnkSimpleCrud {
30
33
  this._customContainerId = `SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
31
34
  this.dataState = undefined;
32
35
  this.dataUnit = undefined;
36
+ this.entityName = undefined;
33
37
  this.mode = SIMPLE_CRUD_MODE.SERVER;
34
38
  this.gridConfig = undefined;
35
39
  this.formConfig = undefined;
36
40
  this._formFields = [];
37
41
  this.multipleSelection = undefined;
38
42
  this.useCancelConfirm = true;
43
+ this.pageSize = 150;
39
44
  this.resourceID = undefined;
40
45
  this.taskbarManager = undefined;
41
46
  this.messagesBuilder = undefined;
@@ -57,9 +62,9 @@ export class SnkSimpleCrud {
57
62
  this.loadFormConfig(true);
58
63
  this.loadGridConfig(true);
59
64
  }
60
- getButtons(selected, changeModeBtn) {
65
+ getButtons(selected, extraButtons) {
61
66
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
62
- .concat(changeModeBtn));
67
+ .concat(extraButtons));
63
68
  }
64
69
  addConfigButton(buttons) {
65
70
  if (this.configName === undefined) {
@@ -99,6 +104,12 @@ export class SnkSimpleCrud {
99
104
  }
100
105
  evt.stopPropagation();
101
106
  }
107
+ async onChangeEntityName(newValue) {
108
+ if (this.dataUnit)
109
+ return;
110
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
111
+ this.dataUnit = await application.getDataUnit(newValue, null, null, this.configName);
112
+ }
102
113
  onModeChange() {
103
114
  if (this.mode == SIMPLE_CRUD_MODE.IN_MEMORY) {
104
115
  this.initInMemoryDataUnit();
@@ -150,10 +161,15 @@ export class SnkSimpleCrud {
150
161
  this._showPopUpGridConfig = true;
151
162
  });
152
163
  }
153
- openFormConfig() {
164
+ async openFormConfig() {
165
+ var _a, _b;
154
166
  //No momento não daremos suporte para configuraçao de formulário quando houver legacy config
155
- if (this.formLegacyConfigName)
167
+ if (this.formLegacyConfigName) {
168
+ const title = (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage("snkSimpleCrud.formConfigUnavaliable.title", undefined);
169
+ const message = (_b = this.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage("snkSimpleCrud.formConfigUnavaliable.message", undefined);
170
+ await this.application.alert(title, message);
156
171
  return;
172
+ }
157
173
  this._showFormConfig = true;
158
174
  }
159
175
  addGridLegacyConfigName() {
@@ -206,6 +222,7 @@ export class SnkSimpleCrud {
206
222
  }
207
223
  async componentWillRender() {
208
224
  this._resourceID = await this.application.getResourceID();
225
+ this.dataExporterProviderStore();
209
226
  this._taskbarProcessor.process(this.getTaskBarId(), this.taskbarManager, this.dataState, this.getTaskBarDisabledButtons());
210
227
  if (this.configName === undefined) {
211
228
  return;
@@ -222,18 +239,21 @@ export class SnkSimpleCrud {
222
239
  this.onModeChange();
223
240
  this.configDatasource();
224
241
  }
242
+ componentDidLoad() {
243
+ CSSVarsUtils.applyVarsGrid(this._element, this._grid);
244
+ }
225
245
  configDatasource() {
226
246
  this._multiSelectionListDataSource.setApplication(this.application);
227
247
  this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
228
248
  }
229
249
  getTaskBarId() {
230
- var _a, _b, _c;
250
+ var _a, _b;
231
251
  if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
232
252
  return "snkSimpleCrudTaskbar.finish_edition";
233
253
  }
234
254
  if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo) &&
235
255
  !this.dataState.selectionInfo.isAllRecords() &&
236
- ((_c = this.dataState.selectionInfo.records) === null || _c === void 0 ? void 0 : _c.length) > 0) {
256
+ this.dataState.selectionInfo.length > 0) {
237
257
  return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
238
258
  }
239
259
  return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
@@ -278,6 +298,13 @@ export class SnkSimpleCrud {
278
298
  var _a;
279
299
  (_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
280
300
  }
301
+ updateConfig() {
302
+ if (this._formConfigManager == undefined) {
303
+ this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
304
+ }
305
+ this._formConfigManager.setConfig(this.formConfig);
306
+ return;
307
+ }
281
308
  processMetadata() {
282
309
  const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
283
310
  const fieldMetadata = [];
@@ -466,9 +493,23 @@ export class SnkSimpleCrud {
466
493
  .then(() => {
467
494
  this.setGridConfig(config);
468
495
  this.closeGridConfig();
496
+ this.dataExporterProviderStore();
469
497
  });
470
498
  evt.stopPropagation();
471
499
  }
500
+ async dataExporterProviderStore() {
501
+ if (this.dataUnit == undefined) {
502
+ return;
503
+ }
504
+ if (this._grid == undefined) {
505
+ return;
506
+ }
507
+ const dataExporterProvider = new ClientSideExporterProvider(this.dataUnit, this._grid);
508
+ store.set("exporterProviders", Object.assign(Object.assign({}, store.get("exporterProviders")), { [this.getDataExporterStoreKey()]: dataExporterProvider }));
509
+ }
510
+ getDataExporterStoreKey() {
511
+ return `SnkSimpleCrudDataExporter:${this.configName == undefined ? this.dataUnit.name : this.configName}`;
512
+ }
472
513
  setGridConfig(config) {
473
514
  this.gridConfig = config;
474
515
  CrudUtils.assertDefaultSorting(this.gridConfig, this.dataUnit);
@@ -484,6 +525,15 @@ export class SnkSimpleCrud {
484
525
  closeFormConfig() {
485
526
  this._showFormConfig = false;
486
527
  }
528
+ getPageSize() {
529
+ if (this.mode === SIMPLE_CRUD_MODE.IN_MEMORY) {
530
+ return 0;
531
+ }
532
+ if (this.pageSize == undefined) {
533
+ return 150;
534
+ }
535
+ return this.pageSize;
536
+ }
487
537
  //No momento não daremos suporte para configuração de formulário quando houver formLegacyConfigName
488
538
  handleShowFormConfig() {
489
539
  return this._showFormConfig && !this.formLegacyConfigName;
@@ -491,15 +541,23 @@ export class SnkSimpleCrud {
491
541
  resolveResourceID() {
492
542
  return StringUtils.isEmpty(this.resourceID) ? this._resourceID : this.resourceID;
493
543
  }
544
+ getFormConfig() {
545
+ var _a, _b;
546
+ const configFromManager = (_a = this._formConfigManager) === null || _a === void 0 ? void 0 : _a.getConfig((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.insertionMode, this.dataUnit, this.ignoreReadOnlyFormFields);
547
+ if (!this.configName && !configFromManager) {
548
+ return this.formConfig;
549
+ }
550
+ return configFromManager;
551
+ }
494
552
  /* istanbul ignore next */
495
553
  render() {
496
- var _a, _b, _c;
554
+ var _a;
497
555
  if (this.dataUnit == undefined) {
498
556
  return;
499
557
  }
500
- return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
558
+ return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
501
559
  ? undefined
502
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: (_b = this._formConfigManager) === null || _b === void 0 ? void 0 : _b.getConfig((_c = this.dataState) === null || _c === void 0 ? void 0 : _c.insertionMode, this.dataUnit, this.ignoreReadOnlyFormFields), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
560
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
503
561
  }
504
562
  static get is() { return "snk-simple-crud"; }
505
563
  static get encapsulation() { return "scoped"; }
@@ -555,6 +613,23 @@ export class SnkSimpleCrud {
555
613
  "text": ""
556
614
  }
557
615
  },
616
+ "entityName": {
617
+ "type": "string",
618
+ "mutable": false,
619
+ "complexType": {
620
+ "original": "string",
621
+ "resolved": "string",
622
+ "references": {}
623
+ },
624
+ "required": false,
625
+ "optional": false,
626
+ "docs": {
627
+ "tags": [],
628
+ "text": "Define o nome da entidade que o componente vai utilizar para fazer as opera\u00E7\u00F5es de CRUD"
629
+ },
630
+ "attribute": "entity-name",
631
+ "reflect": false
632
+ },
558
633
  "mode": {
559
634
  "type": "number",
560
635
  "mutable": false,
@@ -600,7 +675,7 @@ export class SnkSimpleCrud {
600
675
  },
601
676
  "formConfig": {
602
677
  "type": "unknown",
603
- "mutable": false,
678
+ "mutable": true,
604
679
  "complexType": {
605
680
  "original": "IFormConfig",
606
681
  "resolved": "IFormConfig",
@@ -653,6 +728,24 @@ export class SnkSimpleCrud {
653
728
  "reflect": false,
654
729
  "defaultValue": "true"
655
730
  },
731
+ "pageSize": {
732
+ "type": "number",
733
+ "mutable": false,
734
+ "complexType": {
735
+ "original": "number",
736
+ "resolved": "number",
737
+ "references": {}
738
+ },
739
+ "required": false,
740
+ "optional": false,
741
+ "docs": {
742
+ "tags": [],
743
+ "text": "Determina quantas linhas s\u00E3o retornadas por p\u00E1gina."
744
+ },
745
+ "attribute": "page-size",
746
+ "reflect": false,
747
+ "defaultValue": "150"
748
+ },
656
749
  "resourceID": {
657
750
  "type": "string",
658
751
  "mutable": false,
@@ -1088,6 +1181,22 @@ export class SnkSimpleCrud {
1088
1181
  "text": "Usado para fechar o configurator do CRUD",
1089
1182
  "tags": []
1090
1183
  }
1184
+ },
1185
+ "updateConfig": {
1186
+ "complexType": {
1187
+ "signature": "() => Promise<void>",
1188
+ "parameters": [],
1189
+ "references": {
1190
+ "Promise": {
1191
+ "location": "global"
1192
+ }
1193
+ },
1194
+ "return": "Promise<void>"
1195
+ },
1196
+ "docs": {
1197
+ "text": "",
1198
+ "tags": []
1199
+ }
1091
1200
  }
1092
1201
  };
1093
1202
  }
@@ -1096,6 +1205,9 @@ export class SnkSimpleCrud {
1096
1205
  return [{
1097
1206
  "propName": "resourceID",
1098
1207
  "methodName": "handleResourceIDChanged"
1208
+ }, {
1209
+ "propName": "entityName",
1210
+ "methodName": "onChangeEntityName"
1099
1211
  }, {
1100
1212
  "propName": "mode",
1101
1213
  "methodName": "onModeChange"
@@ -47,7 +47,7 @@ export const buildCustomButton = (def, className, dataElementId, action, isEnabl
47
47
  return textButton(def.name, className, dataElementId, text, hint, action, isEnabled);
48
48
  }
49
49
  };
50
- export const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, configName, presentationMode) => {
50
+ export const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, dataExporterStoreKey, presentationMode) => {
51
51
  var _a;
52
52
  const title = getTitle(element);
53
53
  switch (element) {
@@ -90,7 +90,7 @@ export const buildElem = (element, className, dataElementId, getTitle, action, i
90
90
  case TaskbarElement.DIVIDER:
91
91
  return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium", "data-taskbar-divider": true });
92
92
  case TaskbarElement.DATA_EXPORTER:
93
- const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[configName];
93
+ const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[dataExporterStoreKey];
94
94
  return h("snk-data-exporter", { class: className, provider: provider, "data-element-id": dataElementId, "data-taskbar-element": element });
95
95
  case TaskbarElement.ATTACH:
96
96
  return iconButton("anexo", element, className, dataElementId, title, action, isEnabled);
@@ -31,6 +31,8 @@ export class SnkTaskbar {
31
31
  this._customElementsId = undefined;
32
32
  this._slotContainer = undefined;
33
33
  this._hiddenActionsList = [];
34
+ this._lastWidth = undefined;
35
+ this._hasToUpdateOverFlow = false;
34
36
  this.alignRigth = false;
35
37
  this.customSlotId = "TASKBAR_CUSTOM_ELEMENTS";
36
38
  this.customContainerId = undefined;
@@ -56,6 +58,11 @@ export class SnkTaskbar {
56
58
  var _a;
57
59
  (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.forceUpdate();
58
60
  }
61
+ observeLastWidth(newValue, oldValue) {
62
+ if (oldValue === 0 && newValue !== 0) {
63
+ this._hasToUpdateOverFlow = true;
64
+ }
65
+ }
59
66
  // Internal methods
60
67
  elementsFromString(strButtons) {
61
68
  const elements = [];
@@ -149,8 +156,9 @@ export class SnkTaskbar {
149
156
  className += "ez-padding-left--medium";
150
157
  }
151
158
  const taskbarElement = TaskbarElement[def.toString()];
159
+ const dataExporterStoreKey = this._element.dataset.exporterStoreKey || this.configName;
152
160
  if (taskbarElement) {
153
- return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), this.configName, this.presentationMode);
161
+ return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), dataExporterStoreKey, this.presentationMode);
154
162
  }
155
163
  else {
156
164
  return buildCustomButton(def, className, this.getIdElemBtnCustom(def), elem => this.elementClick(elem), elem => this.isEnabled(elem));
@@ -239,10 +247,20 @@ export class SnkTaskbar {
239
247
  this.getCustomElements();
240
248
  }
241
249
  componentWillRender() {
250
+ this.handleDefinitions();
251
+ this.validatePresentationMode();
252
+ this.updateOverFlowIfNeeded();
253
+ }
254
+ handleDefinitions() {
242
255
  if (this._definitions == undefined && this._permissions) {
243
256
  this._definitions = this.elementsFromString(this.buttons);
244
257
  }
245
- this.validatePresentationMode();
258
+ }
259
+ updateOverFlowIfNeeded() {
260
+ if (this._hasToUpdateOverFlow) {
261
+ requestAnimationFrame(() => { var _a; return (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.forceUpdate(); });
262
+ this._hasToUpdateOverFlow = false;
263
+ }
246
264
  }
247
265
  handleOverFlow(overFlowingElements) {
248
266
  const elementsToHandle = overFlowingElements.filter(element => !this.hasToIgnoreOverFlow(element));
@@ -309,6 +327,10 @@ export class SnkTaskbar {
309
327
  }
310
328
  componentDidRender() {
311
329
  this.appendCustomElementsInTaskbar();
330
+ this.updateLastWidth();
331
+ }
332
+ updateLastWidth() {
333
+ this._lastWidth = this._element.getBoundingClientRect().width;
312
334
  }
313
335
  disconnectedCallback() {
314
336
  var _a;
@@ -640,7 +662,9 @@ export class SnkTaskbar {
640
662
  "_customElements": {},
641
663
  "_customElementsId": {},
642
664
  "_slotContainer": {},
643
- "_hiddenActionsList": {}
665
+ "_hiddenActionsList": {},
666
+ "_lastWidth": {},
667
+ "_hasToUpdateOverFlow": {}
644
668
  };
645
669
  }
646
670
  static get events() {
@@ -669,6 +693,9 @@ export class SnkTaskbar {
669
693
  }, {
670
694
  "propName": "disabledButtons",
671
695
  "methodName": "observeDisabledButtons"
696
+ }, {
697
+ "propName": "_lastWidth",
698
+ "methodName": "observeLastWidth"
672
699
  }];
673
700
  }
674
701
  }
@@ -1,6 +1,5 @@
1
1
  import { ChangeOperation, DataType, DataUnit, DateUtils, StringUtils, } from '@sankhyalabs/core';
2
- import { ColumnFilterManager } from "@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";
3
- import PreloadManager from '../http/data-fetcher/fetchers/data-unit/cache/PreloadManager';
2
+ import { applyFilter, applySorting, buildPaginationInfo } from './dataUnitInMemoryUtils';
4
3
  export default class InMemoryLoader {
5
4
  constructor(metadata, records) {
6
5
  this.metadata = metadata;
@@ -13,9 +12,13 @@ export default class InMemoryLoader {
13
12
  this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
14
13
  }
15
14
  getRecordsToLoad() {
16
- if (this._initialRecords == undefined || this.dataUnit.records.length > 0) {
15
+ if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
17
16
  this._initialRecords = this.dataUnit.records;
18
17
  }
18
+ const addedRecords = this.dataUnit.getAddedRecords();
19
+ if (addedRecords) {
20
+ return [...this._initialRecords, ...addedRecords];
21
+ }
19
22
  return this._initialRecords;
20
23
  }
21
24
  get dataUnit() {
@@ -58,7 +61,7 @@ export default class InMemoryLoader {
58
61
  this._initialRecords = newRecords;
59
62
  if (this._dataUnit) {
60
63
  //Isso força o refresh internamente no datunit
61
- this._dataUnit.gotoPage(0);
64
+ this._dataUnit.loadData();
62
65
  }
63
66
  }
64
67
  get metadata() {
@@ -74,30 +77,9 @@ export default class InMemoryLoader {
74
77
  return StringUtils.generateUUID();
75
78
  }
76
79
  inMemoryLoader(dataUnit, request, recordsIn) {
77
- let records = this.applyFilter(recordsIn, dataUnit, request.filters);
78
- records = this.applySorting(records, dataUnit, request.sort);
79
- return Promise.resolve({ records, paginationInfo: buildPaginationInfo(request, records) });
80
- }
81
- applyFilter(records, dataUnit, filters) {
82
- const columnFilters = ColumnFilterManager.getColumnFilters(filters, "");
83
- if (columnFilters == undefined || columnFilters.size == 0) {
84
- return records;
85
- }
86
- const filterFunciton = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
87
- if (filterFunciton == undefined) {
88
- return records;
89
- }
90
- return records.filter(filterFunciton);
91
- }
92
- applySorting(records, dataUnit, sorting) {
93
- if (sorting == undefined || sorting.length == 0) {
94
- return records;
95
- }
96
- const sortingFunction = PreloadManager.getSortingFunction(dataUnit, sorting);
97
- if (sortingFunction == undefined) {
98
- return records;
99
- }
100
- return records.sort(sortingFunction);
80
+ let records = applyFilter(recordsIn, dataUnit, request.filters);
81
+ records = applySorting(records, dataUnit, request.sort);
82
+ return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
101
83
  }
102
84
  metadaLoader() {
103
85
  return Promise.resolve(this._metadata);
@@ -130,16 +112,3 @@ export default class InMemoryLoader {
130
112
  }
131
113
  }
132
114
  InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
133
- function buildPaginationInfo({ offset, limit }, records) {
134
- if (offset === undefined || limit === undefined) {
135
- return undefined;
136
- }
137
- const lastRecord = Math.min(offset + limit, records.length);
138
- return {
139
- currentPage: Math.ceil(offset / limit),
140
- firstRecord: offset,
141
- lastRecord: lastRecord,
142
- total: records.length,
143
- hasMore: !!(records.length - lastRecord),
144
- };
145
- }
@@ -0,0 +1,33 @@
1
+ import SortingUtils from '@sankhyalabs/core/dist/utils/SortingUtils';
2
+ import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
3
+ export function applyFilter(records, dataUnit, filters) {
4
+ const columnFilters = ColumnFilterManager.getColumnFilters(filters, "");
5
+ if (!(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.size)) {
6
+ return records;
7
+ }
8
+ const filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
9
+ if (filterFunction == undefined) {
10
+ return records;
11
+ }
12
+ return records.filter(filterFunction);
13
+ }
14
+ export function applySorting(records, dataUnit, sorting) {
15
+ if (sorting == undefined || sorting.length == 0) {
16
+ return records;
17
+ }
18
+ const sortingFunction = SortingUtils.getSortingFunction(dataUnit, sorting);
19
+ if (sortingFunction == undefined) {
20
+ return records;
21
+ }
22
+ return records.sort(sortingFunction);
23
+ }
24
+ export function buildPaginationInfo(records, offset = 0, limit = 0) {
25
+ const lastRecord = Math.min(offset + limit, records === null || records === void 0 ? void 0 : records.length);
26
+ return {
27
+ currentPage: limit === 0 ? 0 : Math.ceil(offset / limit),
28
+ firstRecord: offset,
29
+ lastRecord: lastRecord,
30
+ total: records === null || records === void 0 ? void 0 : records.length,
31
+ hasMore: !!((records === null || records === void 0 ? void 0 : records.length) - lastRecord),
32
+ };
33
+ }
@@ -21,6 +21,9 @@ export default class DataUnitDataLoader {
21
21
  });
22
22
  });
23
23
  }
24
+ static getCachedRecords(dataUnit) {
25
+ return PreloadManager.getCachedRecords(dataUnit);
26
+ }
24
27
  static async loadFromServer(dataUnit, request, loadingInfo) {
25
28
  try {
26
29
  //Registramos a request com as informações de carga para determinarmos a última.
@@ -1,3 +1,4 @@
1
+ import { ObjectUtils } from "@sankhyalabs/core";
1
2
  export class ArrayRepository {
2
3
  constructor(equalsFunction) {
3
4
  this._list = [];
@@ -77,4 +78,7 @@ export class ArrayRepository {
77
78
  async count() {
78
79
  return Promise.resolve(this._list.length);
79
80
  }
81
+ getFromCache() {
82
+ return ObjectUtils.copy(this._list);
83
+ }
80
84
  }
@@ -1,6 +1,7 @@
1
1
  import { DataUnit, FieldComparator, SortMode } from "@sankhyalabs/core";
2
2
  import { ArrayRepository } from "./ArrayRepository";
3
3
  import { ColumnFilterManager } from "@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";
4
+ import SortingUtils from "@sankhyalabs/core/dist/utils/SortingUtils";
4
5
  export default class PreloadManager {
5
6
  static setLoadingStatus(dataUnit, loadingInProgress) {
6
7
  this._loadingStatus.set(dataUnit.name, loadingInProgress);
@@ -67,7 +68,11 @@ export default class PreloadManager {
67
68
  static async loadData(dataUnit, request, loadFromServer) {
68
69
  try {
69
70
  if (PreloadManager.isCacheEnabled(dataUnit)) {
70
- let useCache = request.source === "EZ_GRID_LOADING_SOURCE" || request.source === DataUnit.CHANGING_PAGE_LOADING_SOURCE;
71
+ const useCache = [
72
+ "EZ_GRID_LOADING_SOURCE",
73
+ DataUnit.CHANGING_PAGE_LOADING_SOURCE,
74
+ DataUnit.ALL_RECORDS_SELECTION_SOURCE
75
+ ].includes(request.source);
71
76
  if (useCache) {
72
77
  const isCacheEmpty = await PreloadManager.getRepository(dataUnit).isEmpty();
73
78
  if (!isCacheEmpty) {
@@ -117,7 +122,7 @@ export default class PreloadManager {
117
122
  const columnFilters = ColumnFilterManager.getColumnFilters(request.filters, "");
118
123
  const { limit, offset, sort } = request;
119
124
  PreloadManager.getRepository(dataUnit)
120
- .load(ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values())), PreloadManager.getSortingFunction(dataUnit, sort), offset, limit)
125
+ .load(ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values())), SortingUtils.getSortingFunction(dataUnit, sort), offset, limit)
121
126
  .then(loadResult => {
122
127
  const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
123
128
  const { count, result: records } = loadResult;
@@ -134,6 +139,9 @@ export default class PreloadManager {
134
139
  .catch(reason => reject(reason));
135
140
  });
136
141
  }
142
+ static getCachedRecords(dataUnit) {
143
+ return PreloadManager.getRepository(dataUnit).getFromCache();
144
+ }
137
145
  }
138
146
  PreloadManager._repositories = new Map();
139
147
  PreloadManager._loadingStatus = new Map();
@@ -111,6 +111,7 @@ export default class DataUnitFetcher {
111
111
  dataUnit.saveLoader = (_dataUnit, changes) => this.saveData(dataUnit, changes);
112
112
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
113
113
  dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
114
+ dataUnit.allRecordsLoader = (dataUnit) => DataUnitDataLoader.getCachedRecords(dataUnit);
114
115
  return dataUnit;
115
116
  }
116
117
  loadMetadata(dataUnit) {
@@ -1,4 +1,8 @@
1
1
  export const snkSimpleCrudMessages = {
2
2
  findColumn: "Busca de colunas",
3
+ formConfigUnavaliable: {
4
+ title: "Aviso",
5
+ message: 'A opção "Configurar formulário" será disponibilizada em breve. Enquanto isso, acesse a configuração do fomulário através dos layouts anteriores, HTML5 ou Flex.'
6
+ }
3
7
  };
4
8
  export default snkSimpleCrudMessages;
@@ -1,7 +1,6 @@
1
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher.js';
1
+ import { R as ResourceFetcher, d as dist, D as DataFetcher, F as FormConfigFetcher } from './form-config-fetcher.js';
2
2
  import { F as FilterItemType } from './filter-item-type.enum.js';
3
3
  import { ObjectUtils } from '@sankhyalabs/core';
4
- import { d as dist, D as DataFetcher } from './DataFetcher.js';
5
4
 
6
5
  var __rest = (undefined && undefined.__rest) || function (s, e) {
7
6
  var t = {};