@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-57523.0 → 0.0.0-bugfix-dev-59880.0

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 (186) hide show
  1. package/dist/cjs/{ConfigStorage-7df9d3bb.js → ConfigStorage-9a53a42c.js} +12 -11
  2. package/dist/cjs/{form-config-fetcher-3c4daeb5.js → DataFetcher-515bda03.js} +0 -251
  3. package/dist/cjs/{IExporterProvider-c307e2b1.js → IExporterProvider-e286ef6a.js} +55 -12
  4. package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-7b222c78.js} +4 -4
  5. package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-4a95fe86.js} +6 -12
  6. package/dist/cjs/{auth-fetcher-e6112be7.js → auth-fetcher-5acb0335.js} +1 -1
  7. package/dist/cjs/{pesquisa-fetcher-cbdaba63.js → dataunit-fetcher-7a08e4dd.js} +74 -175
  8. package/dist/cjs/form-config-fetcher-3f430aee.js +256 -0
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/pesquisa-fetcher-916a935c.js +166 -0
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +10 -8
  13. package/dist/cjs/snk-application.cjs.entry.js +49 -39
  14. package/dist/cjs/snk-attach.cjs.entry.js +19 -17
  15. package/dist/cjs/snk-crud.cjs.entry.js +95 -10
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +11 -9
  17. package/dist/cjs/snk-data-unit-3718477f.js +670 -0
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +8 -3
  21. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -2
  22. package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
  23. package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
  24. package/dist/cjs/snk-form.cjs.entry.js +53 -7
  25. package/dist/cjs/snk-grid.cjs.entry.js +103 -11
  26. package/dist/cjs/{snk-guides-viewer-b0c44e0c.js → snk-guides-viewer-66dd6949.js} +36 -7
  27. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
  28. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -2
  29. package/dist/cjs/snk-simple-crud.cjs.entry.js +153 -14
  30. package/dist/collection/collection-manifest.json +1 -1
  31. package/dist/collection/components/snk-application/snk-application.js +37 -17
  32. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  33. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  34. package/dist/collection/components/snk-crud/snk-crud.js +230 -7
  35. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  36. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
  37. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +112 -5
  38. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +14 -8
  39. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
  40. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +2 -2
  41. package/dist/collection/components/snk-data-unit/snk-data-unit.js +499 -176
  42. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  43. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  44. package/dist/collection/components/snk-form/snk-form.js +101 -4
  45. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +2 -2
  46. package/dist/collection/components/snk-grid/snk-grid.js +219 -8
  47. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +283 -9
  48. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  49. package/dist/collection/lib/dataUnit/InMemoryLoader.js +6 -2
  50. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  51. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  52. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  53. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  54. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +51 -1
  55. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  56. package/dist/collection/lib/message/SnkMessageBuilder.js +25 -32
  57. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  58. package/dist/components/ConfigStorage.js +2 -1
  59. package/dist/components/DataFetcher.js +7024 -0
  60. package/dist/components/IExporterProvider.js +54 -12
  61. package/dist/components/SnkFormConfigManager.js +2 -2
  62. package/dist/components/SnkMessageBuilder.js +6 -12
  63. package/dist/components/dataunit-fetcher.js +64 -166
  64. package/dist/components/form-config-fetcher.js +3 -7023
  65. package/dist/components/pesquisa-fetcher.js +164 -0
  66. package/dist/components/snk-actions-button2.js +4 -2
  67. package/dist/components/snk-application2.js +26 -17
  68. package/dist/components/snk-attach2.js +4 -2
  69. package/dist/components/snk-crud.js +101 -10
  70. package/dist/components/snk-data-exporter2.js +6 -4
  71. package/dist/components/snk-data-unit2.js +424 -177
  72. package/dist/components/snk-detail-view2.js +87 -9
  73. package/dist/components/snk-filter-bar2.js +6 -1
  74. package/dist/components/snk-form-config2.js +1 -1
  75. package/dist/components/snk-form-view2.js +72 -1
  76. package/dist/components/snk-form.js +52 -5
  77. package/dist/components/snk-grid2.js +109 -12
  78. package/dist/components/snk-simple-crud2.js +157 -11
  79. package/dist/esm/{ConfigStorage-928c3bf4.js → ConfigStorage-174101b9.js} +2 -1
  80. package/dist/esm/{form-config-fetcher-e3094014.js → DataFetcher-4b4b7beb.js} +1 -250
  81. package/dist/esm/{IExporterProvider-e2a1195d.js → IExporterProvider-cf5a56ee.js} +54 -12
  82. package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-3bdb3e1f.js} +4 -4
  83. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-3a767111.js} +6 -12
  84. package/dist/esm/{auth-fetcher-e1cb288f.js → auth-fetcher-9f86c346.js} +1 -1
  85. package/dist/esm/{pesquisa-fetcher-6d8e50bb.js → dataunit-fetcher-f3fa35b9.js} +63 -165
  86. package/dist/esm/form-config-fetcher-5d72aaf1.js +253 -0
  87. package/dist/esm/loader.js +1 -1
  88. package/dist/esm/pesquisa-fetcher-9cfab836.js +164 -0
  89. package/dist/esm/sankhyablocks.js +1 -1
  90. package/dist/esm/snk-actions-button_4.entry.js +5 -3
  91. package/dist/esm/snk-application.entry.js +30 -20
  92. package/dist/esm/snk-attach.entry.js +5 -3
  93. package/dist/esm/snk-crud.entry.js +95 -10
  94. package/dist/esm/snk-data-exporter.entry.js +8 -6
  95. package/dist/esm/snk-data-unit-8d6afa43.js +668 -0
  96. package/dist/esm/snk-data-unit.entry.js +10 -2
  97. package/dist/esm/snk-detail-view.entry.js +48 -7
  98. package/dist/esm/snk-filter-bar.entry.js +8 -3
  99. package/dist/esm/snk-filter-modal-item.entry.js +3 -2
  100. package/dist/esm/snk-form-config.entry.js +2 -1
  101. package/dist/esm/snk-form-view.entry.js +67 -0
  102. package/dist/esm/snk-form.entry.js +53 -7
  103. package/dist/esm/snk-grid.entry.js +104 -12
  104. package/dist/esm/{snk-guides-viewer-1fd41a25.js → snk-guides-viewer-11cf8dc7.js} +36 -7
  105. package/dist/esm/snk-guides-viewer.entry.js +8 -6
  106. package/dist/esm/snk-personalized-filter.entry.js +3 -2
  107. package/dist/esm/snk-simple-crud.entry.js +153 -14
  108. package/dist/sankhyablocks/p-010d475f.js +1 -0
  109. package/dist/sankhyablocks/p-0a28cb19.entry.js +1 -0
  110. package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
  111. package/dist/sankhyablocks/p-1c6debe6.entry.js +1 -0
  112. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  113. package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
  114. package/dist/sankhyablocks/p-2cc2d8fd.entry.js +1 -0
  115. package/dist/sankhyablocks/p-3e4c2cfe.entry.js +11 -0
  116. package/dist/sankhyablocks/p-4a8a149d.entry.js +1 -0
  117. package/dist/sankhyablocks/p-4ce73e88.js +1 -0
  118. package/dist/sankhyablocks/p-50e72d6c.js +1 -0
  119. package/dist/sankhyablocks/{p-e27496ed.js → p-566f5f50.js} +6 -6
  120. package/dist/sankhyablocks/p-59dccb7a.entry.js +1 -0
  121. package/dist/sankhyablocks/p-5bd78e4c.entry.js +1 -0
  122. package/dist/sankhyablocks/p-6b2be902.js +6 -0
  123. package/dist/sankhyablocks/p-8171e586.entry.js +1 -0
  124. package/dist/sankhyablocks/p-a6dfa396.js +1 -0
  125. package/dist/sankhyablocks/p-a97060b0.js +1 -0
  126. package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
  127. package/dist/sankhyablocks/p-b27114c4.js +1 -0
  128. package/dist/sankhyablocks/p-b643f746.entry.js +1 -0
  129. package/dist/sankhyablocks/p-b68918fc.entry.js +1 -0
  130. package/dist/sankhyablocks/p-da7c81d6.entry.js +1 -0
  131. package/dist/sankhyablocks/p-e0c27486.js +26 -0
  132. package/dist/sankhyablocks/p-e238279a.entry.js +1 -0
  133. package/dist/sankhyablocks/p-eae66367.js +1 -0
  134. package/dist/sankhyablocks/p-fde91811.js +60 -0
  135. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  136. package/dist/types/components/snk-application/snk-application.d.ts +6 -2
  137. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  138. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  139. package/dist/types/components/snk-crud/snk-crud.d.ts +32 -1
  140. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  141. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
  142. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +19 -0
  143. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +3 -0
  144. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +61 -2
  145. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  146. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  147. package/dist/types/components/snk-form/snk-form.d.ts +14 -0
  148. package/dist/types/components/snk-grid/snk-grid.d.ts +42 -3
  149. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +40 -2
  150. package/dist/types/components.d.ts +180 -4
  151. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  152. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  153. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  154. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  155. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  156. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  157. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  158. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  159. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +2 -0
  160. package/package.json +1 -1
  161. package/dist/cjs/snk-data-unit-abd2113f.js +0 -427
  162. package/dist/esm/snk-data-unit-29eba11a.js +0 -425
  163. package/dist/sankhyablocks/p-029bfc09.js +0 -1
  164. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  165. package/dist/sankhyablocks/p-07825198.js +0 -1
  166. package/dist/sankhyablocks/p-0e8702f0.js +0 -1
  167. package/dist/sankhyablocks/p-13ea113d.entry.js +0 -1
  168. package/dist/sankhyablocks/p-314e2d1a.entry.js +0 -1
  169. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  170. package/dist/sankhyablocks/p-3357af48.js +0 -1
  171. package/dist/sankhyablocks/p-3c2a1f4d.js +0 -65
  172. package/dist/sankhyablocks/p-3e7167dd.js +0 -1
  173. package/dist/sankhyablocks/p-536eeb16.js +0 -26
  174. package/dist/sankhyablocks/p-587f9dcf.entry.js +0 -1
  175. package/dist/sankhyablocks/p-61984566.entry.js +0 -1
  176. package/dist/sankhyablocks/p-61b6126e.entry.js +0 -1
  177. package/dist/sankhyablocks/p-65b6dba3.entry.js +0 -1
  178. package/dist/sankhyablocks/p-6a7bc5c8.entry.js +0 -1
  179. package/dist/sankhyablocks/p-6c9edfd8.entry.js +0 -1
  180. package/dist/sankhyablocks/p-89bde7d3.entry.js +0 -1
  181. package/dist/sankhyablocks/p-91dceecf.entry.js +0 -1
  182. package/dist/sankhyablocks/p-a40cbad8.entry.js +0 -1
  183. package/dist/sankhyablocks/p-b86ea293.entry.js +0 -1
  184. package/dist/sankhyablocks/p-d8ddb2a4.entry.js +0 -11
  185. package/dist/sankhyablocks/p-f92f1f5f.entry.js +0 -1
  186. package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
@@ -0,0 +1,24 @@
1
+ import { DataType } from "@sankhyalabs/core";
2
+ const metadataMock = {
3
+ label: 'metadataMock',
4
+ name: 'metadataMock',
5
+ fields: [
6
+ {
7
+ name: 'TESTE',
8
+ label: 'Teste',
9
+ dataType: DataType.TEXT,
10
+ properties: {
11
+ rm_precision: 'TESTERMP.PRODUTORMP.decVlr'
12
+ }
13
+ },
14
+ {
15
+ name: 'TESTERMP',
16
+ label: 'Teste com RMP',
17
+ dataType: DataType.TEXT,
18
+ properties: {
19
+ rmp: 'PRODUTORMP'
20
+ }
21
+ }
22
+ ]
23
+ };
24
+ export default metadataMock;
@@ -36,6 +36,7 @@ export class SnkFilterBar {
36
36
  this.messagesBuilder = undefined;
37
37
  this.disablePersonalizedFilter = undefined;
38
38
  this.filterBarLegacyConfigName = undefined;
39
+ this.autoLoad = undefined;
39
40
  this.allowDefault = undefined;
40
41
  this.scrollerLocked = false;
41
42
  this.showPersonalizedFilter = false;
@@ -183,7 +184,10 @@ export class SnkFilterBar {
183
184
  }
184
185
  async doLoadData(forceReload = false) {
185
186
  try {
186
- if (this._firstLoad && !forceReload) {
187
+ if (this._firstLoad && this.autoLoad === false) {
188
+ return;
189
+ }
190
+ if (this._firstLoad && !forceReload && this.autoLoad === undefined) {
187
191
  let autoLoad = await this._application.getBooleanParam("global.carregar.registros.iniciar.tela");
188
192
  if (!autoLoad) {
189
193
  return;
@@ -630,6 +634,23 @@ export class SnkFilterBar {
630
634
  },
631
635
  "attribute": "filter-bar-legacy-config-name",
632
636
  "reflect": false
637
+ },
638
+ "autoLoad": {
639
+ "type": "boolean",
640
+ "mutable": false,
641
+ "complexType": {
642
+ "original": "boolean",
643
+ "resolved": "boolean",
644
+ "references": {}
645
+ },
646
+ "required": false,
647
+ "optional": true,
648
+ "docs": {
649
+ "tags": [],
650
+ "text": "Define se a carga dos dados ser\u00E1 feita assim que o componente for carregado."
651
+ },
652
+ "attribute": "auto-load",
653
+ "reflect": false
633
654
  }
634
655
  };
635
656
  }
@@ -4,6 +4,7 @@ import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
4
4
  import ResourceIDUtils from '../../lib/resourceid/ResourceIDUtils';
5
5
  export class SnkForm {
6
6
  constructor() {
7
+ this._customEditors = new Map();
7
8
  this._dataUnit = undefined;
8
9
  this._dataState = undefined;
9
10
  this._showFormConfig = false;
@@ -26,6 +27,24 @@ export class SnkForm {
26
27
  async hideConfig() {
27
28
  this._showFormConfig = false;
28
29
  }
30
+ /**
31
+ * Registra um editor customizado para campos da grade e formulário.
32
+ */
33
+ async addCustomEditor(fieldName, customEditor) {
34
+ if (this._form) {
35
+ this._form.addCustomEditor(fieldName, customEditor);
36
+ return;
37
+ }
38
+ const newCustomEditors = new Map(this._customEditors);
39
+ newCustomEditors.set(fieldName, customEditor);
40
+ this._customEditors = newCustomEditors;
41
+ }
42
+ /**
43
+ * Altera/adiciona uma propriedade nos metadados do campo.
44
+ */
45
+ async setFieldProp(fieldName, propName, value) {
46
+ await this._form.setFieldProp(fieldName, propName, value);
47
+ }
29
48
  closeConfig() {
30
49
  this.hideConfig();
31
50
  }
@@ -33,6 +52,18 @@ export class SnkForm {
33
52
  const dataInfo = { dataUnit: this._dataUnit };
34
53
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
35
54
  }
55
+ setCustomEditors() {
56
+ if (!this._form) {
57
+ return;
58
+ }
59
+ for (const [fieldName, customEditor] of this._customEditors) {
60
+ this._form.addCustomEditor(fieldName, customEditor);
61
+ this._customEditors.delete(fieldName);
62
+ }
63
+ }
64
+ async componentDidRender() {
65
+ this.setCustomEditors();
66
+ }
36
67
  async componentWillLoad() {
37
68
  let parent = this._element.parentElement;
38
69
  while (parent) {
@@ -48,9 +79,7 @@ export class SnkForm {
48
79
  this._dataUnit = evt.detail;
49
80
  });
50
81
  }
51
- this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
52
- this._dataState = evt.detail;
53
- });
82
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
54
83
  break;
55
84
  }
56
85
  parent = parent.parentElement;
@@ -62,6 +91,23 @@ export class SnkForm {
62
91
  this.addFormLegacyConfig();
63
92
  this._configManager.loadConfig();
64
93
  }
94
+ async handleDataStateChange(evt) {
95
+ var _a;
96
+ this._dataState = evt.detail;
97
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
98
+ for (const field of fieldsWithRmPrecision || []) {
99
+ if (!field) {
100
+ continue;
101
+ }
102
+ const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
103
+ if (!rmPrecision && rmPrecision !== 0) {
104
+ continue;
105
+ }
106
+ await this.setFieldProp(field, 'precision', rmPrecision);
107
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
108
+ }
109
+ ;
110
+ }
65
111
  addFormLegacyConfig() {
66
112
  if (this.formLegacyConfigName) {
67
113
  this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
@@ -71,7 +117,7 @@ export class SnkForm {
71
117
  if (!this._dataUnit || !this._dataState) {
72
118
  return undefined;
73
119
  }
74
- return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { 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._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
75
121
  h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
76
122
  }
77
123
  static get is() { return "snk-form"; }
@@ -277,6 +323,57 @@ export class SnkForm {
277
323
  "text": "Fecha a janela de configura\u00E7\u00F5es do formul\u00E1rio.",
278
324
  "tags": []
279
325
  }
326
+ },
327
+ "addCustomEditor": {
328
+ "complexType": {
329
+ "signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
330
+ "parameters": [{
331
+ "tags": [],
332
+ "text": ""
333
+ }, {
334
+ "tags": [],
335
+ "text": ""
336
+ }],
337
+ "references": {
338
+ "Promise": {
339
+ "location": "global"
340
+ },
341
+ "ICustomEditor": {
342
+ "location": "import",
343
+ "path": "@sankhyalabs/ezui/dist/types/utils"
344
+ }
345
+ },
346
+ "return": "Promise<void>"
347
+ },
348
+ "docs": {
349
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
350
+ "tags": []
351
+ }
352
+ },
353
+ "setFieldProp": {
354
+ "complexType": {
355
+ "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
356
+ "parameters": [{
357
+ "tags": [],
358
+ "text": ""
359
+ }, {
360
+ "tags": [],
361
+ "text": ""
362
+ }, {
363
+ "tags": [],
364
+ "text": ""
365
+ }],
366
+ "references": {
367
+ "Promise": {
368
+ "location": "global"
369
+ }
370
+ },
371
+ "return": "Promise<void>"
372
+ },
373
+ "docs": {
374
+ "text": "Altera/adiciona uma propriedade nos metadados do campo.",
375
+ "tags": []
376
+ }
280
377
  }
281
378
  };
282
379
  }
@@ -71,11 +71,11 @@ export class SnkFormConfigManager {
71
71
  var _a;
72
72
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
73
73
  if (fields != undefined && fields.length > 0) {
74
- return fields.map(({ label, name, readOnly }) => {
74
+ return fields.map(({ label, name, readOnly, visible }) => {
75
75
  if (label == undefined) {
76
76
  return dataUnit.getField(name);
77
77
  }
78
- return { name, label, readOnly };
78
+ return { name, label, readOnly, visible };
79
79
  })
80
80
  .filter(field => this.isFieldVisible(field, descriptionFilter));
81
81
  }
@@ -1,5 +1,5 @@
1
1
  import { h, Fragment } from '@stencil/core';
2
- import { ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
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';
5
5
  import { PresentationMode } from '../../lib/@types';
@@ -9,9 +9,12 @@ import SnkMultiSelectionListDataSource from './filtercolumn/SnkMultiSelectionLis
9
9
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
10
10
  import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/field-search';
11
11
  import { CrudUtils } from '../../lib';
12
+ import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
12
13
  import ServerSideExporterProvider from '../snk-data-exporter/providers/ServerSideExporterProvider';
13
14
  export class SnkGrid {
14
15
  constructor() {
16
+ this._customEditors = new Map();
17
+ this._customRenders = new Map();
15
18
  this._topTaskbarProcessor = new TaskbarProcessor({
16
19
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
17
20
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
@@ -31,6 +34,14 @@ export class SnkGrid {
31
34
  "snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
32
35
  "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
33
36
  });
37
+ this.dataUnitInterceptor = {
38
+ interceptAction: async (action) => {
39
+ if (action.type === DUAction.METADATA_LOADED) {
40
+ return await this.interceptMetadataLoaded(action);
41
+ }
42
+ return action;
43
+ }
44
+ };
34
45
  this._dataUnit = undefined;
35
46
  this._dataState = undefined;
36
47
  this._gridConfig = undefined;
@@ -57,6 +68,7 @@ export class SnkGrid {
57
68
  this.disablePersonalizedFilter = undefined;
58
69
  this.gridLegacyConfigName = undefined;
59
70
  this.filterBarLegacyConfigName = undefined;
71
+ this.autoLoad = undefined;
60
72
  }
61
73
  /**
62
74
  * Exibe a janela de configurações da grade.
@@ -101,6 +113,42 @@ export class SnkGrid {
101
113
  async findColumn() {
102
114
  await openFieldSearch(this._moreOptions, this._columnSearch);
103
115
  }
116
+ /**
117
+ * Registra um editor customizado para campos da grade e formulário
118
+ */
119
+ async addCustomEditor(fieldName, customEditor, detailContext) {
120
+ if (this._grid) {
121
+ this._grid.addCustomEditor(fieldName, customEditor, detailContext);
122
+ return;
123
+ }
124
+ const newCustomEditors = new Map(this._customEditors);
125
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
126
+ this._customEditors = newCustomEditors;
127
+ }
128
+ /**
129
+ * Registra um render customizado para colunas da grid.
130
+ */
131
+ async addGridCustomRender(fieldName, customRender, detailContext) {
132
+ if (this._grid) {
133
+ this._grid.addGridCustomRender(fieldName, customRender, detailContext);
134
+ return;
135
+ }
136
+ const newCustomRenders = new Map(this._customRenders);
137
+ newCustomRenders.set(fieldName, { customRender, detailContext });
138
+ this._customRenders = newCustomRenders;
139
+ }
140
+ /**
141
+ * Registra um formatador de valores para uma coluna da grid.
142
+ */
143
+ async addCustomValueFormatter(columnName, customFormatter) {
144
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
145
+ }
146
+ /**
147
+ * Remove o formatador de valores de uma coluna da grid.
148
+ */
149
+ async removeCustomValueFormatter(columnName) {
150
+ this._grid.removeCustomValueFormatter(columnName);
151
+ }
104
152
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
105
153
  if (!newLegacyConfig) {
106
154
  return;
@@ -163,7 +211,23 @@ export class SnkGrid {
163
211
  const dataInfo = { dataUnit: this._dataUnit };
164
212
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
165
213
  }
166
- finshLoading() {
214
+ loadGridCustomFormatters(fields) {
215
+ if (!fields || !this._grid) {
216
+ return;
217
+ }
218
+ fields.forEach((field) => {
219
+ var _a;
220
+ if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) {
221
+ this.addCustomValueFormatter(field.name, this._rmPrecisionCustomValueFormatter);
222
+ }
223
+ });
224
+ }
225
+ async interceptMetadataLoaded(action) {
226
+ this.loadGridCustomFormatters(action.payload.fields);
227
+ return action;
228
+ }
229
+ finishLoading() {
230
+ this._dataUnit.addInterceptor(this.dataUnitInterceptor);
167
231
  CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
168
232
  this.addElementID();
169
233
  if (this.columnFilterDataSource != undefined) {
@@ -171,6 +235,24 @@ export class SnkGrid {
171
235
  this.columnFilterDataSource.setDataUnit(this._dataUnit);
172
236
  }
173
237
  }
238
+ setCustomRenders() {
239
+ if (!this._grid) {
240
+ return;
241
+ }
242
+ for (const [fieldName, customRenderProps] of this._customRenders) {
243
+ this._grid.addGridCustomRender(fieldName, customRenderProps.customRender, customRenderProps.detailContext);
244
+ this._customRenders.delete(fieldName);
245
+ }
246
+ }
247
+ setCustomEditors() {
248
+ if (!this._grid) {
249
+ return;
250
+ }
251
+ for (const [fieldName, customEditorProps] of this._customEditors) {
252
+ this._grid.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
253
+ this._customEditors.delete(fieldName);
254
+ }
255
+ }
174
256
  componentWillLoad() {
175
257
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
176
258
  //TODO: substituir pelo metodo nativo closest
@@ -182,17 +264,15 @@ export class SnkGrid {
182
264
  if (!this._dataUnit) {
183
265
  this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
184
266
  this._dataUnit = evt.detail;
185
- this.finshLoading();
267
+ this.finishLoading();
186
268
  });
187
269
  }
188
270
  else {
189
- this.finshLoading();
271
+ this.finishLoading();
190
272
  }
191
273
  if (!this.messagesBuilder)
192
274
  this.messagesBuilder = this._snkDataUnit.messagesBuilder;
193
- this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
194
- this._dataState = evt.detail;
195
- });
275
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
196
276
  this._snkDataUnit.addEventListener("cancelEdition", () => {
197
277
  var _a;
198
278
  if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.recordsIsEmpty) {
@@ -203,9 +283,20 @@ export class SnkGrid {
203
283
  }
204
284
  parent = parent.parentElement;
205
285
  }
286
+ this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
206
287
  this.addGridLegacyConfigName();
207
288
  this.loadConfig();
208
289
  }
290
+ componentDidRender() {
291
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
292
+ this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
293
+ this.setCustomRenders();
294
+ this.setCustomEditors();
295
+ }
296
+ async handleDataStateChange(evt) {
297
+ this._dataState = evt.detail;
298
+ this._rmPrecisionCustomValueFormatter.setDataState(this._dataState);
299
+ }
209
300
  getHeaderDisabledButtons() {
210
301
  var _a;
211
302
  const disabledButtons = [];
@@ -318,7 +409,7 @@ export class SnkGrid {
318
409
  return undefined;
319
410
  }
320
411
  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 &&
321
- 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 }), 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 }, 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 }))));
412
+ 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 }, 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 }))));
322
413
  }
323
414
  static get is() { return "snk-grid"; }
324
415
  static get encapsulation() { return "scoped"; }
@@ -729,6 +820,23 @@ export class SnkGrid {
729
820
  },
730
821
  "attribute": "filter-bar-legacy-config-name",
731
822
  "reflect": false
823
+ },
824
+ "autoLoad": {
825
+ "type": "boolean",
826
+ "mutable": false,
827
+ "complexType": {
828
+ "original": "boolean",
829
+ "resolved": "boolean",
830
+ "references": {}
831
+ },
832
+ "required": false,
833
+ "optional": true,
834
+ "docs": {
835
+ "tags": [],
836
+ "text": "Define se a carga dos dados ser\u00E1 feita assim que o componente for carregado."
837
+ },
838
+ "attribute": "auto-load",
839
+ "reflect": false
732
840
  }
733
841
  };
734
842
  }
@@ -881,6 +989,109 @@ export class SnkGrid {
881
989
  "text": "Abre o localizador de colunas",
882
990
  "tags": []
883
991
  }
992
+ },
993
+ "addCustomEditor": {
994
+ "complexType": {
995
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
996
+ "parameters": [{
997
+ "tags": [],
998
+ "text": ""
999
+ }, {
1000
+ "tags": [],
1001
+ "text": ""
1002
+ }, {
1003
+ "tags": [],
1004
+ "text": ""
1005
+ }],
1006
+ "references": {
1007
+ "Promise": {
1008
+ "location": "global"
1009
+ },
1010
+ "ICustomEditor": {
1011
+ "location": "import",
1012
+ "path": "@sankhyalabs/ezui/dist/types/utils"
1013
+ }
1014
+ },
1015
+ "return": "Promise<void>"
1016
+ },
1017
+ "docs": {
1018
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
1019
+ "tags": []
1020
+ }
1021
+ },
1022
+ "addGridCustomRender": {
1023
+ "complexType": {
1024
+ "signature": "(fieldName: string, customRender: ICustomRender, detailContext?: string) => Promise<void>",
1025
+ "parameters": [{
1026
+ "tags": [],
1027
+ "text": ""
1028
+ }, {
1029
+ "tags": [],
1030
+ "text": ""
1031
+ }, {
1032
+ "tags": [],
1033
+ "text": ""
1034
+ }],
1035
+ "references": {
1036
+ "Promise": {
1037
+ "location": "global"
1038
+ },
1039
+ "ICustomRender": {
1040
+ "location": "import",
1041
+ "path": "@sankhyalabs/ezui/dist/types/utils"
1042
+ }
1043
+ },
1044
+ "return": "Promise<void>"
1045
+ },
1046
+ "docs": {
1047
+ "text": "Registra um render customizado para colunas da grid.",
1048
+ "tags": []
1049
+ }
1050
+ },
1051
+ "addCustomValueFormatter": {
1052
+ "complexType": {
1053
+ "signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
1054
+ "parameters": [{
1055
+ "tags": [],
1056
+ "text": ""
1057
+ }, {
1058
+ "tags": [],
1059
+ "text": ""
1060
+ }],
1061
+ "references": {
1062
+ "Promise": {
1063
+ "location": "global"
1064
+ },
1065
+ "ICustomFormatter": {
1066
+ "location": "import",
1067
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/interfaces"
1068
+ }
1069
+ },
1070
+ "return": "Promise<void>"
1071
+ },
1072
+ "docs": {
1073
+ "text": "Registra um formatador de valores para uma coluna da grid.",
1074
+ "tags": []
1075
+ }
1076
+ },
1077
+ "removeCustomValueFormatter": {
1078
+ "complexType": {
1079
+ "signature": "(columnName: string) => Promise<void>",
1080
+ "parameters": [{
1081
+ "tags": [],
1082
+ "text": ""
1083
+ }],
1084
+ "references": {
1085
+ "Promise": {
1086
+ "location": "global"
1087
+ }
1088
+ },
1089
+ "return": "Promise<void>"
1090
+ },
1091
+ "docs": {
1092
+ "text": "Remove o formatador de valores de uma coluna da grid.",
1093
+ "tags": []
1094
+ }
884
1095
  }
885
1096
  };
886
1097
  }