@sankhyalabs/sankhyablocks 1.4.0-beta.1 → 1.4.0-beta.2
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-84fe3b86.js +20 -0
- package/dist/cjs/index-93965c41.js +141 -0
- package/dist/cjs/{index-02201bc9.js → index-e90ae303.js} +11 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +43 -25
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +10 -18
- package/dist/cjs/snk-filter-bar.cjs.entry.js +334 -146
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-detail.cjs.entry.js +37 -2
- package/dist/cjs/snk-filter-item.cjs.entry.js +34 -11
- package/dist/cjs/snk-filter-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal.cjs.entry.js +37 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +89 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +2 -2
- package/dist/cjs/snk-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +1 -1
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +1 -1
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- 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 -0
- package/dist/components/index2.js +11 -1
- package/dist/components/index3.js +139 -0
- package/dist/components/snk-application2.js +39 -19
- package/dist/components/snk-crud.js +15 -9
- package/dist/components/snk-data-unit.js +2 -11
- package/dist/components/snk-filter-bar2.js +340 -146
- package/dist/components/snk-filter-detail2.js +36 -1
- package/dist/components/snk-filter-item2.js +32 -9
- 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 +73 -0
- package/dist/components/snk-filter-personalized.d.ts +11 -0
- package/dist/components/snk-filter-personalized.js +107 -0
- package/dist/components/snk-grid2.js +15 -9
- 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/esm/index-5992b7e6.js +139 -0
- package/dist/esm/{index-f1d3e4da.js → index-c683b2b0.js} +11 -1
- package/dist/esm/index-c71285cb.js +17 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +37 -19
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-unit.entry.js +3 -11
- package/dist/esm/snk-filter-bar.entry.js +328 -140
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-detail.entry.js +37 -2
- package/dist/esm/snk-filter-item.entry.js +34 -11
- package/dist/esm/snk-filter-list.entry.js +1 -1
- package/dist/esm/snk-filter-modal.entry.js +33 -0
- package/dist/esm/snk-filter-multi-select.entry.js +1 -1
- package/dist/esm/snk-filter-number.entry.js +1 -1
- package/dist/esm/snk-filter-period.entry.js +1 -1
- package/dist/esm/snk-filter-personalized.entry.js +85 -0
- package/dist/esm/snk-filter-search.entry.js +2 -2
- package/dist/esm/snk-form.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +1 -1
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +1 -1
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/{esm/SnkMessageBuilder-a7da466b.js → sankhyablocks/SnkMessageBuilder-35a20271.js} +15 -119
- package/dist/sankhyablocks/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
- package/dist/sankhyablocks/index-5992b7e6.js +139 -0
- package/dist/sankhyablocks/{index-f1d3e4da.js → index-c683b2b0.js} +11 -1
- package/dist/sankhyablocks/index-c71285cb.js +17 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/sankhyablocks/snk-application.entry.js +37 -19
- package/dist/sankhyablocks/snk-crud.entry.js +1 -1
- package/dist/sankhyablocks/snk-data-unit.entry.js +3 -11
- package/dist/sankhyablocks/snk-filter-bar.entry.js +328 -140
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +1 -1
- package/dist/sankhyablocks/snk-filter-detail.entry.js +37 -2
- package/dist/sankhyablocks/snk-filter-item.entry.js +34 -11
- package/dist/sankhyablocks/snk-filter-list.entry.js +1 -1
- package/dist/sankhyablocks/snk-filter-modal.entry.js +33 -0
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +1 -1
- package/dist/sankhyablocks/snk-filter-number.entry.js +1 -1
- package/dist/sankhyablocks/snk-filter-period.entry.js +1 -1
- package/dist/sankhyablocks/snk-filter-personalized.entry.js +85 -0
- package/dist/sankhyablocks/snk-filter-search.entry.js +2 -2
- package/dist/sankhyablocks/snk-form.entry.js +1 -1
- package/dist/sankhyablocks/snk-grid.entry.js +1 -1
- package/dist/sankhyablocks/snk-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/snk-taskbar.entry.js +1 -1
- package/dist/sankhyablocks/teste-pesquisa.entry.js +1 -1
- 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/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -51
|
@@ -1,11 +1,109 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import { b as DataType,
|
|
2
|
+
import { t as toString, b as DataType, O as ObjectUtils, S as StringUtils, E as ErrorException, A as ApplicationContext } from './index2.js';
|
|
3
3
|
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
4
|
-
import { d as defineCustomElement$
|
|
5
|
-
import { d as defineCustomElement$
|
|
6
|
-
import { d as defineCustomElement$
|
|
4
|
+
import { M as ModalAction, d as defineCustomElement$1 } from './snk-filter-modal2.js';
|
|
5
|
+
import { d as defineCustomElement$4 } from './snk-filter-detail2.js';
|
|
6
|
+
import { d as defineCustomElement$3 } from './snk-filter-item2.js';
|
|
7
|
+
import { d as defineCustomElement$2 } from './snk-filter-list2.js';
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
+
const buildFilter = (item) => {
|
|
10
|
+
switch (item.type) {
|
|
11
|
+
case FilterItemType.DEFAULT_FILTER:
|
|
12
|
+
return buildDefault(item);
|
|
13
|
+
case FilterItemType.BINARY_SELECT:
|
|
14
|
+
return buildBinary(item);
|
|
15
|
+
case FilterItemType.MULTI_SELECT:
|
|
16
|
+
return buildMultSelect(item);
|
|
17
|
+
case FilterItemType.PERIOD:
|
|
18
|
+
return buildPeriod(item);
|
|
19
|
+
case FilterItemType.SEARCH:
|
|
20
|
+
return buildSearch(item);
|
|
21
|
+
case FilterItemType.TEXT:
|
|
22
|
+
return buildText(item);
|
|
23
|
+
case FilterItemType.NUMBER:
|
|
24
|
+
return buildNumber(item);
|
|
25
|
+
case FilterItemType.PERSONALIZED:
|
|
26
|
+
return buildPersonalized(item);
|
|
27
|
+
default:
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function buildDefault(item) {
|
|
32
|
+
return { name: item.id, expression: item.props.expression, params: [] };
|
|
33
|
+
}
|
|
34
|
+
function buildBinary(item) {
|
|
35
|
+
const { id, value, props } = item;
|
|
36
|
+
const options = props.options;
|
|
37
|
+
const selectedOption = options.find(opt => opt.name === value);
|
|
38
|
+
return { name: id, expression: selectedOption.expression, params: [] };
|
|
39
|
+
}
|
|
40
|
+
function buildMultSelect(item) {
|
|
41
|
+
const { id, value, props } = item;
|
|
42
|
+
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
43
|
+
}
|
|
44
|
+
function buildPeriod(item) {
|
|
45
|
+
const { id, value, props } = item;
|
|
46
|
+
let { end, start } = value;
|
|
47
|
+
if (typeof end === "string") {
|
|
48
|
+
end = new Date(end);
|
|
49
|
+
}
|
|
50
|
+
if (typeof start === "string") {
|
|
51
|
+
start = new Date(start);
|
|
52
|
+
}
|
|
53
|
+
const params = [];
|
|
54
|
+
let expression;
|
|
55
|
+
if (end && start) {
|
|
56
|
+
expression = props.expression.fullfill;
|
|
57
|
+
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (start) {
|
|
61
|
+
expression = props.expression.onlystart;
|
|
62
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
expression = props.expression.onlyend;
|
|
66
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { name: id, expression, params };
|
|
70
|
+
}
|
|
71
|
+
function buildSearch(item) {
|
|
72
|
+
const { id, value, props } = item;
|
|
73
|
+
const expression = props.expression;
|
|
74
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
75
|
+
}
|
|
76
|
+
function buildText(item) {
|
|
77
|
+
const { id, value, props } = item;
|
|
78
|
+
const expression = props.expression;
|
|
79
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
80
|
+
}
|
|
81
|
+
function buildNumber(item) {
|
|
82
|
+
const { id, value, props } = item;
|
|
83
|
+
const expression = props.expression;
|
|
84
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
85
|
+
}
|
|
86
|
+
function buildPersonalized(item) {
|
|
87
|
+
var _a;
|
|
88
|
+
const { id, value, props } = item;
|
|
89
|
+
const expression = props.expression;
|
|
90
|
+
return {
|
|
91
|
+
name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
|
|
92
|
+
const valuesArray = Array.from(value);
|
|
93
|
+
const dataType = param.dataType;
|
|
94
|
+
let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
|
|
95
|
+
if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
|
|
96
|
+
paramValue = paramValue["value"];
|
|
97
|
+
}
|
|
98
|
+
if (paramValue == undefined && dataType === DataType.BOOLEAN) {
|
|
99
|
+
paramValue = false;
|
|
100
|
+
}
|
|
101
|
+
return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
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
107
|
|
|
10
108
|
const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
|
|
11
109
|
const DEFAULT_FILTER = "DEFAULT_FILTER";
|
|
@@ -15,6 +113,9 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
15
113
|
super();
|
|
16
114
|
this.__registerHost();
|
|
17
115
|
this._updateSequence = [];
|
|
116
|
+
this._loadingPending = false;
|
|
117
|
+
this._configUpdated = false;
|
|
118
|
+
this._pendingFilters = [];
|
|
18
119
|
this._calculateSortIndex = (item) => {
|
|
19
120
|
let index = item.hardFixed ? 1000000 : 0;
|
|
20
121
|
//campos Hard Fixed não variam a ordem
|
|
@@ -29,6 +130,54 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
29
130
|
return this._calculateSortIndex(b) - this._calculateSortIndex(a);
|
|
30
131
|
};
|
|
31
132
|
}
|
|
133
|
+
observeFilterConfig(newValue, oldValue) {
|
|
134
|
+
if (oldValue != undefined && newValue == undefined) {
|
|
135
|
+
this._loadingPending = true;
|
|
136
|
+
this._configUpdated = true;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
|
|
140
|
+
newValue.forEach(newItem => {
|
|
141
|
+
const oldItem = oldItems.get(newItem.id);
|
|
142
|
+
if (oldItem != undefined) {
|
|
143
|
+
this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
|
|
144
|
+
this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this._configUpdated = true;
|
|
148
|
+
this._loadingPending = this._loadingPending || newItem.value != undefined;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
this.processAfterUpdateConfig();
|
|
153
|
+
}
|
|
154
|
+
processPendingFilter() {
|
|
155
|
+
if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
|
|
156
|
+
this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
|
|
157
|
+
if (this._currentPendingFilter) {
|
|
158
|
+
this._currentPendingFilter.showUp(true).then(() => {
|
|
159
|
+
this._currentPendingFilter = undefined;
|
|
160
|
+
this.processPendingFilter();
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (this._currentPendingFilter == undefined) {
|
|
165
|
+
this.processAfterUpdateConfig();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
processAfterUpdateConfig() {
|
|
169
|
+
if (this._pendingFilters.length > 0) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (this._loadingPending) {
|
|
173
|
+
this._loadingPending = false;
|
|
174
|
+
this.dataUnit.loadData();
|
|
175
|
+
}
|
|
176
|
+
if (this._configUpdated) {
|
|
177
|
+
this._configUpdated = false;
|
|
178
|
+
this._application.saveFilterBarConfig(this.filterConfig, this.configName);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
32
181
|
/**
|
|
33
182
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
34
183
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -41,101 +190,21 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
41
190
|
getFilter(_dataUnit) {
|
|
42
191
|
var _a;
|
|
43
192
|
const filters = [];
|
|
44
|
-
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => item
|
|
45
|
-
const filter =
|
|
193
|
+
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
|
|
194
|
+
const filter = buildFilter(item);
|
|
46
195
|
if (filter) {
|
|
47
196
|
filters.push(filter);
|
|
48
197
|
}
|
|
49
198
|
});
|
|
50
199
|
return filters;
|
|
51
200
|
}
|
|
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;
|
|
201
|
+
isActiveFilter(item) {
|
|
202
|
+
return (item.visible && item.value != undefined) || item.type === FilterItemType.DEFAULT_FILTER;
|
|
105
203
|
}
|
|
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);
|
|
204
|
+
registryFilterProvider() {
|
|
205
|
+
this.dataUnit.addFilterProvider(this);
|
|
206
|
+
if (this.filterConfig) {
|
|
207
|
+
this.dataUnit.loadData();
|
|
139
208
|
}
|
|
140
209
|
}
|
|
141
210
|
getFilterItems() {
|
|
@@ -143,9 +212,8 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
143
212
|
const unpinnedItems = [];
|
|
144
213
|
this.filterConfig
|
|
145
214
|
.filter(item => item.visible)
|
|
146
|
-
.sort((a, b) => this._filtersComparator(a, b))
|
|
147
215
|
.forEach((item, index) => {
|
|
148
|
-
const filterItem = (h("snk-filter-item", { id: `filter-${item.id}`, config:
|
|
216
|
+
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
217
|
if (item.fixed || item.hardFixed) {
|
|
150
218
|
pinnedItems.push(filterItem);
|
|
151
219
|
}
|
|
@@ -168,9 +236,6 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
168
236
|
this._updateSequence.push(item.id);
|
|
169
237
|
}
|
|
170
238
|
}
|
|
171
|
-
filterChangeListener(evt) {
|
|
172
|
-
this.updateFilter(evt.detail);
|
|
173
|
-
}
|
|
174
239
|
normalizeItem(item) {
|
|
175
240
|
const normalized = Object.assign({}, item);
|
|
176
241
|
const optionals = ["props", "value", "hardFixed", "fixed"];
|
|
@@ -184,87 +249,207 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
184
249
|
}
|
|
185
250
|
return normalized;
|
|
186
251
|
}
|
|
187
|
-
updateFilter(newItem
|
|
188
|
-
let needLoad = false;
|
|
189
|
-
let updated = false;
|
|
252
|
+
updateFilter(newItem) {
|
|
190
253
|
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;
|
|
254
|
+
newItem = this.normalizeItem(newItem);
|
|
255
|
+
if (item.id === newItem.id) {
|
|
256
|
+
if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
|
|
257
|
+
this.calculateUpdateSequence(newItem);
|
|
205
258
|
}
|
|
259
|
+
return newItem;
|
|
206
260
|
}
|
|
207
261
|
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;
|
|
262
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
217
263
|
}
|
|
218
264
|
getAddListItems() {
|
|
219
265
|
const hiddenItems = this.filterConfig
|
|
220
|
-
.filter(item => !item.visible)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
]);
|
|
266
|
+
.filter(item => !item.visible && this.isListable(item));
|
|
267
|
+
const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
|
|
268
|
+
if (this.allowDefault) {
|
|
269
|
+
footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
|
|
270
|
+
}
|
|
271
|
+
return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
|
|
272
|
+
.concat(footerItems);
|
|
228
273
|
}
|
|
229
274
|
getActiveClass() {
|
|
230
275
|
const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
|
|
231
276
|
return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
|
|
232
277
|
}
|
|
278
|
+
isListable(item, allowPersonalized = false) {
|
|
279
|
+
return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
|
|
280
|
+
}
|
|
233
281
|
getAppliedListItems() {
|
|
234
282
|
const appliedItems = this.filterConfig
|
|
235
|
-
.filter(item => item.
|
|
236
|
-
.sort(this._filtersComparator);
|
|
283
|
+
.filter(item => this.isActiveFilter(item) && this.isListable(item, true));
|
|
237
284
|
return appliedItems.map(filter => {
|
|
238
285
|
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
239
286
|
}).concat([
|
|
240
287
|
{ name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
|
|
241
288
|
]);
|
|
242
289
|
}
|
|
290
|
+
addPersonalizedFilters(personalizedItems) {
|
|
291
|
+
const activeFilters = {};
|
|
292
|
+
personalizedItems.forEach(item => {
|
|
293
|
+
if (item.active) {
|
|
294
|
+
activeFilters[item.id] = true;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
298
|
+
var _a, _b;
|
|
299
|
+
if (item.type === FilterItemType.PERSONALIZED) {
|
|
300
|
+
const visible = activeFilters[item.id];
|
|
301
|
+
if (!item.visible && visible) {
|
|
302
|
+
this.calculateUpdateSequence(item);
|
|
303
|
+
if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
|
|
304
|
+
this._pendingFilters.push(item.id);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
|
|
308
|
+
}
|
|
309
|
+
return item;
|
|
310
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
311
|
+
}
|
|
312
|
+
openDefaultFilterModal() {
|
|
313
|
+
const filterModal = document.createElement("snk-filter-modal");
|
|
314
|
+
const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
|
|
315
|
+
filterModal.getMessage = (key, props) => this.getMessage(key, props);
|
|
316
|
+
filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
|
|
317
|
+
filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
|
|
318
|
+
filterModal.items = defaultFilter.map(item => {
|
|
319
|
+
return { id: item.id, active: true, enabled: false, label: item.label };
|
|
320
|
+
});
|
|
321
|
+
filterModal.processModalAction = (_action) => {
|
|
322
|
+
this._application.closeModal();
|
|
323
|
+
};
|
|
324
|
+
this._application.showModal(filterModal);
|
|
325
|
+
}
|
|
326
|
+
openPersonalizedModal() {
|
|
327
|
+
const filterModal = document.createElement("snk-filter-modal");
|
|
328
|
+
const personalizedFilter = this.filterConfig
|
|
329
|
+
.filter(item => item.type === FilterItemType.PERSONALIZED)
|
|
330
|
+
.sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
|
|
331
|
+
filterModal.getMessage = (key, props) => this.getMessage(key, props);
|
|
332
|
+
filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
|
|
333
|
+
filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
|
|
334
|
+
filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
|
|
335
|
+
filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
|
|
336
|
+
filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
|
|
337
|
+
filterModal.useSearch = true;
|
|
338
|
+
filterModal.items = personalizedFilter.map(item => {
|
|
339
|
+
return { id: item.id, active: item.visible, enabled: true, label: item.label };
|
|
340
|
+
});
|
|
341
|
+
filterModal.processModalAction = (action) => {
|
|
342
|
+
if (action === ModalAction.CANCEL) {
|
|
343
|
+
// O Botão de cancelar, tem efeito específico:
|
|
344
|
+
// - Desmarcar todos os filtros personalizados.
|
|
345
|
+
filterModal.items = filterModal.items.map(item => {
|
|
346
|
+
return Object.assign(Object.assign({}, item), { active: false });
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
if (action === ModalAction.OK) {
|
|
351
|
+
this.addPersonalizedFilters(filterModal.items);
|
|
352
|
+
}
|
|
353
|
+
this._application.closeModal();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
this._application.showModal(filterModal);
|
|
357
|
+
}
|
|
358
|
+
clearFilters() {
|
|
359
|
+
let changed = false;
|
|
360
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
361
|
+
if (item.value != undefined) {
|
|
362
|
+
changed = true;
|
|
363
|
+
}
|
|
364
|
+
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
365
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
366
|
+
return changed;
|
|
367
|
+
}
|
|
368
|
+
loadPermitions() {
|
|
369
|
+
this._application.isUserSup().then(value => this.allowDefault = value);
|
|
370
|
+
}
|
|
371
|
+
loadConfigFromApplication() {
|
|
372
|
+
this._application.getFilterBarConfig(this.configName)
|
|
373
|
+
.then((filters) => {
|
|
374
|
+
this.filterConfig = filters.map(item => this.normalizeItem(item));
|
|
375
|
+
if (this.dataUnit) {
|
|
376
|
+
this.dataUnit.loadData();
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
.catch(reason => {
|
|
380
|
+
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
attachDataUnit() {
|
|
384
|
+
if (this.dataUnit == undefined) {
|
|
385
|
+
let parent = this._element.parentElement;
|
|
386
|
+
while (parent) {
|
|
387
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
388
|
+
const snkDataUnit = parent;
|
|
389
|
+
this.dataUnit = snkDataUnit.dataUnit;
|
|
390
|
+
if (this.dataUnit) {
|
|
391
|
+
this.registryFilterProvider();
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
395
|
+
this.dataUnit = evt.detail;
|
|
396
|
+
this.registryFilterProvider();
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
parent = parent.parentElement;
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
this.registryFilterProvider();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
filterChangeListener(evt) {
|
|
409
|
+
this.updateFilter(evt.detail);
|
|
410
|
+
}
|
|
243
411
|
addFilterHandler(itemName) {
|
|
244
412
|
const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
|
|
245
|
-
if (
|
|
413
|
+
if (itemName === PERSONALIZED_FILTER) {
|
|
414
|
+
this.openPersonalizedModal();
|
|
415
|
+
}
|
|
416
|
+
else if (itemName === DEFAULT_FILTER) {
|
|
417
|
+
this.openDefaultFilterModal();
|
|
418
|
+
}
|
|
419
|
+
else if (filterItem) {
|
|
246
420
|
this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
|
|
247
421
|
window.requestAnimationFrame(() => {
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
|
|
422
|
+
const filterItemElement = this._element.querySelector("#filter-" + itemName);
|
|
423
|
+
if (filterItemElement) {
|
|
424
|
+
filterItemElement.showUp();
|
|
251
425
|
}
|
|
252
426
|
});
|
|
253
427
|
}
|
|
254
428
|
}
|
|
255
429
|
appliedFilterHandler(itemName) {
|
|
256
430
|
if (itemName === CLEAR_ALL_FILTERS) {
|
|
257
|
-
if (this.
|
|
431
|
+
if (this.clearFilters()) {
|
|
258
432
|
this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
|
|
259
433
|
}
|
|
260
434
|
}
|
|
261
435
|
else {
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
|
|
436
|
+
const filterItemElement = this._element.querySelector("#filter-" + itemName);
|
|
437
|
+
if (filterItemElement) {
|
|
438
|
+
filterItemElement.showUp(true);
|
|
265
439
|
}
|
|
266
440
|
}
|
|
267
441
|
}
|
|
442
|
+
componentWillLoad() {
|
|
443
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
444
|
+
if (this._application) {
|
|
445
|
+
this.loadPermitions();
|
|
446
|
+
this.loadConfigFromApplication();
|
|
447
|
+
}
|
|
448
|
+
this.attachDataUnit();
|
|
449
|
+
}
|
|
450
|
+
componentDidRender() {
|
|
451
|
+
this.processPendingFilter();
|
|
452
|
+
}
|
|
268
453
|
render() {
|
|
269
454
|
if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
|
|
270
455
|
return undefined;
|
|
@@ -272,17 +457,21 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
272
457
|
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
458
|
}
|
|
274
459
|
get _element() { return this; }
|
|
460
|
+
static get watchers() { return {
|
|
461
|
+
"filterConfig": ["observeFilterConfig"]
|
|
462
|
+
}; }
|
|
275
463
|
static get style() { return snkFilterBarCss; }
|
|
276
464
|
}, [2, "snk-filter-bar", {
|
|
277
465
|
"dataUnit": [1040],
|
|
278
466
|
"configName": [1, "config-name"],
|
|
279
|
-
"filterConfig": [1040]
|
|
467
|
+
"filterConfig": [1040],
|
|
468
|
+
"allowDefault": [32]
|
|
280
469
|
}, [[0, "filterChange", "filterChangeListener"]]]);
|
|
281
470
|
function defineCustomElement() {
|
|
282
471
|
if (typeof customElements === "undefined") {
|
|
283
472
|
return;
|
|
284
473
|
}
|
|
285
|
-
const components = ["snk-filter-bar", "snk-filter-detail", "snk-filter-item", "snk-filter-list"];
|
|
474
|
+
const components = ["snk-filter-bar", "snk-filter-detail", "snk-filter-item", "snk-filter-list", "snk-filter-modal"];
|
|
286
475
|
components.forEach(tagName => { switch (tagName) {
|
|
287
476
|
case "snk-filter-bar":
|
|
288
477
|
if (!customElements.get(tagName)) {
|
|
@@ -291,15 +480,20 @@ function defineCustomElement() {
|
|
|
291
480
|
break;
|
|
292
481
|
case "snk-filter-detail":
|
|
293
482
|
if (!customElements.get(tagName)) {
|
|
294
|
-
defineCustomElement$
|
|
483
|
+
defineCustomElement$4();
|
|
295
484
|
}
|
|
296
485
|
break;
|
|
297
486
|
case "snk-filter-item":
|
|
298
487
|
if (!customElements.get(tagName)) {
|
|
299
|
-
defineCustomElement$
|
|
488
|
+
defineCustomElement$3();
|
|
300
489
|
}
|
|
301
490
|
break;
|
|
302
491
|
case "snk-filter-list":
|
|
492
|
+
if (!customElements.get(tagName)) {
|
|
493
|
+
defineCustomElement$2();
|
|
494
|
+
}
|
|
495
|
+
break;
|
|
496
|
+
case "snk-filter-modal":
|
|
303
497
|
if (!customElements.get(tagName)) {
|
|
304
498
|
defineCustomElement$1();
|
|
305
499
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { A as ApplicationUtils } from './index3.js';
|
|
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],
|