@sankhyalabs/sankhyablocks 8.16.0-rc.10 → 8.16.0-rc.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/dist/cjs/{ConfigStorage-e49214c6.js → ConfigStorage-ecc0ed20.js} +2 -2
  2. package/dist/cjs/{IExporterProvider-8c030a7e.js → ContinuousInsertUtils-807730a8.js} +38 -5
  3. package/dist/cjs/{DataFetcher-77729a93.js → DataFetcher-cadeef8e.js} +21 -20
  4. package/dist/cjs/{SnkFormConfigManager-beebf47a.js → SnkFormConfigManager-f1c92f79.js} +72 -16
  5. package/dist/cjs/{SnkMessageBuilder-cceebbae.js → SnkMessageBuilder-bae64d0d.js} +5 -1
  6. package/dist/cjs/{auth-fetcher-29bb791c.js → auth-fetcher-d68841bc.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-d4873076.js → dataunit-fetcher-f89461c1.js} +46 -18
  8. package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
  9. package/dist/cjs/{form-config-fetcher-feb08214.js → form-config-fetcher-ed497282.js} +5 -2
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/{pesquisa-fetcher-a1d0353f.js → pesquisa-fetcher-ca89181c.js} +1 -1
  12. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  13. package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -5
  14. package/dist/cjs/snk-application.cjs.entry.js +7 -7
  15. package/dist/cjs/snk-attach.cjs.entry.js +37 -28
  16. package/dist/cjs/snk-crud.cjs.entry.js +12 -6
  17. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  18. package/dist/cjs/{snk-data-unit-c7dcfa19.js → snk-data-unit-47202e42.js} +4 -3
  19. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  20. package/dist/cjs/snk-detail-view.cjs.entry.js +10 -10
  21. package/dist/cjs/snk-filter-bar.cjs.entry.js +22 -18
  22. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  23. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  24. package/dist/cjs/snk-form-config.cjs.entry.js +15 -4
  25. package/dist/cjs/snk-form.cjs.entry.js +7 -6
  26. package/dist/cjs/snk-grid.cjs.entry.js +58 -18
  27. package/dist/cjs/{snk-guides-viewer-69ec61af.js → snk-guides-viewer-68777d37.js} +23 -11
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -9
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  30. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  31. package/dist/cjs/snk-simple-crud.cjs.entry.js +51 -18
  32. package/dist/collection/components/snk-attach/snk-attach.js +24 -15
  33. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
  34. package/dist/collection/components/snk-crud/snk-crud.js +59 -1
  35. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
  36. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +50 -5
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -1
  38. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +1 -1
  39. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +1 -1
  40. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +44 -14
  41. package/dist/collection/components/snk-form/snk-form.js +2 -2
  42. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +70 -14
  43. package/dist/collection/components/snk-form-config/snk-form-config.js +13 -2
  44. package/dist/collection/components/snk-grid/snk-grid.css +2 -0
  45. package/dist/collection/components/snk-grid/snk-grid.js +67 -7
  46. package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +1 -1
  47. package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +0 -1
  48. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +61 -9
  49. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
  50. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
  51. package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
  52. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
  53. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +21 -20
  54. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js +7 -5
  55. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
  56. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +4 -1
  57. package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
  58. package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
  59. package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +38 -3
  60. package/dist/components/DataFetcher.js +21 -20
  61. package/dist/components/SnkFormConfigManager.js +70 -14
  62. package/dist/components/SnkMessageBuilder.js +5 -1
  63. package/dist/components/dataunit-fetcher.js +45 -15
  64. package/dist/components/form-config-fetcher.js +4 -1
  65. package/dist/components/snk-attach2.js +33 -24
  66. package/dist/components/snk-crud.js +9 -1
  67. package/dist/components/snk-data-unit2.js +3 -2
  68. package/dist/components/snk-detail-view2.js +21 -7
  69. package/dist/components/snk-filter-bar2.js +20 -15
  70. package/dist/components/snk-filter-checkbox-list.js +1 -1
  71. package/dist/components/snk-form-config2.js +13 -2
  72. package/dist/components/snk-form.js +2 -2
  73. package/dist/components/snk-grid2.js +50 -8
  74. package/dist/components/snk-simple-bar2.js +1 -1
  75. package/dist/components/snk-simple-crud2.js +42 -7
  76. package/dist/esm/{ConfigStorage-e476378d.js → ConfigStorage-7b36d041.js} +2 -2
  77. package/dist/esm/{IExporterProvider-f86019db.js → ContinuousInsertUtils-1a82a768.js} +38 -6
  78. package/dist/esm/{DataFetcher-773a3e4b.js → DataFetcher-a9c598f2.js} +21 -20
  79. package/dist/esm/{SnkFormConfigManager-298cd647.js → SnkFormConfigManager-139f09fa.js} +72 -16
  80. package/dist/esm/{SnkMessageBuilder-ae87b754.js → SnkMessageBuilder-6fff4a4c.js} +5 -1
  81. package/dist/esm/{auth-fetcher-a411f73c.js → auth-fetcher-749d880f.js} +1 -1
  82. package/dist/esm/{dataunit-fetcher-3d2ec959.js → dataunit-fetcher-c24c76c6.js} +46 -16
  83. package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
  84. package/dist/esm/{form-config-fetcher-e0382e5a.js → form-config-fetcher-adbe5d34.js} +5 -2
  85. package/dist/esm/loader.js +1 -1
  86. package/dist/esm/{pesquisa-fetcher-a87445a0.js → pesquisa-fetcher-8edaa8cd.js} +1 -1
  87. package/dist/esm/sankhyablocks.js +1 -1
  88. package/dist/esm/snk-actions-button_4.entry.js +5 -5
  89. package/dist/esm/snk-application.entry.js +7 -7
  90. package/dist/esm/snk-attach.entry.js +37 -28
  91. package/dist/esm/snk-crud.entry.js +12 -6
  92. package/dist/esm/snk-data-exporter.entry.js +6 -6
  93. package/dist/esm/{snk-data-unit-3276e55e.js → snk-data-unit-de45e0e1.js} +4 -3
  94. package/dist/esm/snk-data-unit.entry.js +4 -4
  95. package/dist/esm/snk-detail-view.entry.js +10 -10
  96. package/dist/esm/snk-filter-bar.entry.js +22 -18
  97. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  98. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  99. package/dist/esm/snk-form-config.entry.js +15 -4
  100. package/dist/esm/snk-form.entry.js +7 -6
  101. package/dist/esm/snk-grid.entry.js +53 -13
  102. package/dist/esm/{snk-guides-viewer-43f21b03.js → snk-guides-viewer-b5dd30e6.js} +23 -11
  103. package/dist/esm/snk-guides-viewer.entry.js +9 -9
  104. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  105. package/dist/esm/snk-simple-bar.entry.js +1 -1
  106. package/dist/esm/snk-simple-crud.entry.js +47 -14
  107. package/dist/sankhyablocks/p-0035ad6e.entry.js +1 -0
  108. package/dist/sankhyablocks/{p-181975f1.js → p-06421fdb.js} +2 -2
  109. package/dist/sankhyablocks/p-0911e61a.entry.js +1 -0
  110. package/dist/sankhyablocks/p-17425c72.js +1 -0
  111. package/dist/sankhyablocks/{p-25f1fc39.js → p-1bf06cd3.js} +2 -2
  112. package/dist/sankhyablocks/{p-9dfda04a.entry.js → p-212213d9.entry.js} +1 -1
  113. package/dist/sankhyablocks/p-23736d75.js +1 -0
  114. package/dist/sankhyablocks/p-3ae9d08a.js +1 -0
  115. package/dist/sankhyablocks/p-3e3cc017.js +1 -0
  116. package/dist/sankhyablocks/{p-3287a6cc.js → p-4d9549cf.js} +1 -1
  117. package/dist/sankhyablocks/p-50779ad3.entry.js +1 -0
  118. package/dist/sankhyablocks/{p-aaa3ee68.entry.js → p-5f157b09.entry.js} +1 -1
  119. package/dist/sankhyablocks/p-60b29483.entry.js +1 -0
  120. package/dist/sankhyablocks/{p-92ed1d24.entry.js → p-62e048c6.entry.js} +1 -1
  121. package/dist/sankhyablocks/{p-fd8a58ff.entry.js → p-694e1c4a.entry.js} +1 -1
  122. package/dist/sankhyablocks/p-73185e58.entry.js +1 -0
  123. package/dist/sankhyablocks/p-7ac7932c.js +60 -0
  124. package/dist/sankhyablocks/p-7eef0898.entry.js +1 -0
  125. package/dist/sankhyablocks/{p-162b9a59.entry.js → p-a42e7a1e.entry.js} +2 -2
  126. package/dist/sankhyablocks/p-afbb070d.js +1 -0
  127. package/dist/sankhyablocks/p-b9679243.entry.js +1 -0
  128. package/dist/sankhyablocks/{p-6d55957a.js → p-bccfc262.js} +1 -1
  129. package/dist/sankhyablocks/p-c2e468c9.entry.js +1 -0
  130. package/dist/sankhyablocks/{p-0cd3c0a9.js → p-ca5ec380.js} +1 -1
  131. package/dist/sankhyablocks/{p-1a21b61a.entry.js → p-da34270e.entry.js} +1 -1
  132. package/dist/sankhyablocks/p-e16e87fc.entry.js +1 -0
  133. package/dist/sankhyablocks/{p-1e596b15.entry.js → p-eb9f0407.entry.js} +1 -1
  134. package/dist/sankhyablocks/{p-594bc21d.js → p-f3434fc4.js} +1 -1
  135. package/dist/sankhyablocks/{p-bd008859.entry.js → p-fb34e0cf.entry.js} +1 -1
  136. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  137. package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
  138. package/dist/types/components/snk-crud/snk-crud.d.ts +9 -0
  139. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +11 -0
  140. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  141. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
  142. package/dist/types/components/snk-grid/snk-grid.d.ts +12 -0
  143. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -0
  144. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
  145. package/dist/types/components.d.ts +57 -0
  146. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
  147. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.d.ts +3 -2
  148. package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
  149. package/package.json +1 -1
  150. package/dist/sankhyablocks/p-091ce761.js +0 -60
  151. package/dist/sankhyablocks/p-1f35c795.js +0 -1
  152. package/dist/sankhyablocks/p-2e9c764c.entry.js +0 -1
  153. package/dist/sankhyablocks/p-42f7b05d.entry.js +0 -1
  154. package/dist/sankhyablocks/p-4e1b47a4.js +0 -1
  155. package/dist/sankhyablocks/p-53412c1d.entry.js +0 -1
  156. package/dist/sankhyablocks/p-5b26cc7c.entry.js +0 -1
  157. package/dist/sankhyablocks/p-5f016aed.js +0 -1
  158. package/dist/sankhyablocks/p-7b8f7242.entry.js +0 -1
  159. package/dist/sankhyablocks/p-7c4aabe2.js +0 -1
  160. package/dist/sankhyablocks/p-88aa931b.entry.js +0 -1
  161. package/dist/sankhyablocks/p-939e15d3.entry.js +0 -1
  162. package/dist/sankhyablocks/p-aa5b3b2c.entry.js +0 -1
  163. package/dist/sankhyablocks/p-aa6d510d.entry.js +0 -1
  164. package/dist/sankhyablocks/p-c2495304.js +0 -1
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, ElementIDUtils, ErrorException, ObjectUtils } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ElementIDUtils, ObjectUtils, ErrorException } from '@sankhyalabs/core';
2
2
  import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
3
3
  import { h, Host } from '@stencil/core';
4
4
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
@@ -27,6 +27,7 @@ export class SnkFilterBar {
27
27
  this._filtersComparator = (a, b) => {
28
28
  return this._calculateSortIndex(b) - this._calculateSortIndex(a);
29
29
  };
30
+ this.customFilterBarConfig = undefined;
30
31
  this.dataUnit = undefined;
31
32
  this.title = undefined;
32
33
  this.configName = undefined;
@@ -337,20 +338,23 @@ export class SnkFilterBar {
337
338
  }
338
339
  }
339
340
  async loadConfigFromStorage(clearCache) {
340
- if (clearCache) {
341
- await ConfigStorage.deleteFilterBarConfigCache(this.configName, this.resourceID);
341
+ try {
342
+ if (clearCache) {
343
+ await ConfigStorage.deleteFilterBarConfigCache(this.configName, this.resourceID);
344
+ }
345
+ let config;
346
+ if (this.customFilterBarConfig) {
347
+ config = await this.customFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name });
348
+ }
349
+ else {
350
+ config = await ConfigStorage.loadFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name });
351
+ }
352
+ this.filterConfig = config.map(item => this.normalizeItem(item));
353
+ this.filterConfig.sort((a, b) => this._filtersComparator(a, b));
354
+ }
355
+ catch (e) {
356
+ throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), e);
342
357
  }
343
- return new Promise(accept => {
344
- ConfigStorage.loadFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name })
345
- .then((filters) => {
346
- accept();
347
- this.filterConfig = filters.map(item => this.normalizeItem(item));
348
- this.filterConfig.sort((a, b) => this._filtersComparator(a, b));
349
- })
350
- .catch(reason => {
351
- throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
352
- });
353
- });
354
358
  }
355
359
  attachDataUnit() {
356
360
  if (this.dataUnit == undefined) {
@@ -477,6 +481,32 @@ export class SnkFilterBar {
477
481
  }
478
482
  static get properties() {
479
483
  return {
484
+ "customFilterBarConfig": {
485
+ "type": "unknown",
486
+ "mutable": false,
487
+ "complexType": {
488
+ "original": "(configName: string, resourceId: string, options: any) => Promise<Array<SnkFilterItemConfig>>",
489
+ "resolved": "(configName: string, resourceId: string, options: any) => Promise<SnkFilterItemConfig[]>",
490
+ "references": {
491
+ "Promise": {
492
+ "location": "global"
493
+ },
494
+ "Array": {
495
+ "location": "global"
496
+ },
497
+ "SnkFilterItemConfig": {
498
+ "location": "import",
499
+ "path": "./filter-item/snk-filter-item"
500
+ }
501
+ }
502
+ },
503
+ "required": false,
504
+ "optional": true,
505
+ "docs": {
506
+ "tags": [],
507
+ "text": "Loader customizado para carregar as configura\u00E7\u00F5es"
508
+ }
509
+ },
480
510
  "dataUnit": {
481
511
  "type": "unknown",
482
512
  "mutable": true,
@@ -87,7 +87,7 @@ export class SnkForm {
87
87
  if (this.resourceID == undefined) {
88
88
  this.resourceID = await ResourceIDUtils.getResourceID();
89
89
  }
90
- this._configManager = new SnkFormConfigManager(this.configName, this.resourceID);
90
+ this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, undefined, this._dataUnit);
91
91
  this.addFormLegacyConfig();
92
92
  await this._configManager.loadConfig();
93
93
  }
@@ -117,7 +117,7 @@ export class SnkForm {
117
117
  if (!this._dataUnit || !this._dataState) {
118
118
  return undefined;
119
119
  }
120
- 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 &&
120
+ 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 &&
121
121
  h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
122
122
  }
123
123
  static get is() { return "snk-form"; }
@@ -1,11 +1,13 @@
1
1
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
2
2
  import { ObjectUtils, StringUtils } from "@sankhyalabs/core";
3
3
  import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
4
+ import { TAB_NAMES } from "../../lib/utils/constants";
4
5
  export class SnkFormConfigManager {
5
- constructor(configName, resourceID, onConfigChange) {
6
+ constructor(configName, resourceID, onConfigChange, dataUnit) {
6
7
  this._resourceID = resourceID;
7
8
  this._configName = configName;
8
9
  this._onConfigChange = onConfigChange;
10
+ this._dataUnit = dataUnit;
9
11
  }
10
12
  addFormLegacyConfig(legacyConfigName) {
11
13
  if (this._configName) {
@@ -16,6 +18,7 @@ export class SnkFormConfigManager {
16
18
  return new Promise(resolve => {
17
19
  ConfigStorage.loadFormConfig(this._configName, this._resourceID)
18
20
  .then((config) => {
21
+ config = this.buildFormMetadataUITabs(config);
19
22
  this.setConfig(config);
20
23
  resolve(config);
21
24
  })
@@ -24,6 +27,10 @@ export class SnkFormConfigManager {
24
27
  });
25
28
  });
26
29
  }
30
+ getEmptyConfig() {
31
+ const config = this.buildFormMetadataUITabs({ fields: [], emptyConfig: true }, true);
32
+ return config;
33
+ }
27
34
  saveConfig(config) {
28
35
  const configToSave = ObjectUtils.copy(config);
29
36
  return new Promise(accept => {
@@ -67,25 +74,36 @@ export class SnkFormConfigManager {
67
74
  }
68
75
  return updatingCardConfig;
69
76
  }
70
- getFieldsList(dataUnit, descriptionFilter) {
77
+ hasConfig(config) {
78
+ var _a;
79
+ const currentConfig = config !== null && config !== void 0 ? config : this._config;
80
+ if (currentConfig && ((_a = currentConfig.fields) === null || _a === void 0 ? void 0 : _a.length)) {
81
+ return true;
82
+ }
83
+ return false;
84
+ }
85
+ getFieldsList(descriptionFilter, forceEmptyConfig = false) {
71
86
  var _a;
72
87
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
73
- if (fields != undefined && fields.length > 0) {
74
- return fields.map(({ label, name, readOnly, visible, required }) => {
88
+ const hasConfig = this.hasConfig();
89
+ if (hasConfig && !forceEmptyConfig) {
90
+ return fields.map(({ label, name, readOnly, visible, required, tab }) => {
91
+ var _a;
75
92
  if (label == undefined) {
76
- const currentField = dataUnit.getField(name);
77
- 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 });
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 });
78
95
  }
79
- return { name, label, readOnly, visible, required };
96
+ return { name, label, readOnly, visible, required, tab };
80
97
  })
81
98
  .filter(field => this.isFieldVisible(field, descriptionFilter));
82
99
  }
83
- if (dataUnit != undefined) {
84
- return dataUnit.metadata.fields
85
- .filter(field => this.isFieldVisible(field, descriptionFilter))
86
- .map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
100
+ if (!this._dataUnit) {
101
+ return [];
87
102
  }
88
- return [];
103
+ const filteredFields = this._dataUnit.metadata.fields
104
+ .filter(field => this.isFieldVisible(field, descriptionFilter))
105
+ .map(({ label, name, readOnly, visible, required, properties }) => ({ label, name, readOnly, visible, required, tab: properties === null || properties === void 0 ? void 0 : properties.UITabName }));
106
+ return filteredFields;
89
107
  }
90
108
  isFieldVisible(field, descriptionFilter) {
91
109
  if (field.visible === false) {
@@ -98,8 +116,8 @@ export class SnkFormConfigManager {
98
116
  const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
99
117
  return normalizedText.includes(normalizedFilter);
100
118
  }
101
- getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
102
- let fields = this.getFieldsList(dataUnit);
119
+ getFormConfig(dataUnit, ignoreReadOnlyFormFields, forceEmptyConfig = false) {
120
+ let fields = this.getFieldsList(undefined, forceEmptyConfig);
103
121
  if (ignoreReadOnlyFormFields) {
104
122
  fields = fields.filter(field => {
105
123
  if (dataUnit) {
@@ -152,4 +170,42 @@ export class SnkFormConfigManager {
152
170
  async fetchDefaultConfig() {
153
171
  return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
154
172
  }
173
+ parseObjectList(object) {
174
+ if (!object) {
175
+ return [];
176
+ }
177
+ return Array.isArray(object) ? object : [object];
178
+ }
179
+ buildFormMetadataUITabs(config, forceEmptyConfig = false) {
180
+ var _a;
181
+ const hasConfig = this.hasConfig(config);
182
+ if (!forceEmptyConfig && (!this._dataUnit || hasConfig)) {
183
+ return config;
184
+ }
185
+ config = this.getFormConfig(this._dataUnit, false, true);
186
+ config.tabs = this.parseObjectList(config.tabs);
187
+ config.emptyConfig = false;
188
+ config.defaultConfiguration = true;
189
+ const fields = this._dataUnit.metadata.fields;
190
+ for (const currentField of fields) {
191
+ const field = config.fields.find(field => field.name === currentField.name);
192
+ const uiTabName = (_a = currentField.properties) === null || _a === void 0 ? void 0 : _a.UITabName;
193
+ if (!uiTabName || uiTabName === TAB_NAMES.main) {
194
+ continue;
195
+ }
196
+ const haveTab = config.tabs.some((tab) => tab.label === uiTabName);
197
+ if (!haveTab) {
198
+ config.tabs.push({
199
+ label: uiTabName,
200
+ name: uiTabName,
201
+ order: 0,
202
+ visible: true,
203
+ });
204
+ }
205
+ if (field) {
206
+ field.tab = uiTabName;
207
+ }
208
+ }
209
+ return config;
210
+ }
155
211
  }
@@ -193,6 +193,11 @@ export class SnkFormConfig {
193
193
  this.configManager.saveConfig(this.buildConfigToSave())
194
194
  .then(savedConfig => {
195
195
  ApplicationUtils.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"), { iconName: "check" });
196
+ const userOption = this._formConfigOptions
197
+ .find((config) => {
198
+ return config.origin === UserConfigType.USER;
199
+ });
200
+ this.setFormConfig(userOption);
196
201
  this.configChange.emit(savedConfig);
197
202
  });
198
203
  }
@@ -529,9 +534,12 @@ export class SnkFormConfig {
529
534
  switch (this._optionFormConfigSelected.origin) {
530
535
  case UserConfigType.DEFAULT:
531
536
  config = await this.configManager.fetchDefaultConfig();
537
+ if (!config) {
538
+ config = this.configManager.getEmptyConfig();
539
+ }
532
540
  break;
533
- case UserConfigType.DEFAULT:
534
- config = await this.configManager.fetchDefaultConfig();
541
+ default:
542
+ config = this.getConfig();
535
543
  break;
536
544
  }
537
545
  if (config != undefined) {
@@ -734,6 +742,9 @@ export class SnkFormConfig {
734
742
  if (layoutFormConfig == undefined) {
735
743
  layoutFormConfig = [];
736
744
  }
745
+ if (this._formConfig.defaultConfiguration) {
746
+ return layoutFormConfig;
747
+ }
737
748
  return this._formConfig.tabs.map((tab) => {
738
749
  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()); })
739
750
  || { tab: tab.label, groups: [], visible: tab.visible };
@@ -1,11 +1,13 @@
1
1
  :host {
2
2
  --snk-grid-min-height: 300px;
3
+ --snk-grid-padding: var(--space--small);
3
4
  }
4
5
 
5
6
  .snk-grid__container {
6
7
  display: flex;
7
8
  height: 100%;
8
9
  width: 100%;
10
+ padding: var(--snk-grid-padding);
9
11
  }
10
12
 
11
13
  .snk-grid__header {
@@ -1,4 +1,4 @@
1
- import { h, Fragment } from '@stencil/core';
1
+ import { h, Fragment, } from '@stencil/core';
2
2
  import { Action as DUAction, ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
3
3
  import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
4
4
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
@@ -11,6 +11,7 @@ import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/
11
11
  import { CrudUtils } from '../../lib';
12
12
  import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
13
13
  import ServerSideExporterProvider from '../snk-data-exporter/providers/ServerSideExporterProvider';
14
+ import { ContinuousInsertUtils } from '../../lib/utils/ContinuousInsertUtils';
14
15
  export class SnkGrid {
15
16
  constructor() {
16
17
  this._customEditors = new Map();
@@ -19,7 +20,7 @@ export class SnkGrid {
19
20
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
20
21
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
21
22
  "snkGridTopTaskbar.regular.singleTaskbar": [],
22
- "snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE"],
23
+ "snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()],
23
24
  "snkGridTopTaskbar.finish_edition.secondary": [],
24
25
  "snkGridTopTaskbar.finish_edition.singleTaskbar": [],
25
26
  });
@@ -32,7 +33,7 @@ export class SnkGrid {
32
33
  "snkGridHeaderTaskbar.singleTaskbar.selected": ["UPDATE", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "ATTACH", "FORM_MODE", "CONFIGURATOR", "REFRESH", "DATA_EXPORTER", "ACTIONS_BUTTON"],
33
34
  "snkGridHeaderTaskbar.singleTaskbar.detail.unselected": ["INSERT", "FORM_MODE", "CONFIGURATOR", "REFRESH", "MORE_OPTIONS"],
34
35
  "snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
35
- "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
36
+ "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()]
36
37
  });
37
38
  this.dataUnitInterceptor = {
38
39
  interceptAction: async (action) => {
@@ -47,6 +48,7 @@ export class SnkGrid {
47
48
  this._gridConfig = undefined;
48
49
  this._popUpGridConfig = false;
49
50
  this._showSnkFilterBar = true;
51
+ this._enableContinuousInsert = false;
50
52
  this.columnFilterDataSource = new SnkMultiSelectionListDataSource();
51
53
  this.configName = undefined;
52
54
  this.filterBarTitle = undefined;
@@ -70,6 +72,7 @@ export class SnkGrid {
70
72
  this.filterBarLegacyConfigName = undefined;
71
73
  this.autoLoad = undefined;
72
74
  this.autoFocus = true;
75
+ this.enableGridInsert = false;
73
76
  }
74
77
  /**
75
78
  * Exibe a janela de configurações da grade.
@@ -156,6 +159,16 @@ export class SnkGrid {
156
159
  async setFocus() {
157
160
  this._grid.setFocus();
158
161
  }
162
+ async handleClick(event) {
163
+ if (this.hasToBlockEvent(event)) {
164
+ event.preventDefault();
165
+ event.stopPropagation();
166
+ await this._dataUnit.cancelEdition();
167
+ }
168
+ }
169
+ hasToBlockEvent(event) {
170
+ return this._snkFilterBar.contains(event.target) && this.enableGridInsert && this._dataUnit.hasNewRecord();
171
+ }
159
172
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
160
173
  if (!newLegacyConfig) {
161
174
  return;
@@ -166,6 +179,9 @@ export class SnkGrid {
166
179
  this.addGridLegacyConfigName();
167
180
  this.loadConfig();
168
181
  }
182
+ handleAddFormMode() {
183
+ return this.enableGridInsert ? TaskbarElement.FORM_MODE : "";
184
+ }
169
185
  openGridConfig() {
170
186
  this._grid.getColumnsState()
171
187
  .then((gridColumns) => {
@@ -290,13 +306,21 @@ export class SnkGrid {
290
306
  }
291
307
  parent = parent.parentElement;
292
308
  }
309
+ if (this._snkFilterBar) {
310
+ this._snkFilterBar.addEventListener('click', this.handleClick);
311
+ }
293
312
  this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
294
313
  this.addGridLegacyConfigName();
295
314
  this.loadConfig();
315
+ this._continuousInsertUtils = new ContinuousInsertUtils(this._application, this.resourceID, this.configName);
316
+ if (this.enableGridInsert) {
317
+ this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
318
+ }
296
319
  }
297
320
  componentDidRender() {
321
+ var _a, _b;
298
322
  this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
299
- this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
323
+ this.loadGridCustomFormatters((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields);
300
324
  this.setCustomRenders();
301
325
  this.setCustomEditors();
302
326
  }
@@ -394,12 +418,21 @@ export class SnkGrid {
394
418
  eagerInitialize: true,
395
419
  itemBuilder: (actionButton, item) => this.getColumnSearch(actionButton, item)
396
420
  }];
421
+ if (this.enableGridInsert) {
422
+ hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, this.handleEnableContinuousInsert));
423
+ }
424
+ if (this.isGridInsertActive())
425
+ return hardList;
397
426
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
398
427
  const taskbarID = this.getTopTaskBarId();
399
428
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
400
429
  }
401
430
  return hardList.concat(this.actionsList);
402
431
  }
432
+ handleEnableContinuousInsert() {
433
+ this._enableContinuousInsert = !this._enableContinuousInsert;
434
+ this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
435
+ }
403
436
  handleFilterConfigUpdated(filterConfig) {
404
437
  if (!filterConfig.length) {
405
438
  this._showSnkFilterBar = false;
@@ -411,12 +444,20 @@ export class SnkGrid {
411
444
  }
412
445
  this._showSnkFilterBar = true;
413
446
  }
447
+ getGridHeaderButtons() {
448
+ if (this.isGridInsertActive())
449
+ return TaskbarElement.MORE_OPTIONS;
450
+ return this._headerTaskbarProcessor.buttons;
451
+ }
452
+ isGridInsertActive() {
453
+ return this.enableGridInsert && this._dataUnit.hasNewRecord();
454
+ }
414
455
  render() {
415
456
  if (!this._dataUnit) {
416
457
  return undefined;
417
458
  }
418
- 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--medium" }, this._showSnkFilterBar &&
419
- 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 }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, 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 }))));
459
+ 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 &&
460
+ 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 }, 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 }))));
420
461
  }
421
462
  static get is() { return "snk-grid"; }
422
463
  static get encapsulation() { return "scoped"; }
@@ -862,6 +903,24 @@ export class SnkGrid {
862
903
  "attribute": "auto-focus",
863
904
  "reflect": false,
864
905
  "defaultValue": "true"
906
+ },
907
+ "enableGridInsert": {
908
+ "type": "boolean",
909
+ "mutable": false,
910
+ "complexType": {
911
+ "original": "boolean",
912
+ "resolved": "boolean",
913
+ "references": {}
914
+ },
915
+ "required": false,
916
+ "optional": true,
917
+ "docs": {
918
+ "tags": [],
919
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
920
+ },
921
+ "attribute": "enable-grid-insert",
922
+ "reflect": false,
923
+ "defaultValue": "false"
865
924
  }
866
925
  };
867
926
  }
@@ -871,7 +930,8 @@ export class SnkGrid {
871
930
  "_dataState": {},
872
931
  "_gridConfig": {},
873
932
  "_popUpGridConfig": {},
874
- "_showSnkFilterBar": {}
933
+ "_showSnkFilterBar": {},
934
+ "_enableContinuousInsert": {}
875
935
  };
876
936
  }
877
937
  static get events() {
@@ -26,7 +26,7 @@ export class SnkSimpleBar {
26
26
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
27
27
  }
28
28
  render() {
29
- return (h("div", { class: "simple-bar__container ez-margin-vertical--medium ez-padding--extra-small" }, h("div", { class: "simple-bar__left-slot" }, h("ez-button", { class: "ez-padding-right--medium", title: this.getMessage('snkSimpleBar.backTitle'), mode: 'icon', iconName: "arrow_back", size: 'medium', onClick: () => this.exit.emit() }), h("div", { class: "simple-bar__column" }, h("h1", { class: "ez-title ez-title--primary ez-title--extra-large" }, this.label), h("ez-breadcrumb", { items: this.breadcrumbItens, onSelectedItem: ({ detail }) => this.clickBreadcrumbItem.emit(detail) }))), h("div", { class: "simple-bar__right-slot" }, h("slot", { name: "rightSlot" }))));
29
+ return (h("div", { class: "simple-bar__container ez-margin-vertical--small ez-padding--extra-small" }, h("div", { class: "simple-bar__left-slot" }, h("ez-button", { class: "ez-padding-right--medium", title: this.getMessage('snkSimpleBar.backTitle'), mode: 'icon', iconName: "arrow_back", size: 'medium', onClick: () => this.exit.emit() }), h("div", { class: "simple-bar__column" }, h("h1", { class: "ez-title ez-title--primary ez-title--extra-large" }, this.label), h("ez-breadcrumb", { items: this.breadcrumbItens, onSelectedItem: ({ detail }) => this.clickBreadcrumbItem.emit(detail) }))), h("div", { class: "simple-bar__right-slot" }, h("slot", { name: "rightSlot" }))));
30
30
  }
31
31
  static get is() { return "snk-simple-bar"; }
32
32
  static get encapsulation() { return "scoped"; }
@@ -10,7 +10,6 @@
10
10
  .simple-crud__container {
11
11
  display: grid;
12
12
  grid-template-rows: auto 1fr;
13
- row-gap: 12px;
14
13
  height: 100%;
15
14
  width: 100%;
16
15
  }