@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-71072.1 → 0.0.0-bugfix-dev-KB-74246.2

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 (116) hide show
  1. package/dist/cjs/{ConfigStorage-f079f5fd.js → ConfigStorage-9b965af9.js} +1 -1
  2. package/dist/cjs/{ContinuousInsertUtils-64e47516.js → ContinuousInsertUtils-42636ac1.js} +2 -2
  3. package/dist/cjs/{SnkFormConfigManager-63369164.js → SnkFormConfigManager-46e90d8d.js} +8 -6
  4. package/dist/cjs/{auth-fetcher-4f853233.js → auth-fetcher-a78242d1.js} +1 -1
  5. package/dist/cjs/{form-config-fetcher-39397ac5.js → form-config-fetcher-91fba2b1.js} +37 -0
  6. package/dist/cjs/index-f9e81701.js +4 -4
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/{pesquisa-fetcher-a9bfeb22.js → pesquisa-fetcher-2ec4811b.js} +3 -0
  9. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  10. package/dist/cjs/{snk-actions-button_4.cjs.entry.js → snk-actions-button_5.cjs.entry.js} +91 -3
  11. package/dist/cjs/snk-application.cjs.entry.js +4 -4
  12. package/dist/cjs/snk-attach.cjs.entry.js +11 -7
  13. package/dist/cjs/snk-config-options_3.cjs.entry.js +3 -3
  14. package/dist/cjs/snk-crud.cjs.entry.js +3 -3
  15. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  16. package/dist/cjs/snk-detail-view.cjs.entry.js +6 -6
  17. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +5 -3
  18. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +2 -2
  19. package/dist/cjs/snk-grid.cjs.entry.js +6 -5
  20. package/dist/cjs/{snk-guides-viewer-2139481c.js → snk-guides-viewer-7d85e2fb.js} +3 -3
  21. package/dist/cjs/snk-guides-viewer.cjs.entry.js +5 -5
  22. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +3 -3
  23. package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -2
  24. package/dist/cjs/snk-simple-crud.cjs.entry.js +39 -28
  25. package/dist/collection/collection-manifest.json +1 -0
  26. package/dist/collection/components/snk-attach/structure/builder/taskbar-builder.js +8 -4
  27. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
  28. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.css +13 -0
  29. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.js +2 -2
  30. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +3 -1
  31. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -4
  32. package/dist/collection/components/snk-grid/snk-grid.js +20 -1
  33. package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +1 -0
  34. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +52 -24
  35. package/dist/collection/components/snk-simple-form-config/snk-simple-form-config.css +22 -0
  36. package/dist/collection/components/snk-simple-form-config/snk-simple-form-config.js +179 -0
  37. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +41 -4
  38. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -1
  39. package/dist/components/SnkFormConfigManager.js +6 -4
  40. package/dist/components/form-config-fetcher.js +37 -0
  41. package/dist/components/index.d.ts +1 -0
  42. package/dist/components/index.js +1 -0
  43. package/dist/components/pesquisa-fetcher.js +4 -1
  44. package/dist/components/snk-attach2.js +20 -34
  45. package/dist/components/snk-crud.js +61 -55
  46. package/dist/components/snk-detail-view2.js +85 -94
  47. package/dist/components/snk-filter-modal.js +3 -1
  48. package/dist/components/snk-grid2.js +3 -1
  49. package/dist/components/snk-personalized-filter-editor.js +3 -3
  50. package/dist/components/snk-simple-crud2.js +48 -55
  51. package/dist/components/snk-simple-form-config.d.ts +11 -0
  52. package/dist/components/snk-simple-form-config.js +6 -0
  53. package/dist/components/snk-simple-form-config2.js +119 -0
  54. package/dist/esm/{ConfigStorage-6514d66e.js → ConfigStorage-ff99377a.js} +1 -1
  55. package/dist/esm/{ContinuousInsertUtils-b62906f9.js → ContinuousInsertUtils-071e0b6a.js} +2 -2
  56. package/dist/esm/{SnkFormConfigManager-b409c745.js → SnkFormConfigManager-035f2975.js} +8 -6
  57. package/dist/esm/{auth-fetcher-ca5d3a49.js → auth-fetcher-0b78ca31.js} +1 -1
  58. package/dist/esm/{form-config-fetcher-a7d3e277.js → form-config-fetcher-0c2620ef.js} +37 -0
  59. package/dist/esm/index-a7d3d3f1.js +4 -4
  60. package/dist/esm/loader.js +1 -1
  61. package/dist/esm/{pesquisa-fetcher-6bc2e41a.js → pesquisa-fetcher-24e5bba0.js} +4 -1
  62. package/dist/esm/sankhyablocks.js +1 -1
  63. package/dist/esm/{snk-actions-button_4.entry.js → snk-actions-button_5.entry.js} +91 -4
  64. package/dist/esm/snk-application.entry.js +4 -4
  65. package/dist/esm/snk-attach.entry.js +11 -7
  66. package/dist/esm/snk-config-options_3.entry.js +3 -3
  67. package/dist/esm/snk-crud.entry.js +3 -3
  68. package/dist/esm/snk-data-exporter.entry.js +2 -2
  69. package/dist/esm/snk-detail-view.entry.js +6 -6
  70. package/dist/esm/snk-filter-bar_4.entry.js +5 -3
  71. package/dist/esm/snk-filter-modal-item.entry.js +2 -2
  72. package/dist/esm/snk-grid.entry.js +6 -5
  73. package/dist/esm/{snk-guides-viewer-b7ed39eb.js → snk-guides-viewer-2fd50f6b.js} +3 -3
  74. package/dist/esm/snk-guides-viewer.entry.js +5 -5
  75. package/dist/esm/snk-personalized-filter-editor.entry.js +3 -3
  76. package/dist/esm/snk-personalized-filter.entry.js +2 -2
  77. package/dist/esm/snk-simple-crud.entry.js +40 -29
  78. package/dist/sankhyablocks/{p-4138da61.entry.js → p-262583c6.entry.js} +1 -1
  79. package/dist/sankhyablocks/p-29643bef.entry.js +1 -0
  80. package/dist/sankhyablocks/{p-fca0e5cc.entry.js → p-35882caf.entry.js} +1 -1
  81. package/dist/sankhyablocks/{p-046ce9d2.entry.js → p-365d8ed4.entry.js} +1 -1
  82. package/dist/sankhyablocks/p-399e1b74.entry.js +1 -0
  83. package/dist/sankhyablocks/p-47178038.entry.js +1 -0
  84. package/dist/sankhyablocks/{p-e97be1c8.js → p-4c5fde50.js} +1 -1
  85. package/dist/sankhyablocks/{p-ec43fcc8.entry.js → p-5136d9f0.entry.js} +1 -1
  86. package/dist/sankhyablocks/{p-1d3ce0d9.entry.js → p-65650e05.entry.js} +1 -1
  87. package/dist/sankhyablocks/p-70ed0b0f.js +1 -0
  88. package/dist/sankhyablocks/{p-9ffd9fc7.js → p-763edad2.js} +1 -1
  89. package/dist/sankhyablocks/p-82274cb0.js +1 -0
  90. package/dist/sankhyablocks/{p-0387d9d7.entry.js → p-8cf0a9fe.entry.js} +1 -1
  91. package/dist/sankhyablocks/p-acca8a69.js +26 -0
  92. package/dist/sankhyablocks/{p-e4391e16.js → p-c271fbf1.js} +1 -1
  93. package/dist/sankhyablocks/{p-a2c790ac.entry.js → p-c629c07a.entry.js} +1 -1
  94. package/dist/sankhyablocks/p-e6683406.js +6 -0
  95. package/dist/sankhyablocks/{p-e390641b.entry.js → p-e7067256.entry.js} +1 -1
  96. package/dist/sankhyablocks/{p-aa003d4e.entry.js → p-e9432f45.entry.js} +1 -1
  97. package/dist/sankhyablocks/{p-3728d2aa.entry.js → p-eda55eef.entry.js} +3 -3
  98. package/dist/sankhyablocks/p-ff6c8f52.entry.js +1 -0
  99. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  100. package/dist/types/components/snk-grid/snk-grid.d.ts +6 -0
  101. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +9 -3
  102. package/dist/types/components/snk-simple-form-config/snk-simple-form-config.d.ts +33 -0
  103. package/dist/types/components.d.ts +54 -0
  104. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +8 -2
  105. package/package.json +1 -1
  106. package/react/components.d.ts +1 -0
  107. package/react/components.js +1 -0
  108. package/react/components.js.map +1 -1
  109. package/dist/sankhyablocks/p-0e206e62.js +0 -1
  110. package/dist/sankhyablocks/p-126c58ea.js +0 -26
  111. package/dist/sankhyablocks/p-341465ce.js +0 -6
  112. package/dist/sankhyablocks/p-4e1f992e.entry.js +0 -1
  113. package/dist/sankhyablocks/p-5b51491f.entry.js +0 -1
  114. package/dist/sankhyablocks/p-a3fadd0b.entry.js +0 -1
  115. package/dist/sankhyablocks/p-aaf94476.js +0 -1
  116. package/dist/sankhyablocks/p-af7f7b3e.entry.js +0 -1
@@ -87,13 +87,15 @@ export class SnkFormConfigManager {
87
87
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
88
88
  const hasConfig = this.hasConfig();
89
89
  if (hasConfig && !forceEmptyConfig) {
90
- return fields.map(({ label, name, readOnly, visible, required, tab }) => {
90
+ return fields.map(({ label, name, readOnly, visible, required, tab, group }) => {
91
91
  var _a;
92
92
  if (label == undefined) {
93
93
  const currentField = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
94
- 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 });
94
+ if (!currentField)
95
+ return;
96
+ 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, group: group });
95
97
  }
96
- return { name, label, readOnly, visible, required, tab };
98
+ return { name, label, readOnly, visible, required, tab, group };
97
99
  })
98
100
  .filter(field => this.isFieldVisible(field, descriptionFilter));
99
101
  }
@@ -106,7 +108,7 @@ export class SnkFormConfigManager {
106
108
  return filteredFields;
107
109
  }
108
110
  isFieldVisible(field, descriptionFilter) {
109
- if (field.visible === false) {
111
+ if (field === undefined || field.visible === false) {
110
112
  return false;
111
113
  }
112
114
  if (descriptionFilter == undefined) {
@@ -74,6 +74,7 @@ export class SnkGrid {
74
74
  this.autoFocus = true;
75
75
  this.enableGridInsert = false;
76
76
  this.enableLockManger = false;
77
+ this.outlineMode = false;
77
78
  }
78
79
  /**
79
80
  * Exibe a janela de configurações da grade.
@@ -462,7 +463,7 @@ export class SnkGrid {
462
463
  return undefined;
463
464
  }
464
465
  return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--extra-small" }, this._showSnkFilterBar &&
465
- h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.getGridHeaderButtons(), presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
466
+ h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger, outlineMode: this.outlineMode }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.getGridHeaderButtons(), presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
466
467
  }
467
468
  static get is() { return "snk-grid"; }
468
469
  static get encapsulation() { return "scoped"; }
@@ -944,6 +945,24 @@ export class SnkGrid {
944
945
  "attribute": "enable-lock-manger",
945
946
  "reflect": false,
946
947
  "defaultValue": "false"
948
+ },
949
+ "outlineMode": {
950
+ "type": "boolean",
951
+ "mutable": false,
952
+ "complexType": {
953
+ "original": "boolean",
954
+ "resolved": "boolean",
955
+ "references": {}
956
+ },
957
+ "required": false,
958
+ "optional": true,
959
+ "docs": {
960
+ "tags": [],
961
+ "text": "Altera visualmente as sombras e bordas do componente\nQuando false, aplica o padr\u00E3o de sombras ao componente (Utilizar quando for o elemento principal do layout)\nQuando true, aplica o padr\u00E3o de outline ao componente (Utilizar quando estiver contido em outro elemento como um painel ou pop-up)"
962
+ },
963
+ "attribute": "outline-mode",
964
+ "reflect": false,
965
+ "defaultValue": "false"
947
966
  }
948
967
  };
949
968
  }
@@ -25,6 +25,7 @@
25
25
 
26
26
  ez-grid {
27
27
  --ez-grid__container--shadow: none;
28
+ --ez-grid__container--shadow--outline: none;
28
29
  --ez-grid--min-height: var(--snk-simple-crud-grid--min-height);
29
30
  }
30
31
 
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
1
+ import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, KeyboardManager, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
2
  import { CSSVarsUtils } from '@sankhyalabs/ezui/dist/collection/utils';
3
3
  import { h } from '@stencil/core';
4
4
  import { SIMPLE_CRUD_MODE, VIEW_MODE } from '../../lib/utils/constants';
@@ -30,7 +30,6 @@ export class SnkSimpleCrud {
30
30
  "snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
31
31
  });
32
32
  this._showPopUpGridConfig = false;
33
- this._showFormConfig = false;
34
33
  this._currentViewMode = VIEW_MODE.GRID;
35
34
  this._config = undefined;
36
35
  this._fieldToGetFocus = undefined;
@@ -62,6 +61,7 @@ export class SnkSimpleCrud {
62
61
  this.autoFocus = true;
63
62
  this.domainMessagesBuilder = undefined;
64
63
  this.autoLoad = undefined;
64
+ this.outlineMode = false;
65
65
  }
66
66
  /**
67
67
  * Registra um editor customizado para campos da grade e formulário.
@@ -250,15 +250,9 @@ export class SnkSimpleCrud {
250
250
  });
251
251
  }
252
252
  async openFormConfig() {
253
- var _a, _b;
254
- //No momento não daremos suporte para configuraçao de formulário quando houver legacy config
255
- if (this.formLegacyConfigName) {
256
- const title = (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage("snkSimpleCrud.formConfigUnavaliable.title", undefined);
257
- const message = (_b = this.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage("snkSimpleCrud.formConfigUnavaliable.message", undefined);
258
- await this.application.alert(title, message);
259
- return;
253
+ if (this.formLegacyConfigName || this.configName) {
254
+ await this._snkSimpleFormConfig.show();
260
255
  }
261
- this._showFormConfig = true;
262
256
  }
263
257
  addGridLegacyConfigName() {
264
258
  if (this.gridLegacyConfigName && this.configName) {
@@ -288,7 +282,7 @@ export class SnkSimpleCrud {
288
282
  formConfigIsLoaded() {
289
283
  return this.formConfig != undefined || this._formConfigAlreadyLoaded;
290
284
  }
291
- async loadFormConfig(forceLoad = false) {
285
+ async loadFormConfig(forceLoad = false, forceSetNewConfig = false) {
292
286
  if (this.configName === undefined) {
293
287
  return;
294
288
  }
@@ -303,7 +297,7 @@ export class SnkSimpleCrud {
303
297
  let loadedLegacyConfig = await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);
304
298
  if (loadedLegacyConfig != undefined) {
305
299
  this._formConfigManager.setConfig(loadedLegacyConfig);
306
- this.setFormConfig(loadedLegacyConfig);
300
+ this.setFormConfig(loadedLegacyConfig, forceSetNewConfig);
307
301
  return;
308
302
  }
309
303
  this.setFormConfig(await this._formConfigManager.loadConfig());
@@ -341,6 +335,7 @@ export class SnkSimpleCrud {
341
335
  }
342
336
  componentDidLoad() {
343
337
  CSSVarsUtils.applyVarsGrid(this._element, this._grid);
338
+ this.initKeyboardManager();
344
339
  }
345
340
  setCustomRenders() {
346
341
  if (!this._grid) {
@@ -686,9 +681,6 @@ export class SnkSimpleCrud {
686
681
  closeGridConfig() {
687
682
  this._showPopUpGridConfig = false;
688
683
  }
689
- closeFormConfig() {
690
- this._showFormConfig = false;
691
- }
692
684
  getPageSize() {
693
685
  if (this.mode === SIMPLE_CRUD_MODE.IN_MEMORY) {
694
686
  return 0;
@@ -698,10 +690,6 @@ export class SnkSimpleCrud {
698
690
  }
699
691
  return this.pageSize;
700
692
  }
701
- //No momento não daremos suporte para configuração de formulário quando houver formLegacyConfigName
702
- handleShowFormConfig() {
703
- return this._showFormConfig && !this.formLegacyConfigName;
704
- }
705
693
  resolveResourceID() {
706
694
  return StringUtils.isEmpty(this.resourceID) ? this._resourceID : this.resourceID;
707
695
  }
@@ -714,7 +702,10 @@ export class SnkSimpleCrud {
714
702
  return configFromManager;
715
703
  }
716
704
  updateFormConfig() {
717
- const newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
705
+ let newConfig = this.formConfig;
706
+ if (this.formLegacyConfigName == undefined) {
707
+ newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
708
+ }
718
709
  this.setFormConfig(newConfig, true);
719
710
  if (this._formConfigManager == undefined) {
720
711
  this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
@@ -726,18 +717,38 @@ export class SnkSimpleCrud {
726
717
  return;
727
718
  this.goToView(VIEW_MODE.FORM);
728
719
  }
720
+ async initKeyboardManager() {
721
+ const keyboardManager = new KeyboardManager();
722
+ const dataUnit = this.dataUnit || await this._snkDataUnit.getDataUnit();
723
+ keyboardManager
724
+ .bind("F7", () => dataUnit.saveData(), { description: "Salva os dados.", element: this._element })
725
+ .bind("F8", dataUnit.addRecord.bind(dataUnit), { description: "Adiciona um novo registro.", element: this._element })
726
+ .bind("F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: "Remove o registro selecionado.", element: this._element })
727
+ .bind("Escape", () => {
728
+ if (dataUnit.isDirty()) {
729
+ dataUnit.cancelEdition();
730
+ }
731
+ }, {
732
+ debounceTime: 1000,
733
+ description: "Cancela uma ação.", element: this._element
734
+ });
735
+ }
736
+ async handleFormConfigSaved() {
737
+ await this.loadFormConfig(true, true);
738
+ }
729
739
  renderTaskbarContent() {
730
740
  var _a;
731
- return (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "ez-box ez-box--shadow ez-padding--small", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
741
+ return (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && `ez-box ${this.outlineMode ? 'ez-box--outline' : 'ez-box--shadow-xsmall'} ez-padding--small`, dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
732
742
  }
733
743
  /* istanbul ignore next */
734
744
  render() {
745
+ var _a;
735
746
  if (this.dataUnit == undefined) {
736
747
  return;
737
748
  }
738
- return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
749
+ return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: `ez-box ${this.outlineMode ? 'ez-box--outline' : 'ez-box--shadow'} simple-crud__container-section` }, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
739
750
  ? undefined
740
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, this.renderTaskbarContent(), h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, this.renderTaskbarContent(), h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
751
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger, outlineMode: this.outlineMode }, this.renderTaskbarContent(), h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, this.renderTaskbarContent(), h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), h("snk-simple-form-config", { ref: (ref) => this._snkSimpleFormConfig = ref, dataUnit: this.dataUnit, onSnkConfigSaved: this.handleFormConfigSaved.bind(this), configName: (_a = this.formLegacyConfigName) !== null && _a !== void 0 ? _a : this.configName })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
741
752
  }
742
753
  static get is() { return "snk-simple-crud"; }
743
754
  static get encapsulation() { return "scoped"; }
@@ -1197,13 +1208,30 @@ export class SnkSimpleCrud {
1197
1208
  },
1198
1209
  "attribute": "auto-load",
1199
1210
  "reflect": false
1211
+ },
1212
+ "outlineMode": {
1213
+ "type": "boolean",
1214
+ "mutable": false,
1215
+ "complexType": {
1216
+ "original": "boolean",
1217
+ "resolved": "boolean",
1218
+ "references": {}
1219
+ },
1220
+ "required": false,
1221
+ "optional": true,
1222
+ "docs": {
1223
+ "tags": [],
1224
+ "text": "Altera visualmente as sombras e bordas do componente\nQuando false, aplica o padr\u00E3o de sombras ao componente (Utilizar quando for o elemento principal do layout)\nQuando true, aplica o padr\u00E3o de outline ao componente (Utilizar quando estiver contido em outro elemento como um painel ou pop-up)"
1225
+ },
1226
+ "attribute": "outline-mode",
1227
+ "reflect": false,
1228
+ "defaultValue": "false"
1200
1229
  }
1201
1230
  };
1202
1231
  }
1203
1232
  static get states() {
1204
1233
  return {
1205
1234
  "_showPopUpGridConfig": {},
1206
- "_showFormConfig": {},
1207
1235
  "_currentViewMode": {},
1208
1236
  "_config": {},
1209
1237
  "_fieldToGetFocus": {},
@@ -0,0 +1,22 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .config-container {
6
+ display: flex;
7
+ flex-direction: column;
8
+ align-items: center;
9
+ justify-content: space-between;
10
+ }
11
+
12
+ .config-lists {
13
+ margin-bottom: 12px;
14
+ }
15
+
16
+ .config-actions {
17
+ display: flex;
18
+ flex-direction: row;
19
+ justify-content: flex-end;
20
+ width: 100%;
21
+ gap: 12px;
22
+ }
@@ -0,0 +1,179 @@
1
+ import { h } from '@stencil/core';
2
+ import { FormConfigFetcher } from '../../lib';
3
+ export class SnkSimpleFormConfig {
4
+ constructor() {
5
+ this._formConfigFetcher = new FormConfigFetcher();
6
+ this.fieldsToSave = [];
7
+ this.dataUnit = undefined;
8
+ this.configName = undefined;
9
+ this.avaliableFields = [];
10
+ this.selectedFields = [];
11
+ }
12
+ /**
13
+ * Responsável por abrir o configurador.
14
+ */
15
+ async show() {
16
+ await this.initializeFormConfig();
17
+ this.ezPopupRef.opened = true;
18
+ }
19
+ ;
20
+ async initializeFormConfig() {
21
+ if (!this.configName)
22
+ return;
23
+ const allFields = this.getAllVisibleFieldsFromDataUnit();
24
+ const displayedFieldNameList = await this.getConfig();
25
+ //Quando não retorna dados, é por quê não existe configuração do usuário salva.
26
+ if (displayedFieldNameList.length === 0) {
27
+ this.avaliableFields = [];
28
+ this.selectedFields = [...allFields];
29
+ this.fieldsToSave = [...this.selectedFields];
30
+ return;
31
+ }
32
+ const selectedFieldsAux = this.sortDisplayedFields(displayedFieldNameList, allFields);
33
+ const avaliableFieldsAux = allFields.filter(field => !displayedFieldNameList.includes(field.id));
34
+ this.avaliableFields = [...avaliableFieldsAux];
35
+ this.selectedFields = [...selectedFieldsAux];
36
+ this.fieldsToSave = [...this.selectedFields];
37
+ }
38
+ async getConfig() {
39
+ const fieldList = await this._formConfigFetcher.fetchSimpleFormConfig(this.configName);
40
+ return [...this.removeDuplicates(fieldList)];
41
+ }
42
+ removeDuplicates(strings) {
43
+ return strings.filter((item, index) => strings.indexOf(item) === index);
44
+ }
45
+ sortDisplayedFields(displayedFieldNameList, allFields) {
46
+ const selectedFieldsAux = [];
47
+ //É preciso garantir a ordem na qual os campos vieram na resposta do fetchSimpleFormConfig.
48
+ displayedFieldNameList.forEach(fieldName => {
49
+ const field = allFields.find(field => field.id === fieldName);
50
+ if (!field)
51
+ return;
52
+ selectedFieldsAux.push(field);
53
+ });
54
+ return selectedFieldsAux;
55
+ }
56
+ getAllVisibleFieldsFromDataUnit() {
57
+ var _a, _b, _c;
58
+ const visibleFields = ((_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields) !== null && _c !== void 0 ? _c : []).filter(field => field.visible);
59
+ return visibleFields.map(field => {
60
+ return { id: field.name, label: field.label };
61
+ });
62
+ }
63
+ close() {
64
+ this.ezPopupRef.opened = false;
65
+ }
66
+ async handleResetConfigs() {
67
+ await this._formConfigFetcher.restoreFormConfig(this.configName);
68
+ await this.initializeFormConfig();
69
+ await this.handleSave();
70
+ }
71
+ handleCancel() {
72
+ this.close();
73
+ }
74
+ async handleSave() {
75
+ const saveList = this.fieldsToSave.map(field => field.id);
76
+ await this._formConfigFetcher.saveSimpleFormConfig(this.configName, saveList);
77
+ this.close();
78
+ this.snkConfigSaved.emit();
79
+ }
80
+ render() {
81
+ return (h("ez-popup", { ref: (ref) => this.ezPopupRef = ref, heightMode: 'auto', size: 'auto', ezTitle: 'Configurar formul\u00E1rio' }, h("div", { class: 'config-container' }, h("div", { class: 'config-lists' }, h("ez-double-list", { leftList: this.avaliableFields, leftTitle: 'Campos disponíveis', rightList: this.selectedFields, rightTitle: 'Campos selecionados', onEzRightListChanged: ({ detail }) => this.fieldsToSave = [...detail], entityLabel: 'campo', entityLabelPlural: 'campos' })), h("div", { class: 'config-actions' }, h("ez-button", { label: 'Restaurar', onClick: this.handleResetConfigs.bind(this), size: 'small' }), h("ez-button", { label: 'Cancelar', onClick: this.handleCancel.bind(this), size: 'small' }), h("ez-button", { label: 'Salvar', class: 'ez-button--primary', onClick: this.handleSave.bind(this), size: 'small' })))));
82
+ }
83
+ static get is() { return "snk-simple-form-config"; }
84
+ static get originalStyleUrls() {
85
+ return {
86
+ "$": ["snk-simple-form-config.css"]
87
+ };
88
+ }
89
+ static get styleUrls() {
90
+ return {
91
+ "$": ["snk-simple-form-config.css"]
92
+ };
93
+ }
94
+ static get properties() {
95
+ return {
96
+ "dataUnit": {
97
+ "type": "unknown",
98
+ "mutable": false,
99
+ "complexType": {
100
+ "original": "DataUnit",
101
+ "resolved": "DataUnit",
102
+ "references": {
103
+ "DataUnit": {
104
+ "location": "import",
105
+ "path": "@sankhyalabs/core"
106
+ }
107
+ }
108
+ },
109
+ "required": false,
110
+ "optional": false,
111
+ "docs": {
112
+ "tags": [],
113
+ "text": "Data unit respons\u00E1vel pelos campos dispon\u00EDveis"
114
+ }
115
+ },
116
+ "configName": {
117
+ "type": "string",
118
+ "mutable": false,
119
+ "complexType": {
120
+ "original": "string",
121
+ "resolved": "string",
122
+ "references": {}
123
+ },
124
+ "required": false,
125
+ "optional": false,
126
+ "docs": {
127
+ "tags": [],
128
+ "text": "Chave que representa a configura\u00E7\u00E3o do formul\u00E1rio"
129
+ },
130
+ "attribute": "config-name",
131
+ "reflect": false
132
+ }
133
+ };
134
+ }
135
+ static get states() {
136
+ return {
137
+ "avaliableFields": {},
138
+ "selectedFields": {}
139
+ };
140
+ }
141
+ static get events() {
142
+ return [{
143
+ "method": "snkConfigSaved",
144
+ "name": "snkConfigSaved",
145
+ "bubbles": true,
146
+ "cancelable": true,
147
+ "composed": true,
148
+ "docs": {
149
+ "tags": [],
150
+ "text": ""
151
+ },
152
+ "complexType": {
153
+ "original": "void",
154
+ "resolved": "void",
155
+ "references": {}
156
+ }
157
+ }];
158
+ }
159
+ static get methods() {
160
+ return {
161
+ "show": {
162
+ "complexType": {
163
+ "signature": "() => Promise<void>",
164
+ "parameters": [],
165
+ "references": {
166
+ "Promise": {
167
+ "location": "global"
168
+ }
169
+ },
170
+ "return": "Promise<void>"
171
+ },
172
+ "docs": {
173
+ "text": "Respons\u00E1vel por abrir o configurador.",
174
+ "tags": []
175
+ }
176
+ }
177
+ };
178
+ }
179
+ }
@@ -1,7 +1,7 @@
1
- import { gql } from "graphql-request";
2
- import { ObjectUtils } from "@sankhyalabs/core";
3
- import { ResourceFetcher } from "./resource-fetcher";
4
- import { DataFetcher } from "../DataFetcher";
1
+ import { gql } from 'graphql-request';
2
+ import { ObjectUtils } from '@sankhyalabs/core';
3
+ import { ResourceFetcher } from './resource-fetcher';
4
+ import { DataFetcher } from '../DataFetcher';
5
5
  export class FormConfigFetcher extends ResourceFetcher {
6
6
  constructor() {
7
7
  super();
@@ -178,6 +178,43 @@ export class FormConfigFetcher extends ResourceFetcher {
178
178
  return undefined;
179
179
  return this.buildLegacyConfigurableForm(response);
180
180
  }
181
+ async fetchSimpleFormConfig(configName) {
182
+ const payload = { 'requestBody': { 'formConfig': { 'configName': configName } } };
183
+ const response = await DataFetcher.get().callServiceBroker('FormConfig.getFormConfig', JSON.stringify(payload));
184
+ return this.processConfig(response);
185
+ }
186
+ async saveSimpleFormConfig(configName, fieldList) {
187
+ const payload = this.buildSaveSimpleFormConfigPayload(configName, fieldList);
188
+ const response = await DataFetcher.get().callServiceBroker('FormConfig.saveFormConfig', JSON.stringify(payload));
189
+ this.processConfig(response);
190
+ }
191
+ processConfig(response) {
192
+ if (ObjectUtils.isEmpty(response))
193
+ return [];
194
+ const fields = this.getResponseAsArray(response);
195
+ return fields.map(field => field.name);
196
+ }
197
+ getResponseAsArray(response) {
198
+ var _a, _b, _c;
199
+ const rawFields = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.formConfig) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.field) !== null && _c !== void 0 ? _c : [];
200
+ return Array.isArray(rawFields) ? rawFields : [rawFields];
201
+ }
202
+ buildSaveSimpleFormConfigPayload(configName, fieldNameList) {
203
+ const fieldList = fieldNameList.map(fieldName => { return { name: fieldName }; });
204
+ return {
205
+ formConfig: {
206
+ configName,
207
+ layout: {
208
+ field: fieldList,
209
+ },
210
+ metadata: { field: [] },
211
+ }
212
+ };
213
+ }
214
+ async restoreFormConfig(configName) {
215
+ const payload = { 'requestBody': { 'formConfig': { 'configName': configName } } };
216
+ await DataFetcher.get().callServiceBroker('FormConfig.restoreFormConfig', JSON.stringify(payload));
217
+ }
181
218
  buildLegacyConfigurableForm(config) {
182
219
  var _a, _b, _c;
183
220
  const rawFields = (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.formConfig) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.field) !== null && _c !== void 0 ? _c : [];
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, DataType } from "@sankhyalabs/core";
1
+ import { ApplicationContext, DataType, ErrorException } from "@sankhyalabs/core";
2
2
  import { gql } from "graphql-request";
3
3
  import { DataFetcher } from "../DataFetcher";
4
4
  export class PesquisaFetcher {
@@ -73,6 +73,9 @@ export class PesquisaFetcher {
73
73
  value = ApplicationContext.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${match[1]})__`);
74
74
  }
75
75
  }
76
+ if (param.dataType === DataType.NUMBER && value === undefined) {
77
+ throw new ErrorException("Falha detectada", `O campo ${param.name} deve ser informado.`);
78
+ }
76
79
  let type = param.dataType;
77
80
  if (type === DataType.OBJECT) {
78
81
  value = value.value;
@@ -88,13 +88,15 @@ class SnkFormConfigManager {
88
88
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
89
89
  const hasConfig = this.hasConfig();
90
90
  if (hasConfig && !forceEmptyConfig) {
91
- return fields.map(({ label, name, readOnly, visible, required, tab }) => {
91
+ return fields.map(({ label, name, readOnly, visible, required, tab, group }) => {
92
92
  var _a;
93
93
  if (label == undefined) {
94
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 });
95
+ if (!currentField)
96
+ return;
97
+ 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, group: group });
96
98
  }
97
- return { name, label, readOnly, visible, required, tab };
99
+ return { name, label, readOnly, visible, required, tab, group };
98
100
  })
99
101
  .filter(field => this.isFieldVisible(field, descriptionFilter));
100
102
  }
@@ -107,7 +109,7 @@ class SnkFormConfigManager {
107
109
  return filteredFields;
108
110
  }
109
111
  isFieldVisible(field, descriptionFilter) {
110
- if (field.visible === false) {
112
+ if (field === undefined || field.visible === false) {
111
113
  return false;
112
114
  }
113
115
  if (descriptionFilter == undefined) {
@@ -240,6 +240,43 @@ class FormConfigFetcher extends ResourceFetcher {
240
240
  return undefined;
241
241
  return this.buildLegacyConfigurableForm(response);
242
242
  }
243
+ async fetchSimpleFormConfig(configName) {
244
+ const payload = { 'requestBody': { 'formConfig': { 'configName': configName } } };
245
+ const response = await DataFetcher.get().callServiceBroker('FormConfig.getFormConfig', JSON.stringify(payload));
246
+ return this.processConfig(response);
247
+ }
248
+ async saveSimpleFormConfig(configName, fieldList) {
249
+ const payload = this.buildSaveSimpleFormConfigPayload(configName, fieldList);
250
+ const response = await DataFetcher.get().callServiceBroker('FormConfig.saveFormConfig', JSON.stringify(payload));
251
+ this.processConfig(response);
252
+ }
253
+ processConfig(response) {
254
+ if (ObjectUtils.isEmpty(response))
255
+ return [];
256
+ const fields = this.getResponseAsArray(response);
257
+ return fields.map(field => field.name);
258
+ }
259
+ getResponseAsArray(response) {
260
+ var _a, _b, _c;
261
+ const rawFields = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.formConfig) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.field) !== null && _c !== void 0 ? _c : [];
262
+ return Array.isArray(rawFields) ? rawFields : [rawFields];
263
+ }
264
+ buildSaveSimpleFormConfigPayload(configName, fieldNameList) {
265
+ const fieldList = fieldNameList.map(fieldName => { return { name: fieldName }; });
266
+ return {
267
+ formConfig: {
268
+ configName,
269
+ layout: {
270
+ field: fieldList,
271
+ },
272
+ metadata: { field: [] },
273
+ }
274
+ };
275
+ }
276
+ async restoreFormConfig(configName) {
277
+ const payload = { 'requestBody': { 'formConfig': { 'configName': configName } } };
278
+ await DataFetcher.get().callServiceBroker('FormConfig.restoreFormConfig', JSON.stringify(payload));
279
+ }
243
280
  buildLegacyConfigurableForm(config) {
244
281
  var _a, _b, _c;
245
282
  const rawFields = (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.formConfig) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.field) !== null && _c !== void 0 ? _c : [];
@@ -47,6 +47,7 @@ export { SnkPrintSelector as SnkPrintSelector } from '../types/components/snk-pr
47
47
  export { SelectBox as SnkSelectBox } from '../types/components/snk-grid-config/snk-select-box/snk-select-box';
48
48
  export { SnkSimpleBar as SnkSimpleBar } from '../types/components/snk-simple-bar/snk-simple-bar';
49
49
  export { SnkSimpleCrud as SnkSimpleCrud } from '../types/components/snk-simple-crud/snk-simple-crud';
50
+ export { SnkSimpleFormConfig as SnkSimpleFormConfig } from '../types/components/snk-simple-form-config/snk-simple-form-config';
50
51
  export { SnkTabConfig as SnkTabConfig } from '../types/components/snk-form-config/subcomponents/snk-tab-config/snk-tab-config';
51
52
  export { SnkTaskbar as SnkTaskbar } from '../types/components/snk-taskbar/snk-taskbar';
52
53
  export { TaskbarActionsButton as TaskbarActionsButton } from '../types/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button';
@@ -47,6 +47,7 @@ export { SnkPrintSelector, defineCustomElement as defineCustomElementSnkPrintSel
47
47
  export { SnkSelectBox, defineCustomElement as defineCustomElementSnkSelectBox } from './snk-select-box.js';
48
48
  export { SnkSimpleBar, defineCustomElement as defineCustomElementSnkSimpleBar } from './snk-simple-bar.js';
49
49
  export { SnkSimpleCrud, defineCustomElement as defineCustomElementSnkSimpleCrud } from './snk-simple-crud.js';
50
+ export { SnkSimpleFormConfig, defineCustomElement as defineCustomElementSnkSimpleFormConfig } from './snk-simple-form-config.js';
50
51
  export { SnkTabConfig, defineCustomElement as defineCustomElementSnkTabConfig } from './snk-tab-config.js';
51
52
  export { SnkTaskbar, defineCustomElement as defineCustomElementSnkTaskbar } from './snk-taskbar.js';
52
53
  export { TaskbarActionsButton, defineCustomElement as defineCustomElementTaskbarActionsButton } from './taskbar-actions-button.js';