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

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 (99) 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/{IExporterProvider-10b7fed5.js → IExporterProvider-9ac15aaf.js} +4 -4
  4. package/dist/cjs/{SnkFormConfigManager-beebf47a.js → SnkFormConfigManager-f1c92f79.js} +72 -16
  5. package/dist/cjs/{auth-fetcher-29bb791c.js → auth-fetcher-d68841bc.js} +1 -1
  6. package/dist/cjs/{dataunit-fetcher-d4873076.js → dataunit-fetcher-4b12f70c.js} +1 -1
  7. package/dist/cjs/{form-config-fetcher-feb08214.js → form-config-fetcher-ed497282.js} +5 -2
  8. package/dist/cjs/{pesquisa-fetcher-a1d0353f.js → pesquisa-fetcher-ca89181c.js} +1 -1
  9. package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -5
  10. package/dist/cjs/snk-application.cjs.entry.js +6 -6
  11. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  12. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  13. package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -5
  14. package/dist/cjs/{snk-data-unit-11e31d8d.js → snk-data-unit-c095fb1a.js} +1 -1
  15. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
  16. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -8
  17. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -3
  18. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  19. package/dist/cjs/snk-form-config.cjs.entry.js +15 -4
  20. package/dist/cjs/snk-form.cjs.entry.js +7 -6
  21. package/dist/cjs/snk-grid.cjs.entry.js +6 -6
  22. package/dist/cjs/{snk-guides-viewer-aafc3073.js → snk-guides-viewer-866447ab.js} +10 -7
  23. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
  24. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  25. package/dist/cjs/snk-simple-crud.cjs.entry.js +8 -8
  26. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
  27. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +5 -2
  28. package/dist/collection/components/snk-form/snk-form.js +2 -2
  29. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +70 -14
  30. package/dist/collection/components/snk-form-config/snk-form-config.js +13 -2
  31. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
  32. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +21 -20
  33. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +4 -1
  34. package/dist/components/DataFetcher.js +21 -20
  35. package/dist/components/SnkFormConfigManager.js +70 -14
  36. package/dist/components/form-config-fetcher.js +4 -1
  37. package/dist/components/snk-detail-view2.js +6 -3
  38. package/dist/components/snk-form-config2.js +13 -2
  39. package/dist/components/snk-form.js +2 -2
  40. package/dist/components/snk-simple-crud2.js +1 -1
  41. package/dist/esm/{ConfigStorage-e476378d.js → ConfigStorage-7b36d041.js} +2 -2
  42. package/dist/esm/{DataFetcher-773a3e4b.js → DataFetcher-a9c598f2.js} +21 -20
  43. package/dist/esm/{IExporterProvider-d597f27d.js → IExporterProvider-09df2e3e.js} +4 -4
  44. package/dist/esm/{SnkFormConfigManager-298cd647.js → SnkFormConfigManager-139f09fa.js} +72 -16
  45. package/dist/esm/{auth-fetcher-a411f73c.js → auth-fetcher-749d880f.js} +1 -1
  46. package/dist/esm/{dataunit-fetcher-3d2ec959.js → dataunit-fetcher-3aac1a53.js} +1 -1
  47. package/dist/esm/{form-config-fetcher-e0382e5a.js → form-config-fetcher-adbe5d34.js} +5 -2
  48. package/dist/esm/{pesquisa-fetcher-a87445a0.js → pesquisa-fetcher-8edaa8cd.js} +1 -1
  49. package/dist/esm/snk-actions-button_4.entry.js +5 -5
  50. package/dist/esm/snk-application.entry.js +6 -6
  51. package/dist/esm/snk-attach.entry.js +5 -5
  52. package/dist/esm/snk-crud.entry.js +5 -5
  53. package/dist/esm/snk-data-exporter.entry.js +5 -5
  54. package/dist/esm/{snk-data-unit-29de836f.js → snk-data-unit-75fc8910.js} +1 -1
  55. package/dist/esm/snk-data-unit.entry.js +3 -3
  56. package/dist/esm/snk-detail-view.entry.js +8 -8
  57. package/dist/esm/snk-filter-bar.entry.js +3 -3
  58. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  59. package/dist/esm/snk-form-config.entry.js +15 -4
  60. package/dist/esm/snk-form.entry.js +7 -6
  61. package/dist/esm/snk-grid.entry.js +6 -6
  62. package/dist/esm/{snk-guides-viewer-62124f3d.js → snk-guides-viewer-cb8a0b48.js} +10 -7
  63. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  64. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  65. package/dist/esm/snk-simple-crud.entry.js +8 -8
  66. package/dist/sankhyablocks/{p-181975f1.js → p-06421fdb.js} +2 -2
  67. package/dist/sankhyablocks/{p-5b9160c6.entry.js → p-16969508.entry.js} +1 -1
  68. package/dist/sankhyablocks/p-17aba142.entry.js +1 -0
  69. package/dist/sankhyablocks/{p-76a65660.js → p-1ab19772.js} +1 -1
  70. package/dist/sankhyablocks/{p-25f1fc39.js → p-1bf06cd3.js} +2 -2
  71. package/dist/sankhyablocks/{p-51999ab5.entry.js → p-1f47a0b2.entry.js} +1 -1
  72. package/dist/sankhyablocks/{p-9dfda04a.entry.js → p-212213d9.entry.js} +1 -1
  73. package/dist/sankhyablocks/{p-12f45f86.entry.js → p-3757394b.entry.js} +1 -1
  74. package/dist/sankhyablocks/{p-53949130.entry.js → p-41556e8a.entry.js} +1 -1
  75. package/dist/sankhyablocks/{p-3287a6cc.js → p-4d9549cf.js} +1 -1
  76. package/dist/sankhyablocks/p-60b29483.entry.js +1 -0
  77. package/dist/sankhyablocks/{p-162b9a59.entry.js → p-640140b3.entry.js} +2 -2
  78. package/dist/sankhyablocks/p-73185e58.entry.js +1 -0
  79. package/dist/sankhyablocks/{p-70001ac1.js → p-a31e761f.js} +1 -1
  80. package/dist/sankhyablocks/p-afbb070d.js +1 -0
  81. package/dist/sankhyablocks/{p-5b26cc7c.entry.js → p-b2caaaf9.entry.js} +1 -1
  82. package/dist/sankhyablocks/p-bc4b94d2.entry.js +1 -0
  83. package/dist/sankhyablocks/{p-0cd3c0a9.js → p-ca5ec380.js} +1 -1
  84. package/dist/sankhyablocks/{p-421bec84.entry.js → p-d137ae48.entry.js} +1 -1
  85. package/dist/sankhyablocks/{p-8f4e743f.js → p-df8f4c4f.js} +1 -1
  86. package/dist/sankhyablocks/{p-5e384af4.entry.js → p-e2a1273a.entry.js} +1 -1
  87. package/dist/sankhyablocks/{p-594bc21d.js → p-f3434fc4.js} +1 -1
  88. package/dist/sankhyablocks/{p-091ce761.js → p-f8698ad3.js} +1 -1
  89. package/dist/sankhyablocks/{p-094eebf6.entry.js → p-fb0313db.entry.js} +1 -1
  90. package/dist/sankhyablocks/{p-bd008859.entry.js → p-fb34e0cf.entry.js} +1 -1
  91. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  92. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +1 -0
  93. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
  94. package/package.json +1 -1
  95. package/dist/sankhyablocks/p-08c28ddd.entry.js +0 -1
  96. package/dist/sankhyablocks/p-2e9c764c.entry.js +0 -1
  97. package/dist/sankhyablocks/p-5f016aed.js +0 -1
  98. package/dist/sankhyablocks/p-939e15d3.entry.js +0 -1
  99. package/dist/sankhyablocks/p-d65d98ed.entry.js +0 -1
@@ -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);
@@ -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; }
@@ -360,7 +360,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
360
360
  return;
361
361
  }
362
362
  if (this._formConfigManager == undefined) {
363
- this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
363
+ this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID(), undefined, this.dataUnit);
364
364
  this._formConfigManager.setConfig(this.formConfig);
365
365
  }
366
366
  if (this.formConfigIsLoaded() && !forceLoad) {
@@ -1,7 +1,7 @@
1
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-e0382e5a.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-adbe5d34.js';
2
2
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
3
3
  import { ObjectUtils } from '@sankhyalabs/core';
4
- import { d as dist, D as DataFetcher } from './DataFetcher-773a3e4b.js';
4
+ import { d as dist, D as DataFetcher } from './DataFetcher-a9c598f2.js';
5
5
 
6
6
  class GridConfigFetcher extends ResourceFetcher {
7
7
  constructor() {
@@ -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,13 +1,13 @@
1
- import { D as DataFetcher } from './DataFetcher-773a3e4b.js';
2
- import './pesquisa-fetcher-a87445a0.js';
1
+ import { D as DataFetcher } from './DataFetcher-a9c598f2.js';
2
+ import './pesquisa-fetcher-8edaa8cd.js';
3
3
  import { SortMode, ApplicationContext, UserInterface, DateUtils, ObjectUtils, NumberUtils, DataType } from '@sankhyalabs/core';
4
4
  import './index-3aa4977a.js';
5
5
  import './ISave-d8c8bc59.js';
6
6
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
7
7
  import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
8
- import { P as PreloadManager } from './dataunit-fetcher-3d2ec959.js';
8
+ import { P as PreloadManager } from './dataunit-fetcher-3aac1a53.js';
9
9
  import './filter-item-type.enum-d45e026f.js';
10
- import './form-config-fetcher-e0382e5a.js';
10
+ import './form-config-fetcher-adbe5d34.js';
11
11
  import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
12
12
 
13
13
  class CrudUtils {
@@ -1,12 +1,14 @@
1
- import { C as ConfigStorage } from './ConfigStorage-e476378d.js';
1
+ import { C as ConfigStorage } from './ConfigStorage-7b36d041.js';
2
2
  import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
3
- import { F as FormConfigFetcher } from './form-config-fetcher-e0382e5a.js';
3
+ import { F as FormConfigFetcher } from './form-config-fetcher-adbe5d34.js';
4
+ import { T as TAB_NAMES } from './constants-8457af36.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 };
@@ -1,5 +1,5 @@
1
1
  import { ObjectUtils } from '@sankhyalabs/core';
2
- import { R as ResourceFetcher } from './form-config-fetcher-e0382e5a.js';
2
+ import { R as ResourceFetcher } from './form-config-fetcher-adbe5d34.js';
3
3
 
4
4
  class AuthFetcher extends ResourceFetcher {
5
5
  getData(resourceID) {
@@ -1,5 +1,5 @@
1
1
  import { ObjectUtils, DataUnit, DataType, DateUtils, StringUtils, ChangeOperation, ApplicationContext, UserInterface, DataUnitStorage } from '@sankhyalabs/core';
2
- import { D as DataFetcher, d as dist } from './DataFetcher-773a3e4b.js';
2
+ import { D as DataFetcher, d as dist } from './DataFetcher-a9c598f2.js';
3
3
  import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
4
4
  import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
5
5
  import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
@@ -1,4 +1,4 @@
1
- import { d as dist, D as DataFetcher } from './DataFetcher-773a3e4b.js';
1
+ import { d as dist, D as DataFetcher } from './DataFetcher-a9c598f2.js';
2
2
  import { ObjectUtils } from '@sankhyalabs/core';
3
3
 
4
4
  class ResourceFetcher {
@@ -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);
@@ -1,5 +1,5 @@
1
1
  import { DataType, ApplicationContext } from '@sankhyalabs/core';
2
- import { d as dist, D as DataFetcher } from './DataFetcher-773a3e4b.js';
2
+ import { d as dist, D as DataFetcher } from './DataFetcher-a9c598f2.js';
3
3
 
4
4
  class PesquisaFetcher {
5
5
  constructor() {
@@ -1,19 +1,19 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-a7d3d3f1.js';
2
2
  import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
3
- import { D as DataFetcher } from './DataFetcher-773a3e4b.js';
3
+ import { D as DataFetcher } from './DataFetcher-a9c598f2.js';
4
4
  import { P as ParamType } from './ParamType-d5152b06.js';
5
- import './pesquisa-fetcher-a87445a0.js';
5
+ import './pesquisa-fetcher-8edaa8cd.js';
6
6
  import './index-3aa4977a.js';
7
7
  import './ISave-d8c8bc59.js';
8
8
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
9
9
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
10
- import './dataunit-fetcher-3d2ec959.js';
10
+ import './dataunit-fetcher-3aac1a53.js';
11
11
  import './filter-item-type.enum-d45e026f.js';
12
- import './form-config-fetcher-e0382e5a.js';
12
+ import './form-config-fetcher-adbe5d34.js';
13
13
  import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
14
14
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
15
15
  import { CheckMode } from '@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode';
16
- import { C as ConfigStorage } from './ConfigStorage-e476378d.js';
16
+ import { C as ConfigStorage } from './ConfigStorage-7b36d041.js';
17
17
  import { O as ORDER_VALUES } from './constants-8457af36.js';
18
18
  import './PrintUtils-3e4ff0f5.js';
19
19
  import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
@@ -1,13 +1,13 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a7d3d3f1.js';
2
2
  import { DateUtils, StringUtils, ObjectUtils, WaitingChangeException, WarningException, ErrorException, KeyboardManager, OnboardingUtils, DependencyType, ArrayUtils, SearchUtils, ElementIDUtils, ApplicationContext, DataType, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { C as ConfigStorage } from './ConfigStorage-e476378d.js';
5
- import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-773a3e4b.js';
6
- import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-a411f73c.js';
7
- import { D as DataUnitFetcher } from './dataunit-fetcher-3d2ec959.js';
8
- import { P as PesquisaFetcher } from './pesquisa-fetcher-a87445a0.js';
4
+ import { C as ConfigStorage } from './ConfigStorage-7b36d041.js';
5
+ import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-a9c598f2.js';
6
+ import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-749d880f.js';
7
+ import { D as DataUnitFetcher } from './dataunit-fetcher-3aac1a53.js';
8
+ import { P as PesquisaFetcher } from './pesquisa-fetcher-8edaa8cd.js';
9
9
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-ae87b754.js';
10
- import './form-config-fetcher-e0382e5a.js';
10
+ import './form-config-fetcher-adbe5d34.js';
11
11
  import './filter-item-type.enum-d45e026f.js';
12
12
  import './PrintUtils-3e4ff0f5.js';
13
13
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
@@ -1,14 +1,14 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-a7d3d3f1.js';
2
2
  import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnit } from '@sankhyalabs/core';
3
- import { D as DataFetcher } from './DataFetcher-773a3e4b.js';
4
- import './pesquisa-fetcher-a87445a0.js';
3
+ import { D as DataFetcher } from './DataFetcher-a9c598f2.js';
4
+ import './pesquisa-fetcher-8edaa8cd.js';
5
5
  import './index-3aa4977a.js';
6
6
  import { S as SaveErrorsEnum } from './ISave-d8c8bc59.js';
7
- import { P as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-3d2ec959.js';
7
+ import { P as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-3aac1a53.js';
8
8
  import './filter-item-type.enum-d45e026f.js';
9
- import './form-config-fetcher-e0382e5a.js';
9
+ import './form-config-fetcher-adbe5d34.js';
10
10
  import { d as VIEW_MODE } from './constants-8457af36.js';
11
- import { A as AutorizationType } from './auth-fetcher-a411f73c.js';
11
+ import { A as AutorizationType } from './auth-fetcher-749d880f.js';
12
12
  import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
13
13
  import './PrintUtils-3e4ff0f5.js';
14
14
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
@@ -1,17 +1,17 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
2
2
  import { StringUtils, ElementIDUtils, ApplicationContext, JSUtils, FloatingManager } from '@sankhyalabs/core';
3
3
  import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
4
- import './DataFetcher-773a3e4b.js';
5
- import './pesquisa-fetcher-a87445a0.js';
4
+ import './DataFetcher-a9c598f2.js';
5
+ import './pesquisa-fetcher-8edaa8cd.js';
6
6
  import { P as PresentationMode } from './index-3aa4977a.js';
7
7
  import './ISave-d8c8bc59.js';
8
8
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
9
9
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
10
- import './dataunit-fetcher-3d2ec959.js';
10
+ import './dataunit-fetcher-3aac1a53.js';
11
11
  import './filter-item-type.enum-d45e026f.js';
12
- import './form-config-fetcher-e0382e5a.js';
12
+ import './form-config-fetcher-adbe5d34.js';
13
13
  import { d as VIEW_MODE } from './constants-8457af36.js';
14
- import { A as AutorizationType } from './auth-fetcher-a411f73c.js';
14
+ import { A as AutorizationType } from './auth-fetcher-749d880f.js';
15
15
  import './index-bdf75557.js';
16
16
  import './PrintUtils-3e4ff0f5.js';
17
17
  import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';