@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-71601.0 → 0.0.0-bugfix-dev-KB-72026.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 (138) hide show
  1. package/dist/cjs/{ConfigStorage-e49214c6.js → ConfigStorage-ecc0ed20.js} +2 -2
  2. package/dist/cjs/{DataFetcher-77729a93.js → DataFetcher-cadeef8e.js} +21 -20
  3. package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
  4. package/dist/cjs/{IExporterProvider-a6e2acaa.js → IExporterProvider-9ac15aaf.js} +4 -4
  5. package/dist/cjs/{SnkFormConfigManager-beebf47a.js → SnkFormConfigManager-f1c92f79.js} +72 -16
  6. package/dist/cjs/{auth-fetcher-29bb791c.js → auth-fetcher-d68841bc.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-4c0d1485.js → dataunit-fetcher-4b12f70c.js} +12 -26
  8. package/dist/cjs/{form-config-fetcher-feb08214.js → form-config-fetcher-ed497282.js} +5 -2
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-a1d0353f.js → pesquisa-fetcher-ca89181c.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +17 -14
  13. package/dist/cjs/snk-application.cjs.entry.js +6 -6
  14. package/dist/cjs/snk-attach.cjs.entry.js +6 -12
  15. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  17. package/dist/cjs/{snk-data-unit-054841d2.js → snk-data-unit-2f2e6f8c.js} +3 -3
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +9 -9
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -3
  21. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  22. package/dist/cjs/snk-form-config.cjs.entry.js +15 -4
  23. package/dist/cjs/snk-form.cjs.entry.js +7 -6
  24. package/dist/cjs/snk-grid.cjs.entry.js +8 -8
  25. package/dist/cjs/{snk-guides-viewer-58907f8d.js → snk-guides-viewer-866447ab.js} +10 -7
  26. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  27. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  28. package/dist/cjs/snk-simple-crud.cjs.entry.js +10 -10
  29. package/dist/cjs/snk-taskbar.cjs.entry.js +23 -1
  30. package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
  31. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -8
  32. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +2 -2
  33. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +5 -2
  34. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
  35. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
  36. package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -2
  37. package/dist/collection/components/snk-form/snk-form.js +2 -2
  38. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +70 -14
  39. package/dist/collection/components/snk-form-config/snk-form-config.js +13 -2
  40. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
  41. package/dist/collection/components/snk-taskbar/snk-taskbar.js +64 -0
  42. package/dist/collection/lib/dataUnit/InMemoryLoader.js +3 -17
  43. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +9 -9
  44. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +21 -20
  45. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +4 -1
  46. package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
  47. package/dist/components/DataFetcher.js +21 -20
  48. package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
  49. package/dist/components/SnkFormConfigManager.js +70 -14
  50. package/dist/components/dataunit-fetcher.js +11 -25
  51. package/dist/components/form-config-fetcher.js +4 -1
  52. package/dist/components/snk-actions-button2.js +12 -9
  53. package/dist/components/snk-attach2.js +1 -7
  54. package/dist/components/snk-data-unit2.js +4 -41
  55. package/dist/components/snk-detail-view2.js +7 -4
  56. package/dist/components/snk-form-config2.js +13 -2
  57. package/dist/components/snk-form.js +2 -2
  58. package/dist/components/snk-grid2.js +2 -2
  59. package/dist/components/snk-simple-crud2.js +4 -3
  60. package/dist/components/snk-taskbar2.js +24 -2
  61. package/dist/esm/{ConfigStorage-e476378d.js → ConfigStorage-7b36d041.js} +2 -2
  62. package/dist/esm/{DataFetcher-773a3e4b.js → DataFetcher-a9c598f2.js} +21 -20
  63. package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
  64. package/dist/esm/{IExporterProvider-66c83d70.js → IExporterProvider-09df2e3e.js} +4 -4
  65. package/dist/esm/{SnkFormConfigManager-298cd647.js → SnkFormConfigManager-139f09fa.js} +72 -16
  66. package/dist/esm/{auth-fetcher-a411f73c.js → auth-fetcher-749d880f.js} +1 -1
  67. package/dist/esm/{dataunit-fetcher-1c1cdd90.js → dataunit-fetcher-3aac1a53.js} +12 -26
  68. package/dist/esm/{form-config-fetcher-e0382e5a.js → form-config-fetcher-adbe5d34.js} +5 -2
  69. package/dist/esm/loader.js +1 -1
  70. package/dist/esm/{pesquisa-fetcher-a87445a0.js → pesquisa-fetcher-8edaa8cd.js} +1 -1
  71. package/dist/esm/sankhyablocks.js +1 -1
  72. package/dist/esm/snk-actions-button_4.entry.js +17 -14
  73. package/dist/esm/snk-application.entry.js +6 -6
  74. package/dist/esm/snk-attach.entry.js +6 -12
  75. package/dist/esm/snk-crud.entry.js +5 -5
  76. package/dist/esm/snk-data-exporter.entry.js +6 -6
  77. package/dist/esm/{snk-data-unit-a0a8b82a.js → snk-data-unit-acf3dd64.js} +3 -3
  78. package/dist/esm/snk-data-unit.entry.js +4 -4
  79. package/dist/esm/snk-detail-view.entry.js +9 -9
  80. package/dist/esm/snk-filter-bar.entry.js +3 -3
  81. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  82. package/dist/esm/snk-form-config.entry.js +15 -4
  83. package/dist/esm/snk-form.entry.js +7 -6
  84. package/dist/esm/snk-grid.entry.js +8 -8
  85. package/dist/esm/{snk-guides-viewer-5fe10c89.js → snk-guides-viewer-cb8a0b48.js} +10 -7
  86. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  87. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  88. package/dist/esm/snk-simple-crud.entry.js +10 -10
  89. package/dist/esm/snk-taskbar.entry.js +23 -1
  90. package/dist/sankhyablocks/{p-181975f1.js → p-06421fdb.js} +2 -2
  91. package/dist/sankhyablocks/{p-b6f1135c.entry.js → p-0e9a872d.entry.js} +1 -1
  92. package/dist/sankhyablocks/{p-7a0d7901.entry.js → p-16969508.entry.js} +1 -1
  93. package/dist/sankhyablocks/p-18ed15f4.entry.js +1 -0
  94. package/dist/sankhyablocks/{p-c0b3a683.js → p-1ab19772.js} +1 -1
  95. package/dist/sankhyablocks/{p-25f1fc39.js → p-1bf06cd3.js} +2 -2
  96. package/dist/sankhyablocks/{p-8c8ad7b9.entry.js → p-1f47a0b2.entry.js} +1 -1
  97. package/dist/sankhyablocks/{p-9dfda04a.entry.js → p-212213d9.entry.js} +1 -1
  98. package/dist/sankhyablocks/p-3757394b.entry.js +1 -0
  99. package/dist/sankhyablocks/p-3d542b58.entry.js +1 -0
  100. package/dist/sankhyablocks/{p-3287a6cc.js → p-4d9549cf.js} +1 -1
  101. package/dist/sankhyablocks/p-53c1d25d.entry.js +1 -0
  102. package/dist/sankhyablocks/p-60b29483.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-9c5e0d8a.entry.js → p-640140b3.entry.js} +2 -2
  104. package/dist/sankhyablocks/p-73185e58.entry.js +1 -0
  105. package/dist/sankhyablocks/p-7dd49d15.js +1 -0
  106. package/dist/sankhyablocks/{p-42bd6a34.entry.js → p-8862ba4a.entry.js} +1 -1
  107. package/dist/sankhyablocks/p-8d7e2747.entry.js +1 -0
  108. package/dist/sankhyablocks/{p-1b64a684.js → p-a31e761f.js} +1 -1
  109. package/dist/sankhyablocks/p-afbb070d.js +1 -0
  110. package/dist/sankhyablocks/{p-5b26cc7c.entry.js → p-b2caaaf9.entry.js} +1 -1
  111. package/dist/sankhyablocks/p-bc4b94d2.entry.js +1 -0
  112. package/dist/sankhyablocks/{p-0cd3c0a9.js → p-ca5ec380.js} +1 -1
  113. package/dist/sankhyablocks/p-ce6eed2c.js +1 -0
  114. package/dist/sankhyablocks/{p-594bc21d.js → p-f3434fc4.js} +1 -1
  115. package/dist/sankhyablocks/p-f8698ad3.js +60 -0
  116. package/dist/sankhyablocks/{p-bd008859.entry.js → p-fb34e0cf.entry.js} +1 -1
  117. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  118. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
  119. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +1 -0
  120. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
  121. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
  122. package/dist/types/components.d.ts +8 -0
  123. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +1 -6
  124. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
  125. package/package.json +1 -1
  126. package/dist/sankhyablocks/p-2e9c764c.entry.js +0 -1
  127. package/dist/sankhyablocks/p-449df4bf.entry.js +0 -1
  128. package/dist/sankhyablocks/p-5f016aed.js +0 -1
  129. package/dist/sankhyablocks/p-67525bf6.entry.js +0 -1
  130. package/dist/sankhyablocks/p-812e5d2e.entry.js +0 -1
  131. package/dist/sankhyablocks/p-939e15d3.entry.js +0 -1
  132. package/dist/sankhyablocks/p-959fdc87.entry.js +0 -1
  133. package/dist/sankhyablocks/p-9863d682.js +0 -1
  134. package/dist/sankhyablocks/p-a4c04730.js +0 -60
  135. package/dist/sankhyablocks/p-e6ab759c.js +0 -1
  136. package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
  137. package/dist/sankhyablocks/p-fb5798b4.entry.js +0 -1
  138. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -29,6 +29,7 @@ export class SnkTaskbar {
29
29
  this.onSaveEvent = (action) => {
30
30
  switch (action.type) {
31
31
  case DUAction.FIELD_INVALIDATED:
32
+ case DUAction.INVALIDATE_CLEAN:
32
33
  case DUAction.DATA_SAVED:
33
34
  case DUAction.SAVING_ERROR:
34
35
  this._isWaitingForSave = false;
@@ -67,6 +68,16 @@ export class SnkTaskbar {
67
68
  this.getCustomElements(true);
68
69
  }
69
70
  }
71
+ handleTaskbarSaveLocker() {
72
+ if (this._isWaitingForSave !== true) {
73
+ this._isWaitingForSave = true;
74
+ }
75
+ }
76
+ handleTaskbarSaveUnlocker() {
77
+ if (this._isWaitingForSave === true) {
78
+ this._isWaitingForSave = false;
79
+ }
80
+ }
70
81
  hasToSearchCustomElements(event) {
71
82
  return this.customSlotId === event.detail && !this._slotContainer;
72
83
  }
@@ -85,6 +96,14 @@ export class SnkTaskbar {
85
96
  this._hasToUpdateOverFlow = true;
86
97
  }
87
98
  }
99
+ observeIsWaitingForSave(newValue, oldValue) {
100
+ if (newValue == true && oldValue == false) {
101
+ this.taskbarSaveLocker.emit();
102
+ }
103
+ if (newValue == false && oldValue == true) {
104
+ this.taskbarSaveUnlocker.emit();
105
+ }
106
+ }
88
107
  // Internal methods
89
108
  elementsFromString(strButtons) {
90
109
  const elements = [];
@@ -719,6 +738,36 @@ export class SnkTaskbar {
719
738
  "resolved": "string",
720
739
  "references": {}
721
740
  }
741
+ }, {
742
+ "method": "taskbarSaveLocker",
743
+ "name": "taskbarSaveLocker",
744
+ "bubbles": true,
745
+ "cancelable": true,
746
+ "composed": true,
747
+ "docs": {
748
+ "tags": [],
749
+ "text": "Emitido sempre que um save \u00E9 iniciado pela taskbar."
750
+ },
751
+ "complexType": {
752
+ "original": "void",
753
+ "resolved": "void",
754
+ "references": {}
755
+ }
756
+ }, {
757
+ "method": "taskbarSaveUnlocker",
758
+ "name": "taskbarSaveUnlocker",
759
+ "bubbles": true,
760
+ "cancelable": true,
761
+ "composed": true,
762
+ "docs": {
763
+ "tags": [],
764
+ "text": "Emitido sempre que o ocorre alguma action que libera o save."
765
+ },
766
+ "complexType": {
767
+ "original": "void",
768
+ "resolved": "void",
769
+ "references": {}
770
+ }
722
771
  }];
723
772
  }
724
773
  static get elementRef() { return "_element"; }
@@ -732,6 +781,9 @@ export class SnkTaskbar {
732
781
  }, {
733
782
  "propName": "_lastWidth",
734
783
  "methodName": "observeLastWidth"
784
+ }, {
785
+ "propName": "_isWaitingForSave",
786
+ "methodName": "observeIsWaitingForSave"
735
787
  }];
736
788
  }
737
789
  static get listeners() {
@@ -741,6 +793,18 @@ export class SnkTaskbar {
741
793
  "target": "window",
742
794
  "capture": false,
743
795
  "passive": false
796
+ }, {
797
+ "name": "taskbarSaveLocker",
798
+ "method": "handleTaskbarSaveLocker",
799
+ "target": "window",
800
+ "capture": false,
801
+ "passive": false
802
+ }, {
803
+ "name": "taskbarSaveUnlocker",
804
+ "method": "handleTaskbarSaveUnlocker",
805
+ "target": "window",
806
+ "capture": false,
807
+ "passive": false
744
808
  }];
745
809
  }
746
810
  }
@@ -1,5 +1,5 @@
1
1
  import { ChangeOperation, DataType, DataUnit, DateUtils, StringUtils, } from '@sankhyalabs/core';
2
- import { applyFilter, applySorting, buildPaginationInfo, } from './dataUnitInMemoryUtils';
2
+ import { applyFilter, applySorting, buildPaginationInfo } from './dataUnitInMemoryUtils';
3
3
  export default class InMemoryLoader {
4
4
  constructor(metadata, records, config) {
5
5
  this.metadata = metadata;
@@ -82,23 +82,9 @@ export default class InMemoryLoader {
82
82
  return StringUtils.generateUUID();
83
83
  }
84
84
  inMemoryLoader(dataUnit, request, recordsIn) {
85
- let records = recordsIn ? [...recordsIn] : [];
86
- records = applyFilter(records, dataUnit, request.filters);
85
+ let records = applyFilter(recordsIn, dataUnit, request.filters);
87
86
  records = applySorting(records, dataUnit, request.sort);
88
- const { offset, limit } = request;
89
- let pageRecords = records ? [...records] : [];
90
- if (records && offset >= 0 && limit >= 0) {
91
- pageRecords = records.slice(offset, offset + limit);
92
- }
93
- const paginationInfoBuilderParams = {
94
- recordsLength: records.length,
95
- offset,
96
- recordsPerPage: limit
97
- };
98
- return Promise.resolve({
99
- records: pageRecords,
100
- paginationInfo: buildPaginationInfo(paginationInfoBuilderParams)
101
- });
87
+ return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
102
88
  }
103
89
  metadaLoader() {
104
90
  return Promise.resolve(this._metadata);
@@ -21,17 +21,17 @@ export function applySorting(records, dataUnit, sorting) {
21
21
  }
22
22
  return records.sort(sortingFunction);
23
23
  }
24
- export function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
25
- if (!recordsLength) {
26
- return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
24
+ export function buildPaginationInfo(records, offset = 0, limit = 0) {
25
+ if (records === undefined) {
26
+ return undefined;
27
27
  }
28
- const lastRecordIndex = offset + recordsPerPage;
29
- const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
28
+ const total = (records === null || records === void 0 ? void 0 : records.length) || 0;
29
+ const lastRecord = Math.min(offset + limit, total);
30
30
  return {
31
- currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
32
- firstRecord: offset + 1,
31
+ currentPage: limit === 0 ? 0 : Math.ceil(offset / limit),
32
+ firstRecord: offset,
33
33
  lastRecord: lastRecord,
34
- total: recordsLength,
35
- hasMore: lastRecord < recordsLength,
34
+ total: total,
35
+ hasMore: !!(total - lastRecord),
36
36
  };
37
37
  }
@@ -352,6 +352,7 @@ export class DataFetcher {
352
352
  }
353
353
  }
354
354
  async executePendingRequest(watingRequestsById) {
355
+ var _a, _b;
355
356
  const requestsBatch = [];
356
357
  let quietMode = true;
357
358
  watingRequestsById.forEach((waitingReq) => {
@@ -362,36 +363,36 @@ export class DataFetcher {
362
363
  const response = await this.fecthGraphQL(requestsBatch, quietMode);
363
364
  const { data: dataResponse, errors: errorsResponse, extensions } = response;
364
365
  //Reject promises with errors from query
365
- errorsResponse.forEach((errorResponse) => {
366
- Object.entries(errorResponse).forEach(async ([key, val]) => {
367
- const waitingRequest = watingRequestsById.get(val.request.variables[val.index].queryID);
366
+ for (const errorResponse of errorsResponse) {
367
+ const values = Object.values(errorResponse);
368
+ for (const value of values) {
369
+ const waitingRequest = watingRequestsById.get(value.request.variables[value.index].queryID);
368
370
  const hasClientEvent = await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
369
- Promise.race([
371
+ const data = await Promise.race([
370
372
  waitingRequest.promise,
371
373
  new Promise((resolve) => {
372
374
  resolve(false);
373
375
  })
374
- ]).then((data) => {
375
- var _a, _b;
376
- if (!hasClientEvent || data === false) {
377
- if (Object.keys(errorResponse[0].extensions).includes("SERVICE_CANCELED") || Object.keys(extensions).includes("isServiceCancelled")) {
378
- (((_a = watingRequestsById.get(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ServiceCanceledException("Service canceled", val.message));
379
- }
380
- else {
381
- (((_b = watingRequestsById.get(val.request.variables[val.index].queryID)) === null || _b === void 0 ? void 0 : _b.reject) || Promise.reject)(new ErrorException("Falha detectada", val.message));
382
- }
376
+ ]);
377
+ if (!hasClientEvent || data === false) {
378
+ if (Object.keys(errorResponse[0].extensions).includes("SERVICE_CANCELED") || Object.keys(extensions).includes("isServiceCancelled")) {
379
+ (((_a = watingRequestsById.get(value.request.variables[value.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ServiceCanceledException("Service canceled", value.message));
383
380
  }
384
- });
385
- });
386
- });
381
+ else {
382
+ (((_b = watingRequestsById.get(value.request.variables[value.index].queryID)) === null || _b === void 0 ? void 0 : _b.reject) || Promise.reject)(new ErrorException("Falha detectada", value.message));
383
+ }
384
+ }
385
+ }
386
+ }
387
387
  //Resolve promises with data from query
388
- dataResponse.forEach((data) => {
389
- Object.entries(data).forEach(async ([key, val]) => {
388
+ for (const data of dataResponse) {
389
+ const entries = Object.entries(data);
390
+ for (const [key, val] of entries) {
390
391
  const waitingRequest = watingRequestsById.get(key);
391
392
  await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
392
393
  ((waitingRequest === null || waitingRequest === void 0 ? void 0 : waitingRequest.resolve) || Promise.resolve)(val);
393
- });
394
- });
394
+ }
395
+ }
395
396
  }
396
397
  buildGraphQlURL(quietMode) {
397
398
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -155,7 +155,10 @@ export class FormConfigFetcher extends ResourceFetcher {
155
155
  query: this.queryConfig.get("fetchDefaultConfig"),
156
156
  })
157
157
  .then((result) => {
158
- resolve(ObjectUtils.stringToObject((result === null || result === void 0 ? void 0 : result.resource) || ''));
158
+ if (!(result === null || result === void 0 ? void 0 : result.resource)) {
159
+ resolve(null);
160
+ }
161
+ resolve(ObjectUtils.stringToObject(result === null || result === void 0 ? void 0 : result.resource));
159
162
  })
160
163
  .catch((error) => {
161
164
  reject(error);
@@ -1,29 +1,29 @@
1
1
  import { DataType, JSUtils } from "@sankhyalabs/core";
2
- export const getSelectedIDs = (dataUnit) => {
3
- const selectionInfo = dataUnit.getSelectionInfo();
2
+ export function getSelectedRecordsIDsInfo(dataUnit) {
3
+ const selectionInfo = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo();
4
4
  if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
5
5
  return [];
6
6
  }
7
7
  const selectedRecordsIDsInfo = [];
8
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
8
+ const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
9
9
  if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
10
- selectedRecords.forEach(recordId => {
11
- if (!dataUnit.isNewRecord(recordId)) {
10
+ selectedRecords.forEach(({ __record__id__ }) => {
11
+ if (!dataUnit.isNewRecord(__record__id__)) {
12
12
  /*
13
13
  Esse if foi necessário para tratar corretamente o ID
14
14
  do record quando está sendo utilizado no modo standAlone
15
15
  isso não faz a exportação da grid funcionar no modo standAlone
16
16
  mas deixa de causar erro nas oprações de CRUD.
17
17
  */
18
- if (!JSUtils.isBase64(recordId)) {
18
+ if (!JSUtils.isBase64(__record__id__)) {
19
19
  selectedRecordsIDsInfo.push({
20
20
  name: "__record__id__",
21
21
  type: DataType.TEXT,
22
- value: recordId
22
+ value: __record__id__
23
23
  });
24
24
  return;
25
25
  }
26
- const revertBase64ToObject = JSON.parse(window.atob(recordId));
26
+ const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
27
27
  Object.entries(revertBase64ToObject).forEach(([name, value]) => {
28
28
  const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
29
29
  if (metadataField == undefined) {
@@ -35,4 +35,4 @@ export const getSelectedIDs = (dataUnit) => {
35
35
  });
36
36
  }
37
37
  return selectedRecordsIDsInfo;
38
- };
38
+ }
@@ -6863,6 +6863,7 @@ class DataFetcher {
6863
6863
  }
6864
6864
  }
6865
6865
  async executePendingRequest(watingRequestsById) {
6866
+ var _a, _b;
6866
6867
  const requestsBatch = [];
6867
6868
  let quietMode = true;
6868
6869
  watingRequestsById.forEach((waitingReq) => {
@@ -6873,36 +6874,36 @@ class DataFetcher {
6873
6874
  const response = await this.fecthGraphQL(requestsBatch, quietMode);
6874
6875
  const { data: dataResponse, errors: errorsResponse, extensions } = response;
6875
6876
  //Reject promises with errors from query
6876
- errorsResponse.forEach((errorResponse) => {
6877
- Object.entries(errorResponse).forEach(async ([key, val]) => {
6878
- const waitingRequest = watingRequestsById.get(val.request.variables[val.index].queryID);
6877
+ for (const errorResponse of errorsResponse) {
6878
+ const values = Object.values(errorResponse);
6879
+ for (const value of values) {
6880
+ const waitingRequest = watingRequestsById.get(value.request.variables[value.index].queryID);
6879
6881
  const hasClientEvent = await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
6880
- Promise.race([
6882
+ const data = await Promise.race([
6881
6883
  waitingRequest.promise,
6882
6884
  new Promise((resolve) => {
6883
6885
  resolve(false);
6884
6886
  })
6885
- ]).then((data) => {
6886
- var _a, _b;
6887
- if (!hasClientEvent || data === false) {
6888
- if (Object.keys(errorResponse[0].extensions).includes("SERVICE_CANCELED") || Object.keys(extensions).includes("isServiceCancelled")) {
6889
- (((_a = watingRequestsById.get(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ServiceCanceledException("Service canceled", val.message));
6890
- }
6891
- else {
6892
- (((_b = watingRequestsById.get(val.request.variables[val.index].queryID)) === null || _b === void 0 ? void 0 : _b.reject) || Promise.reject)(new ErrorException("Falha detectada", val.message));
6893
- }
6887
+ ]);
6888
+ if (!hasClientEvent || data === false) {
6889
+ if (Object.keys(errorResponse[0].extensions).includes("SERVICE_CANCELED") || Object.keys(extensions).includes("isServiceCancelled")) {
6890
+ (((_a = watingRequestsById.get(value.request.variables[value.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ServiceCanceledException("Service canceled", value.message));
6894
6891
  }
6895
- });
6896
- });
6897
- });
6892
+ else {
6893
+ (((_b = watingRequestsById.get(value.request.variables[value.index].queryID)) === null || _b === void 0 ? void 0 : _b.reject) || Promise.reject)(new ErrorException("Falha detectada", value.message));
6894
+ }
6895
+ }
6896
+ }
6897
+ }
6898
6898
  //Resolve promises with data from query
6899
- dataResponse.forEach((data) => {
6900
- Object.entries(data).forEach(async ([key, val]) => {
6899
+ for (const data of dataResponse) {
6900
+ const entries = Object.entries(data);
6901
+ for (const [key, val] of entries) {
6901
6902
  const waitingRequest = watingRequestsById.get(key);
6902
6903
  await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
6903
6904
  ((waitingRequest === null || waitingRequest === void 0 ? void 0 : waitingRequest.resolve) || Promise.resolve)(val);
6904
- });
6905
- });
6905
+ }
6906
+ }
6906
6907
  }
6907
6908
  buildGraphQlURL(quietMode) {
6908
6909
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -1,30 +1,30 @@
1
1
  import { JSUtils, DataType } from '@sankhyalabs/core';
2
2
 
3
- const getSelectedIDs = (dataUnit) => {
4
- const selectionInfo = dataUnit.getSelectionInfo();
3
+ function getSelectedRecordsIDsInfo(dataUnit) {
4
+ const selectionInfo = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo();
5
5
  if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
6
6
  return [];
7
7
  }
8
8
  const selectedRecordsIDsInfo = [];
9
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
9
+ const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
10
10
  if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
11
- selectedRecords.forEach(recordId => {
12
- if (!dataUnit.isNewRecord(recordId)) {
11
+ selectedRecords.forEach(({ __record__id__ }) => {
12
+ if (!dataUnit.isNewRecord(__record__id__)) {
13
13
  /*
14
14
  Esse if foi necessário para tratar corretamente o ID
15
15
  do record quando está sendo utilizado no modo standAlone
16
16
  isso não faz a exportação da grid funcionar no modo standAlone
17
17
  mas deixa de causar erro nas oprações de CRUD.
18
18
  */
19
- if (!JSUtils.isBase64(recordId)) {
19
+ if (!JSUtils.isBase64(__record__id__)) {
20
20
  selectedRecordsIDsInfo.push({
21
21
  name: "__record__id__",
22
22
  type: DataType.TEXT,
23
- value: recordId
23
+ value: __record__id__
24
24
  });
25
25
  return;
26
26
  }
27
- const revertBase64ToObject = JSON.parse(window.atob(recordId));
27
+ const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
28
28
  Object.entries(revertBase64ToObject).forEach(([name, value]) => {
29
29
  const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
30
30
  if (metadataField == undefined) {
@@ -36,6 +36,6 @@ const getSelectedIDs = (dataUnit) => {
36
36
  });
37
37
  }
38
38
  return selectedRecordsIDsInfo;
39
- };
39
+ }
40
40
 
41
- export { getSelectedIDs as g };
41
+ export { getSelectedRecordsIDsInfo as g };
@@ -1,12 +1,14 @@
1
1
  import { C as ConfigStorage } from './ConfigStorage.js';
2
2
  import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
3
3
  import { F as FormConfigFetcher } from './form-config-fetcher.js';
4
+ import { c as TAB_NAMES } from './constants.js';
4
5
 
5
6
  class SnkFormConfigManager {
6
- constructor(configName, resourceID, onConfigChange) {
7
+ constructor(configName, resourceID, onConfigChange, dataUnit) {
7
8
  this._resourceID = resourceID;
8
9
  this._configName = configName;
9
10
  this._onConfigChange = onConfigChange;
11
+ this._dataUnit = dataUnit;
10
12
  }
11
13
  addFormLegacyConfig(legacyConfigName) {
12
14
  if (this._configName) {
@@ -17,6 +19,7 @@ class SnkFormConfigManager {
17
19
  return new Promise(resolve => {
18
20
  ConfigStorage.loadFormConfig(this._configName, this._resourceID)
19
21
  .then((config) => {
22
+ config = this.buildFormMetadataUITabs(config);
20
23
  this.setConfig(config);
21
24
  resolve(config);
22
25
  })
@@ -25,6 +28,10 @@ class SnkFormConfigManager {
25
28
  });
26
29
  });
27
30
  }
31
+ getEmptyConfig() {
32
+ const config = this.buildFormMetadataUITabs({ fields: [], emptyConfig: true }, true);
33
+ return config;
34
+ }
28
35
  saveConfig(config) {
29
36
  const configToSave = ObjectUtils.copy(config);
30
37
  return new Promise(accept => {
@@ -68,25 +75,36 @@ class SnkFormConfigManager {
68
75
  }
69
76
  return updatingCardConfig;
70
77
  }
71
- getFieldsList(dataUnit, descriptionFilter) {
78
+ hasConfig(config) {
79
+ var _a;
80
+ const currentConfig = config !== null && config !== void 0 ? config : this._config;
81
+ if (currentConfig && ((_a = currentConfig.fields) === null || _a === void 0 ? void 0 : _a.length)) {
82
+ return true;
83
+ }
84
+ return false;
85
+ }
86
+ getFieldsList(descriptionFilter, forceEmptyConfig = false) {
72
87
  var _a;
73
88
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
74
- if (fields != undefined && fields.length > 0) {
75
- return fields.map(({ label, name, readOnly, visible, required }) => {
89
+ const hasConfig = this.hasConfig();
90
+ if (hasConfig && !forceEmptyConfig) {
91
+ return fields.map(({ label, name, readOnly, visible, required, tab }) => {
92
+ var _a;
76
93
  if (label == undefined) {
77
- const currentField = dataUnit.getField(name);
78
- return Object.assign(Object.assign({}, currentField), { name: name !== null && name !== void 0 ? name : currentField.name, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : currentField.readOnly, visible: visible !== null && visible !== void 0 ? visible : currentField.visible, required: required !== null && required !== void 0 ? required : currentField.required });
94
+ const currentField = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
95
+ return Object.assign(Object.assign({}, currentField), { name: name !== null && name !== void 0 ? name : currentField.name, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : currentField.readOnly, visible: visible !== null && visible !== void 0 ? visible : currentField.visible, required: required !== null && required !== void 0 ? required : currentField.required, tab: tab });
79
96
  }
80
- return { name, label, readOnly, visible, required };
97
+ return { name, label, readOnly, visible, required, tab };
81
98
  })
82
99
  .filter(field => this.isFieldVisible(field, descriptionFilter));
83
100
  }
84
- if (dataUnit != undefined) {
85
- return dataUnit.metadata.fields
86
- .filter(field => this.isFieldVisible(field, descriptionFilter))
87
- .map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
101
+ if (!this._dataUnit) {
102
+ return [];
88
103
  }
89
- return [];
104
+ const filteredFields = this._dataUnit.metadata.fields
105
+ .filter(field => this.isFieldVisible(field, descriptionFilter))
106
+ .map(({ label, name, readOnly, visible, required, properties }) => ({ label, name, readOnly, visible, required, tab: properties === null || properties === void 0 ? void 0 : properties.UITabName }));
107
+ return filteredFields;
90
108
  }
91
109
  isFieldVisible(field, descriptionFilter) {
92
110
  if (field.visible === false) {
@@ -99,8 +117,8 @@ class SnkFormConfigManager {
99
117
  const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
100
118
  return normalizedText.includes(normalizedFilter);
101
119
  }
102
- getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
103
- let fields = this.getFieldsList(dataUnit);
120
+ getFormConfig(dataUnit, ignoreReadOnlyFormFields, forceEmptyConfig = false) {
121
+ let fields = this.getFieldsList(undefined, forceEmptyConfig);
104
122
  if (ignoreReadOnlyFormFields) {
105
123
  fields = fields.filter(field => {
106
124
  if (dataUnit) {
@@ -153,6 +171,44 @@ class SnkFormConfigManager {
153
171
  async fetchDefaultConfig() {
154
172
  return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
155
173
  }
174
+ parseObjectList(object) {
175
+ if (!object) {
176
+ return [];
177
+ }
178
+ return Array.isArray(object) ? object : [object];
179
+ }
180
+ buildFormMetadataUITabs(config, forceEmptyConfig = false) {
181
+ var _a;
182
+ const hasConfig = this.hasConfig(config);
183
+ if (!forceEmptyConfig && (!this._dataUnit || hasConfig)) {
184
+ return config;
185
+ }
186
+ config = this.getFormConfig(this._dataUnit, false, true);
187
+ config.tabs = this.parseObjectList(config.tabs);
188
+ config.emptyConfig = false;
189
+ config.defaultConfiguration = true;
190
+ const fields = this._dataUnit.metadata.fields;
191
+ for (const currentField of fields) {
192
+ const field = config.fields.find(field => field.name === currentField.name);
193
+ const uiTabName = (_a = currentField.properties) === null || _a === void 0 ? void 0 : _a.UITabName;
194
+ if (!uiTabName || uiTabName === TAB_NAMES.main) {
195
+ continue;
196
+ }
197
+ const haveTab = config.tabs.some((tab) => tab.label === uiTabName);
198
+ if (!haveTab) {
199
+ config.tabs.push({
200
+ label: uiTabName,
201
+ name: uiTabName,
202
+ order: 0,
203
+ visible: true,
204
+ });
205
+ }
206
+ if (field) {
207
+ field.tab = uiTabName;
208
+ }
209
+ }
210
+ return config;
211
+ }
156
212
  }
157
213
 
158
214
  export { SnkFormConfigManager as S };
@@ -245,18 +245,18 @@ function applySorting(records, dataUnit, sorting) {
245
245
  }
246
246
  return records.sort(sortingFunction);
247
247
  }
248
- function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
249
- if (!recordsLength) {
250
- return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
248
+ function buildPaginationInfo(records, offset = 0, limit = 0) {
249
+ if (records === undefined) {
250
+ return undefined;
251
251
  }
252
- const lastRecordIndex = offset + recordsPerPage;
253
- const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
252
+ const total = (records === null || records === void 0 ? void 0 : records.length) || 0;
253
+ const lastRecord = Math.min(offset + limit, total);
254
254
  return {
255
- currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
256
- firstRecord: offset + 1,
255
+ currentPage: limit === 0 ? 0 : Math.ceil(offset / limit),
256
+ firstRecord: offset,
257
257
  lastRecord: lastRecord,
258
- total: recordsLength,
259
- hasMore: lastRecord < recordsLength,
258
+ total: total,
259
+ hasMore: !!(total - lastRecord),
260
260
  };
261
261
  }
262
262
 
@@ -342,23 +342,9 @@ class InMemoryLoader {
342
342
  return StringUtils.generateUUID();
343
343
  }
344
344
  inMemoryLoader(dataUnit, request, recordsIn) {
345
- let records = recordsIn ? [...recordsIn] : [];
346
- records = applyFilter(records, dataUnit, request.filters);
345
+ let records = applyFilter(recordsIn, dataUnit, request.filters);
347
346
  records = applySorting(records, dataUnit, request.sort);
348
- const { offset, limit } = request;
349
- let pageRecords = records ? [...records] : [];
350
- if (records && offset >= 0 && limit >= 0) {
351
- pageRecords = records.slice(offset, offset + limit);
352
- }
353
- const paginationInfoBuilderParams = {
354
- recordsLength: records.length,
355
- offset,
356
- recordsPerPage: limit
357
- };
358
- return Promise.resolve({
359
- records: pageRecords,
360
- paginationInfo: buildPaginationInfo(paginationInfoBuilderParams)
361
- });
347
+ return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
362
348
  }
363
349
  metadaLoader() {
364
350
  return Promise.resolve(this._metadata);
@@ -217,7 +217,10 @@ class FormConfigFetcher extends ResourceFetcher {
217
217
  query: this.queryConfig.get("fetchDefaultConfig"),
218
218
  })
219
219
  .then((result) => {
220
- resolve(ObjectUtils.stringToObject((result === null || result === void 0 ? void 0 : result.resource) || ''));
220
+ if (!(result === null || result === void 0 ? void 0 : result.resource)) {
221
+ resolve(null);
222
+ }
223
+ resolve(ObjectUtils.stringToObject(result === null || result === void 0 ? void 0 : result.resource));
221
224
  })
222
225
  .catch((error) => {
223
226
  reject(error);