@sankhyalabs/sankhyablocks 1.4.0-beta.1 → 1.4.0-beta.3
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/{SnkMessageBuilder-7717f1e4.js → SnkMessageBuilder-d8215915.js} +14 -119
- package/dist/cjs/{filter-item-type.enum-e2e1bc5b.js → filter-item-type.enum-3daf58d3.js} +2 -0
- package/dist/cjs/{index-b0b676c5.js → index-6fcf07f3.js} +159 -1515
- package/dist/cjs/loader.cjs.js +2 -18
- package/dist/cjs/sankhyablocks.cjs.js +4 -116
- package/dist/cjs/snk-application.cjs.entry.js +84 -230
- package/dist/cjs/snk-crud.cjs.entry.js +3 -3
- package/dist/cjs/snk-data-unit.cjs.entry.js +24 -32
- package/dist/cjs/snk-filter-bar_5.cjs.entry.js +902 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-detail.cjs.entry.js +38 -3
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-number.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-period.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +90 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +4 -4
- package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
- package/dist/cjs/{snk-form.cjs.entry.js → snk-form_2.cjs.entry.js} +119 -5
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
- package/dist/cjs/{taskbar-elements-283c737e.js → taskbar-elements-aedfeae6.js} +1 -1
- package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/snk-application/snk-application.js +54 -7
- package/dist/collection/components/snk-crud/snk-crud.js +2 -4
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +0 -27
- package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +161 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +2 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +36 -1
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +32 -9
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +196 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +22 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +238 -139
- package/dist/collection/components/snk-grid/snk-grid.js +2 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +18 -10
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -2
- package/dist/components/SnkMessageBuilder.js +15 -119
- package/dist/components/filter-item-type.enum.js +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -4
- package/dist/components/snk-application2.js +47 -191
- package/dist/components/snk-crud.js +16 -10
- package/dist/components/snk-data-unit.js +3 -12
- package/dist/components/snk-filter-bar2.js +342 -146
- package/dist/components/snk-filter-detail2.js +36 -1
- package/dist/components/snk-filter-item2.js +33 -10
- package/dist/components/snk-filter-list2.js +1 -1
- package/dist/components/snk-filter-modal.d.ts +11 -0
- package/dist/components/snk-filter-modal.js +6 -0
- package/dist/components/snk-filter-modal2.js +58 -0
- package/dist/components/snk-filter-personalized.d.ts +11 -0
- package/dist/components/snk-filter-personalized.js +108 -0
- package/dist/components/snk-filter-search.js +1 -1
- package/dist/components/snk-form2.js +1 -1
- package/dist/components/snk-grid2.js +16 -10
- package/dist/components/snk-pesquisa2.js +1 -1
- package/dist/components/snk-taskbar2.js +1 -1
- package/dist/components/teste-pesquisa.js +1 -1
- package/dist/{sankhyablocks/SnkMessageBuilder-a7da466b.js → esm/SnkMessageBuilder-35a20271.js} +15 -119
- package/dist/esm/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
- package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-81dda3cf.js} +160 -1508
- package/dist/esm/loader.js +2 -18
- package/dist/esm/sankhyablocks.js +4 -116
- package/dist/esm/snk-application.entry.js +46 -192
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-data-unit.entry.js +4 -12
- package/dist/esm/snk-filter-bar_5.entry.js +894 -0
- package/dist/esm/snk-filter-binary-select.entry.js +2 -2
- package/dist/esm/snk-filter-detail.entry.js +38 -3
- package/dist/esm/snk-filter-multi-select.entry.js +2 -2
- package/dist/esm/snk-filter-number.entry.js +2 -2
- package/dist/esm/snk-filter-period.entry.js +2 -2
- package/dist/esm/snk-filter-personalized.entry.js +86 -0
- package/dist/esm/snk-filter-search.entry.js +3 -3
- package/dist/esm/snk-filter-text.entry.js +1 -1
- package/dist/esm/{snk-form.entry.js → snk-form_2.entry.js} +117 -4
- package/dist/esm/snk-pesquisa.entry.js +2 -2
- package/dist/{sankhyablocks/taskbar-elements-35d64ff9.js → esm/taskbar-elements-38eb5d51.js} +1 -1
- package/dist/esm/teste-pesquisa.entry.js +2 -2
- package/dist/sankhyablocks/index.esm.js +0 -1
- package/dist/sankhyablocks/p-0352c0e2.entry.js +1 -0
- package/dist/sankhyablocks/p-07ebda01.entry.js +1 -0
- package/dist/sankhyablocks/p-322c0df2.entry.js +1 -0
- package/dist/sankhyablocks/p-46caa101.entry.js +1 -0
- package/dist/sankhyablocks/p-473cedf9.entry.js +1 -0
- package/dist/sankhyablocks/p-586e2522.js +1 -0
- package/dist/sankhyablocks/p-86f15ffe.js +1 -0
- package/dist/sankhyablocks/p-8f3c5709.entry.js +1 -0
- package/dist/sankhyablocks/p-97009a2c.entry.js +1 -0
- package/dist/sankhyablocks/p-9be74b46.entry.js +74 -0
- package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
- package/dist/sankhyablocks/p-a8b59c61.entry.js +1 -0
- package/dist/sankhyablocks/p-aecf3e0a.entry.js +1 -0
- package/dist/sankhyablocks/p-c1c3b5d8.entry.js +1 -0
- package/dist/sankhyablocks/p-c78cb79a.entry.js +1 -0
- package/dist/sankhyablocks/p-c9eec639.entry.js +1 -0
- package/dist/sankhyablocks/p-dc482a42.entry.js +1 -0
- package/dist/sankhyablocks/p-fac2b6a9.js +2 -0
- package/dist/sankhyablocks/p-fb705f81.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
- package/dist/types/components/snk-application/snk-application.d.ts +4 -1
- package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +23 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +3 -1
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +2 -0
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +23 -0
- package/dist/types/components.d.ts +56 -8
- package/package.json +3 -3
- package/react/components.d.ts +19 -0
- package/react/components.js +19 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/app-globals-3a1e7e63.js +0 -5
- package/dist/cjs/css-shim-b8158822.js +0 -6
- package/dist/cjs/dom-36862b77.js +0 -75
- package/dist/cjs/index-02201bc9.js +0 -2397
- package/dist/cjs/shadow-css-346c0795.js +0 -389
- package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -278
- package/dist/cjs/snk-filter-item.cjs.entry.js +0 -154
- package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
- package/dist/cjs/snk-grid.cjs.entry.js +0 -79
- package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
- package/dist/cjs/taskbar-processor-6bd0d35c.js +0 -47
- package/dist/components/index2.js +0 -2384
- package/dist/esm/SnkMessageBuilder-a7da466b.js +0 -303
- package/dist/esm/app-globals-0f993ce5.js +0 -3
- package/dist/esm/css-shim-b3f2ee8d.js +0 -4
- package/dist/esm/dom-665d6011.js +0 -73
- package/dist/esm/index-2b4d2d14.js +0 -3262
- package/dist/esm/index-f1d3e4da.js +0 -2384
- package/dist/esm/shadow-css-b18e99d7.js +0 -387
- package/dist/esm/snk-filter-bar.entry.js +0 -274
- package/dist/esm/snk-filter-item.entry.js +0 -150
- package/dist/esm/snk-filter-list.entry.js +0 -87
- package/dist/esm/snk-grid.entry.js +0 -75
- package/dist/esm/snk-taskbar.entry.js +0 -156
- package/dist/esm/taskbar-elements-35d64ff9.js +0 -90
- package/dist/esm/taskbar-processor-aa6772c9.js +0 -45
- package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
- package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
- package/dist/sankhyablocks/dom-665d6011.js +0 -73
- package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +0 -12
- package/dist/sankhyablocks/index-f1d3e4da.js +0 -2384
- package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
- package/dist/sankhyablocks/snk-application.entry.js +0 -8148
- package/dist/sankhyablocks/snk-crud.entry.js +0 -66
- package/dist/sankhyablocks/snk-data-unit.entry.js +0 -276
- package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -274
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
- package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -45
- package/dist/sankhyablocks/snk-filter-item.entry.js +0 -150
- package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
- package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
- package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
- package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
- package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
- package/dist/sankhyablocks/snk-form.entry.js +0 -129
- package/dist/sankhyablocks/snk-grid.entry.js +0 -75
- package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
- package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
- package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
- package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -51
|
@@ -1,11 +1,111 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { DataType, ObjectUtils, StringUtils, ErrorException, ApplicationContext } from '@sankhyalabs/core';
|
|
3
3
|
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { d as defineCustomElement$
|
|
4
|
+
import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
|
|
5
|
+
import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
|
6
|
+
import { d as defineCustomElement$4 } from './snk-filter-detail2.js';
|
|
7
|
+
import { d as defineCustomElement$3 } from './snk-filter-item2.js';
|
|
8
|
+
import { d as defineCustomElement$2 } from './snk-filter-list2.js';
|
|
9
|
+
import { d as defineCustomElement$1 } from './snk-filter-modal2.js';
|
|
7
10
|
|
|
8
|
-
const
|
|
11
|
+
const buildFilter = (item) => {
|
|
12
|
+
switch (item.type) {
|
|
13
|
+
case FilterItemType.DEFAULT_FILTER:
|
|
14
|
+
return buildDefault(item);
|
|
15
|
+
case FilterItemType.BINARY_SELECT:
|
|
16
|
+
return buildBinary(item);
|
|
17
|
+
case FilterItemType.MULTI_SELECT:
|
|
18
|
+
return buildMultSelect(item);
|
|
19
|
+
case FilterItemType.PERIOD:
|
|
20
|
+
return buildPeriod(item);
|
|
21
|
+
case FilterItemType.SEARCH:
|
|
22
|
+
return buildSearch(item);
|
|
23
|
+
case FilterItemType.TEXT:
|
|
24
|
+
return buildText(item);
|
|
25
|
+
case FilterItemType.NUMBER:
|
|
26
|
+
return buildNumber(item);
|
|
27
|
+
case FilterItemType.PERSONALIZED:
|
|
28
|
+
return buildPersonalized(item);
|
|
29
|
+
default:
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function buildDefault(item) {
|
|
34
|
+
return { name: item.id, expression: item.props.expression, params: [] };
|
|
35
|
+
}
|
|
36
|
+
function buildBinary(item) {
|
|
37
|
+
const { id, value, props } = item;
|
|
38
|
+
const options = props.options;
|
|
39
|
+
const selectedOption = options.find(opt => opt.name === value);
|
|
40
|
+
return { name: id, expression: selectedOption.expression, params: [] };
|
|
41
|
+
}
|
|
42
|
+
function buildMultSelect(item) {
|
|
43
|
+
const { id, value, props } = item;
|
|
44
|
+
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
45
|
+
}
|
|
46
|
+
function buildPeriod(item) {
|
|
47
|
+
const { id, value, props } = item;
|
|
48
|
+
let { end, start } = value;
|
|
49
|
+
if (typeof end === "string") {
|
|
50
|
+
end = new Date(end);
|
|
51
|
+
}
|
|
52
|
+
if (typeof start === "string") {
|
|
53
|
+
start = new Date(start);
|
|
54
|
+
}
|
|
55
|
+
const params = [];
|
|
56
|
+
let expression;
|
|
57
|
+
if (end && start) {
|
|
58
|
+
expression = props.expression.fullfill;
|
|
59
|
+
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (start) {
|
|
63
|
+
expression = props.expression.onlystart;
|
|
64
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
expression = props.expression.onlyend;
|
|
68
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { name: id, expression, params };
|
|
72
|
+
}
|
|
73
|
+
function buildSearch(item) {
|
|
74
|
+
const { id, value, props } = item;
|
|
75
|
+
const expression = props.expression;
|
|
76
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
77
|
+
}
|
|
78
|
+
function buildText(item) {
|
|
79
|
+
const { id, value, props } = item;
|
|
80
|
+
const expression = props.expression;
|
|
81
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
82
|
+
}
|
|
83
|
+
function buildNumber(item) {
|
|
84
|
+
const { id, value, props } = item;
|
|
85
|
+
const expression = props.expression;
|
|
86
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
87
|
+
}
|
|
88
|
+
function buildPersonalized(item) {
|
|
89
|
+
var _a;
|
|
90
|
+
const { id, value, props } = item;
|
|
91
|
+
const expression = props.expression;
|
|
92
|
+
return {
|
|
93
|
+
name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
|
|
94
|
+
const valuesArray = Array.from(value);
|
|
95
|
+
const dataType = param.dataType;
|
|
96
|
+
let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
|
|
97
|
+
if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
|
|
98
|
+
paramValue = paramValue["value"];
|
|
99
|
+
}
|
|
100
|
+
if (paramValue == undefined && dataType === DataType.BOOLEAN) {
|
|
101
|
+
paramValue = false;
|
|
102
|
+
}
|
|
103
|
+
return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const snkFilterBarCss = ".sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 1);background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;flex-grow:0}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px)}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.preselected.sc-snk-filter-bar{background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:\"\";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{display:flex;flex-direction:row;border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium);width:100%}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:100%;height:100%}";
|
|
9
109
|
|
|
10
110
|
const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
|
|
11
111
|
const DEFAULT_FILTER = "DEFAULT_FILTER";
|
|
@@ -15,6 +115,9 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
15
115
|
super();
|
|
16
116
|
this.__registerHost();
|
|
17
117
|
this._updateSequence = [];
|
|
118
|
+
this._loadingPending = false;
|
|
119
|
+
this._configUpdated = false;
|
|
120
|
+
this._pendingFilters = [];
|
|
18
121
|
this._calculateSortIndex = (item) => {
|
|
19
122
|
let index = item.hardFixed ? 1000000 : 0;
|
|
20
123
|
//campos Hard Fixed não variam a ordem
|
|
@@ -29,6 +132,54 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
29
132
|
return this._calculateSortIndex(b) - this._calculateSortIndex(a);
|
|
30
133
|
};
|
|
31
134
|
}
|
|
135
|
+
observeFilterConfig(newValue, oldValue) {
|
|
136
|
+
if (oldValue != undefined && newValue == undefined) {
|
|
137
|
+
this._loadingPending = true;
|
|
138
|
+
this._configUpdated = true;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
|
|
142
|
+
newValue.forEach(newItem => {
|
|
143
|
+
const oldItem = oldItems.get(newItem.id);
|
|
144
|
+
if (oldItem != undefined) {
|
|
145
|
+
this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
|
|
146
|
+
this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
this._configUpdated = true;
|
|
150
|
+
this._loadingPending = this._loadingPending || newItem.value != undefined;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
this.processAfterUpdateConfig();
|
|
155
|
+
}
|
|
156
|
+
processPendingFilter() {
|
|
157
|
+
if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
|
|
158
|
+
this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
|
|
159
|
+
if (this._currentPendingFilter) {
|
|
160
|
+
this._currentPendingFilter.showUp(true).then(() => {
|
|
161
|
+
this._currentPendingFilter = undefined;
|
|
162
|
+
this.processPendingFilter();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (this._currentPendingFilter == undefined) {
|
|
167
|
+
this.processAfterUpdateConfig();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
processAfterUpdateConfig() {
|
|
171
|
+
if (this._pendingFilters.length > 0) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (this._loadingPending) {
|
|
175
|
+
this._loadingPending = false;
|
|
176
|
+
this.dataUnit.loadData();
|
|
177
|
+
}
|
|
178
|
+
if (this._configUpdated) {
|
|
179
|
+
this._configUpdated = false;
|
|
180
|
+
this._application.saveFilterBarConfig(this.filterConfig, this.configName);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
32
183
|
/**
|
|
33
184
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
34
185
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -41,101 +192,21 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
41
192
|
getFilter(_dataUnit) {
|
|
42
193
|
var _a;
|
|
43
194
|
const filters = [];
|
|
44
|
-
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => item
|
|
45
|
-
const filter =
|
|
195
|
+
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
|
|
196
|
+
const filter = buildFilter(item);
|
|
46
197
|
if (filter) {
|
|
47
198
|
filters.push(filter);
|
|
48
199
|
}
|
|
49
200
|
});
|
|
50
201
|
return filters;
|
|
51
202
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (value && visible) {
|
|
55
|
-
if (type === FilterItemType.BINARY_SELECT) {
|
|
56
|
-
const options = props.options;
|
|
57
|
-
const selectedOption = options.find(opt => opt.name === value);
|
|
58
|
-
//FIXME: ajustar o backend para não exigir parametros
|
|
59
|
-
return { name: id, expression: selectedOption.expression, params: [] };
|
|
60
|
-
}
|
|
61
|
-
if (type === FilterItemType.MULTI_SELECT) {
|
|
62
|
-
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
63
|
-
}
|
|
64
|
-
if (type === FilterItemType.PERIOD) {
|
|
65
|
-
let { end, start } = value;
|
|
66
|
-
if (typeof end === "string") {
|
|
67
|
-
end = new Date(end);
|
|
68
|
-
}
|
|
69
|
-
if (typeof start === "string") {
|
|
70
|
-
start = new Date(start);
|
|
71
|
-
}
|
|
72
|
-
const params = [];
|
|
73
|
-
let expression;
|
|
74
|
-
if (end && start) {
|
|
75
|
-
expression = props.expression.fullfill;
|
|
76
|
-
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
if (start) {
|
|
80
|
-
expression = props.expression.onlystart;
|
|
81
|
-
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
expression = props.expression.onlyend;
|
|
85
|
-
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return { name: id, expression, params };
|
|
89
|
-
}
|
|
90
|
-
if (type === FilterItemType.SEARCH) {
|
|
91
|
-
const expression = props.expression;
|
|
92
|
-
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
93
|
-
}
|
|
94
|
-
if (type === FilterItemType.TEXT) {
|
|
95
|
-
const expression = props.expression;
|
|
96
|
-
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
97
|
-
}
|
|
98
|
-
if (type === FilterItemType.NUMBER) {
|
|
99
|
-
const expression = props.expression;
|
|
100
|
-
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
101
|
-
}
|
|
102
|
-
//No mapeamento dos outros tipos precisamos saber o tipo de dado.
|
|
103
|
-
}
|
|
104
|
-
return undefined;
|
|
203
|
+
isActiveFilter(item) {
|
|
204
|
+
return (item.visible && item.value != undefined) || item.type === FilterItemType.DEFAULT_FILTER;
|
|
105
205
|
}
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
if (this.
|
|
109
|
-
this.
|
|
110
|
-
.then((filters) => {
|
|
111
|
-
this.filterConfig = filters;
|
|
112
|
-
})
|
|
113
|
-
.catch(reason => {
|
|
114
|
-
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (this.dataUnit == undefined) {
|
|
118
|
-
let parent = this._element.parentElement;
|
|
119
|
-
while (parent) {
|
|
120
|
-
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
121
|
-
const snkDataUnit = parent;
|
|
122
|
-
this.dataUnit = snkDataUnit.dataUnit;
|
|
123
|
-
if (this.dataUnit) {
|
|
124
|
-
this.dataUnit.addFilterProvider(this);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
128
|
-
this.dataUnit = evt.detail;
|
|
129
|
-
this.dataUnit.addFilterProvider(this);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
parent = parent.parentElement;
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
this.dataUnit.addFilterProvider(this);
|
|
206
|
+
registryFilterProvider() {
|
|
207
|
+
this.dataUnit.addFilterProvider(this);
|
|
208
|
+
if (this.filterConfig) {
|
|
209
|
+
this.dataUnit.loadData();
|
|
139
210
|
}
|
|
140
211
|
}
|
|
141
212
|
getFilterItems() {
|
|
@@ -143,9 +214,8 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
143
214
|
const unpinnedItems = [];
|
|
144
215
|
this.filterConfig
|
|
145
216
|
.filter(item => item.visible)
|
|
146
|
-
.sort((a, b) => this._filtersComparator(a, b))
|
|
147
217
|
.forEach((item, index) => {
|
|
148
|
-
const filterItem = (h("snk-filter-item", { id: `filter-${item.id}`, config:
|
|
218
|
+
const filterItem = (h("snk-filter-item", { id: `filter-${item.id}`, config: item, class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
|
|
149
219
|
if (item.fixed || item.hardFixed) {
|
|
150
220
|
pinnedItems.push(filterItem);
|
|
151
221
|
}
|
|
@@ -168,9 +238,6 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
168
238
|
this._updateSequence.push(item.id);
|
|
169
239
|
}
|
|
170
240
|
}
|
|
171
|
-
filterChangeListener(evt) {
|
|
172
|
-
this.updateFilter(evt.detail);
|
|
173
|
-
}
|
|
174
241
|
normalizeItem(item) {
|
|
175
242
|
const normalized = Object.assign({}, item);
|
|
176
243
|
const optionals = ["props", "value", "hardFixed", "fixed"];
|
|
@@ -184,87 +251,207 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
184
251
|
}
|
|
185
252
|
return normalized;
|
|
186
253
|
}
|
|
187
|
-
updateFilter(newItem
|
|
188
|
-
let needLoad = false;
|
|
189
|
-
let updated = false;
|
|
254
|
+
updateFilter(newItem) {
|
|
190
255
|
this.filterConfig = this.filterConfig.map(item => {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
if (item.id === newItem.id) {
|
|
200
|
-
const normalizedOne = this.normalizeItem(item);
|
|
201
|
-
const normalizedTwo = this.normalizeItem(newItem);
|
|
202
|
-
updated = ObjectUtils.objectToString(normalizedOne) != ObjectUtils.objectToString(normalizedTwo);
|
|
203
|
-
needLoad = ObjectUtils.objectToString(normalizedOne.value) !== ObjectUtils.objectToString(normalizedTwo.value);
|
|
204
|
-
return newItem;
|
|
256
|
+
newItem = this.normalizeItem(newItem);
|
|
257
|
+
if (item.id === newItem.id) {
|
|
258
|
+
if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
|
|
259
|
+
this.calculateUpdateSequence(newItem);
|
|
205
260
|
}
|
|
261
|
+
return newItem;
|
|
206
262
|
}
|
|
207
263
|
return item;
|
|
208
|
-
});
|
|
209
|
-
if (needLoad) {
|
|
210
|
-
this.dataUnit.loadData();
|
|
211
|
-
}
|
|
212
|
-
if (updated) {
|
|
213
|
-
this.calculateUpdateSequence(newItem);
|
|
214
|
-
this._application.saveFilterBarConfig(this.filterConfig, this.configName);
|
|
215
|
-
}
|
|
216
|
-
return needLoad;
|
|
264
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
217
265
|
}
|
|
218
266
|
getAddListItems() {
|
|
219
267
|
const hiddenItems = this.filterConfig
|
|
220
|
-
.filter(item => !item.visible)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
]);
|
|
268
|
+
.filter(item => !item.visible && this.isListable(item));
|
|
269
|
+
const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
|
|
270
|
+
if (this.allowDefault) {
|
|
271
|
+
footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
|
|
272
|
+
}
|
|
273
|
+
return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
|
|
274
|
+
.concat(footerItems);
|
|
228
275
|
}
|
|
229
276
|
getActiveClass() {
|
|
230
277
|
const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
|
|
231
278
|
return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
|
|
232
279
|
}
|
|
280
|
+
isListable(item, allowPersonalized = false) {
|
|
281
|
+
return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
|
|
282
|
+
}
|
|
233
283
|
getAppliedListItems() {
|
|
234
284
|
const appliedItems = this.filterConfig
|
|
235
|
-
.filter(item => item.
|
|
236
|
-
.sort(this._filtersComparator);
|
|
285
|
+
.filter(item => this.isActiveFilter(item) && this.isListable(item, true));
|
|
237
286
|
return appliedItems.map(filter => {
|
|
238
287
|
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
239
288
|
}).concat([
|
|
240
289
|
{ name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
|
|
241
290
|
]);
|
|
242
291
|
}
|
|
292
|
+
addPersonalizedFilters(personalizedItems) {
|
|
293
|
+
const activeFilters = {};
|
|
294
|
+
personalizedItems.forEach(item => {
|
|
295
|
+
if (item.active) {
|
|
296
|
+
activeFilters[item.id] = true;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
if (item.type === FilterItemType.PERSONALIZED) {
|
|
302
|
+
const visible = activeFilters[item.id];
|
|
303
|
+
if (!item.visible && visible) {
|
|
304
|
+
this.calculateUpdateSequence(item);
|
|
305
|
+
if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
|
|
306
|
+
this._pendingFilters.push(item.id);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
|
|
310
|
+
}
|
|
311
|
+
return item;
|
|
312
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
313
|
+
}
|
|
314
|
+
openDefaultFilterModal() {
|
|
315
|
+
const filterModal = document.createElement("snk-filter-modal");
|
|
316
|
+
const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
|
|
317
|
+
filterModal.getMessage = (key, props) => this.getMessage(key, props);
|
|
318
|
+
filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
|
|
319
|
+
filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
|
|
320
|
+
filterModal.items = defaultFilter.map(item => {
|
|
321
|
+
return { id: item.id, active: true, enabled: false, label: item.label };
|
|
322
|
+
});
|
|
323
|
+
filterModal.processModalAction = (_action) => {
|
|
324
|
+
this._application.closeModal();
|
|
325
|
+
};
|
|
326
|
+
this._application.showModal(filterModal);
|
|
327
|
+
}
|
|
328
|
+
openPersonalizedModal() {
|
|
329
|
+
const filterModal = document.createElement("snk-filter-modal");
|
|
330
|
+
const personalizedFilter = this.filterConfig
|
|
331
|
+
.filter(item => item.type === FilterItemType.PERSONALIZED)
|
|
332
|
+
.sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
|
|
333
|
+
filterModal.getMessage = (key, props) => this.getMessage(key, props);
|
|
334
|
+
filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
|
|
335
|
+
filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
|
|
336
|
+
filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
|
|
337
|
+
filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
|
|
338
|
+
filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
|
|
339
|
+
filterModal.useSearch = true;
|
|
340
|
+
filterModal.items = personalizedFilter.map(item => {
|
|
341
|
+
return { id: item.id, active: item.visible, enabled: true, label: item.label };
|
|
342
|
+
});
|
|
343
|
+
filterModal.processModalAction = (action) => {
|
|
344
|
+
if (action === ModalAction.CANCEL) {
|
|
345
|
+
// O Botão de cancelar, tem efeito específico:
|
|
346
|
+
// - Desmarcar todos os filtros personalizados.
|
|
347
|
+
filterModal.items = filterModal.items.map(item => {
|
|
348
|
+
return Object.assign(Object.assign({}, item), { active: false });
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
if (action === ModalAction.OK) {
|
|
353
|
+
this.addPersonalizedFilters(filterModal.items);
|
|
354
|
+
}
|
|
355
|
+
this._application.closeModal();
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
this._application.showModal(filterModal);
|
|
359
|
+
}
|
|
360
|
+
clearFilters() {
|
|
361
|
+
let changed = false;
|
|
362
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
363
|
+
if (item.value != undefined) {
|
|
364
|
+
changed = true;
|
|
365
|
+
}
|
|
366
|
+
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
367
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
368
|
+
return changed;
|
|
369
|
+
}
|
|
370
|
+
loadPermitions() {
|
|
371
|
+
this._application.isUserSup().then(value => this.allowDefault = value);
|
|
372
|
+
}
|
|
373
|
+
loadConfigFromApplication() {
|
|
374
|
+
this._application.getFilterBarConfig(this.configName)
|
|
375
|
+
.then((filters) => {
|
|
376
|
+
this.filterConfig = filters.map(item => this.normalizeItem(item));
|
|
377
|
+
if (this.dataUnit) {
|
|
378
|
+
this.dataUnit.loadData();
|
|
379
|
+
}
|
|
380
|
+
})
|
|
381
|
+
.catch(reason => {
|
|
382
|
+
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
attachDataUnit() {
|
|
386
|
+
if (this.dataUnit == undefined) {
|
|
387
|
+
let parent = this._element.parentElement;
|
|
388
|
+
while (parent) {
|
|
389
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
390
|
+
const snkDataUnit = parent;
|
|
391
|
+
this.dataUnit = snkDataUnit.dataUnit;
|
|
392
|
+
if (this.dataUnit) {
|
|
393
|
+
this.registryFilterProvider();
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
397
|
+
this.dataUnit = evt.detail;
|
|
398
|
+
this.registryFilterProvider();
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
parent = parent.parentElement;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
this.registryFilterProvider();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
filterChangeListener(evt) {
|
|
411
|
+
this.updateFilter(evt.detail);
|
|
412
|
+
}
|
|
243
413
|
addFilterHandler(itemName) {
|
|
244
414
|
const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
|
|
245
|
-
if (
|
|
415
|
+
if (itemName === PERSONALIZED_FILTER) {
|
|
416
|
+
this.openPersonalizedModal();
|
|
417
|
+
}
|
|
418
|
+
else if (itemName === DEFAULT_FILTER) {
|
|
419
|
+
this.openDefaultFilterModal();
|
|
420
|
+
}
|
|
421
|
+
else if (filterItem) {
|
|
246
422
|
this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
|
|
247
423
|
window.requestAnimationFrame(() => {
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
|
|
424
|
+
const filterItemElement = this._element.querySelector("#filter-" + itemName);
|
|
425
|
+
if (filterItemElement) {
|
|
426
|
+
filterItemElement.showUp();
|
|
251
427
|
}
|
|
252
428
|
});
|
|
253
429
|
}
|
|
254
430
|
}
|
|
255
431
|
appliedFilterHandler(itemName) {
|
|
256
432
|
if (itemName === CLEAR_ALL_FILTERS) {
|
|
257
|
-
if (this.
|
|
433
|
+
if (this.clearFilters()) {
|
|
258
434
|
this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
|
|
259
435
|
}
|
|
260
436
|
}
|
|
261
437
|
else {
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
|
|
438
|
+
const filterItemElement = this._element.querySelector("#filter-" + itemName);
|
|
439
|
+
if (filterItemElement) {
|
|
440
|
+
filterItemElement.showUp(true);
|
|
265
441
|
}
|
|
266
442
|
}
|
|
267
443
|
}
|
|
444
|
+
componentWillLoad() {
|
|
445
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
446
|
+
if (this._application) {
|
|
447
|
+
this.loadPermitions();
|
|
448
|
+
this.loadConfigFromApplication();
|
|
449
|
+
}
|
|
450
|
+
this.attachDataUnit();
|
|
451
|
+
}
|
|
452
|
+
componentDidRender() {
|
|
453
|
+
this.processPendingFilter();
|
|
454
|
+
}
|
|
268
455
|
render() {
|
|
269
456
|
if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
|
|
270
457
|
return undefined;
|
|
@@ -272,17 +459,21 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
272
459
|
return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), h("snk-filter-list", { items: this.getAppliedListItems(), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyAppliedFiltersList"), findFilterText: this.getMessage("snkFilterBar.findFilter"), iconName: "filter", class: "ez-padding-left--medium", buttonClass: this.getActiveClass(), onSnkItemSelected: evt => this.appliedFilterHandler(evt.detail) }), h("snk-filter-list", { items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyFiltersList"), findFilterText: this.getMessage("snkFilterBar.findField"), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
|
|
273
460
|
}
|
|
274
461
|
get _element() { return this; }
|
|
462
|
+
static get watchers() { return {
|
|
463
|
+
"filterConfig": ["observeFilterConfig"]
|
|
464
|
+
}; }
|
|
275
465
|
static get style() { return snkFilterBarCss; }
|
|
276
466
|
}, [2, "snk-filter-bar", {
|
|
277
467
|
"dataUnit": [1040],
|
|
278
468
|
"configName": [1, "config-name"],
|
|
279
|
-
"filterConfig": [1040]
|
|
469
|
+
"filterConfig": [1040],
|
|
470
|
+
"allowDefault": [32]
|
|
280
471
|
}, [[0, "filterChange", "filterChangeListener"]]]);
|
|
281
472
|
function defineCustomElement() {
|
|
282
473
|
if (typeof customElements === "undefined") {
|
|
283
474
|
return;
|
|
284
475
|
}
|
|
285
|
-
const components = ["snk-filter-bar", "snk-filter-detail", "snk-filter-item", "snk-filter-list"];
|
|
476
|
+
const components = ["snk-filter-bar", "snk-filter-detail", "snk-filter-item", "snk-filter-list", "snk-filter-modal"];
|
|
286
477
|
components.forEach(tagName => { switch (tagName) {
|
|
287
478
|
case "snk-filter-bar":
|
|
288
479
|
if (!customElements.get(tagName)) {
|
|
@@ -291,15 +482,20 @@ function defineCustomElement() {
|
|
|
291
482
|
break;
|
|
292
483
|
case "snk-filter-detail":
|
|
293
484
|
if (!customElements.get(tagName)) {
|
|
294
|
-
defineCustomElement$
|
|
485
|
+
defineCustomElement$4();
|
|
295
486
|
}
|
|
296
487
|
break;
|
|
297
488
|
case "snk-filter-item":
|
|
298
489
|
if (!customElements.get(tagName)) {
|
|
299
|
-
defineCustomElement$
|
|
490
|
+
defineCustomElement$3();
|
|
300
491
|
}
|
|
301
492
|
break;
|
|
302
493
|
case "snk-filter-list":
|
|
494
|
+
if (!customElements.get(tagName)) {
|
|
495
|
+
defineCustomElement$2();
|
|
496
|
+
}
|
|
497
|
+
break;
|
|
498
|
+
case "snk-filter-modal":
|
|
303
499
|
if (!customElements.get(tagName)) {
|
|
304
500
|
defineCustomElement$1();
|
|
305
501
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
2
3
|
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
3
4
|
|
|
4
5
|
const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
@@ -22,6 +23,8 @@ const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
22
23
|
return "snk-filter-search";
|
|
23
24
|
case FilterItemType.NUMBER:
|
|
24
25
|
return "snk-filter-number";
|
|
26
|
+
case FilterItemType.PERSONALIZED:
|
|
27
|
+
return "snk-filter-personalized";
|
|
25
28
|
}
|
|
26
29
|
return "snk-filter-text";
|
|
27
30
|
}
|
|
@@ -37,9 +40,41 @@ const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
37
40
|
h("ez-icon", { title: this.getMessage(this.config.fixed ? "snkFilterBar.unpinFilter" : "snkFilterBar.pinFilter"), class: "ez-margin-left--small sc-snk-filter-bar snk-filter-item__editor-header-button", iconName: this.config.fixed ? "un-pin" : "push-pin", onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { fixed: !this.config.fixed })) })
|
|
38
41
|
]);
|
|
39
42
|
}
|
|
43
|
+
apply() {
|
|
44
|
+
var _a;
|
|
45
|
+
let isValid = true;
|
|
46
|
+
const value = this._editor["value"];
|
|
47
|
+
/* WARNING: Temporário. Isso só está sendo feito até desconsiderar os parametros não informados para PersonalizedFilter*/
|
|
48
|
+
if (value != undefined && this.config.type === FilterItemType.PERSONALIZED) {
|
|
49
|
+
const params = ((_a = this.config.props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || [];
|
|
50
|
+
if (params.length > 1) {
|
|
51
|
+
if (params.length > value.length) {
|
|
52
|
+
isValid = false;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
value.forEach(item => {
|
|
56
|
+
if (item == undefined) {
|
|
57
|
+
isValid = false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!isValid) {
|
|
63
|
+
this.keepOpened = true;
|
|
64
|
+
ApplicationUtils.alert("Filtro parcialmente preenchido", "Favor completar todas as informações do filtro.").then(() => setTimeout(() => this.keepOpened = false, 1));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/* WARNING: Temporário.*/
|
|
68
|
+
if (isValid) {
|
|
69
|
+
this.changeConfig(Object.assign(Object.assign({}, this.config), { value: value }));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
clear() {
|
|
73
|
+
this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
|
|
74
|
+
}
|
|
40
75
|
render() {
|
|
41
76
|
const ContentEditor = this.getContentEditor();
|
|
42
|
-
return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, fix: () => this.keepOpened = true, unfix: () => this.keepOpened = false }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.
|
|
77
|
+
return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, fix: () => this.keepOpened = true, unfix: () => this.keepOpened = false }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" }), h("ez-button", { label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
|
|
43
78
|
}
|
|
44
79
|
}, [0, "snk-filter-detail", {
|
|
45
80
|
"config": [1040],
|