@sankhyalabs/sankhyablocks 8.15.0-dev.60 → 8.15.0-dev.62

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 (171) 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-1ed8e92a.js → IExporterProvider-d3a3ccd1.js} +55 -12
  4. package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-dda10d75.js} +2 -2
  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-cb768be1.js → dataunit-fetcher-e2109392.js} +68 -173
  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 +43 -9
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +9 -7
  17. package/dist/cjs/snk-data-unit-dee38ccd.js +614 -0
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -6
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -2
  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 +36 -0
  24. package/dist/cjs/snk-form.cjs.entry.js +28 -7
  25. package/dist/cjs/snk-grid.cjs.entry.js +55 -10
  26. package/dist/cjs/{snk-guides-viewer-bec9c1a5.js → snk-guides-viewer-af4a6ae5.js} +19 -6
  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 +96 -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/snk-crud.js +109 -6
  33. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +79 -0
  34. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +41 -4
  35. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +14 -8
  36. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +413 -165
  38. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  39. package/dist/collection/components/snk-form/snk-form.js +50 -4
  40. package/dist/collection/components/snk-grid/snk-grid.js +96 -7
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +156 -8
  42. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  43. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  46. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +51 -1
  47. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  48. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -2
  49. package/dist/collection/lib/message/SnkMessageBuilder.js +25 -32
  50. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  51. package/dist/components/ConfigStorage.js +2 -1
  52. package/dist/components/DataFetcher.js +7024 -0
  53. package/dist/components/IExporterProvider.js +54 -12
  54. package/dist/components/SnkMessageBuilder.js +6 -12
  55. package/dist/components/dataunit-fetcher.js +58 -164
  56. package/dist/components/form-config-fetcher.js +3 -7023
  57. package/dist/components/pesquisa-fetcher.js +164 -0
  58. package/dist/components/snk-actions-button2.js +4 -2
  59. package/dist/components/snk-application2.js +26 -17
  60. package/dist/components/snk-attach2.js +4 -2
  61. package/dist/components/snk-crud.js +46 -9
  62. package/dist/components/snk-data-exporter2.js +4 -2
  63. package/dist/components/snk-data-unit2.js +356 -166
  64. package/dist/components/snk-detail-view2.js +21 -6
  65. package/dist/components/snk-form-config2.js +1 -1
  66. package/dist/components/snk-form-view2.js +39 -1
  67. package/dist/components/snk-form.js +26 -5
  68. package/dist/components/snk-grid2.js +58 -11
  69. package/dist/components/snk-simple-crud2.js +96 -10
  70. package/dist/esm/{ConfigStorage-928c3bf4.js → ConfigStorage-174101b9.js} +2 -1
  71. package/dist/esm/{form-config-fetcher-e3094014.js → DataFetcher-4b4b7beb.js} +1 -250
  72. package/dist/esm/{IExporterProvider-ceabfb7e.js → IExporterProvider-640e1f6b.js} +54 -12
  73. package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-87bd8082.js} +2 -2
  74. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-3a767111.js} +6 -12
  75. package/dist/esm/{auth-fetcher-e1cb288f.js → auth-fetcher-9f86c346.js} +1 -1
  76. package/dist/esm/{pesquisa-fetcher-72125b13.js → dataunit-fetcher-87ecba4a.js} +57 -163
  77. package/dist/esm/form-config-fetcher-5d72aaf1.js +253 -0
  78. package/dist/esm/loader.js +1 -1
  79. package/dist/esm/pesquisa-fetcher-9cfab836.js +164 -0
  80. package/dist/esm/sankhyablocks.js +1 -1
  81. package/dist/esm/snk-actions-button_4.entry.js +5 -3
  82. package/dist/esm/snk-application.entry.js +30 -20
  83. package/dist/esm/snk-attach.entry.js +5 -3
  84. package/dist/esm/snk-crud.entry.js +43 -9
  85. package/dist/esm/snk-data-exporter.entry.js +6 -4
  86. package/dist/esm/snk-data-unit-1132e40b.js +612 -0
  87. package/dist/esm/snk-data-unit.entry.js +10 -2
  88. package/dist/esm/snk-detail-view.entry.js +8 -6
  89. package/dist/esm/snk-filter-bar.entry.js +3 -2
  90. package/dist/esm/snk-filter-modal-item.entry.js +3 -2
  91. package/dist/esm/snk-form-config.entry.js +2 -1
  92. package/dist/esm/snk-form-view.entry.js +36 -0
  93. package/dist/esm/snk-form.entry.js +28 -7
  94. package/dist/esm/snk-grid.entry.js +56 -11
  95. package/dist/esm/{snk-guides-viewer-303aafb4.js → snk-guides-viewer-359e39a7.js} +19 -6
  96. package/dist/esm/snk-guides-viewer.entry.js +8 -6
  97. package/dist/esm/snk-personalized-filter.entry.js +3 -2
  98. package/dist/esm/snk-simple-crud.entry.js +95 -13
  99. package/dist/sankhyablocks/p-010d475f.js +1 -0
  100. package/dist/sankhyablocks/p-08fee6e8.js +60 -0
  101. package/dist/sankhyablocks/p-0bcc6e83.js +1 -0
  102. package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-0e8702f0.js → p-2eb90860.js} +1 -1
  104. package/dist/sankhyablocks/p-33f695d6.entry.js +1 -0
  105. package/dist/sankhyablocks/p-3519a984.entry.js +1 -0
  106. package/dist/sankhyablocks/p-4ce73e88.js +1 -0
  107. package/dist/sankhyablocks/{p-e27496ed.js → p-566f5f50.js} +6 -6
  108. package/dist/sankhyablocks/p-59dccb7a.entry.js +1 -0
  109. package/dist/sankhyablocks/p-5c8a9e27.entry.js +1 -0
  110. package/dist/sankhyablocks/p-66a31d30.entry.js +11 -0
  111. package/dist/sankhyablocks/p-6b2be902.js +6 -0
  112. package/dist/sankhyablocks/p-7ecaaea2.entry.js +1 -0
  113. package/dist/sankhyablocks/p-83950924.entry.js +1 -0
  114. package/dist/sankhyablocks/p-873d2e6a.entry.js +1 -0
  115. package/dist/sankhyablocks/p-931343a1.entry.js +1 -0
  116. package/dist/sankhyablocks/p-a6dfa396.js +1 -0
  117. package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
  118. package/dist/sankhyablocks/p-b11921ca.entry.js +1 -0
  119. package/dist/sankhyablocks/p-cb91634d.js +1 -0
  120. package/dist/sankhyablocks/p-cf9d2d1e.entry.js +1 -0
  121. package/dist/sankhyablocks/p-d29a252c.js +1 -0
  122. package/dist/sankhyablocks/p-d799aa7f.entry.js +1 -0
  123. package/dist/sankhyablocks/p-da6e3dcf.entry.js +1 -0
  124. package/dist/sankhyablocks/p-e0c27486.js +26 -0
  125. package/dist/sankhyablocks/p-f72e8835.entry.js +1 -0
  126. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  127. package/dist/types/components/snk-application/snk-application.d.ts +6 -2
  128. package/dist/types/components/snk-crud/snk-crud.d.ts +14 -1
  129. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +13 -1
  130. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +6 -0
  131. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +3 -0
  132. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +45 -1
  133. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  134. package/dist/types/components/snk-form/snk-form.d.ts +6 -0
  135. package/dist/types/components/snk-grid/snk-grid.d.ts +19 -3
  136. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +22 -0
  137. package/dist/types/components.d.ts +68 -4
  138. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  139. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  140. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  141. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  142. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  143. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  144. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +2 -0
  145. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
  146. package/package.json +1 -1
  147. package/dist/cjs/snk-data-unit-abd2113f.js +0 -427
  148. package/dist/esm/snk-data-unit-29eba11a.js +0 -425
  149. package/dist/sankhyablocks/p-029bfc09.js +0 -1
  150. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  151. package/dist/sankhyablocks/p-07825198.js +0 -1
  152. package/dist/sankhyablocks/p-13ea113d.entry.js +0 -1
  153. package/dist/sankhyablocks/p-1fa244c0.entry.js +0 -1
  154. package/dist/sankhyablocks/p-2d972c2e.entry.js +0 -1
  155. package/dist/sankhyablocks/p-314e2d1a.entry.js +0 -1
  156. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  157. package/dist/sankhyablocks/p-3494a28e.entry.js +0 -1
  158. package/dist/sankhyablocks/p-35bd4df7.entry.js +0 -1
  159. package/dist/sankhyablocks/p-536eeb16.js +0 -26
  160. package/dist/sankhyablocks/p-563701f3.js +0 -1
  161. package/dist/sankhyablocks/p-61984566.entry.js +0 -1
  162. package/dist/sankhyablocks/p-64977b22.entry.js +0 -1
  163. package/dist/sankhyablocks/p-65b6dba3.entry.js +0 -1
  164. package/dist/sankhyablocks/p-6bc64fb0.entry.js +0 -1
  165. package/dist/sankhyablocks/p-aedf37fb.js +0 -65
  166. package/dist/sankhyablocks/p-b233f5aa.entry.js +0 -1
  167. package/dist/sankhyablocks/p-b86ea293.entry.js +0 -1
  168. package/dist/sankhyablocks/p-c73482cf.js +0 -1
  169. package/dist/sankhyablocks/p-cb3c7b4a.entry.js +0 -11
  170. package/dist/sankhyablocks/p-d911a023.entry.js +0 -1
  171. package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
@@ -6,9 +6,10 @@ const index = require('./index-f9e81701.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const filterItemType_enum = require('./filter-item-type.enum-a7ffdaa6.js');
8
8
  const presentationMode = require('./presentationMode-52ec3bdd.js');
9
- const ConfigStorage = require('./ConfigStorage-7df9d3bb.js');
9
+ const ConfigStorage = require('./ConfigStorage-9a53a42c.js');
10
10
  const filterType_enum = require('./filter-type.enum-b14ce507.js');
11
- require('./form-config-fetcher-3c4daeb5.js');
11
+ require('./form-config-fetcher-3f430aee.js');
12
+ require('./DataFetcher-515bda03.js');
12
13
  require('./PrintUtils-bcaeb82f.js');
13
14
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
14
15
 
@@ -7,8 +7,9 @@ const Sortable = require('./Sortable-fb1c4cbb.js');
7
7
  const core = require('@sankhyalabs/core');
8
8
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
9
9
  const constants = require('./constants-35ddd366.js');
10
- const formConfigFetcher = require('./form-config-fetcher-3c4daeb5.js');
10
+ const formConfigFetcher = require('./form-config-fetcher-3f430aee.js');
11
11
  const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
12
+ require('./DataFetcher-515bda03.js');
12
13
  require('./PrintUtils-bcaeb82f.js');
13
14
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
14
15
 
@@ -14,6 +14,7 @@ const SnkFormView = class {
14
14
  this.snkContentCardChanged = index.createEvent(this, "snkContentCardChanged", 7);
15
15
  this.snkRequestClearFieldToFocus = index.createEvent(this, "snkRequestClearFieldToFocus", 7);
16
16
  this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
17
+ this._fieldProps = new Map();
17
18
  this.levelPath = undefined;
18
19
  this.label = undefined;
19
20
  this.name = undefined;
@@ -27,12 +28,29 @@ const SnkFormView = class {
27
28
  this.canFix = true;
28
29
  this.recordsValidator = undefined;
29
30
  this.fieldToFocus = undefined;
31
+ this.fieldsProps = undefined;
30
32
  }
31
33
  async showUp() {
32
34
  if (this._formView) {
33
35
  this._formView.showUp();
34
36
  }
35
37
  }
38
+ /**
39
+ * Altera/adiciona uma propriedade nos metadados do campo.
40
+ */
41
+ async setFieldProp(fieldName, propName, value) {
42
+ const props = this._fieldProps.get(fieldName) || [];
43
+ this._fieldProps.set(fieldName, [...props, { propName, value }]);
44
+ }
45
+ async observeFieldsProps(newValue) {
46
+ for (const field in newValue) {
47
+ const fieldProps = newValue[field];
48
+ const propNames = Object.keys(fieldProps);
49
+ for (const propName of propNames) {
50
+ await this.setFieldProp(field, propName, fieldProps[propName]);
51
+ }
52
+ }
53
+ }
36
54
  changeFix() {
37
55
  this.fixed = !this.fixed;
38
56
  this.emitEvent("fixed");
@@ -91,7 +109,11 @@ const SnkFormView = class {
91
109
  this._dataBinder.onDisconnectedCallback();
92
110
  }
93
111
  }
112
+ componentDidLoad() {
113
+ this.observeFieldsProps(this.fieldsProps);
114
+ }
94
115
  componentDidRender() {
116
+ this.setFieldProps();
95
117
  if (this.fieldToFocus == undefined) {
96
118
  return;
97
119
  }
@@ -103,6 +125,17 @@ const SnkFormView = class {
103
125
  this.snkRequestClearFieldToFocus.emit();
104
126
  });
105
127
  }
128
+ setFieldProps() {
129
+ if (!this._formView) {
130
+ return;
131
+ }
132
+ for (const [fieldName, propsToChange] of this._fieldProps) {
133
+ propsToChange.forEach(prop => {
134
+ this._formView.setFieldProp(fieldName, prop.propName, prop.value);
135
+ this._fieldProps.delete(fieldName);
136
+ });
137
+ }
138
+ }
106
139
  render() {
107
140
  return (index.h(index.Host, { class: "ez-box__container" }, index.h("div", { class: "summary-header ez-flex ez-size-width--full" }, index.h("div", { class: "ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9" }, this.levelPath ? index.h("span", { class: "level-path" }, this.levelPath + " /") : undefined, this.label), index.h("div", { class: "ez-flex ez-flex--justify-end ez-col--sd-3" }, this.canFix &&
108
141
  index.h("ez-button", { class: "ez-padding-left--medium", mode: "icon", size: "small", iconName: this.fixed ? "un-pin" : "push-pin", "data-element-id": core.ElementIDUtils.getInternalIDInfo("toggleFixed_ezFormCard"), onClick: () => this.changeFix(), title: this.fixed ? "Desafixar" : "Fixar" }), this.canExpand &&
@@ -112,6 +145,9 @@ const SnkFormView = class {
112
145
  :
113
146
  index.h("ez-form-view", { ref: ref => this._formView = ref, fields: this.fields, onEzContentReady: evt => this.bindFields(evt.detail), onFormItemsReady: (event) => this.handleFormItemsReady(event) })));
114
147
  }
148
+ static get watchers() { return {
149
+ "fieldsProps": ["observeFieldsProps"]
150
+ }; }
115
151
  };
116
152
  SnkFormView.style = snkFormViewCss;
117
153
 
@@ -4,10 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-f9e81701.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const SnkFormConfigManager = require('./SnkFormConfigManager-4259edbe.js');
7
+ const SnkFormConfigManager = require('./SnkFormConfigManager-dda10d75.js');
8
8
  const ResourceIDUtils = require('./ResourceIDUtils-5ff86aa7.js');
9
- require('./ConfigStorage-7df9d3bb.js');
10
- require('./form-config-fetcher-3c4daeb5.js');
9
+ require('./ConfigStorage-9a53a42c.js');
10
+ require('./form-config-fetcher-3f430aee.js');
11
+ require('./DataFetcher-515bda03.js');
11
12
  require('./PrintUtils-bcaeb82f.js');
12
13
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
13
14
  require('./filter-item-type.enum-a7ffdaa6.js');
@@ -42,6 +43,12 @@ const SnkForm = class {
42
43
  async hideConfig() {
43
44
  this._showFormConfig = false;
44
45
  }
46
+ /**
47
+ * Altera/adiciona uma propriedade nos metadados do campo.
48
+ */
49
+ async setFieldProp(fieldName, propName, value) {
50
+ await this._form.setFieldProp(fieldName, propName, value);
51
+ }
45
52
  closeConfig() {
46
53
  this.hideConfig();
47
54
  }
@@ -64,9 +71,7 @@ const SnkForm = class {
64
71
  this._dataUnit = evt.detail;
65
72
  });
66
73
  }
67
- this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
68
- this._dataState = evt.detail;
69
- });
74
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
70
75
  break;
71
76
  }
72
77
  parent = parent.parentElement;
@@ -78,6 +83,22 @@ const SnkForm = class {
78
83
  this.addFormLegacyConfig();
79
84
  this._configManager.loadConfig();
80
85
  }
86
+ async handleDataStateChange(evt) {
87
+ var _a;
88
+ this._dataState = evt.detail;
89
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
90
+ for (const field of fieldsWithRmPrecision || []) {
91
+ if (!field) {
92
+ continue;
93
+ }
94
+ const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
95
+ if (!rmPrecision) {
96
+ continue;
97
+ }
98
+ await this.setFieldProp(field, 'precision', rmPrecision);
99
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
100
+ }
101
+ }
81
102
  addFormLegacyConfig() {
82
103
  if (this.formLegacyConfigName) {
83
104
  this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
@@ -87,7 +108,7 @@ const SnkForm = class {
87
108
  if (!this._dataUnit || !this._dataState) {
88
109
  return undefined;
89
110
  }
90
- return (index.h("section", null, index.h("div", { class: "ez-row" }, index.h("div", { class: "ez-col ez-col--sd-12" }, index.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 &&
111
+ return (index.h("section", null, index.h("div", { class: "ez-row" }, index.h("div", { class: "ez-col ez-col--sd-12" }, index.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 &&
91
112
  index.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
92
113
  }
93
114
  get _element() { return index.getElement(this); }
@@ -5,18 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-f9e81701.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const taskbarElements = require('./taskbar-elements-d9392685.js');
8
- const ConfigStorage = require('./ConfigStorage-7df9d3bb.js');
8
+ const ConfigStorage = require('./ConfigStorage-9a53a42c.js');
9
9
  const index$1 = require('./index-0922807b.js');
10
10
  const fieldSearch = require('./field-search-f56aa7d6.js');
11
11
  const index$2 = require('./index-102ba62d.js');
12
- const IExporterProvider = require('./IExporterProvider-1ed8e92a.js');
12
+ const IExporterProvider = require('./IExporterProvider-d3a3ccd1.js');
13
13
  const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
14
- require('./form-config-fetcher-3c4daeb5.js');
15
- require('./pesquisa-fetcher-cb768be1.js');
14
+ require('./DataFetcher-515bda03.js');
15
+ require('./pesquisa-fetcher-916a935c.js');
16
16
  require('./ISave-e91b70a7.js');
17
17
  require('@sankhyalabs/ezui/dist/collection/utils/constants');
18
18
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
19
+ require('./dataunit-fetcher-e2109392.js');
19
20
  require('./filter-item-type.enum-a7ffdaa6.js');
21
+ require('./form-config-fetcher-3f430aee.js');
20
22
  const RecordIDUtils = require('./RecordIDUtils-3735135c.js');
21
23
  require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource');
22
24
  require('./PrintUtils-bcaeb82f.js');
@@ -104,6 +106,14 @@ const SnkGrid = class {
104
106
  "snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
105
107
  "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
106
108
  });
109
+ this.dataUnitInterceptor = {
110
+ interceptAction: async (action) => {
111
+ if (action.type === core.Action.METADATA_LOADED) {
112
+ return await this.interceptMetadataLoaded(action);
113
+ }
114
+ return action;
115
+ }
116
+ };
107
117
  this._dataUnit = undefined;
108
118
  this._dataState = undefined;
109
119
  this._gridConfig = undefined;
@@ -174,6 +184,18 @@ const SnkGrid = class {
174
184
  async findColumn() {
175
185
  await fieldSearch.openFieldSearch(this._moreOptions, this._columnSearch);
176
186
  }
187
+ /**
188
+ * Registra um formatador de valores para uma coluna da grid.
189
+ */
190
+ async addCustomValueFormatter(columnName, customFormatter) {
191
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
192
+ }
193
+ /**
194
+ * Remove o formatador de valores de uma coluna da grid.
195
+ */
196
+ async removeCustomValueFormatter(columnName) {
197
+ this._grid.removeCustomValueFormatter(columnName);
198
+ }
177
199
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
178
200
  if (!newLegacyConfig) {
179
201
  return;
@@ -236,7 +258,23 @@ const SnkGrid = class {
236
258
  const dataInfo = { dataUnit: this._dataUnit };
237
259
  core.ElementIDUtils.addIDInfo(this._element, null, dataInfo);
238
260
  }
239
- finshLoading() {
261
+ loadGridCustomFormatters(fields) {
262
+ if (!fields || !this._grid) {
263
+ return;
264
+ }
265
+ fields.forEach((field) => {
266
+ var _a;
267
+ if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) {
268
+ this.addCustomValueFormatter(field.name, this._rmPrecisionCustomValueFormatter);
269
+ }
270
+ });
271
+ }
272
+ async interceptMetadataLoaded(action) {
273
+ this.loadGridCustomFormatters(action.payload.fields);
274
+ return action;
275
+ }
276
+ finishLoading() {
277
+ this._dataUnit.addInterceptor(this.dataUnitInterceptor);
240
278
  IExporterProvider.CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
241
279
  this.addElementID();
242
280
  if (this.columnFilterDataSource != undefined) {
@@ -255,17 +293,15 @@ const SnkGrid = class {
255
293
  if (!this._dataUnit) {
256
294
  this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
257
295
  this._dataUnit = evt.detail;
258
- this.finshLoading();
296
+ this.finishLoading();
259
297
  });
260
298
  }
261
299
  else {
262
- this.finshLoading();
300
+ this.finishLoading();
263
301
  }
264
302
  if (!this.messagesBuilder)
265
303
  this.messagesBuilder = this._snkDataUnit.messagesBuilder;
266
- this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
267
- this._dataState = evt.detail;
268
- });
304
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
269
305
  this._snkDataUnit.addEventListener("cancelEdition", () => {
270
306
  var _a;
271
307
  if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.recordsIsEmpty) {
@@ -276,9 +312,18 @@ const SnkGrid = class {
276
312
  }
277
313
  parent = parent.parentElement;
278
314
  }
315
+ this._rmPrecisionCustomValueFormatter = new IExporterProvider.RmPrecisionCustomValueFormatter();
279
316
  this.addGridLegacyConfigName();
280
317
  this.loadConfig();
281
318
  }
319
+ componentDidRender() {
320
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
321
+ this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
322
+ }
323
+ async handleDataStateChange(evt) {
324
+ this._dataState = evt.detail;
325
+ this._rmPrecisionCustomValueFormatter.setDataState(this._dataState);
326
+ }
282
327
  getHeaderDisabledButtons() {
283
328
  var _a;
284
329
  const disabledButtons = [];
@@ -2,18 +2,20 @@
2
2
 
3
3
  const index = require('./index-f9e81701.js');
4
4
  const core = require('@sankhyalabs/core');
5
- const SnkFormConfigManager = require('./SnkFormConfigManager-4259edbe.js');
5
+ const SnkFormConfigManager = require('./SnkFormConfigManager-dda10d75.js');
6
6
  const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
7
7
  const fieldSearch = require('./field-search-f56aa7d6.js');
8
8
  const taskbarElements = require('./taskbar-elements-d9392685.js');
9
9
  const constants = require('./constants-35ddd366.js');
10
- require('./form-config-fetcher-3c4daeb5.js');
11
- require('./pesquisa-fetcher-cb768be1.js');
10
+ require('./DataFetcher-515bda03.js');
11
+ require('./pesquisa-fetcher-916a935c.js');
12
12
  const index$1 = require('./index-0922807b.js');
13
13
  require('./ISave-e91b70a7.js');
14
14
  require('@sankhyalabs/ezui/dist/collection/utils/constants');
15
15
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
16
+ require('./dataunit-fetcher-e2109392.js');
16
17
  require('./filter-item-type.enum-a7ffdaa6.js');
18
+ require('./form-config-fetcher-3f430aee.js');
17
19
  const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
18
20
 
19
21
  const snkGuidesViewerCss = ".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";
@@ -47,6 +49,7 @@ const SnkGuidesViewer = class {
47
49
  this._formEditorConfigManager = undefined;
48
50
  this._formEditorDataUnit = undefined;
49
51
  this._fieldToGetFocus = undefined;
52
+ this._fieldsProps = {};
50
53
  }
51
54
  observeDataUnit() {
52
55
  this.loadGuides(true);
@@ -77,6 +80,15 @@ const SnkGuidesViewer = class {
77
80
  async findField() {
78
81
  await fieldSearch.openFieldSearch(this._moreOptions, this._fieldSearch);
79
82
  }
83
+ /**
84
+ * Altera/adiciona uma propriedade nos metadados do campo.
85
+ */
86
+ async setFieldProp(fieldName, propName, value) {
87
+ const newFieldsProps = {
88
+ [fieldName]: Object.assign(Object.assign({}, this._fieldsProps[fieldName]), { [propName]: value })
89
+ };
90
+ this._fieldsProps = Object.assign(Object.assign({}, this._fieldsProps), newFieldsProps);
91
+ }
80
92
  exitViewer() {
81
93
  if (this.dataUnit.isDirty()) {
82
94
  this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
@@ -219,7 +231,7 @@ const SnkGuidesViewer = class {
219
231
  if (sheet == undefined) {
220
232
  return;
221
233
  }
222
- return index.h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); } });
234
+ return index.h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); }, fieldsProps: params.fieldsProps });
223
235
  })));
224
236
  }
225
237
  wrapDetail(levels, content) {
@@ -268,7 +280,7 @@ const SnkGuidesViewer = class {
268
280
  const sheet = this._masterFormMetadata.getSheet(cardId);
269
281
  if (sheet) {
270
282
  const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
271
- content = index.h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler() }, this.presentationMode == index$1.PresentationMode.SECONDARY && this.buildTaskBar());
283
+ content = index.h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler(), fieldsProps: this._fieldsProps }, this.presentationMode == index$1.PresentationMode.SECONDARY && this.buildTaskBar());
272
284
  }
273
285
  }
274
286
  return content;
@@ -474,7 +486,8 @@ const SnkGuidesViewer = class {
474
486
  dataUnit: this.dataUnit,
475
487
  recordsValidator: this.recordsValidator,
476
488
  fieldToFocus: this._fieldToGetFocus,
477
- onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this)
489
+ onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this),
490
+ fieldsProps: this._fieldsProps
478
491
  }), this.getContent())), index.h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this.getConfigViewMode(), onConfigSelected: (evt) => this.changeConfigViewMode(evt.detail), messagesBuilder: this.messagesBuilder, onOpenConfig: (evt) => this.openConfig(evt.detail), resourceID: this.resourceID })));
479
492
  }
480
493
  static get watchers() { return {
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const snkGuidesViewer = require('./snk-guides-viewer-bec9c1a5.js');
5
+ const snkGuidesViewer = require('./snk-guides-viewer-af4a6ae5.js');
6
6
  require('./index-f9e81701.js');
7
7
  require('@sankhyalabs/core');
8
- require('./SnkFormConfigManager-4259edbe.js');
9
- require('./ConfigStorage-7df9d3bb.js');
10
- require('./form-config-fetcher-3c4daeb5.js');
8
+ require('./SnkFormConfigManager-dda10d75.js');
9
+ require('./ConfigStorage-9a53a42c.js');
10
+ require('./form-config-fetcher-3f430aee.js');
11
+ require('./DataFetcher-515bda03.js');
11
12
  require('./PrintUtils-bcaeb82f.js');
12
13
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
13
14
  require('./filter-item-type.enum-a7ffdaa6.js');
@@ -17,12 +18,13 @@ require('./taskbar-elements-d9392685.js');
17
18
  require('./index-0922807b.js');
18
19
  require('./index-102ba62d.js');
19
20
  require('./constants-35ddd366.js');
20
- require('./pesquisa-fetcher-cb768be1.js');
21
+ require('./pesquisa-fetcher-916a935c.js');
22
+ require('./ISave-e91b70a7.js');
21
23
  require('@sankhyalabs/ezui/dist/collection/utils/constants');
24
+ require('./dataunit-fetcher-e2109392.js');
22
25
  require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils');
23
26
  require('@sankhyalabs/core/dist/utils/SortingUtils');
24
27
  require('./ResourceIDUtils-5ff86aa7.js');
25
- require('./ISave-e91b70a7.js');
26
28
  require('@sankhyalabs/core/dist/dataunit/DataUnit');
27
29
 
28
30
 
@@ -5,12 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-f9e81701.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const PersonalizedFilterUtils = require('./PersonalizedFilterUtils-0184ffbb.js');
8
- const ConfigStorage = require('./ConfigStorage-7df9d3bb.js');
8
+ const ConfigStorage = require('./ConfigStorage-9a53a42c.js');
9
9
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
10
10
  const index$1 = require('./index-c5771aba.js');
11
11
  const index$2 = require('./index-102ba62d.js');
12
12
  require('./filter-item-type.enum-a7ffdaa6.js');
13
- require('./form-config-fetcher-3c4daeb5.js');
13
+ require('./form-config-fetcher-3f430aee.js');
14
+ require('./DataFetcher-515bda03.js');
14
15
  require('./PrintUtils-bcaeb82f.js');
15
16
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
16
17
 
@@ -7,24 +7,26 @@ const core = require('@sankhyalabs/core');
7
7
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
8
8
  const constants = require('./constants-35ddd366.js');
9
9
  const taskbarElements = require('./taskbar-elements-d9392685.js');
10
- const formConfigFetcher = require('./form-config-fetcher-3c4daeb5.js');
11
- const pesquisaFetcher = require('./pesquisa-fetcher-cb768be1.js');
12
- const IExporterProvider = require('./IExporterProvider-1ed8e92a.js');
10
+ require('./DataFetcher-515bda03.js');
11
+ require('./pesquisa-fetcher-916a935c.js');
12
+ const IExporterProvider = require('./IExporterProvider-d3a3ccd1.js');
13
13
  const index = require('./index-0922807b.js');
14
14
  require('./ISave-e91b70a7.js');
15
15
  require('@sankhyalabs/ezui/dist/collection/utils/constants');
16
16
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
17
+ const dataunitFetcher = require('./dataunit-fetcher-e2109392.js');
17
18
  require('./filter-item-type.enum-a7ffdaa6.js');
19
+ const formConfigFetcher = require('./form-config-fetcher-3f430aee.js');
18
20
  const fieldSearch = require('./field-search-f56aa7d6.js');
19
- const ConfigStorage = require('./ConfigStorage-7df9d3bb.js');
20
- const SnkFormConfigManager = require('./SnkFormConfigManager-4259edbe.js');
21
+ const ConfigStorage = require('./ConfigStorage-9a53a42c.js');
22
+ const SnkFormConfigManager = require('./SnkFormConfigManager-dda10d75.js');
21
23
  const RecordIDUtils = require('./RecordIDUtils-3735135c.js');
22
24
  const index$2 = require('./index-102ba62d.js');
23
25
  require('./PrintUtils-bcaeb82f.js');
26
+ require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource');
24
27
  require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils');
25
28
  require('@sankhyalabs/core/dist/utils/SortingUtils');
26
29
  require('./ResourceIDUtils-5ff86aa7.js');
27
- require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource');
28
30
 
29
31
  const REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
30
32
  const REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
@@ -75,6 +77,11 @@ class ClientSideExporterProvider extends IExporterProvider.CommonsExporter {
75
77
  if (fieldDescriptor.userInterface === core.UserInterface.SEARCH) {
76
78
  return value.value;
77
79
  }
80
+ if (column.customFormatter) {
81
+ const ezGridColumn = this.getColumnsState().find(columnState => column.id === columnState.name);
82
+ const formattedValue = column.customFormatter.format(value, ezGridColumn, record.__record__id__);
83
+ return formattedValue;
84
+ }
78
85
  return this.dataUnit.getFormattedValue(id, value);
79
86
  }
80
87
  }
@@ -113,6 +120,7 @@ const SnkSimpleCrud = class {
113
120
  this.gridConfig = undefined;
114
121
  this.formConfig = undefined;
115
122
  this._formFields = [];
123
+ this._fieldsProps = new Map();
116
124
  this.multipleSelection = undefined;
117
125
  this.useCancelConfirm = true;
118
126
  this.pageSize = 150;
@@ -137,6 +145,27 @@ const SnkSimpleCrud = class {
137
145
  this.loadFormConfig(true);
138
146
  this.loadGridConfig(true);
139
147
  }
148
+ /**
149
+ * Registra um formatador de valores para uma coluna da grid.
150
+ */
151
+ async addCustomValueFormatter(columnName, customFormatter) {
152
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
153
+ }
154
+ /**
155
+ * Remove o formatador de valores de uma coluna da grid.
156
+ */
157
+ async removeCustomValueFormatter(columnName) {
158
+ this._grid.removeCustomValueFormatter(columnName);
159
+ }
160
+ /**
161
+ * Altera/adiciona uma propriedade nos metadados do campo.
162
+ */
163
+ async setFieldProp(fieldName, propName, value) {
164
+ const newCustomFieldProps = new Map(this._fieldsProps);
165
+ const currentProps = this._fieldsProps.get(fieldName);
166
+ newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
167
+ this._fieldsProps = newCustomFieldProps;
168
+ }
140
169
  getButtons(selected, extraButtons) {
141
170
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
142
171
  .concat(extraButtons));
@@ -191,9 +220,7 @@ const SnkSimpleCrud = class {
191
220
  }
192
221
  }
193
222
  observeDataState(newValue, oldValue) {
194
- if (core.ObjectUtils.objectToString(oldValue) != core.ObjectUtils.objectToString(newValue)) {
195
- this.dataStateChange.emit(newValue);
196
- }
223
+ this.handleDataStateChange(newValue, oldValue);
197
224
  }
198
225
  async observeFormLegacy(newValue, oldValue) {
199
226
  await this.handleUpdateFormLegacyConfig(newValue, oldValue);
@@ -201,6 +228,28 @@ const SnkSimpleCrud = class {
201
228
  async observeGridLegacy(newValue, oldValue) {
202
229
  await this.handleUpdateGridLegacyConfig(newValue, oldValue);
203
230
  }
231
+ async handleDataStateChange(newValue, oldValue) {
232
+ if (core.ObjectUtils.objectToString(oldValue) != core.ObjectUtils.objectToString(newValue)) {
233
+ this.dataStateChange.emit(newValue);
234
+ }
235
+ await this.processRmPrecision();
236
+ }
237
+ async processRmPrecision() {
238
+ var _a, _b;
239
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
240
+ for (const field of fieldsWithRmPrecision || []) {
241
+ if (!field) {
242
+ continue;
243
+ }
244
+ const rmPrecision = (_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata) === null || _b === void 0 ? void 0 : _b.getProp('rm_precision', field);
245
+ if (!rmPrecision) {
246
+ continue;
247
+ }
248
+ await this.setFieldProp(field, 'precision', rmPrecision);
249
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
250
+ }
251
+ this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
252
+ }
204
253
  async handleUpdateGridLegacyConfig(newValue, oldValue) {
205
254
  if (newValue == undefined || newValue == oldValue) {
206
255
  return;
@@ -309,10 +358,16 @@ const SnkSimpleCrud = class {
309
358
  this.loadGridConfig();
310
359
  this.loadFormConfig();
311
360
  }
361
+ componentDidRender() {
362
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
363
+ this.addGridCustomValueFormattters();
364
+ this.setFieldsProps();
365
+ }
312
366
  componentWillLoad() {
313
367
  this.processMetadata();
314
368
  this.onModeChange();
315
369
  this.configDatasource();
370
+ this._rmPrecisionCustomValueFormatter = new IExporterProvider.RmPrecisionCustomValueFormatter();
316
371
  }
317
372
  componentDidLoad() {
318
373
  utils.CSSVarsUtils.applyVarsGrid(this._element, this._grid);
@@ -321,6 +376,17 @@ const SnkSimpleCrud = class {
321
376
  this._multiSelectionListDataSource.setApplication(this.application);
322
377
  this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
323
378
  }
379
+ setFieldsProps() {
380
+ if (!this._form) {
381
+ return;
382
+ }
383
+ for (const [fieldName, props] of this._fieldsProps) {
384
+ for (const prop in props) {
385
+ this._form.setFieldProp(fieldName, prop, props[prop]);
386
+ }
387
+ this._fieldsProps.delete(fieldName);
388
+ }
389
+ }
324
390
  getTaskBarId() {
325
391
  var _a, _b;
326
392
  if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
@@ -334,7 +400,7 @@ const SnkSimpleCrud = class {
334
400
  return this._currentViewMode === constants.VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
335
401
  }
336
402
  initInMemoryDataUnit() {
337
- this._inMemoryLoader = new pesquisaFetcher.InMemoryLoader(this._metadata);
403
+ this._inMemoryLoader = new dataunitFetcher.InMemoryLoader(this._metadata);
338
404
  this.dataUnit = this._inMemoryLoader.dataUnit;
339
405
  this.dataUnitReady.emit(this.dataUnit);
340
406
  }
@@ -373,12 +439,11 @@ const SnkSimpleCrud = class {
373
439
  var _a;
374
440
  (_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
375
441
  }
376
- updateConfig() {
442
+ async updateConfig() {
377
443
  if (this._formConfigManager == undefined) {
378
444
  this._formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resolveResourceID());
379
445
  }
380
446
  this._formConfigManager.setConfig(this.formConfig);
381
- return;
382
447
  }
383
448
  processMetadata() {
384
449
  const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
@@ -410,6 +475,23 @@ const SnkSimpleCrud = class {
410
475
  };
411
476
  }
412
477
  }
478
+ addGridCustomValueFormattters() {
479
+ var _a, _b, _c;
480
+ const metadataFields = ((_a = this._metadata) === null || _a === void 0 ? void 0 : _a.fields) || ((_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.fields);
481
+ if (!metadataFields) {
482
+ return;
483
+ }
484
+ const fieldsWithRmPrecision = [];
485
+ metadataFields.forEach((field) => {
486
+ var _a;
487
+ if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
488
+ fieldsWithRmPrecision.push(field.name);
489
+ }
490
+ });
491
+ fieldsWithRmPrecision.forEach(field => {
492
+ this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
493
+ });
494
+ }
413
495
  onDataStateChange(evt) {
414
496
  this.dataState = Object.assign({}, evt.detail);
415
497
  }
@@ -630,9 +712,9 @@ const SnkSimpleCrud = class {
630
712
  if (this.dataUnit == undefined) {
631
713
  return;
632
714
  }
633
- return (index$1.h("snk-data-unit", { 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.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, index$1.h("header", null, index$1.h("slot", { name: "snkSimpleCrudHeader" })), index$1.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, index$1.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", 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: index.PresentationMode.SECONDARY }, index$1.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index$1.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index$1.h("stack-item", null, index$1.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(constants.VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(pesquisaFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
715
+ return (index$1.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.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, index$1.h("header", null, index$1.h("slot", { name: "snkSimpleCrudHeader" })), index$1.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, index$1.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", 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: index.PresentationMode.SECONDARY }, index$1.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index$1.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index$1.h("stack-item", null, index$1.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(constants.VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
634
716
  ? undefined
635
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index$1.h("div", { slot: "footer" }, index$1.h("slot", { name: "snkSimpleCrudFooter" })))), index$1.h("stack-item", null, index$1.h("ez-form", { 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() && index$1.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && index$1.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 })), index$1.h("div", { id: `${this._customContainerId}` }, index$1.h("slot", { name: "SnkConfigContainerSlot" }))), index$1.h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, index$1.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
717
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index$1.h("div", { slot: "footer" }, index$1.h("slot", { name: "snkSimpleCrudFooter" })))), index$1.h("stack-item", null, index$1.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() && index$1.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && index$1.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 })), index$1.h("div", { id: `${this._customContainerId}` }, index$1.h("slot", { name: "SnkConfigContainerSlot" }))), index$1.h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, index$1.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
636
718
  }
637
719
  get _element() { return index$1.getElement(this); }
638
720
  static get watchers() { return {