@sankhyalabs/sankhyablocks 1.3.31-beta.16 → 1.3.31-beta.17

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 (170) hide show
  1. package/dist/cjs/{SnkMessageBuilder-79cf15c5.js → SnkMessageBuilder-cb132e6d.js} +133 -1
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/css-shim-b8158822.js +6 -0
  4. package/dist/cjs/dom-36862b77.js +75 -0
  5. package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
  6. package/dist/cjs/index-02201bc9.js +2397 -0
  7. package/dist/cjs/{index-5575fe3d.js → index-b0b676c5.js} +1598 -145
  8. package/dist/cjs/loader.cjs.js +18 -2
  9. package/dist/cjs/sankhyablocks.cjs.js +116 -4
  10. package/dist/cjs/shadow-css-346c0795.js +389 -0
  11. package/dist/cjs/snk-application.cjs.entry.js +542 -66
  12. package/dist/cjs/snk-crud.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +23 -24
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +199 -0
  15. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
  16. package/dist/cjs/snk-filter-detail.cjs.entry.js +44 -0
  17. package/dist/cjs/snk-filter-item.cjs.entry.js +131 -0
  18. package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
  19. package/dist/cjs/snk-filter-number.cjs.entry.js +23 -0
  20. package/dist/cjs/snk-filter-period.cjs.entry.js +26 -0
  21. package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
  22. package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
  23. package/dist/cjs/{snk-form_2.cjs.entry.js → snk-form.cjs.entry.js} +3 -65
  24. package/dist/cjs/snk-grid.cjs.entry.js +69 -0
  25. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  26. package/dist/cjs/snk-taskbar.cjs.entry.js +5 -4
  27. package/dist/cjs/{taskbar-elements-2ae0d005.js → taskbar-elements-efa44ff1.js} +1 -1
  28. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  29. package/dist/collection/collection-manifest.json +9 -0
  30. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +7 -0
  31. package/dist/collection/components/snk-application/snk-application.js +89 -17
  32. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
  33. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +64 -0
  34. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +69 -0
  35. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
  36. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
  37. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
  38. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +113 -0
  39. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +209 -0
  40. package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +182 -0
  41. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +99 -0
  42. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +257 -0
  43. package/dist/collection/components/snk-grid/snk-grid.css +14 -1
  44. package/dist/collection/components/snk-grid/snk-grid.js +1 -1
  45. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +24 -2
  46. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +1 -1
  47. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +268 -0
  48. package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
  49. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -0
  50. package/dist/components/SnkMessageBuilder.js +133 -2
  51. package/dist/components/filter-item-type.enum.js +12 -0
  52. package/dist/components/index.d.ts +9 -0
  53. package/dist/components/index.js +13 -0
  54. package/dist/components/index2.js +2384 -0
  55. package/dist/components/snk-application2.js +508 -30
  56. package/dist/components/snk-crud.js +25 -1
  57. package/dist/components/snk-data-unit.js +2 -3
  58. package/dist/components/snk-filter-bar.d.ts +11 -0
  59. package/dist/components/snk-filter-bar.js +6 -0
  60. package/dist/components/snk-filter-bar2.js +230 -0
  61. package/dist/components/snk-filter-binary-select.d.ts +11 -0
  62. package/dist/components/snk-filter-binary-select.js +63 -0
  63. package/dist/components/snk-filter-detail.d.ts +11 -0
  64. package/dist/components/snk-filter-detail.js +6 -0
  65. package/dist/components/snk-filter-detail2.js +58 -0
  66. package/dist/components/snk-filter-item.d.ts +11 -0
  67. package/dist/components/snk-filter-item.js +6 -0
  68. package/dist/components/snk-filter-item2.js +151 -0
  69. package/dist/components/snk-filter-list.d.ts +11 -0
  70. package/dist/components/snk-filter-list.js +6 -0
  71. package/dist/components/snk-filter-list2.js +108 -0
  72. package/dist/components/snk-filter-number.d.ts +11 -0
  73. package/dist/components/snk-filter-number.js +39 -0
  74. package/dist/components/snk-filter-period.d.ts +11 -0
  75. package/dist/components/snk-filter-period.js +42 -0
  76. package/dist/components/snk-filter-search.d.ts +11 -0
  77. package/dist/components/snk-filter-search.js +62 -0
  78. package/dist/components/snk-filter-text.d.ts +11 -0
  79. package/dist/components/snk-filter-text.js +38 -0
  80. package/dist/components/snk-form2.js +1 -1
  81. package/dist/components/snk-grid2.js +28 -4
  82. package/dist/components/snk-pesquisa2.js +1 -1
  83. package/dist/components/snk-taskbar2.js +2 -1
  84. package/dist/components/teste-pesquisa.js +1 -1
  85. package/dist/esm/{SnkMessageBuilder-3cdde541.js → SnkMessageBuilder-cff80920.js} +133 -2
  86. package/dist/esm/app-globals-0f993ce5.js +3 -0
  87. package/dist/esm/css-shim-b3f2ee8d.js +4 -0
  88. package/dist/esm/dom-665d6011.js +73 -0
  89. package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
  90. package/dist/esm/index-2b4d2d14.js +3262 -0
  91. package/dist/esm/index-e5b61043.js +2384 -0
  92. package/dist/esm/loader.js +18 -2
  93. package/dist/esm/sankhyablocks.js +116 -4
  94. package/dist/esm/shadow-css-b18e99d7.js +387 -0
  95. package/dist/esm/snk-application.entry.js +507 -31
  96. package/dist/esm/snk-crud.entry.js +1 -1
  97. package/dist/esm/snk-data-unit.entry.js +3 -4
  98. package/dist/esm/snk-filter-bar.entry.js +195 -0
  99. package/dist/esm/snk-filter-binary-select.entry.js +43 -0
  100. package/dist/esm/snk-filter-detail.entry.js +40 -0
  101. package/dist/esm/snk-filter-item.entry.js +127 -0
  102. package/dist/esm/snk-filter-list.entry.js +87 -0
  103. package/dist/esm/snk-filter-number.entry.js +19 -0
  104. package/dist/esm/snk-filter-period.entry.js +22 -0
  105. package/dist/esm/snk-filter-search.entry.js +40 -0
  106. package/dist/esm/snk-filter-text.entry.js +18 -0
  107. package/dist/esm/{snk-form_2.entry.js → snk-form.entry.js} +3 -64
  108. package/dist/esm/snk-grid.entry.js +65 -0
  109. package/dist/esm/snk-pesquisa.entry.js +2 -2
  110. package/dist/esm/snk-taskbar.entry.js +4 -3
  111. package/dist/esm/{taskbar-elements-bcccc0ff.js → taskbar-elements-c119510a.js} +1 -1
  112. package/dist/esm/teste-pesquisa.entry.js +2 -2
  113. package/dist/sankhyablocks/SnkMessageBuilder-cff80920.js +299 -0
  114. package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
  115. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
  116. package/dist/sankhyablocks/dom-665d6011.js +73 -0
  117. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
  118. package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
  119. package/dist/sankhyablocks/index-e5b61043.js +2384 -0
  120. package/dist/sankhyablocks/index.esm.js +1 -0
  121. package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
  122. package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
  123. package/dist/sankhyablocks/snk-application.entry.js +8306 -0
  124. package/dist/sankhyablocks/snk-crud.entry.js +60 -0
  125. package/dist/sankhyablocks/snk-data-unit.entry.js +272 -0
  126. package/dist/sankhyablocks/snk-filter-bar.entry.js +195 -0
  127. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
  128. package/dist/sankhyablocks/snk-filter-detail.entry.js +40 -0
  129. package/dist/sankhyablocks/snk-filter-item.entry.js +127 -0
  130. package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
  131. package/dist/sankhyablocks/snk-filter-number.entry.js +19 -0
  132. package/dist/sankhyablocks/snk-filter-period.entry.js +22 -0
  133. package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
  134. package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
  135. package/dist/sankhyablocks/snk-form.entry.js +111 -0
  136. package/dist/sankhyablocks/snk-grid.entry.js +65 -0
  137. package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
  138. package/dist/sankhyablocks/snk-taskbar.entry.js +153 -0
  139. package/dist/sankhyablocks/taskbar-elements-c119510a.js +72 -0
  140. package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
  141. package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
  142. package/dist/types/components/snk-application/snk-application.d.ts +9 -0
  143. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
  144. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
  145. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +13 -0
  146. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
  147. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
  148. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
  149. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +13 -0
  150. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +37 -0
  151. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +43 -0
  152. package/dist/types/components.d.ts +199 -0
  153. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  154. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +5 -0
  155. package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
  156. package/package.json +2 -2
  157. package/react/components.d.ts +0 -7
  158. package/react/components.js +0 -7
  159. package/react/components.js.map +1 -1
  160. package/dist/esm/index-cf91f542.js +0 -1817
  161. package/dist/sankhyablocks/p-1ba29824.entry.js +0 -74
  162. package/dist/sankhyablocks/p-2266555e.entry.js +0 -1
  163. package/dist/sankhyablocks/p-23c4c94f.js +0 -2
  164. package/dist/sankhyablocks/p-2454be94.js +0 -1
  165. package/dist/sankhyablocks/p-49743bc5.js +0 -1
  166. package/dist/sankhyablocks/p-4fa389bd.entry.js +0 -1
  167. package/dist/sankhyablocks/p-5327ba05.entry.js +0 -1
  168. package/dist/sankhyablocks/p-7a922fb4.entry.js +0 -1
  169. package/dist/sankhyablocks/p-92d6f826.entry.js +0 -1
  170. package/dist/sankhyablocks/p-bdeef7f2.entry.js +0 -1
@@ -0,0 +1,257 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { ApplicationContext, DataType, ErrorException, ObjectUtils } from '@sankhyalabs/core';
3
+ import FilterItemType from './filter-item/filter-item-type.enum';
4
+ import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
5
+ const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
6
+ const DEFAULT_FILTER = "DEFAULT_FILTER";
7
+ export class SnkFilterBar {
8
+ constructor() {
9
+ this._updateSequence = [];
10
+ this._calculateSortIndex = (item) => {
11
+ let index = item.hardFixed ? 1000000 : 0;
12
+ //campos Hard Fixed não variam a ordem
13
+ if (!item.hardFixed) {
14
+ index += item.fixed ? 100000 : 0;
15
+ index += item.value == undefined ? 0 : 10000;
16
+ index += this._updateSequence.lastIndexOf(item.id) + 1;
17
+ }
18
+ return index;
19
+ };
20
+ this._filtersComparator = (a, b) => {
21
+ return this._calculateSortIndex(b) - this._calculateSortIndex(a);
22
+ };
23
+ }
24
+ /**
25
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
26
+ * através de um pequeno modulo na estrutura da aplicação:
27
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
28
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
29
+ */
30
+ getMessage(key, params) {
31
+ return this._application.messagesBuilder.getMessage(key, params);
32
+ }
33
+ getFilter(_dataUnit) {
34
+ const filters = [];
35
+ this.filterConfig.filter(item => item.value).forEach(item => {
36
+ const filter = this.buildDUFilter(item);
37
+ if (filter) {
38
+ filters.push(filter);
39
+ }
40
+ });
41
+ return filters;
42
+ }
43
+ buildDUFilter(item) {
44
+ const { id, value, type, props, visible } = item;
45
+ if (value && visible) {
46
+ if (type === FilterItemType.BINARY_SELECT) {
47
+ const options = props.options;
48
+ const selectedOption = options.find(opt => opt.name === value);
49
+ //FIXME: ajustar o backend para não exigir parametros
50
+ return { name: id, expression: selectedOption.expression, params: [] };
51
+ }
52
+ if (type === FilterItemType.PERIOD) {
53
+ const { end, start } = value;
54
+ const params = [];
55
+ let expression;
56
+ if (end && start) {
57
+ expression = props.expression.fullfill;
58
+ params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
59
+ }
60
+ else {
61
+ if (start) {
62
+ expression = props.expression.onlystart;
63
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
64
+ }
65
+ else {
66
+ expression = props.expression.onlyend;
67
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
68
+ }
69
+ }
70
+ return { name: id, expression, params };
71
+ }
72
+ if (type === FilterItemType.SEARCH) {
73
+ const expression = props.expression;
74
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
75
+ }
76
+ if (type === FilterItemType.TEXT) {
77
+ const expression = props.expression;
78
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
79
+ }
80
+ if (type === FilterItemType.NUMBER) {
81
+ const expression = props.expression;
82
+ return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
83
+ }
84
+ //No mapeamento dos outros tipos precisamos saber o tipo de dado.
85
+ }
86
+ return undefined;
87
+ }
88
+ componentWillLoad() {
89
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
90
+ if (this._application) {
91
+ this._application.getFilterBarConfig()
92
+ .then((filters) => {
93
+ this.filterConfig = filters;
94
+ })
95
+ .catch(reason => {
96
+ throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
97
+ });
98
+ }
99
+ if (this.dataUnit == undefined) {
100
+ let parent = this._element.parentElement;
101
+ while (parent) {
102
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
103
+ const snkDataUnit = parent;
104
+ this.dataUnit = snkDataUnit.dataUnit;
105
+ if (this.dataUnit) {
106
+ this.dataUnit.addFilterProvider(this);
107
+ }
108
+ else {
109
+ snkDataUnit.addEventListener("dataUnitReady", (evt) => {
110
+ this.dataUnit = evt.detail;
111
+ this.dataUnit.addFilterProvider(this);
112
+ });
113
+ }
114
+ break;
115
+ }
116
+ parent = parent.parentElement;
117
+ }
118
+ }
119
+ }
120
+ getFilterItems() {
121
+ const pinnedItems = [];
122
+ const unpinnedItems = [];
123
+ this._items = this.filterConfig
124
+ .filter(item => item.visible)
125
+ .sort((a, b) => this._filtersComparator(a, b))
126
+ .map((item, index) => {
127
+ const filterItem = (h("snk-filter-item", { config: item, class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
128
+ if (item.fixed || item.hardFixed) {
129
+ pinnedItems.push(filterItem);
130
+ }
131
+ else {
132
+ unpinnedItems.push(filterItem);
133
+ }
134
+ return filterItem;
135
+ });
136
+ const elements = [];
137
+ elements.push(...pinnedItems);
138
+ if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
139
+ elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
140
+ }
141
+ elements.push(...unpinnedItems);
142
+ return elements;
143
+ }
144
+ calculateUpdateSequence(item) {
145
+ this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
146
+ this._updateSequence.push(item.id);
147
+ }
148
+ filterChangeListener(evt) {
149
+ this.updateFilter(evt.detail);
150
+ }
151
+ updateFilter(newItem) {
152
+ this.calculateUpdateSequence(newItem);
153
+ let needRefresh = false;
154
+ this.filterConfig = this.filterConfig.map(item => {
155
+ if (item.id === newItem.id) {
156
+ needRefresh = ObjectUtils.objectToString(item.value) !== ObjectUtils.objectToString(newItem.value);
157
+ return newItem;
158
+ }
159
+ return item;
160
+ });
161
+ if (needRefresh) {
162
+ this.dataUnit.loadData();
163
+ }
164
+ }
165
+ getAddListItems() {
166
+ const hiddenItems = this.filterConfig
167
+ .filter(item => !item.visible)
168
+ .sort(this._filtersComparator);
169
+ return hiddenItems.map(filter => {
170
+ return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
171
+ }).concat([
172
+ { name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" },
173
+ { name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" }
174
+ ]);
175
+ }
176
+ addFilterHandler(itemName) {
177
+ const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
178
+ if (filterItem) {
179
+ this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
180
+ }
181
+ }
182
+ render() {
183
+ if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
184
+ return undefined;
185
+ }
186
+ return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), h("ez-button", { mode: "icon", size: "small", iconName: "filter", class: "ez-padding-left--medium" }), h("snk-filter-list", { items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
187
+ }
188
+ static get is() { return "snk-filter-bar"; }
189
+ static get encapsulation() { return "scoped"; }
190
+ static get originalStyleUrls() {
191
+ return {
192
+ "$": ["snk-filter-bar.css"]
193
+ };
194
+ }
195
+ static get styleUrls() {
196
+ return {
197
+ "$": ["snk-filter-bar.css"]
198
+ };
199
+ }
200
+ static get properties() {
201
+ return {
202
+ "dataUnit": {
203
+ "type": "unknown",
204
+ "mutable": true,
205
+ "complexType": {
206
+ "original": "DataUnit",
207
+ "resolved": "DataUnit",
208
+ "references": {
209
+ "DataUnit": {
210
+ "location": "import",
211
+ "path": "@sankhyalabs/core"
212
+ }
213
+ }
214
+ },
215
+ "required": false,
216
+ "optional": false,
217
+ "docs": {
218
+ "tags": [],
219
+ "text": "Recebe o DataUnit do ambiente. Se n\u00E3o for informado, procura pela refer\u00EAncia\ndo SnkDataUnit. Necess\u00E1rio para se registrar como provedor de filtros."
220
+ }
221
+ },
222
+ "filterConfig": {
223
+ "type": "unknown",
224
+ "mutable": true,
225
+ "complexType": {
226
+ "original": "Array<SnkFilterItemConfig>",
227
+ "resolved": "SnkFilterItemConfig[]",
228
+ "references": {
229
+ "Array": {
230
+ "location": "global"
231
+ },
232
+ "SnkFilterItemConfig": {
233
+ "location": "import",
234
+ "path": "./filter-item/snk-filter-item"
235
+ }
236
+ }
237
+ },
238
+ "required": false,
239
+ "optional": false,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": "Lista de todos os filtros dispon\u00EDveis ao usu\u00E1rio."
243
+ }
244
+ }
245
+ };
246
+ }
247
+ static get elementRef() { return "_element"; }
248
+ static get listeners() {
249
+ return [{
250
+ "name": "filterChange",
251
+ "method": "filterChangeListener",
252
+ "target": undefined,
253
+ "capture": false,
254
+ "passive": false
255
+ }];
256
+ }
257
+ }
@@ -1,5 +1,18 @@
1
- :host {
1
+ .snk-grid__container{
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
5
5
  }
6
+
7
+ .snk-grid__header{
8
+ display: flex;
9
+ flex-wrap: nowrap;
10
+ width: 100%;
11
+ }
12
+
13
+ .snk-grid__filter-bar{
14
+ width: 100%;
15
+ }
16
+ .snk-grid__header-divider{
17
+ margin-bottom: var(--space--small);
18
+ }
@@ -48,7 +48,7 @@ export class SnkGrid {
48
48
  if (!this._configLoaded || !this._dataUnit) {
49
49
  return undefined;
50
50
  }
51
- return (h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" }, h("slot", { name: "SnkGridHeader" })), h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" }, h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))), h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: evt => { this.saveConfig(evt.detail); }, onEzDoubleClick: () => this.gridDoubleClick.emit() }, h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList })), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" }))));
51
+ 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-padding-bottom--medium ez-margin-bottom--medium" }, h("snk-filter-bar", { class: "snk-grid__filter-bar ez-align--top" }), 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", onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" })), h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: evt => { this.saveConfig(evt.detail); }, onEzDoubleClick: () => this.gridDoubleClick.emit() }, h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList })), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" }))));
52
52
  }
53
53
  static get is() { return "snk-grid"; }
54
54
  static get encapsulation() { return "scoped"; }
@@ -1,4 +1,4 @@
1
- import { ErrorException } from '@sankhyalabs/core';
1
+ import { ErrorException, WarningException } from '@sankhyalabs/core';
2
2
  import { batchRequests } from 'graphql-request';
3
3
  import UrlUtils from "../../../lib/utils/urlutils";
4
4
  import { StringUtils } from '@sankhyalabs/core';
@@ -33,6 +33,27 @@ export class DataFetcher {
33
33
  DataFetcher.requestListener.splice(index, 1);
34
34
  }
35
35
  }
36
+ processErrorInfo(errors) {
37
+ var _a, _b;
38
+ const POSITION_ERROR_INFO = 0;
39
+ const errorTitle = "Falha detectada";
40
+ const error = errors[POSITION_ERROR_INFO];
41
+ if (error.length > 0) { //As informações do erro vem no primeiro indice de um array
42
+ const errorInfo = error[POSITION_ERROR_INFO];
43
+ const errorMessage = (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.message) ? errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.message : "Não há mensagem de erro";
44
+ const errorLevel = ((_a = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.extensions) === null || _a === void 0 ? void 0 : _a.level) ? errorInfo.extensions.level : "ERROR";
45
+ const errorCode = ((_b = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.extensions) === null || _b === void 0 ? void 0 : _b.code) ? errorInfo.extensions.code : "";
46
+ switch (errorLevel) {
47
+ case "WARNING":
48
+ return new WarningException(errorTitle, errorMessage, errorCode);
49
+ default:
50
+ return new ErrorException(errorTitle, errorMessage, errorCode);
51
+ }
52
+ }
53
+ else {
54
+ return new ErrorException(errorTitle, "Não há informações sobre o erro");
55
+ }
56
+ }
36
57
  async callGraphQL(req) {
37
58
  var _a;
38
59
  const reqKey = this.getReqKey(req);
@@ -43,7 +64,8 @@ export class DataFetcher {
43
64
  let query = this.getQueryTemplate(req);
44
65
  const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
45
66
  if (res.errors.length > 0) {
46
- reject(new ErrorException("Falha detectada", res.errors[0][0].message));
67
+ const error = this.processErrorInfo(res.errors);
68
+ reject(error);
47
69
  }
48
70
  else {
49
71
  resolve(res.data[0][reqKey]);
@@ -146,7 +146,7 @@ export default class DataUnitFetcher {
146
146
  const { limit, offset, total, hasMore, records } = resp.data;
147
147
  let paginationInfo;
148
148
  if (limit) {
149
- const firstRecord = offset + 1;
149
+ const firstRecord = total == 0 ? 0 : offset + 1;
150
150
  const lastRecord = offset + Math.min(records.length, limit);
151
151
  const currentPage = offset / limit;
152
152
  paginationInfo = {
@@ -0,0 +1,268 @@
1
+ import FilterItemType from "../../../../components/snk-filter-bar/filter-item/filter-item-type.enum";
2
+ import { ResourceFetcher } from "./resource-fetcher";
3
+ export default class FilterBarConfigFetcher extends ResourceFetcher {
4
+ getConfig(resourceID) {
5
+ return new Promise((resolve) => {
6
+ if (resourceID === "br.com.sankhya.fin.cad.movimentacaoFinanceira") {
7
+ resolve([{
8
+ id: "RECDESP",
9
+ visible: true,
10
+ label: "Receitas + Despesas",
11
+ detailTitle: "Selecione o que deseja ver",
12
+ type: FilterItemType.BINARY_SELECT,
13
+ hardFixed: true,
14
+ props: {
15
+ options: [
16
+ { name: "RECEITA", expression: "this.RECDESP = 1", label: "Receitas" },
17
+ { name: "DESPESA", expression: "this.RECDESP = -1", label: "Despesas" }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ id: "PROVISAO",
23
+ visible: true,
24
+ label: "Real + Provisão",
25
+ detailTitle: "Selecione o que deseja ver",
26
+ type: FilterItemType.BINARY_SELECT,
27
+ hardFixed: true,
28
+ props: {
29
+ options: [
30
+ { name: "REAL", expression: "nullvalue(this.PROVISAO, 'N') = 'N'", label: "Real" },
31
+ { name: "PROVISAO", expression: "nullvalue(this.PROVISAO, 'N') = 'S'", label: "Provisão" }
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ id: "BAIXADO",
37
+ visible: true,
38
+ label: "Pendentes + Baixados",
39
+ detailTitle: "Selecione o que deseja ver",
40
+ type: FilterItemType.BINARY_SELECT,
41
+ hardFixed: true,
42
+ props: {
43
+ options: [
44
+ { name: "PENDENTE", expression: "this.DHBAIXA IS NULL", label: "Pendentes" },
45
+ { name: "BAIXADO", expression: "this.DHBAIXA IS NOT NULL", label: "Baixados" }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ id: "DTVENC",
51
+ visible: true,
52
+ type: FilterItemType.PERIOD,
53
+ label: "Dt. Vencimento",
54
+ detailTitle: "Informe a data ou período",
55
+ props: {
56
+ expression: {
57
+ fullfill: "onlydate(this.DTVENC) >= :DTVENC.START AND onlydate(this.DTVENC) <= :DTVENC.END",
58
+ onlystart: "onlydate(this.DTVENC) >= :DTVENC",
59
+ onlyend: "onlydate(this.DTVENC) <= :DTVENC"
60
+ }
61
+ }
62
+ },
63
+ {
64
+ id: "CODPARC",
65
+ visible: true,
66
+ type: FilterItemType.SEARCH,
67
+ label: "Parceiro",
68
+ detailTitle: "Informe o parceiro",
69
+ props: {
70
+ expression: "this.CODPARC = :CODPARC",
71
+ searchContext: {
72
+ entity: "Parceiro",
73
+ entityDescription: "Parceiro",
74
+ searchOptions: {
75
+ rootEntity: "Financeiro",
76
+ descriptionFieldName: "NOMEPARC",
77
+ codeFieldName: "CODPARC",
78
+ showInactives: false
79
+ }
80
+ }
81
+ }
82
+ },
83
+ {
84
+ id: "NUFIN",
85
+ type: FilterItemType.NUMBER,
86
+ visible: true,
87
+ label: "Nr. único",
88
+ detailTitle: "Informe o número único",
89
+ props: {
90
+ expression: "this.NUFIN = :NUFIN"
91
+ }
92
+ },
93
+ {
94
+ id: "NUMNOTA",
95
+ visible: true,
96
+ type: FilterItemType.NUMBER,
97
+ label: "Nr. Nota",
98
+ detailTitle: "Informe o número da nota",
99
+ props: {
100
+ expression: "this.NUMNOTA = :NUMNOTA"
101
+ }
102
+ },
103
+ {
104
+ id: "DHBAIXA",
105
+ visible: true,
106
+ type: FilterItemType.PERIOD,
107
+ label: "Data da Baixa",
108
+ detailTitle: "Informe a data ou período",
109
+ props: {
110
+ expression: {
111
+ fullfill: "onlydate(this.DHBAIXA) >= :DHBAIXA.START AND onlydate(this.DHBAIXA) <= :DHBAIXA.END",
112
+ onlystart: "onlydate(this.DHBAIXA) >= :DHBAIXA",
113
+ onlyend: "onlydate(this.DHBAIXA) <= :DHBAIXA"
114
+ }
115
+ }
116
+ },
117
+ {
118
+ id: "CODEMP",
119
+ visible: false,
120
+ type: FilterItemType.SEARCH,
121
+ label: "Empresa",
122
+ detailTitle: "Informe a empresa",
123
+ props: {
124
+ expression: "this.CODEMP = :CODEMP",
125
+ searchContext: {
126
+ entity: "Empresa",
127
+ entityDescription: "Empresa",
128
+ searchOptions: {
129
+ rootEntity: "Financeiro",
130
+ descriptionFieldName: "NOMEFANTASIA",
131
+ codeFieldName: "CODEMP",
132
+ showInactives: false
133
+ }
134
+ }
135
+ }
136
+ },
137
+ {
138
+ id: "CODNAT",
139
+ visible: false,
140
+ type: FilterItemType.SEARCH,
141
+ label: "Natureza",
142
+ detailTitle: "Informe a natureza",
143
+ props: {
144
+ expression: "this.CODNAT = :CODNAT",
145
+ searchContext: {
146
+ entity: "Natureza",
147
+ entityDescription: "Natureza",
148
+ searchOptions: {
149
+ rootEntity: "Financeiro",
150
+ descriptionFieldName: "DESCRNAT",
151
+ codeFieldName: "CODNAT",
152
+ showInactives: false
153
+ }
154
+ }
155
+ }
156
+ },
157
+ {
158
+ id: "DTNEG",
159
+ visible: false,
160
+ type: FilterItemType.PERIOD,
161
+ label: "Dt. Negociação",
162
+ detailTitle: "Informe a data ou período",
163
+ props: {
164
+ expression: {
165
+ fullfill: "onlydate(this.DTNEG) >= :DTNEG.START AND onlydate(this.DTNEG) <= :DTNEG.END",
166
+ onlystart: "onlydate(this.DTNEG) >= :DTNEG",
167
+ onlyend: "onlydate(this.DTNEG) <= :DTNEG"
168
+ }
169
+ }
170
+ },
171
+ {
172
+ id: "NUNOTA",
173
+ visible: false,
174
+ type: FilterItemType.NUMBER,
175
+ label: "Nro Único do Pedido",
176
+ detailTitle: "Informe o número único do pedido",
177
+ props: {
178
+ expression: "this.NUNOTA = :NUNOTA"
179
+ }
180
+ },
181
+ {
182
+ id: "CODCENCUS",
183
+ visible: false,
184
+ type: FilterItemType.SEARCH,
185
+ label: "Centro de resultado",
186
+ detailTitle: "Informe o centro de resultado",
187
+ props: {
188
+ expression: "this.CODCENCUS = :CODCENCUS",
189
+ searchContext: {
190
+ entity: "CentroResultado",
191
+ entityDescription: "Centro de resultado",
192
+ searchOptions: {
193
+ rootEntity: "Financeiro",
194
+ descriptionFieldName: "DESCRCENCUS",
195
+ codeFieldName: "CODCENCUS",
196
+ showInactives: false
197
+ }
198
+ }
199
+ }
200
+ },
201
+ {
202
+ id: "CODCTABCOINT",
203
+ visible: false,
204
+ type: FilterItemType.SEARCH,
205
+ label: "Conta bancária",
206
+ detailTitle: "Informe a conta bancária",
207
+ props: {
208
+ expression: "this.CODCTABCOINT = :CODCTABCOINT",
209
+ searchContext: {
210
+ entity: "ContaBancaria",
211
+ entityDescription: "Conta bancária",
212
+ searchOptions: {
213
+ rootEntity: "Financeiro",
214
+ descriptionFieldName: "DESCRICAO",
215
+ codeFieldName: "CODCTABCOINT",
216
+ showInactives: false
217
+ }
218
+ }
219
+ }
220
+ },
221
+ {
222
+ id: "CODBCO",
223
+ visible: false,
224
+ type: FilterItemType.SEARCH,
225
+ label: "Banco",
226
+ detailTitle: "Informe o banco",
227
+ props: {
228
+ expression: "this.CODBCO = :CODBCO",
229
+ searchContext: {
230
+ entity: "Banco",
231
+ entityDescription: "Banco",
232
+ searchOptions: {
233
+ rootEntity: "Financeiro",
234
+ descriptionFieldName: "NOMEBCO",
235
+ codeFieldName: "CODBCO",
236
+ showInactives: false
237
+ }
238
+ }
239
+ }
240
+ },
241
+ {
242
+ id: "CODPROJ",
243
+ visible: false,
244
+ type: FilterItemType.SEARCH,
245
+ label: "Projeto",
246
+ detailTitle: "Informe o projeto",
247
+ props: {
248
+ expression: "this.CODPROJ = :CODPROJ",
249
+ searchContext: {
250
+ entity: "Projeto",
251
+ entityDescription: "Projeto",
252
+ searchOptions: {
253
+ rootEntity: "Financeiro",
254
+ descriptionFieldName: "IDENTIFICACAO",
255
+ codeFieldName: "CODPROJ",
256
+ showInactives: false
257
+ }
258
+ }
259
+ }
260
+ }
261
+ ]);
262
+ }
263
+ else {
264
+ resolve(undefined);
265
+ }
266
+ });
267
+ }
268
+ }
@@ -1,4 +1,5 @@
1
1
  import snkDataUnitMessages from "./resources/snk-data-unit.msg.js";
2
+ import snkFilterBarMessages from "./resources/snk-filter-bar.msg.js";
2
3
  import snkFormMessages from "./resources/snk-form.msg.js";
3
4
  import snkTaskbarMessages from "./resources/snk-taskbar.msg.js";
4
5
  export class SnkMessageBuilder {
@@ -6,7 +7,8 @@ export class SnkMessageBuilder {
6
7
  this._defaults = {
7
8
  snkDataUnit: snkDataUnitMessages,
8
9
  snkForm: snkFormMessages,
9
- snkTaskbar: snkTaskbarMessages
10
+ snkTaskbar: snkTaskbarMessages,
11
+ snkFilterBar: snkFilterBarMessages
10
12
  };
11
13
  this._currentOperation = OperationMap.CLEAN;
12
14
  this.loadAppMessages().then((msgs) => {
@@ -0,0 +1,14 @@
1
+ const snkFilterBarMessages = {
2
+ "addFilter": "Adicionar filtro",
3
+ "pinFilter": "Fixar filtro",
4
+ "unpinFilter": "Desfixar filtro",
5
+ "removeFilter": "Remover filtro",
6
+ "cleanFilter": "Limpar",
7
+ "applyFilter": "Aplicar",
8
+ "findFilter": "Buscar campo...",
9
+ "emptyFilterList": "Há há campos disponíveis",
10
+ "customFilter": "Filtro personalizado",
11
+ "defaultFilter": "Filtro padrao",
12
+ "failToLoadConfig": "Falha ao buscar configuração de filtros"
13
+ };
14
+ export default snkFilterBarMessages;