@sankhyalabs/sankhyablocks 9.2.0-dev.17 → 9.2.0-dev.19
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.
- package/dist/cjs/{ConfigStorage-0ebc800f.js → ConfigStorage-52c38bb9.js} +2 -2
- package/dist/cjs/{DataFetcher-602cdc72.js → DataFetcher-9af55840.js} +15 -0
- package/dist/cjs/{ISave-18205d86.js → ISave-c4918000.js} +1 -1
- package/dist/cjs/{SnkFormConfigManager-4b651537.js → SnkFormConfigManager-cef663d1.js} +2 -2
- package/dist/cjs/{ClientSideExporterProvider-bb0b2273.js → SnkMultiSelectionListDataSource-58ded10c.js} +78 -78
- package/dist/cjs/{auth-fetcher-82317d4d.js → auth-fetcher-a3a3bb16.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-93077a2f.js → dataunit-fetcher-ae454648.js} +1 -1
- package/dist/cjs/filter-validate-6993f6f2.js +30 -0
- package/dist/cjs/{form-config-fetcher-05d210e7.js → form-config-fetcher-d7bb4f41.js} +1 -1
- package/dist/cjs/index-1cf293c1.js +8 -8
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +4 -4
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_8.cjs.entry.js +5 -5
- package/dist/cjs/snk-application.cjs.entry.js +6 -6
- package/dist/cjs/snk-attach.cjs.entry.js +5 -5
- package/dist/cjs/snk-crud.cjs.entry.js +5 -5
- package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -5
- package/dist/cjs/{snk-data-unit-28d629e4.js → snk-data-unit-a59a7ade.js} +2 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +7 -7
- package/dist/cjs/snk-entity-list.cjs.entry.js +10 -3
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +164 -100
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +23 -2
- package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +20 -2
- package/dist/cjs/snk-filter-detail.cjs.entry.js +25 -8
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +9 -14
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +16 -3
- package/dist/cjs/snk-filter-number.cjs.entry.js +34 -3
- package/dist/cjs/snk-filter-period.cjs.entry.js +59 -14
- package/dist/cjs/snk-filter-search.cjs.entry.js +14 -3
- package/dist/cjs/snk-filter-text.cjs.entry.js +18 -1
- package/dist/cjs/snk-form_2.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid.cjs.entry.js +38 -21
- package/dist/cjs/{snk-guides-viewer-73d40f42.js → snk-guides-viewer-e7c08c71.js} +5 -5
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-pesquisa.cjs.entry.js +4 -4
- package/dist/cjs/snk-simple-crud.cjs.entry.js +13 -13
- package/dist/collection/components/snk-entity-list/snk-entity-list.js +28 -4
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +72 -2
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +73 -2
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +51 -5
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +83 -3
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +118 -27
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +49 -5
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +71 -1
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +62 -11
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +70 -8
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.css +0 -4
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +112 -16
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +8 -16
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +106 -52
- package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
- package/dist/collection/components/snk-filter-bar/utils/filter-validate.js +24 -0
- package/dist/collection/components/snk-grid/snk-grid.js +89 -11
- package/dist/collection/lib/message/resources/en-us/snk-filter-bar.msg.js +1 -0
- package/dist/collection/lib/message/resources/en-us/snk-grid.msg.js +4 -0
- package/dist/collection/lib/message/resources/es-es/snk-filter-bar.msg.js +1 -0
- package/dist/collection/lib/message/resources/es-es/snk-grid.msg.js +4 -0
- package/dist/collection/lib/message/resources/pt-br/snk-filter-bar.msg.js +1 -0
- package/dist/collection/lib/message/resources/pt-br/snk-grid.msg.js +4 -0
- package/dist/components/DataFetcher.js +15 -0
- package/dist/components/snk-crud.js +62 -44
- package/dist/components/snk-detail-view2.js +89 -56
- package/dist/components/snk-entity-list.js +11 -3
- package/dist/components/snk-filter-bar2.js +77 -93
- package/dist/components/snk-filter-binary-select.js +27 -3
- package/dist/components/snk-filter-checkbox-list.js +24 -3
- package/dist/components/snk-filter-detail2.js +28 -9
- package/dist/components/snk-filter-item2.js +70 -8
- package/dist/components/snk-filter-modal-item2.js +7 -12
- package/dist/components/snk-filter-modal.js +1 -325
- package/dist/components/snk-filter-modal2.js +391 -0
- package/dist/components/snk-filter-multi-select.js +19 -4
- package/dist/components/snk-filter-number.js +38 -4
- package/dist/components/snk-filter-period.js +64 -16
- package/dist/components/snk-filter-search.js +17 -4
- package/dist/components/snk-filter-text.js +22 -2
- package/dist/components/snk-grid2.js +65 -29
- package/dist/esm/{ConfigStorage-fc4e3a42.js → ConfigStorage-1e758486.js} +2 -2
- package/dist/esm/{DataFetcher-01ce1a4f.js → DataFetcher-2f7ba7ae.js} +15 -0
- package/dist/esm/{ISave-d36bade4.js → ISave-4c9742c1.js} +1 -1
- package/dist/esm/{SnkFormConfigManager-71dae34e.js → SnkFormConfigManager-d7031fcb.js} +2 -2
- package/dist/esm/{ClientSideExporterProvider-21a99af1.js → SnkMultiSelectionListDataSource-eace25fd.js} +83 -83
- package/dist/esm/{auth-fetcher-2e565c35.js → auth-fetcher-d8169b9c.js} +1 -1
- package/dist/esm/{dataunit-fetcher-14ba162b.js → dataunit-fetcher-1f7a73df.js} +1 -1
- package/dist/esm/filter-validate-d765d450.js +27 -0
- package/dist/esm/{form-config-fetcher-a1ccc944.js → form-config-fetcher-eb03ac08.js} +1 -1
- package/dist/esm/index-479e1293.js +8 -8
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-grid_2.entry.js +4 -4
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_8.entry.js +5 -5
- package/dist/esm/snk-application.entry.js +6 -6
- package/dist/esm/snk-attach.entry.js +5 -5
- package/dist/esm/snk-crud.entry.js +5 -5
- package/dist/esm/snk-data-exporter.entry.js +5 -5
- package/dist/esm/{snk-data-unit-3977725e.js → snk-data-unit-a94dd52a.js} +2 -2
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-detail-view.entry.js +7 -7
- package/dist/esm/snk-entity-list.entry.js +10 -3
- package/dist/esm/snk-filter-bar_4.entry.js +165 -101
- package/dist/esm/snk-filter-binary-select.entry.js +23 -2
- package/dist/esm/snk-filter-checkbox-list.entry.js +20 -2
- package/dist/esm/snk-filter-detail.entry.js +25 -8
- package/dist/esm/snk-filter-modal-item.entry.js +9 -14
- package/dist/esm/snk-filter-multi-select.entry.js +16 -3
- package/dist/esm/snk-filter-number.entry.js +34 -3
- package/dist/esm/snk-filter-period.entry.js +59 -14
- package/dist/esm/snk-filter-search.entry.js +14 -3
- package/dist/esm/snk-filter-text.entry.js +18 -1
- package/dist/esm/snk-form_2.entry.js +4 -4
- package/dist/esm/snk-grid.entry.js +31 -14
- package/dist/esm/{snk-guides-viewer-f800c9aa.js → snk-guides-viewer-e716659f.js} +5 -5
- package/dist/esm/snk-guides-viewer.entry.js +7 -7
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-pesquisa.entry.js +4 -4
- package/dist/esm/snk-simple-crud.entry.js +8 -8
- package/dist/sankhyablocks/p-093f58fa.entry.js +1 -0
- package/dist/sankhyablocks/{p-e63cc25f.js → p-0dc071de.js} +1 -1
- package/dist/sankhyablocks/{p-f4bf0517.entry.js → p-0f6f2a84.entry.js} +1 -1
- package/dist/sankhyablocks/{p-2b2c2718.js → p-1129ded7.js} +1 -1
- package/dist/sankhyablocks/p-12cba660.entry.js +1 -0
- package/dist/sankhyablocks/{p-51209229.js → p-12db5588.js} +1 -1
- package/dist/sankhyablocks/{p-65517fcf.js → p-3d4a3965.js} +1 -1
- package/dist/sankhyablocks/p-3ed04f0d.entry.js +1 -0
- package/dist/sankhyablocks/{p-b6b42620.entry.js → p-4033a6e3.entry.js} +1 -1
- package/dist/sankhyablocks/p-49ddc27a.entry.js +1 -0
- package/dist/sankhyablocks/{p-c3eea705.entry.js → p-4a42d004.entry.js} +1 -1
- package/dist/sankhyablocks/p-4c763b10.entry.js +1 -0
- package/dist/sankhyablocks/p-4eeb06fc.js +1 -0
- package/dist/sankhyablocks/{p-dc8bb41f.js → p-552bdfdc.js} +1 -1
- package/dist/sankhyablocks/{p-3cdfd7fb.js → p-66e6569e.js} +1 -1
- package/dist/sankhyablocks/p-6909c146.entry.js +1 -0
- package/dist/sankhyablocks/p-69d0afa4.js +1 -0
- package/dist/sankhyablocks/{p-c3bab5f4.js → p-75b80a92.js} +1 -1
- package/dist/sankhyablocks/p-7f7fe6c4.entry.js +1 -0
- package/dist/sankhyablocks/{p-e5571279.entry.js → p-86009ea5.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7b97f9af.entry.js → p-864066bb.entry.js} +1 -1
- package/dist/sankhyablocks/p-96d45943.entry.js +1 -0
- package/dist/sankhyablocks/{p-34222890.entry.js → p-a0b4c940.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a60028f1.entry.js → p-a4be272f.entry.js} +1 -1
- package/dist/sankhyablocks/p-ab2ba522.entry.js +1 -0
- package/dist/sankhyablocks/p-ac9488fd.entry.js +1 -0
- package/dist/sankhyablocks/{p-7a1d3cb6.entry.js → p-b1d8cbf7.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7535d592.js → p-b393f1df.js} +1 -1
- package/dist/sankhyablocks/{p-dfbe4d7f.entry.js → p-c5d281ad.entry.js} +1 -1
- package/dist/sankhyablocks/{p-41e5a485.entry.js → p-c6d8c86b.entry.js} +1 -1
- package/dist/sankhyablocks/p-cb4343c4.entry.js +1 -0
- package/dist/sankhyablocks/p-d235314c.entry.js +1 -0
- package/dist/sankhyablocks/{p-dde9da7a.entry.js → p-d76f1aa5.entry.js} +1 -1
- package/dist/sankhyablocks/{p-aba06047.entry.js → p-de58a26f.entry.js} +1 -1
- package/dist/sankhyablocks/p-e258de96.entry.js +1 -0
- package/dist/sankhyablocks/p-fd8047b8.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +8 -4
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +12 -4
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +16 -4
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +17 -3
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +10 -2
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +8 -3
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +27 -4
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +17 -3
- package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +2 -3
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +15 -2
- package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +4 -2
- package/dist/types/components/snk-filter-bar/utils/filter-validate.d.ts +11 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +21 -8
- package/dist/types/components.d.ts +202 -17
- package/package.json +1 -1
- package/dist/sankhyablocks/p-07b14811.entry.js +0 -1
- package/dist/sankhyablocks/p-082e7ba8.entry.js +0 -1
- package/dist/sankhyablocks/p-25209340.entry.js +0 -1
- package/dist/sankhyablocks/p-295b83ae.entry.js +0 -1
- package/dist/sankhyablocks/p-3143bb44.entry.js +0 -1
- package/dist/sankhyablocks/p-353b4a74.js +0 -1
- package/dist/sankhyablocks/p-398cdd67.entry.js +0 -1
- package/dist/sankhyablocks/p-5bab470d.entry.js +0 -1
- package/dist/sankhyablocks/p-9fd87bfd.entry.js +0 -1
- package/dist/sankhyablocks/p-a76e6d51.entry.js +0 -1
- package/dist/sankhyablocks/p-ae2ebab7.js +0 -1
- package/dist/sankhyablocks/p-b21aa190.entry.js +0 -1
- package/dist/sankhyablocks/p-c6a8a8bc.entry.js +0 -1
- package/dist/sankhyablocks/p-c8932b14.entry.js +0 -1
- package/dist/sankhyablocks/p-dff65083.entry.js +0 -1
@@ -1,9 +1,10 @@
|
|
1
|
-
import { ElementIDUtils,
|
1
|
+
import { DateUtils, ElementIDUtils, KeyboardManager, MaskFormatter } from '@sankhyalabs/core';
|
2
2
|
import { h, Host } from '@stencil/core';
|
3
|
-
import FilterItemType from './filter-item-type.enum';
|
4
3
|
import { FilterNumberVariation } from './editors/enum/filterNumberVariation';
|
4
|
+
import FilterItemType from './filter-item-type.enum';
|
5
5
|
export class SnkFilterItem {
|
6
6
|
constructor() {
|
7
|
+
this._keyboardManager = undefined;
|
7
8
|
this.detailIsVisible = undefined;
|
8
9
|
this.config = undefined;
|
9
10
|
this.getMessage = undefined;
|
@@ -27,13 +28,15 @@ export class SnkFilterItem {
|
|
27
28
|
if (open) {
|
28
29
|
await ((_a = this._chipElement) === null || _a === void 0 ? void 0 : _a.setBlur());
|
29
30
|
await this._popover.showUnder(this._chipElement);
|
31
|
+
await this._filterDetail.setFocusField();
|
30
32
|
}
|
31
33
|
}
|
32
34
|
/**
|
33
35
|
* Oculta os detalhes de um item da lista.
|
34
36
|
*/
|
35
37
|
async hideDetail() {
|
36
|
-
|
38
|
+
var _a;
|
39
|
+
await ((_a = this._popover) === null || _a === void 0 ? void 0 : _a.hide());
|
37
40
|
}
|
38
41
|
getConfigChanges() {
|
39
42
|
var _a;
|
@@ -53,12 +56,15 @@ export class SnkFilterItem {
|
|
53
56
|
this.filterChange.emit(configChanged);
|
54
57
|
}
|
55
58
|
else {
|
56
|
-
this.togglePopover();
|
59
|
+
this.togglePopover(event);
|
57
60
|
}
|
58
61
|
}
|
59
62
|
async togglePopover(event) {
|
60
63
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
61
64
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
65
|
+
if (this.config.enabled === false) {
|
66
|
+
return;
|
67
|
+
}
|
62
68
|
if (this.detailIsVisible) {
|
63
69
|
await this.hideDetail();
|
64
70
|
}
|
@@ -207,8 +213,9 @@ export class SnkFilterItem {
|
|
207
213
|
return undefined;
|
208
214
|
}
|
209
215
|
hasActiveElements(value) {
|
210
|
-
var _a
|
211
|
-
|
216
|
+
var _a;
|
217
|
+
const list = Array.isArray(value) ? value : value === null || value === void 0 ? void 0 : value.elements;
|
218
|
+
return ((_a = list === null || list === void 0 ? void 0 : list.filter((val) => val === null || val === void 0 ? void 0 : val.check)) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
212
219
|
}
|
213
220
|
hasActiveValue(config) {
|
214
221
|
return (config.type !== FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
|
@@ -223,12 +230,67 @@ export class SnkFilterItem {
|
|
223
230
|
}
|
224
231
|
return this.hasActiveValue(this.config);
|
225
232
|
}
|
226
|
-
handleVisibilityPopover(event) {
|
233
|
+
async handleVisibilityPopover(event) {
|
227
234
|
this.detailIsVisible = event.detail;
|
235
|
+
if (!this.detailIsVisible) {
|
236
|
+
await this._filterDetail.clearValue();
|
237
|
+
}
|
238
|
+
}
|
239
|
+
getCustomMessage(key, params) {
|
240
|
+
var _a;
|
241
|
+
return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
|
242
|
+
}
|
243
|
+
hasValue() {
|
244
|
+
if (this.config.type === FilterItemType.MULTI_LIST) {
|
245
|
+
return this.hasActiveElements(this.config.value);
|
246
|
+
}
|
247
|
+
return this.config.value !== undefined && this.config.value !== null;
|
248
|
+
}
|
249
|
+
getTooltipMessage() {
|
250
|
+
var _a, _b;
|
251
|
+
if (this.config.required && !this.hasValue()) {
|
252
|
+
return {
|
253
|
+
message: (_a = this.config.requiredMessage) !== null && _a !== void 0 ? _a : this.getCustomMessage('validations.requiredFilter'),
|
254
|
+
type: 'error'
|
255
|
+
};
|
256
|
+
}
|
257
|
+
if (this.config.enabled === false && this.config.disabledMessage) {
|
258
|
+
return { message: this.config.disabledMessage, type: 'warning' };
|
259
|
+
}
|
260
|
+
return {
|
261
|
+
message: (_b = this.config.defaultMessage) !== null && _b !== void 0 ? _b : this.getLabel(true),
|
262
|
+
type: 'default'
|
263
|
+
};
|
264
|
+
}
|
265
|
+
getTypeChip(type) {
|
266
|
+
switch (type) {
|
267
|
+
case 'default':
|
268
|
+
return 'secondary';
|
269
|
+
case 'warning':
|
270
|
+
return 'warning-light';
|
271
|
+
case 'error':
|
272
|
+
return 'error-light';
|
273
|
+
case 'success':
|
274
|
+
return 'success-light';
|
275
|
+
default:
|
276
|
+
return type;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
initKeyboardManager() {
|
280
|
+
this._keyboardManager = new KeyboardManager({ element: this._filterItemElement, propagate: true });
|
281
|
+
this._keyboardManager
|
282
|
+
.bind("Escape", () => this.hideDetail());
|
283
|
+
}
|
284
|
+
connectedCallback() {
|
285
|
+
this.initKeyboardManager();
|
286
|
+
}
|
287
|
+
disconnectedCallback() {
|
288
|
+
this._keyboardManager.unbindAllShortcutKeys();
|
228
289
|
}
|
229
290
|
render() {
|
230
291
|
const leftIcon = this.getLeftIconName();
|
231
|
-
|
292
|
+
const { type, message } = this.getTooltipMessage();
|
293
|
+
return (h(Host, null, this.showChips && (h("ez-tooltip", { id: this.config.id, message: message, type: type, active: !this.detailIsVisible, strategy: "fixed" }, h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip(), onClick: (event) => this.togglePopover(event), disableAutoUpdateValue: true, type: this.getTypeChip(type), enabled: this.config.enabled }, leftIcon && (h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, slot: "leftIcon" })), h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), slot: "rightIcon", id: "removeFilter", onClick: (event) => this.clearFilter(event) })))), h("ez-popover-core", { ref: elem => this._popover = elem, onEzVisibilityChange: (event) => this.handleVisibilityPopover(event) }, h("snk-filter-detail", { ref: ref => this._filterDetail = ref, key: this.config.id, config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips && !this.config.required, removalBlocked: this.config.required }))));
|
232
294
|
}
|
233
295
|
static get is() { return "snk-filter-item"; }
|
234
296
|
static get encapsulation() { return "scoped"; }
|
@@ -3,8 +3,6 @@ ez-modal {
|
|
3
3
|
}
|
4
4
|
|
5
5
|
.snk-filter-modal__container {
|
6
|
-
width: 344px;
|
7
|
-
max-width: 344px;
|
8
6
|
min-width: 344px;
|
9
7
|
overflow: hidden;
|
10
8
|
}
|
@@ -24,8 +22,6 @@ ez-modal {
|
|
24
22
|
|
25
23
|
.snk-filter-modal__rendered-items {
|
26
24
|
max-height: 760px;
|
27
|
-
overflow-x: hidden;
|
28
|
-
overflow-y: auto;
|
29
25
|
}
|
30
26
|
|
31
27
|
.snk-filter-modal__rendered-items::-webkit-scrollbar {
|
@@ -1,18 +1,22 @@
|
|
1
|
-
import {
|
1
|
+
import { ApplicationContext, ObjectUtils } from '@sankhyalabs/core';
|
2
2
|
import { ModalAction } from "@sankhyalabs/ezui/dist/collection/components/ez-modal-container";
|
3
3
|
import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import { ApplicationContext, ObjectUtils } from '@sankhyalabs/core';
|
4
|
+
import { h } from '@stencil/core';
|
5
|
+
import { DefaultFilter } from '../../snk-personalized-filter/interfaces';
|
7
6
|
import { PersonalizedFilterUtils } from '../../snk-personalized-filter/subcomponents/snk-filter-param-config/utils/PersonalizedFilterUtils';
|
8
7
|
import { FilterNumberVariation } from '../filter-item/editors/enum/filterNumberVariation';
|
8
|
+
import FilterItemType from '../filter-item/filter-item-type.enum';
|
9
9
|
import { ActionDefaultFilter } from '../types/default-filters';
|
10
|
-
import
|
10
|
+
import FilterType from '../types/filter-type.enum';
|
11
|
+
import { getInvalidFilters } from '../utils/filter-validate';
|
11
12
|
export class SnkFilterModal {
|
12
13
|
constructor() {
|
14
|
+
this.filters = [];
|
15
|
+
this.filtersWithError = [];
|
13
16
|
this.getMessage = undefined;
|
14
17
|
this.configName = undefined;
|
15
|
-
this.
|
18
|
+
this.filterConfig = undefined;
|
19
|
+
this.opened = false;
|
16
20
|
this.applyFilters = undefined;
|
17
21
|
this.closeModal = undefined;
|
18
22
|
this.addPersonalizedFilter = undefined;
|
@@ -21,6 +25,11 @@ export class SnkFilterModal {
|
|
21
25
|
this.filtersToDelete = [];
|
22
26
|
this.filterDefaultToDelete = undefined;
|
23
27
|
this.disablePersonalizedFilter = undefined;
|
28
|
+
this.filterCustomConfigInterceptor = undefined;
|
29
|
+
}
|
30
|
+
filterConfigChangeHandler(newValue) {
|
31
|
+
this.filters = ObjectUtils.copy(newValue);
|
32
|
+
this.validateFilters();
|
24
33
|
}
|
25
34
|
/**
|
26
35
|
* Emitido quando um filtro personalizado é deletado.
|
@@ -79,7 +88,7 @@ export class SnkFilterModal {
|
|
79
88
|
});
|
80
89
|
}
|
81
90
|
hasChangeToSave() {
|
82
|
-
const hasChangesPersonalizedFilters = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this.
|
91
|
+
const hasChangesPersonalizedFilters = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this.filters);
|
83
92
|
return hasChangesPersonalizedFilters;
|
84
93
|
}
|
85
94
|
handleClose() {
|
@@ -94,6 +103,9 @@ export class SnkFilterModal {
|
|
94
103
|
});
|
95
104
|
}
|
96
105
|
handleApplyFilters() {
|
106
|
+
if (!this.validateFilters()) {
|
107
|
+
return;
|
108
|
+
}
|
97
109
|
const filterPersonalized = this.filters.find(filter => filter.filterType === FilterType.CUSTOM_FILTER || filter.filterType === FilterType.DEFAULT_FILTER);
|
98
110
|
if (this.isValidCustomFilter(filterPersonalized)) {
|
99
111
|
this.applyFilters(this.filters);
|
@@ -134,8 +146,14 @@ export class SnkFilterModal {
|
|
134
146
|
break;
|
135
147
|
}
|
136
148
|
}
|
137
|
-
handleFilterChange(
|
138
|
-
|
149
|
+
handleFilterChange(event) {
|
150
|
+
event.stopPropagation();
|
151
|
+
const filterConfig = event.detail;
|
152
|
+
let config = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
|
153
|
+
if (this.filterCustomConfigInterceptor) {
|
154
|
+
config = this.filterCustomConfigInterceptor(config);
|
155
|
+
}
|
156
|
+
this.filters = ObjectUtils.copy(config);
|
139
157
|
}
|
140
158
|
handleClearFilterList(filterList) {
|
141
159
|
this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
@@ -168,8 +186,22 @@ export class SnkFilterModal {
|
|
168
186
|
});
|
169
187
|
return valueList;
|
170
188
|
}
|
189
|
+
validateFilters() {
|
190
|
+
const notValidFilters = getInvalidFilters(this.filters);
|
191
|
+
this.filtersWithError = notValidFilters.map(item => item.id);
|
192
|
+
if (notValidFilters.length === 0) {
|
193
|
+
return true;
|
194
|
+
}
|
195
|
+
notValidFilters.forEach(item => {
|
196
|
+
const filterItem = this._element.querySelector(`#filter-item-${item.id}`);
|
197
|
+
if (filterItem) {
|
198
|
+
filterItem["errorMessage"] = item.requiredMessage || this.getCustomMessage('validations.requiredFilter');
|
199
|
+
}
|
200
|
+
});
|
201
|
+
return false;
|
202
|
+
}
|
171
203
|
renderFilterItem(filterItem, fullRow) {
|
172
|
-
return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event
|
204
|
+
return (h("snk-filter-modal-item", { key: `modal-item-${filterItem.id}`, class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
|
173
205
|
}
|
174
206
|
isDefaultFilterNumberVariation(filter) {
|
175
207
|
var _a;
|
@@ -206,8 +238,9 @@ export class SnkFilterModal {
|
|
206
238
|
}
|
207
239
|
getIformedFiltersCount(listItems) {
|
208
240
|
let countInformedItens = 0;
|
209
|
-
listItems.forEach(
|
241
|
+
listItems.forEach(localItem => {
|
210
242
|
var _a, _b, _c, _d, _e, _f;
|
243
|
+
const item = this.filterConfig.find(filter => filter.id === localItem.id);
|
211
244
|
if (FilterItemType.MULTI_LIST === item.type) {
|
212
245
|
countInformedItens += (_e = (_d = (_c = ((_b = (_a = item.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : item.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
|
213
246
|
return;
|
@@ -233,7 +266,8 @@ export class SnkFilterModal {
|
|
233
266
|
return null;
|
234
267
|
const appliedFilters = this.getIformedFiltersCount(listItems);
|
235
268
|
const lines = this.mountFiltersLines(listItems);
|
236
|
-
|
269
|
+
const countFiltersWithError = this.filtersWithError.filter(item => listItems.some(filter => filter.id === item)).length;
|
270
|
+
return (h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, h("div", { class: "ez-flex ez-flex--justify-end grow", slot: "rightSlot" }, !!appliedFilters && (h("ez-badge", { class: "ez-badge--primary-subtle", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), !!countFiltersWithError && (h("ez-badge", { class: "ez-badge--error-subtle", label: countFiltersWithError === null || countFiltersWithError === void 0 ? void 0 : countFiltersWithError.toString() }))), h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { class: "ez-button--tertiary", size: "medium", label: this.getCustomMessage("clearModal"), onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
|
237
271
|
}
|
238
272
|
handleDeleteFilter() {
|
239
273
|
this._application.confirm(this.getMessage('snkPersonalizedFilter.deleteConfirm.title'), this.getMessage('snkPersonalizedFilter.info.deleteDefaultFilterConfirm'), "alert-circle-inverted", "critical").then((actionConfirmed) => {
|
@@ -269,6 +303,7 @@ export class SnkFilterModal {
|
|
269
303
|
}
|
270
304
|
componentWillLoad() {
|
271
305
|
this._application = ApplicationContext.getContextValue('__SNK__APPLICATION__');
|
306
|
+
this.filters = ObjectUtils.copy(this.filterConfig);
|
272
307
|
}
|
273
308
|
componentWillRender() {
|
274
309
|
this._modalTitle = this.getCustomMessage('title');
|
@@ -276,15 +311,14 @@ export class SnkFilterModal {
|
|
276
311
|
this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
|
277
312
|
}
|
278
313
|
componentDidLoad() {
|
279
|
-
|
280
|
-
this._originalFilterConfig = this.filters;
|
314
|
+
this.validateFilters();
|
281
315
|
}
|
282
316
|
render() {
|
283
317
|
this._defaultFilter = this.getDefaultFilter(this.filters);
|
284
318
|
const customFilters = this.getCustomFilter(this.filters);
|
285
319
|
const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
|
286
320
|
const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
|
287
|
-
return (h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, h("snk-default-filter", { getMessage: this.getCustomMessage.bind(this), hasDefaultFilter: !!this._defaultFilter, onActionSelected: this.handleActionSelectedDefaultFilter.bind(this) }), !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true)))));
|
321
|
+
return (h("ez-modal", { opened: this.opened, modalSize: "col--sd-3", align: "right", heightMode: "full", closeEsc: true }, h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, h("snk-default-filter", { getMessage: this.getCustomMessage.bind(this), hasDefaultFilter: !!this._defaultFilter, onActionSelected: this.handleActionSelectedDefaultFilter.bind(this) }), !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true))))));
|
288
322
|
}
|
289
323
|
static get is() { return "snk-filter-modal"; }
|
290
324
|
static get originalStyleUrls() {
|
@@ -331,7 +365,7 @@ export class SnkFilterModal {
|
|
331
365
|
"attribute": "config-name",
|
332
366
|
"reflect": false
|
333
367
|
},
|
334
|
-
"
|
368
|
+
"filterConfig": {
|
335
369
|
"type": "unknown",
|
336
370
|
"mutable": true,
|
337
371
|
"complexType": {
|
@@ -354,6 +388,24 @@ export class SnkFilterModal {
|
|
354
388
|
"text": "Filtros a serem apresentados"
|
355
389
|
}
|
356
390
|
},
|
391
|
+
"opened": {
|
392
|
+
"type": "boolean",
|
393
|
+
"mutable": false,
|
394
|
+
"complexType": {
|
395
|
+
"original": "boolean",
|
396
|
+
"resolved": "boolean",
|
397
|
+
"references": {}
|
398
|
+
},
|
399
|
+
"required": false,
|
400
|
+
"optional": false,
|
401
|
+
"docs": {
|
402
|
+
"tags": [],
|
403
|
+
"text": "Define se o modal est\u00E1 aberto ou n\u00E3o."
|
404
|
+
},
|
405
|
+
"attribute": "opened",
|
406
|
+
"reflect": false,
|
407
|
+
"defaultValue": "false"
|
408
|
+
},
|
357
409
|
"applyFilters": {
|
358
410
|
"type": "unknown",
|
359
411
|
"mutable": false,
|
@@ -499,9 +551,53 @@ export class SnkFilterModal {
|
|
499
551
|
},
|
500
552
|
"attribute": "disable-personalized-filter",
|
501
553
|
"reflect": false
|
554
|
+
},
|
555
|
+
"filterCustomConfigInterceptor": {
|
556
|
+
"type": "unknown",
|
557
|
+
"mutable": false,
|
558
|
+
"complexType": {
|
559
|
+
"original": "(config: Array<SnkFilterItemConfig>) => Array<SnkFilterItemConfig>",
|
560
|
+
"resolved": "(config: SnkFilterItemConfig[]) => SnkFilterItemConfig[]",
|
561
|
+
"references": {
|
562
|
+
"Array": {
|
563
|
+
"location": "global"
|
564
|
+
},
|
565
|
+
"SnkFilterItemConfig": {
|
566
|
+
"location": "import",
|
567
|
+
"path": "../filter-item/snk-filter-item"
|
568
|
+
}
|
569
|
+
}
|
570
|
+
},
|
571
|
+
"required": false,
|
572
|
+
"optional": true,
|
573
|
+
"docs": {
|
574
|
+
"tags": [{
|
575
|
+
"name": "description",
|
576
|
+
"text": "Intercepta a configura\u00E7\u00E3o dos filtros antes de serem aplicadas."
|
577
|
+
}, {
|
578
|
+
"name": "param",
|
579
|
+
"text": "config - Lista de configura\u00E7\u00F5es de filtros."
|
580
|
+
}, {
|
581
|
+
"name": "returns",
|
582
|
+
"text": "Retorna a lista de configura\u00E7\u00F5es de filtros."
|
583
|
+
}],
|
584
|
+
"text": ""
|
585
|
+
}
|
502
586
|
}
|
503
587
|
};
|
504
588
|
}
|
589
|
+
static get states() {
|
590
|
+
return {
|
591
|
+
"filtersWithError": {}
|
592
|
+
};
|
593
|
+
}
|
594
|
+
static get elementRef() { return "_element"; }
|
595
|
+
static get watchers() {
|
596
|
+
return [{
|
597
|
+
"propName": "filterConfig",
|
598
|
+
"methodName": "filterConfigChangeHandler"
|
599
|
+
}];
|
600
|
+
}
|
505
601
|
static get listeners() {
|
506
602
|
return [{
|
507
603
|
"name": "deleteFilter",
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { h, Host } from '@stencil/core';
|
2
1
|
import { ElementIDUtils, ObjectUtils } from '@sankhyalabs/core';
|
3
|
-
import
|
4
|
-
import { EPresentationMode } from '../../filter-item/editors/enum/presentationMode';
|
2
|
+
import { h, Host } from '@stencil/core';
|
5
3
|
import { ConfigStorage } from '../../../../lib/configs/ConfigStorage';
|
4
|
+
import { EPresentationMode } from '../../filter-item/editors/enum/presentationMode';
|
5
|
+
import FilterItemType from '../../filter-item/filter-item-type.enum';
|
6
6
|
import FilterType from '../../types/filter-type.enum';
|
7
7
|
export class SnkFilterModalItem {
|
8
8
|
constructor() {
|
@@ -10,12 +10,6 @@ export class SnkFilterModalItem {
|
|
10
10
|
this.configName = undefined;
|
11
11
|
this.resourceID = undefined;
|
12
12
|
}
|
13
|
-
observeFilterItem(newValue) {
|
14
|
-
var _a, _b;
|
15
|
-
this._editor && (this._editor["config"] = newValue);
|
16
|
-
(_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a['reloadList']) === null || _b === void 0 ? void 0 : _b.call(_a);
|
17
|
-
this.filterChange.emit(newValue);
|
18
|
-
}
|
19
13
|
getContentEditorConfig() {
|
20
14
|
const props = { presentationMode: EPresentationMode.MODAL };
|
21
15
|
switch (this.filterItem.type) {
|
@@ -50,6 +44,7 @@ export class SnkFilterModalItem {
|
|
50
44
|
return !this.filterItem.visible ? newValue !== undefined : true;
|
51
45
|
}
|
52
46
|
updateFilterValue(data) {
|
47
|
+
var _a, _b;
|
53
48
|
const newValue = (data === null || data === void 0 ? void 0 : data.value) !== undefined ? data.value : data;
|
54
49
|
if (this.filterItem.groupedItems != undefined) {
|
55
50
|
this.filterItem = Object.assign(Object.assign({}, this.filterItem), { visible: newValue > 0, value: newValue, groupedItems: data.items });
|
@@ -57,6 +52,9 @@ export class SnkFilterModalItem {
|
|
57
52
|
else {
|
58
53
|
this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: this.filterItem.type === (FilterItemType.SEARCH || FilterItemType.CHECK_BOX_LIST) ? data : newValue, visible: this.isVisible(newValue) });
|
59
54
|
}
|
55
|
+
this._editor && (this._editor["config"] = this.filterItem);
|
56
|
+
(_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a['reloadList']) === null || _b === void 0 ? void 0 : _b.call(_a);
|
57
|
+
this.filterChange.emit(this.filterItem);
|
60
58
|
}
|
61
59
|
handleDeleteFilter(filter, filterItemType) {
|
62
60
|
if (filterItemType === FilterItemType.PERSONALIZED) {
|
@@ -86,7 +84,7 @@ export class SnkFilterModalItem {
|
|
86
84
|
}
|
87
85
|
render() {
|
88
86
|
const { tag: ContentEditor, props } = this.getContentEditorConfig();
|
89
|
-
return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("
|
87
|
+
return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("label", { class: "ez-text ez-text--medium ez-text--primary ez-margin-bottom--extra-small", htmlFor: `filter-item-${this.filterItem.id}` }, this.filterItem.detailModal)), h(ContentEditor, Object.assign({ ref: ref => this._editor = ref, id: `filter-item-${this.filterItem.id}`, config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, props)))));
|
90
88
|
}
|
91
89
|
static get is() { return "snk-filter-modal-item"; }
|
92
90
|
static get originalStyleUrls() {
|
@@ -211,10 +209,4 @@ export class SnkFilterModalItem {
|
|
211
209
|
}];
|
212
210
|
}
|
213
211
|
static get elementRef() { return "_element"; }
|
214
|
-
static get watchers() {
|
215
|
-
return [{
|
216
|
-
"propName": "filterItem",
|
217
|
-
"methodName": "observeFilterItem"
|
218
|
-
}];
|
219
|
-
}
|
220
212
|
}
|