@sankhyalabs/sankhyablocks 8.16.0-dev.20 → 8.16.0-dev.22

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 (118) 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-10b7fed5.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-d4873076.js → dataunit-fetcher-4b12f70c.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-feb08214.js → form-config-fetcher-ed497282.js} +5 -2
  9. package/dist/cjs/{pesquisa-fetcher-a1d0353f.js → pesquisa-fetcher-ca89181c.js} +1 -1
  10. package/dist/cjs/snk-actions-button_4.cjs.entry.js +17 -14
  11. package/dist/cjs/snk-application.cjs.entry.js +6 -6
  12. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  13. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  14. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  15. package/dist/cjs/{snk-data-unit-11e31d8d.js → snk-data-unit-2f2e6f8c.js} +3 -3
  16. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  17. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -8
  18. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -3
  19. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-form-config.cjs.entry.js +15 -4
  21. package/dist/cjs/snk-form.cjs.entry.js +7 -6
  22. package/dist/cjs/snk-grid.cjs.entry.js +8 -8
  23. package/dist/cjs/{snk-guides-viewer-aafc3073.js → snk-guides-viewer-866447ab.js} +10 -7
  24. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  25. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  26. package/dist/cjs/snk-simple-crud.cjs.entry.js +10 -10
  27. package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
  28. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
  29. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +5 -2
  30. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
  31. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
  32. package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -2
  33. package/dist/collection/components/snk-form/snk-form.js +2 -2
  34. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +70 -14
  35. package/dist/collection/components/snk-form-config/snk-form-config.js +13 -2
  36. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
  37. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +21 -20
  38. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +4 -1
  39. package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
  40. package/dist/components/DataFetcher.js +21 -20
  41. package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
  42. package/dist/components/SnkFormConfigManager.js +70 -14
  43. package/dist/components/form-config-fetcher.js +4 -1
  44. package/dist/components/snk-actions-button2.js +12 -9
  45. package/dist/components/snk-data-unit2.js +4 -41
  46. package/dist/components/snk-detail-view2.js +6 -3
  47. package/dist/components/snk-form-config2.js +13 -2
  48. package/dist/components/snk-form.js +2 -2
  49. package/dist/components/snk-grid2.js +2 -2
  50. package/dist/components/snk-simple-crud2.js +4 -3
  51. package/dist/esm/{ConfigStorage-e476378d.js → ConfigStorage-7b36d041.js} +2 -2
  52. package/dist/esm/{DataFetcher-773a3e4b.js → DataFetcher-a9c598f2.js} +21 -20
  53. package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
  54. package/dist/esm/{IExporterProvider-d597f27d.js → IExporterProvider-09df2e3e.js} +4 -4
  55. package/dist/esm/{SnkFormConfigManager-298cd647.js → SnkFormConfigManager-139f09fa.js} +72 -16
  56. package/dist/esm/{auth-fetcher-a411f73c.js → auth-fetcher-749d880f.js} +1 -1
  57. package/dist/esm/{dataunit-fetcher-3d2ec959.js → dataunit-fetcher-3aac1a53.js} +1 -1
  58. package/dist/esm/{form-config-fetcher-e0382e5a.js → form-config-fetcher-adbe5d34.js} +5 -2
  59. package/dist/esm/{pesquisa-fetcher-a87445a0.js → pesquisa-fetcher-8edaa8cd.js} +1 -1
  60. package/dist/esm/snk-actions-button_4.entry.js +17 -14
  61. package/dist/esm/snk-application.entry.js +6 -6
  62. package/dist/esm/snk-attach.entry.js +5 -5
  63. package/dist/esm/snk-crud.entry.js +5 -5
  64. package/dist/esm/snk-data-exporter.entry.js +6 -6
  65. package/dist/esm/{snk-data-unit-29de836f.js → snk-data-unit-acf3dd64.js} +3 -3
  66. package/dist/esm/snk-data-unit.entry.js +4 -4
  67. package/dist/esm/snk-detail-view.entry.js +8 -8
  68. package/dist/esm/snk-filter-bar.entry.js +3 -3
  69. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  70. package/dist/esm/snk-form-config.entry.js +15 -4
  71. package/dist/esm/snk-form.entry.js +7 -6
  72. package/dist/esm/snk-grid.entry.js +8 -8
  73. package/dist/esm/{snk-guides-viewer-62124f3d.js → snk-guides-viewer-cb8a0b48.js} +10 -7
  74. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  75. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  76. package/dist/esm/snk-simple-crud.entry.js +10 -10
  77. package/dist/sankhyablocks/{p-181975f1.js → p-06421fdb.js} +2 -2
  78. package/dist/sankhyablocks/{p-094eebf6.entry.js → p-0e9a872d.entry.js} +1 -1
  79. package/dist/sankhyablocks/{p-5b9160c6.entry.js → p-16969508.entry.js} +1 -1
  80. package/dist/sankhyablocks/{p-76a65660.js → p-1ab19772.js} +1 -1
  81. package/dist/sankhyablocks/{p-25f1fc39.js → p-1bf06cd3.js} +2 -2
  82. package/dist/sankhyablocks/{p-51999ab5.entry.js → p-1f47a0b2.entry.js} +1 -1
  83. package/dist/sankhyablocks/{p-9dfda04a.entry.js → p-212213d9.entry.js} +1 -1
  84. package/dist/sankhyablocks/{p-12f45f86.entry.js → p-3757394b.entry.js} +1 -1
  85. package/dist/sankhyablocks/p-3d542b58.entry.js +1 -0
  86. package/dist/sankhyablocks/{p-3287a6cc.js → p-4d9549cf.js} +1 -1
  87. package/dist/sankhyablocks/p-53c1d25d.entry.js +1 -0
  88. package/dist/sankhyablocks/p-60b29483.entry.js +1 -0
  89. package/dist/sankhyablocks/{p-162b9a59.entry.js → p-640140b3.entry.js} +2 -2
  90. package/dist/sankhyablocks/p-73185e58.entry.js +1 -0
  91. package/dist/sankhyablocks/p-7dd49d15.js +1 -0
  92. package/dist/sankhyablocks/{p-53949130.entry.js → p-8862ba4a.entry.js} +1 -1
  93. package/dist/sankhyablocks/p-8d7e2747.entry.js +1 -0
  94. package/dist/sankhyablocks/{p-70001ac1.js → p-a31e761f.js} +1 -1
  95. package/dist/sankhyablocks/p-afbb070d.js +1 -0
  96. package/dist/sankhyablocks/{p-5b26cc7c.entry.js → p-b2caaaf9.entry.js} +1 -1
  97. package/dist/sankhyablocks/p-bc4b94d2.entry.js +1 -0
  98. package/dist/sankhyablocks/{p-0cd3c0a9.js → p-ca5ec380.js} +1 -1
  99. package/dist/sankhyablocks/p-ce6eed2c.js +1 -0
  100. package/dist/sankhyablocks/{p-594bc21d.js → p-f3434fc4.js} +1 -1
  101. package/dist/sankhyablocks/{p-091ce761.js → p-f8698ad3.js} +1 -1
  102. package/dist/sankhyablocks/{p-bd008859.entry.js → p-fb34e0cf.entry.js} +1 -1
  103. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  104. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
  105. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +1 -0
  106. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
  107. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
  108. package/package.json +1 -1
  109. package/dist/sankhyablocks/p-08c28ddd.entry.js +0 -1
  110. package/dist/sankhyablocks/p-2e9c764c.entry.js +0 -1
  111. package/dist/sankhyablocks/p-421bec84.entry.js +0 -1
  112. package/dist/sankhyablocks/p-5e384af4.entry.js +0 -1
  113. package/dist/sankhyablocks/p-5f016aed.js +0 -1
  114. package/dist/sankhyablocks/p-8f4e743f.js +0 -1
  115. package/dist/sankhyablocks/p-939e15d3.entry.js +0 -1
  116. package/dist/sankhyablocks/p-9863d682.js +0 -1
  117. package/dist/sankhyablocks/p-d65d98ed.entry.js +0 -1
  118. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -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 };
@@ -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);
@@ -9,6 +9,7 @@ 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';
12
13
  import { R as ResourceIDUtils } from './ResourceIDUtils.js';
13
14
 
14
15
  const SERVICE_ACTION_EXECUTE_JAVA = 'ActionButtonsSP.executeJava';
@@ -161,7 +162,6 @@ var RefreshType;
161
162
 
162
163
  const MASTER_ROW_PROPERTY = "__MASTER_ROW__";
163
164
  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,6 +173,10 @@ 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
+ }
176
180
  apply(action, hasParamsToSave) {
177
181
  this._application.closePopUp();
178
182
  this._actionsExecuteInterface.execute(action, this._dataUnit)
@@ -441,6 +445,7 @@ class Actions {
441
445
  executeAction(execSource);
442
446
  }
443
447
  addRows(execSource) {
448
+ const primaryKeys = this.getPrimaryKeys();
444
449
  const rows = {
445
450
  row: []
446
451
  };
@@ -454,15 +459,13 @@ class Actions {
454
459
  delete sourceRow[MASTER_ROW_PROPERTY];
455
460
  delete sourceRow[ENTITY_NAME_PROPERTY];
456
461
  }
457
- for (const fieldName in sourceRow) {
458
- if (fieldName !== NUFIN_COLUMN)
459
- continue;
460
- if (!row.field) {
461
- row.field = [];
462
- }
462
+ if (!row.field) {
463
+ row.field = [];
464
+ }
465
+ for (const primaryKey of primaryKeys) {
463
466
  row.field.push({
464
- fieldName: fieldName,
465
- $: sourceRow[fieldName]
467
+ fieldName: primaryKey,
468
+ $: sourceRow[primaryKey]
466
469
  });
467
470
  }
468
471
  rows.row.push(row);
@@ -1,47 +1,10 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { JSUtils, DataType, Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
2
+ import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
5
5
  import { g as getRecordValue, d as DatasetStrategy } from './dataunit-fetcher.js';
6
6
  import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
7
-
8
- const getSelectedIDs = (dataUnit) => {
9
- const selectionInfo = dataUnit.getSelectionInfo();
10
- if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
11
- return [];
12
- }
13
- const selectedRecordsIDsInfo = [];
14
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
15
- if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
16
- selectedRecords.forEach(recordId => {
17
- if (!dataUnit.isNewRecord(recordId)) {
18
- /*
19
- Esse if foi necessário para tratar corretamente o ID
20
- do record quando está sendo utilizado no modo standAlone
21
- isso não faz a exportação da grid funcionar no modo standAlone
22
- mas deixa de causar erro nas oprações de CRUD.
23
- */
24
- if (!JSUtils.isBase64(recordId)) {
25
- selectedRecordsIDsInfo.push({
26
- name: "__record__id__",
27
- type: DataType.TEXT,
28
- value: recordId
29
- });
30
- return;
31
- }
32
- const revertBase64ToObject = JSON.parse(window.atob(recordId));
33
- Object.entries(revertBase64ToObject).forEach(([name, value]) => {
34
- const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
35
- if (metadataField == undefined) {
36
- return;
37
- }
38
- selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
39
- });
40
- }
41
- });
42
- }
43
- return selectedRecordsIDsInfo;
44
- };
7
+ import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
45
8
 
46
9
  const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
47
10
  constructor() {
@@ -153,7 +116,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
153
116
  * @returns Retorna a lista de IDs dos registros selecionados.
154
117
  */
155
118
  async getSelectedRecordsIDsInfo() {
156
- return Promise.resolve(getSelectedIDs(this.dataUnit));
119
+ return getSelectedRecordsIDsInfo(this.dataUnit);
157
120
  }
158
121
  /**
159
122
  * Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
@@ -757,4 +720,4 @@ function defineCustomElement() {
757
720
  } });
758
721
  }
759
722
 
760
- export { SnkDataUnit as S, defineCustomElement as d, getSelectedIDs as g };
723
+ export { SnkDataUnit as S, defineCustomElement as d };
@@ -404,11 +404,14 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
404
404
  this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
405
405
  }
406
406
  }
407
+ setMasterFormConfig(config) {
408
+ this.masterFormConfig = config;
409
+ }
407
410
  componentWillLoad() {
408
411
  if (this.resourceID == undefined) {
409
412
  throw new Error("Erro interno: resourceID não informado");
410
413
  }
411
- this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, config => this.masterFormConfig = config);
414
+ this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, this.setMasterFormConfig.bind(this), this.dataUnit);
412
415
  this.addFormLegacyConfigName();
413
416
  this._configManager.loadConfig();
414
417
  }
@@ -436,7 +439,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
436
439
  return this._fieldSearch;
437
440
  }
438
441
  fieldsOptionLoader(argument) {
439
- return Promise.resolve(this._configManager.getFieldsList(this.dataUnit, argument)
442
+ return Promise.resolve(this._configManager.getFieldsList(argument)
440
443
  .map(field => ({ value: field.name, label: field.label })));
441
444
  }
442
445
  onSelectField(option, actionButton) {
@@ -1008,7 +1011,7 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
1008
1011
  }
1009
1012
  componentWillLoad() {
1010
1013
  this._configName = `dynaform.${this.entityName}`;
1011
- this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata());
1014
+ this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata(), this.dataUnit);
1012
1015
  this.formConfigManager.loadConfig();
1013
1016
  if (this.messagesBuilder == undefined) {
1014
1017
  this.messagesBuilder = new SnkMessageBuilder(this.entityName);
@@ -202,6 +202,11 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
202
202
  this.configManager.saveConfig(this.buildConfigToSave())
203
203
  .then(savedConfig => {
204
204
  ApplicationUtils.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"), { iconName: "check" });
205
+ const userOption = this._formConfigOptions
206
+ .find((config) => {
207
+ return config.origin === UserConfigType.USER;
208
+ });
209
+ this.setFormConfig(userOption);
205
210
  this.configChange.emit(savedConfig);
206
211
  });
207
212
  }
@@ -535,9 +540,12 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
535
540
  switch (this._optionFormConfigSelected.origin) {
536
541
  case UserConfigType.DEFAULT:
537
542
  config = await this.configManager.fetchDefaultConfig();
543
+ if (!config) {
544
+ config = this.configManager.getEmptyConfig();
545
+ }
538
546
  break;
539
- case UserConfigType.DEFAULT:
540
- config = await this.configManager.fetchDefaultConfig();
547
+ default:
548
+ config = this.getConfig();
541
549
  break;
542
550
  }
543
551
  if (config != undefined) {
@@ -740,6 +748,9 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
740
748
  if (layoutFormConfig == undefined) {
741
749
  layoutFormConfig = [];
742
750
  }
751
+ if (this._formConfig.defaultConfiguration) {
752
+ return layoutFormConfig;
753
+ }
743
754
  return this._formConfig.tabs.map((tab) => {
744
755
  return layoutFormConfig.find(config => { var _a, _b; return ((_a = tab.label) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = config.tab) === null || _b === void 0 ? void 0 : _b.toLowerCase()); })
745
756
  || { tab: tab.label, groups: [], visible: tab.visible };
@@ -99,7 +99,7 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
99
99
  if (this.resourceID == undefined) {
100
100
  this.resourceID = await ResourceIDUtils.getResourceID();
101
101
  }
102
- this._configManager = new SnkFormConfigManager(this.configName, this.resourceID);
102
+ this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, undefined, this._dataUnit);
103
103
  this.addFormLegacyConfig();
104
104
  await this._configManager.loadConfig();
105
105
  }
@@ -128,7 +128,7 @@ const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
128
128
  if (!this._dataUnit || !this._dataState) {
129
129
  return undefined;
130
130
  }
131
- return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
131
+ return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
132
132
  h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
133
133
  }
134
134
  get _element() { return this; }
@@ -13,7 +13,7 @@ import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
13
13
  import './dataunit-fetcher.js';
14
14
  import './filter-item-type.enum.js';
15
15
  import './form-config-fetcher.js';
16
- import { g as getSelectedIDs } from './snk-data-unit2.js';
16
+ import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
17
17
  import { d as defineCustomElement$i } from './snk-actions-button2.js';
18
18
  import { d as defineCustomElement$h } from './snk-data-exporter2.js';
19
19
  import { d as defineCustomElement$g } from './snk-exporter-email-sender2.js';
@@ -54,7 +54,7 @@ class ServerSideExporterProvider extends CommonsExporter {
54
54
  return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
55
55
  }
56
56
  getSelectedIDs() {
57
- return getSelectedIDs(this.dataUnit);
57
+ return getSelectedRecordsIDsInfo(this.dataUnit);
58
58
  }
59
59
  getOffset() {
60
60
  return this.getExporterOffset(this.getPaginationInfo());
@@ -14,12 +14,13 @@ import './filter-item-type.enum.js';
14
14
  import { F as FormConfigFetcher } from './form-config-fetcher.js';
15
15
  import { C as ConfigStorage } from './ConfigStorage.js';
16
16
  import { S as SnkFormConfigManager } from './SnkFormConfigManager.js';
17
- import { g as getSelectedIDs, d as defineCustomElement$9 } from './snk-data-unit2.js';
17
+ import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
18
18
  import { s as store } from './index2.js';
19
19
  import { d as defineCustomElement$d } from './snk-actions-button2.js';
20
20
  import { d as defineCustomElement$c } from './snk-config-options2.js';
21
21
  import { d as defineCustomElement$b } from './snk-configurator2.js';
22
22
  import { d as defineCustomElement$a } from './snk-data-exporter2.js';
23
+ import { d as defineCustomElement$9 } from './snk-data-unit2.js';
23
24
  import { d as defineCustomElement$8 } from './snk-exporter-email-sender2.js';
24
25
  import { d as defineCustomElement$7 } from './snk-field-config2.js';
25
26
  import { d as defineCustomElement$6 } from './snk-form-config2.js';
@@ -41,7 +42,7 @@ class ClientSideExporterProvider extends CommonsExporter {
41
42
  return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
42
43
  }
43
44
  getSelectedIDs() {
44
- return getSelectedIDs(this.dataUnit);
45
+ return getSelectedRecordsIDsInfo(this.dataUnit);
45
46
  }
46
47
  getRecordID() {
47
48
  var _a, _b, _c;
@@ -360,7 +361,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
360
361
  return;
361
362
  }
362
363
  if (this._formConfigManager == undefined) {
363
- this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
364
+ this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID(), undefined, this.dataUnit);
364
365
  this._formConfigManager.setConfig(this.formConfig);
365
366
  }
366
367
  if (this.formConfigIsLoaded() && !forceLoad) {