@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-72026.1 → 0.0.0-bugfix-dev-KB-71601.1

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-ecc0ed20.js → ConfigStorage-e49214c6.js} +2 -2
  2. package/dist/cjs/{DataFetcher-cadeef8e.js → DataFetcher-77729a93.js} +20 -21
  3. package/dist/cjs/{IExporterProvider-9ac15aaf.js → IExporterProvider-5d129ffd.js} +4 -4
  4. package/dist/cjs/{GetSelectedRecordsIDsInfo-bd50caf1.js → RecordIDUtils-3735135c.js} +10 -10
  5. package/dist/cjs/{SnkFormConfigManager-f1c92f79.js → SnkFormConfigManager-beebf47a.js} +16 -72
  6. package/dist/cjs/{auth-fetcher-d68841bc.js → auth-fetcher-29bb791c.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-4b12f70c.js → dataunit-fetcher-0c2f5903.js} +37 -16
  8. package/dist/cjs/{form-config-fetcher-ed497282.js → form-config-fetcher-feb08214.js} +2 -5
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-ca89181c.js → pesquisa-fetcher-a1d0353f.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +14 -17
  13. package/dist/cjs/snk-application.cjs.entry.js +6 -6
  14. package/dist/cjs/snk-attach.cjs.entry.js +6 -8
  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-2f2e6f8c.js → snk-data-unit-610fb4bc.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 +4 -15
  23. package/dist/cjs/snk-form.cjs.entry.js +6 -7
  24. package/dist/cjs/snk-grid.cjs.entry.js +8 -8
  25. package/dist/cjs/{snk-guides-viewer-866447ab.js → snk-guides-viewer-d6d543af.js} +7 -10
  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 +1 -23
  30. package/dist/collection/components/snk-actions-button/actions/index.js +9 -12
  31. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
  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 +2 -5
  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/{lib/utils/GetSelectedRecordsIDsInfo.js → components/snk-data-exporter/utils/RecordIDUtils.js} +9 -9
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -2
  38. package/dist/collection/components/snk-form/snk-form.js +2 -2
  39. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +14 -70
  40. package/dist/collection/components/snk-form-config/snk-form-config.js +2 -13
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
  42. package/dist/collection/components/snk-taskbar/snk-taskbar.js +0 -64
  43. package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
  44. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
  45. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +20 -21
  46. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +1 -4
  47. package/dist/components/DataFetcher.js +20 -21
  48. package/dist/components/SnkFormConfigManager.js +14 -70
  49. package/dist/components/dataunit-fetcher.js +36 -13
  50. package/dist/components/form-config-fetcher.js +1 -4
  51. package/dist/components/snk-actions-button2.js +9 -12
  52. package/dist/components/snk-attach2.js +2 -4
  53. package/dist/components/snk-data-unit2.js +42 -5
  54. package/dist/components/snk-detail-view2.js +4 -7
  55. package/dist/components/snk-form-config2.js +2 -13
  56. package/dist/components/snk-form.js +2 -2
  57. package/dist/components/snk-grid2.js +2 -2
  58. package/dist/components/snk-simple-crud2.js +3 -4
  59. package/dist/components/snk-taskbar2.js +2 -24
  60. package/dist/esm/{ConfigStorage-7b36d041.js → ConfigStorage-e476378d.js} +2 -2
  61. package/dist/esm/{DataFetcher-a9c598f2.js → DataFetcher-773a3e4b.js} +20 -21
  62. package/dist/esm/{IExporterProvider-09df2e3e.js → IExporterProvider-24f1d5be.js} +4 -4
  63. package/dist/esm/{GetSelectedRecordsIDsInfo-9fa41508.js → RecordIDUtils-87d02110.js} +10 -10
  64. package/dist/esm/{SnkFormConfigManager-139f09fa.js → SnkFormConfigManager-298cd647.js} +16 -72
  65. package/dist/esm/{auth-fetcher-749d880f.js → auth-fetcher-a411f73c.js} +1 -1
  66. package/dist/esm/{dataunit-fetcher-3aac1a53.js → dataunit-fetcher-3308edba.js} +37 -14
  67. package/dist/esm/{form-config-fetcher-adbe5d34.js → form-config-fetcher-e0382e5a.js} +2 -5
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/{pesquisa-fetcher-8edaa8cd.js → pesquisa-fetcher-a87445a0.js} +1 -1
  70. package/dist/esm/sankhyablocks.js +1 -1
  71. package/dist/esm/snk-actions-button_4.entry.js +14 -17
  72. package/dist/esm/snk-application.entry.js +6 -6
  73. package/dist/esm/snk-attach.entry.js +6 -8
  74. package/dist/esm/snk-crud.entry.js +5 -5
  75. package/dist/esm/snk-data-exporter.entry.js +6 -6
  76. package/dist/esm/{snk-data-unit-acf3dd64.js → snk-data-unit-f4727294.js} +3 -3
  77. package/dist/esm/snk-data-unit.entry.js +4 -4
  78. package/dist/esm/snk-detail-view.entry.js +9 -9
  79. package/dist/esm/snk-filter-bar.entry.js +3 -3
  80. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  81. package/dist/esm/snk-form-config.entry.js +4 -15
  82. package/dist/esm/snk-form.entry.js +6 -7
  83. package/dist/esm/snk-grid.entry.js +8 -8
  84. package/dist/esm/{snk-guides-viewer-cb8a0b48.js → snk-guides-viewer-57cfa507.js} +7 -10
  85. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  86. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  87. package/dist/esm/snk-simple-crud.entry.js +10 -10
  88. package/dist/esm/snk-taskbar.entry.js +1 -23
  89. package/dist/sankhyablocks/p-038f6a70.entry.js +1 -0
  90. package/dist/sankhyablocks/p-0611c5d4.js +1 -0
  91. package/dist/sankhyablocks/{p-ca5ec380.js → p-0cd3c0a9.js} +1 -1
  92. package/dist/sankhyablocks/p-0e7db332.entry.js +1 -0
  93. package/dist/sankhyablocks/{p-06421fdb.js → p-181975f1.js} +2 -2
  94. package/dist/sankhyablocks/{p-1ab19772.js → p-1d13de28.js} +1 -1
  95. package/dist/sankhyablocks/{p-0e9a872d.entry.js → p-1f2f07c2.entry.js} +1 -1
  96. package/dist/sankhyablocks/{p-8862ba4a.entry.js → p-212c54c1.entry.js} +1 -1
  97. package/dist/sankhyablocks/{p-1bf06cd3.js → p-25f1fc39.js} +2 -2
  98. package/dist/sankhyablocks/{p-640140b3.entry.js → p-29016f61.entry.js} +2 -2
  99. package/dist/sankhyablocks/p-2e9c764c.entry.js +1 -0
  100. package/dist/sankhyablocks/{p-4d9549cf.js → p-3287a6cc.js} +1 -1
  101. package/dist/sankhyablocks/p-4c92bf50.entry.js +1 -0
  102. package/dist/sankhyablocks/{p-1f47a0b2.entry.js → p-50d7d40b.entry.js} +1 -1
  103. package/dist/sankhyablocks/{p-f3434fc4.js → p-594bc21d.js} +1 -1
  104. package/dist/sankhyablocks/{p-b2caaaf9.entry.js → p-5b26cc7c.entry.js} +1 -1
  105. package/dist/sankhyablocks/p-5f016aed.js +1 -0
  106. package/dist/sankhyablocks/p-8ad41dcb.entry.js +1 -0
  107. package/dist/sankhyablocks/p-939e15d3.entry.js +1 -0
  108. package/dist/sankhyablocks/p-9863d682.js +1 -0
  109. package/dist/sankhyablocks/{p-212213d9.entry.js → p-9dfda04a.entry.js} +1 -1
  110. package/dist/sankhyablocks/{p-16969508.entry.js → p-a0e0c10f.entry.js} +1 -1
  111. package/dist/sankhyablocks/p-a875c5f2.js +60 -0
  112. package/dist/sankhyablocks/{p-fb34e0cf.entry.js → p-bd008859.entry.js} +1 -1
  113. package/dist/sankhyablocks/{p-a31e761f.js → p-c319fccd.js} +1 -1
  114. package/dist/sankhyablocks/p-cfb72d5e.entry.js +1 -0
  115. package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
  116. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  117. package/dist/types/components/snk-actions-button/actions/index.d.ts +0 -1
  118. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +0 -1
  119. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
  120. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +2 -7
  121. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +0 -11
  122. package/dist/types/components.d.ts +0 -8
  123. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
  124. package/package.json +1 -1
  125. package/dist/components/GetSelectedRecordsIDsInfo.js +0 -41
  126. package/dist/sankhyablocks/p-18ed15f4.entry.js +0 -1
  127. package/dist/sankhyablocks/p-3757394b.entry.js +0 -1
  128. package/dist/sankhyablocks/p-3d542b58.entry.js +0 -1
  129. package/dist/sankhyablocks/p-53c1d25d.entry.js +0 -1
  130. package/dist/sankhyablocks/p-60b29483.entry.js +0 -1
  131. package/dist/sankhyablocks/p-73185e58.entry.js +0 -1
  132. package/dist/sankhyablocks/p-7dd49d15.js +0 -1
  133. package/dist/sankhyablocks/p-8d7e2747.entry.js +0 -1
  134. package/dist/sankhyablocks/p-afbb070d.js +0 -1
  135. package/dist/sankhyablocks/p-bc4b94d2.entry.js +0 -1
  136. package/dist/sankhyablocks/p-ce6eed2c.js +0 -1
  137. package/dist/sankhyablocks/p-f8698ad3.js +0 -60
  138. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +0 -3
@@ -29,7 +29,6 @@ export class SnkTaskbar {
29
29
  this.onSaveEvent = (action) => {
30
30
  switch (action.type) {
31
31
  case DUAction.FIELD_INVALIDATED:
32
- case DUAction.INVALIDATE_CLEAN:
33
32
  case DUAction.DATA_SAVED:
34
33
  case DUAction.SAVING_ERROR:
35
34
  this._isWaitingForSave = false;
@@ -68,16 +67,6 @@ export class SnkTaskbar {
68
67
  this.getCustomElements(true);
69
68
  }
70
69
  }
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
- }
81
70
  hasToSearchCustomElements(event) {
82
71
  return this.customSlotId === event.detail && !this._slotContainer;
83
72
  }
@@ -96,14 +85,6 @@ export class SnkTaskbar {
96
85
  this._hasToUpdateOverFlow = true;
97
86
  }
98
87
  }
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
- }
107
88
  // Internal methods
108
89
  elementsFromString(strButtons) {
109
90
  const elements = [];
@@ -738,36 +719,6 @@ export class SnkTaskbar {
738
719
  "resolved": "string",
739
720
  "references": {}
740
721
  }
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
- }
771
722
  }];
772
723
  }
773
724
  static get elementRef() { return "_element"; }
@@ -781,9 +732,6 @@ export class SnkTaskbar {
781
732
  }, {
782
733
  "propName": "_lastWidth",
783
734
  "methodName": "observeLastWidth"
784
- }, {
785
- "propName": "_isWaitingForSave",
786
- "methodName": "observeIsWaitingForSave"
787
735
  }];
788
736
  }
789
737
  static get listeners() {
@@ -793,18 +741,6 @@ export class SnkTaskbar {
793
741
  "target": "window",
794
742
  "capture": false,
795
743
  "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
808
744
  }];
809
745
  }
810
746
  }
@@ -1,5 +1,5 @@
1
1
  import { ChangeOperation, DataType, DataUnit, DateUtils, StringUtils, } from '@sankhyalabs/core';
2
- import { applyFilter, applySorting, buildPaginationInfo } from './dataUnitInMemoryUtils';
2
+ import { buildLoadDataResponse } from './dataUnitInMemoryUtils';
3
3
  export default class InMemoryLoader {
4
4
  constructor(metadata, records, config) {
5
5
  this.metadata = metadata;
@@ -82,9 +82,7 @@ export default class InMemoryLoader {
82
82
  return StringUtils.generateUUID();
83
83
  }
84
84
  inMemoryLoader(dataUnit, request, recordsIn) {
85
- let records = applyFilter(recordsIn, dataUnit, request.filters);
86
- records = applySorting(records, dataUnit, request.sort);
87
- return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
85
+ return buildLoadDataResponse(recordsIn, dataUnit, request);
88
86
  }
89
87
  metadaLoader() {
90
88
  return Promise.resolve(this._metadata);
@@ -11,6 +11,21 @@ export function applyFilter(records, dataUnit, filters) {
11
11
  }
12
12
  return records.filter(filterFunction);
13
13
  }
14
+ export function buildLoadDataResponse(recordsIn, dataUnit, request) {
15
+ let records = recordsIn ? [...recordsIn] : [];
16
+ records = applyFilter(records, dataUnit, request.filters);
17
+ records = applySorting(records, dataUnit, request.sort);
18
+ const { offset, limit } = request;
19
+ const paginationInfoBuilderParams = {
20
+ recordsLength: records.length,
21
+ offset,
22
+ recordsPerPage: limit,
23
+ };
24
+ return Promise.resolve({
25
+ records: getPagesByRecords(records, offset, limit),
26
+ paginationInfo: buildPaginationInfo(paginationInfoBuilderParams),
27
+ });
28
+ }
14
29
  export function applySorting(records, dataUnit, sorting) {
15
30
  if (sorting == undefined || sorting.length == 0) {
16
31
  return records;
@@ -21,17 +36,27 @@ export function applySorting(records, dataUnit, sorting) {
21
36
  }
22
37
  return records.sort(sortingFunction);
23
38
  }
24
- export function buildPaginationInfo(records, offset = 0, limit = 0) {
25
- if (records === undefined) {
26
- return undefined;
39
+ function hasValidLimitAndOffset(offset, limit) {
40
+ return offset >= 0 && limit >= 0;
41
+ }
42
+ export function getPagesByRecords(records, offset = 0, limit = 0) {
43
+ if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
44
+ return [];
45
+ if (limit === 0 && offset === 0)
46
+ return records;
47
+ return records.slice(offset, offset + limit);
48
+ }
49
+ export function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
50
+ if (!recordsLength) {
51
+ return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
27
52
  }
28
- const total = (records === null || records === void 0 ? void 0 : records.length) || 0;
29
- const lastRecord = Math.min(offset + limit, total);
53
+ const lastRecordIndex = offset + recordsPerPage;
54
+ const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
30
55
  return {
31
- currentPage: limit === 0 ? 0 : Math.ceil(offset / limit),
32
- firstRecord: offset,
56
+ currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
57
+ firstRecord: offset + 1,
33
58
  lastRecord: lastRecord,
34
- total: total,
35
- hasMore: !!(total - lastRecord),
59
+ total: recordsLength,
60
+ hasMore: lastRecord < recordsLength,
36
61
  };
37
62
  }
@@ -352,7 +352,6 @@ export class DataFetcher {
352
352
  }
353
353
  }
354
354
  async executePendingRequest(watingRequestsById) {
355
- var _a, _b;
356
355
  const requestsBatch = [];
357
356
  let quietMode = true;
358
357
  watingRequestsById.forEach((waitingReq) => {
@@ -363,36 +362,36 @@ export class DataFetcher {
363
362
  const response = await this.fecthGraphQL(requestsBatch, quietMode);
364
363
  const { data: dataResponse, errors: errorsResponse, extensions } = response;
365
364
  //Reject promises with errors from query
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);
365
+ errorsResponse.forEach((errorResponse) => {
366
+ Object.entries(errorResponse).forEach(async ([key, val]) => {
367
+ const waitingRequest = watingRequestsById.get(val.request.variables[val.index].queryID);
370
368
  const hasClientEvent = await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
371
- const data = await Promise.race([
369
+ Promise.race([
372
370
  waitingRequest.promise,
373
371
  new Promise((resolve) => {
374
372
  resolve(false);
375
373
  })
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));
380
- }
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));
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
+ }
383
383
  }
384
- }
385
- }
386
- }
384
+ });
385
+ });
386
+ });
387
387
  //Resolve promises with data from query
388
- for (const data of dataResponse) {
389
- const entries = Object.entries(data);
390
- for (const [key, val] of entries) {
388
+ dataResponse.forEach((data) => {
389
+ Object.entries(data).forEach(async ([key, val]) => {
391
390
  const waitingRequest = watingRequestsById.get(key);
392
391
  await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
393
392
  ((waitingRequest === null || waitingRequest === void 0 ? void 0 : waitingRequest.resolve) || Promise.resolve)(val);
394
- }
395
- }
393
+ });
394
+ });
396
395
  }
397
396
  buildGraphQlURL(quietMode) {
398
397
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -155,10 +155,7 @@ export class FormConfigFetcher extends ResourceFetcher {
155
155
  query: this.queryConfig.get("fetchDefaultConfig"),
156
156
  })
157
157
  .then((result) => {
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));
158
+ resolve(ObjectUtils.stringToObject((result === null || result === void 0 ? void 0 : result.resource) || ''));
162
159
  })
163
160
  .catch((error) => {
164
161
  reject(error);
@@ -6863,7 +6863,6 @@ class DataFetcher {
6863
6863
  }
6864
6864
  }
6865
6865
  async executePendingRequest(watingRequestsById) {
6866
- var _a, _b;
6867
6866
  const requestsBatch = [];
6868
6867
  let quietMode = true;
6869
6868
  watingRequestsById.forEach((waitingReq) => {
@@ -6874,36 +6873,36 @@ class DataFetcher {
6874
6873
  const response = await this.fecthGraphQL(requestsBatch, quietMode);
6875
6874
  const { data: dataResponse, errors: errorsResponse, extensions } = response;
6876
6875
  //Reject promises with errors from query
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);
6876
+ errorsResponse.forEach((errorResponse) => {
6877
+ Object.entries(errorResponse).forEach(async ([key, val]) => {
6878
+ const waitingRequest = watingRequestsById.get(val.request.variables[val.index].queryID);
6881
6879
  const hasClientEvent = await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
6882
- const data = await Promise.race([
6880
+ Promise.race([
6883
6881
  waitingRequest.promise,
6884
6882
  new Promise((resolve) => {
6885
6883
  resolve(false);
6886
6884
  })
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));
6891
- }
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));
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
+ }
6894
6894
  }
6895
- }
6896
- }
6897
- }
6895
+ });
6896
+ });
6897
+ });
6898
6898
  //Resolve promises with data from query
6899
- for (const data of dataResponse) {
6900
- const entries = Object.entries(data);
6901
- for (const [key, val] of entries) {
6899
+ dataResponse.forEach((data) => {
6900
+ Object.entries(data).forEach(async ([key, val]) => {
6902
6901
  const waitingRequest = watingRequestsById.get(key);
6903
6902
  await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
6904
6903
  ((waitingRequest === null || waitingRequest === void 0 ? void 0 : waitingRequest.resolve) || Promise.resolve)(val);
6905
- }
6906
- }
6904
+ });
6905
+ });
6907
6906
  }
6908
6907
  buildGraphQlURL(quietMode) {
6909
6908
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -1,14 +1,12 @@
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';
5
4
 
6
5
  class SnkFormConfigManager {
7
- constructor(configName, resourceID, onConfigChange, dataUnit) {
6
+ constructor(configName, resourceID, onConfigChange) {
8
7
  this._resourceID = resourceID;
9
8
  this._configName = configName;
10
9
  this._onConfigChange = onConfigChange;
11
- this._dataUnit = dataUnit;
12
10
  }
13
11
  addFormLegacyConfig(legacyConfigName) {
14
12
  if (this._configName) {
@@ -19,7 +17,6 @@ class SnkFormConfigManager {
19
17
  return new Promise(resolve => {
20
18
  ConfigStorage.loadFormConfig(this._configName, this._resourceID)
21
19
  .then((config) => {
22
- config = this.buildFormMetadataUITabs(config);
23
20
  this.setConfig(config);
24
21
  resolve(config);
25
22
  })
@@ -28,10 +25,6 @@ class SnkFormConfigManager {
28
25
  });
29
26
  });
30
27
  }
31
- getEmptyConfig() {
32
- const config = this.buildFormMetadataUITabs({ fields: [], emptyConfig: true }, true);
33
- return config;
34
- }
35
28
  saveConfig(config) {
36
29
  const configToSave = ObjectUtils.copy(config);
37
30
  return new Promise(accept => {
@@ -75,36 +68,25 @@ class SnkFormConfigManager {
75
68
  }
76
69
  return updatingCardConfig;
77
70
  }
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) {
71
+ getFieldsList(dataUnit, descriptionFilter) {
87
72
  var _a;
88
73
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
89
- const hasConfig = this.hasConfig();
90
- if (hasConfig && !forceEmptyConfig) {
91
- return fields.map(({ label, name, readOnly, visible, required, tab }) => {
92
- var _a;
74
+ if (fields != undefined && fields.length > 0) {
75
+ return fields.map(({ label, name, readOnly, visible, required }) => {
93
76
  if (label == undefined) {
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 });
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 });
96
79
  }
97
- return { name, label, readOnly, visible, required, tab };
80
+ return { name, label, readOnly, visible, required };
98
81
  })
99
82
  .filter(field => this.isFieldVisible(field, descriptionFilter));
100
83
  }
101
- if (!this._dataUnit) {
102
- return [];
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 }; });
103
88
  }
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;
89
+ return [];
108
90
  }
109
91
  isFieldVisible(field, descriptionFilter) {
110
92
  if (field.visible === false) {
@@ -117,8 +99,8 @@ class SnkFormConfigManager {
117
99
  const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
118
100
  return normalizedText.includes(normalizedFilter);
119
101
  }
120
- getFormConfig(dataUnit, ignoreReadOnlyFormFields, forceEmptyConfig = false) {
121
- let fields = this.getFieldsList(undefined, forceEmptyConfig);
102
+ getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
103
+ let fields = this.getFieldsList(dataUnit);
122
104
  if (ignoreReadOnlyFormFields) {
123
105
  fields = fields.filter(field => {
124
106
  if (dataUnit) {
@@ -171,44 +153,6 @@ class SnkFormConfigManager {
171
153
  async fetchDefaultConfig() {
172
154
  return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
173
155
  }
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
- }
212
156
  }
213
157
 
214
158
  export { SnkFormConfigManager as S };
@@ -235,6 +235,21 @@ function applyFilter(records, dataUnit, filters) {
235
235
  }
236
236
  return records.filter(filterFunction);
237
237
  }
238
+ function buildLoadDataResponse(recordsIn, dataUnit, request) {
239
+ let records = recordsIn ? [...recordsIn] : [];
240
+ records = applyFilter(records, dataUnit, request.filters);
241
+ records = applySorting(records, dataUnit, request.sort);
242
+ const { offset, limit } = request;
243
+ const paginationInfoBuilderParams = {
244
+ recordsLength: records.length,
245
+ offset,
246
+ recordsPerPage: limit,
247
+ };
248
+ return Promise.resolve({
249
+ records: getPagesByRecords(records, offset, limit),
250
+ paginationInfo: buildPaginationInfo(paginationInfoBuilderParams),
251
+ });
252
+ }
238
253
  function applySorting(records, dataUnit, sorting) {
239
254
  if (sorting == undefined || sorting.length == 0) {
240
255
  return records;
@@ -245,18 +260,28 @@ function applySorting(records, dataUnit, sorting) {
245
260
  }
246
261
  return records.sort(sortingFunction);
247
262
  }
248
- function buildPaginationInfo(records, offset = 0, limit = 0) {
249
- if (records === undefined) {
250
- return undefined;
263
+ function hasValidLimitAndOffset(offset, limit) {
264
+ return offset >= 0 && limit >= 0;
265
+ }
266
+ function getPagesByRecords(records, offset = 0, limit = 0) {
267
+ if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
268
+ return [];
269
+ if (limit === 0 && offset === 0)
270
+ return records;
271
+ return records.slice(offset, offset + limit);
272
+ }
273
+ function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
274
+ if (!recordsLength) {
275
+ return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
251
276
  }
252
- const total = (records === null || records === void 0 ? void 0 : records.length) || 0;
253
- const lastRecord = Math.min(offset + limit, total);
277
+ const lastRecordIndex = offset + recordsPerPage;
278
+ const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
254
279
  return {
255
- currentPage: limit === 0 ? 0 : Math.ceil(offset / limit),
256
- firstRecord: offset,
280
+ currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
281
+ firstRecord: offset + 1,
257
282
  lastRecord: lastRecord,
258
- total: total,
259
- hasMore: !!(total - lastRecord),
283
+ total: recordsLength,
284
+ hasMore: lastRecord < recordsLength,
260
285
  };
261
286
  }
262
287
 
@@ -342,9 +367,7 @@ class InMemoryLoader {
342
367
  return StringUtils.generateUUID();
343
368
  }
344
369
  inMemoryLoader(dataUnit, request, recordsIn) {
345
- let records = applyFilter(recordsIn, dataUnit, request.filters);
346
- records = applySorting(records, dataUnit, request.sort);
347
- return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
370
+ return buildLoadDataResponse(recordsIn, dataUnit, request);
348
371
  }
349
372
  metadaLoader() {
350
373
  return Promise.resolve(this._metadata);
@@ -1052,4 +1075,4 @@ class DataUnitFetcher {
1052
1075
  }
1053
1076
  }
1054
1077
 
1055
- export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, applyFilter as a, applySorting as b, buildPaginationInfo as c, DatasetStrategy as d, getRecordValue as g };
1078
+ export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a, buildLoadDataResponse as b, getRecordValue as g };
@@ -217,10 +217,7 @@ class FormConfigFetcher extends ResourceFetcher {
217
217
  query: this.queryConfig.get("fetchDefaultConfig"),
218
218
  })
219
219
  .then((result) => {
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));
220
+ resolve(ObjectUtils.stringToObject((result === null || result === void 0 ? void 0 : result.resource) || ''));
224
221
  })
225
222
  .catch((error) => {
226
223
  reject(error);
@@ -9,7 +9,6 @@ import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
9
9
  import './dataunit-fetcher.js';
10
10
  import './filter-item-type.enum.js';
11
11
  import './form-config-fetcher.js';
12
- import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
13
12
  import { R as ResourceIDUtils } from './ResourceIDUtils.js';
14
13
 
15
14
  const SERVICE_ACTION_EXECUTE_JAVA = 'ActionButtonsSP.executeJava';
@@ -162,6 +161,7 @@ var RefreshType;
162
161
 
163
162
  const MASTER_ROW_PROPERTY = "__MASTER_ROW__";
164
163
  const ENTITY_NAME_PROPERTY = '__ENTITY_NAME__';
164
+ const NUFIN_COLUMN = 'NUFIN';
165
165
  const SERVICE_GET_CONFIGURATIONS = 'SystemUtilsSP.getConf';
166
166
  class Actions {
167
167
  constructor(actionsExecuteInterface, dataUnit, appResourceId) {
@@ -173,10 +173,6 @@ class Actions {
173
173
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
174
174
  this._appResourceId = appResourceId;
175
175
  }
176
- getPrimaryKeys() {
177
- const ids = getSelectedRecordsIDsInfo(this._dataUnit);
178
- return ids.map(({ name }) => name);
179
- }
180
176
  apply(action, hasParamsToSave) {
181
177
  this._application.closePopUp();
182
178
  this._actionsExecuteInterface.execute(action, this._dataUnit)
@@ -445,7 +441,6 @@ class Actions {
445
441
  executeAction(execSource);
446
442
  }
447
443
  addRows(execSource) {
448
- const primaryKeys = this.getPrimaryKeys();
449
444
  const rows = {
450
445
  row: []
451
446
  };
@@ -459,13 +454,15 @@ class Actions {
459
454
  delete sourceRow[MASTER_ROW_PROPERTY];
460
455
  delete sourceRow[ENTITY_NAME_PROPERTY];
461
456
  }
462
- if (!row.field) {
463
- row.field = [];
464
- }
465
- for (const primaryKey of primaryKeys) {
457
+ for (const fieldName in sourceRow) {
458
+ if (fieldName !== NUFIN_COLUMN)
459
+ continue;
460
+ if (!row.field) {
461
+ row.field = [];
462
+ }
466
463
  row.field.push({
467
- fieldName: primaryKey,
468
- $: sourceRow[primaryKey]
464
+ fieldName: fieldName,
465
+ $: sourceRow[fieldName]
469
466
  });
470
467
  }
471
468
  rows.row.push(row);
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataU
3
3
  import { D as DataFetcher } from './DataFetcher.js';
4
4
  import './pesquisa-fetcher.js';
5
5
  import { S as SaveErrorsEnum } from './ISave.js';
6
- import { P as PreloadManager, a as applyFilter, b as applySorting, c as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
6
+ import { P as PreloadManager, b as buildLoadDataResponse, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
7
7
  import './filter-item-type.enum.js';
8
8
  import './form-config-fetcher.js';
9
9
  import { V as VIEW_MODE } from './constants.js';
@@ -466,9 +466,7 @@ class AttachFetcherDataUnitFactory {
466
466
  });
467
467
  this._records = records;
468
468
  }
469
- let records = applyFilter(this._records, dataUnit, request.filters);
470
- records = applySorting(records, dataUnit, request.sort);
471
- return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
469
+ return buildLoadDataResponse(this._records, dataUnit, request);
472
470
  }
473
471
  saveLoader(changes, fetcher) {
474
472
  return new Promise((resolve) => {