@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,13 +1,17 @@
|
|
|
1
1
|
import { h, Host } from '@stencil/core';
|
|
2
|
-
import { ApplicationContext,
|
|
2
|
+
import { ApplicationContext, ErrorException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
|
3
3
|
import FilterItemType from './filter-item/filter-item-type.enum';
|
|
4
|
-
import {
|
|
4
|
+
import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
|
|
5
|
+
import buildFilter from './filter-item/dataunitfilter/data-unit-filter-builder';
|
|
5
6
|
const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
|
|
6
7
|
const DEFAULT_FILTER = "DEFAULT_FILTER";
|
|
7
8
|
const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
|
|
8
9
|
export class SnkFilterBar {
|
|
9
10
|
constructor() {
|
|
10
11
|
this._updateSequence = [];
|
|
12
|
+
this._loadingPending = false;
|
|
13
|
+
this._configUpdated = false;
|
|
14
|
+
this._pendingFilters = [];
|
|
11
15
|
this._calculateSortIndex = (item) => {
|
|
12
16
|
let index = item.hardFixed ? 1000000 : 0;
|
|
13
17
|
//campos Hard Fixed não variam a ordem
|
|
@@ -22,6 +26,54 @@ export class SnkFilterBar {
|
|
|
22
26
|
return this._calculateSortIndex(b) - this._calculateSortIndex(a);
|
|
23
27
|
};
|
|
24
28
|
}
|
|
29
|
+
observeFilterConfig(newValue, oldValue) {
|
|
30
|
+
if (oldValue != undefined && newValue == undefined) {
|
|
31
|
+
this._loadingPending = true;
|
|
32
|
+
this._configUpdated = true;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
|
|
36
|
+
newValue.forEach(newItem => {
|
|
37
|
+
const oldItem = oldItems.get(newItem.id);
|
|
38
|
+
if (oldItem != undefined) {
|
|
39
|
+
this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
|
|
40
|
+
this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this._configUpdated = true;
|
|
44
|
+
this._loadingPending = this._loadingPending || newItem.value != undefined;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
this.processAfterUpdateConfig();
|
|
49
|
+
}
|
|
50
|
+
processPendingFilter() {
|
|
51
|
+
if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
|
|
52
|
+
this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
|
|
53
|
+
if (this._currentPendingFilter) {
|
|
54
|
+
this._currentPendingFilter.showUp(true).then(() => {
|
|
55
|
+
this._currentPendingFilter = undefined;
|
|
56
|
+
this.processPendingFilter();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (this._currentPendingFilter == undefined) {
|
|
61
|
+
this.processAfterUpdateConfig();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
processAfterUpdateConfig() {
|
|
65
|
+
if (this._pendingFilters.length > 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (this._loadingPending) {
|
|
69
|
+
this._loadingPending = false;
|
|
70
|
+
this.dataUnit.loadData();
|
|
71
|
+
}
|
|
72
|
+
if (this._configUpdated) {
|
|
73
|
+
this._configUpdated = false;
|
|
74
|
+
this._application.saveFilterBarConfig(this.filterConfig, this.configName);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
25
77
|
/**
|
|
26
78
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
27
79
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -34,101 +86,21 @@ export class SnkFilterBar {
|
|
|
34
86
|
getFilter(_dataUnit) {
|
|
35
87
|
var _a;
|
|
36
88
|
const filters = [];
|
|
37
|
-
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => item
|
|
38
|
-
const filter =
|
|
89
|
+
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
|
|
90
|
+
const filter = buildFilter(item);
|
|
39
91
|
if (filter) {
|
|
40
92
|
filters.push(filter);
|
|
41
93
|
}
|
|
42
94
|
});
|
|
43
95
|
return filters;
|
|
44
96
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (value && visible) {
|
|
48
|
-
if (type === FilterItemType.BINARY_SELECT) {
|
|
49
|
-
const options = props.options;
|
|
50
|
-
const selectedOption = options.find(opt => opt.name === value);
|
|
51
|
-
//FIXME: ajustar o backend para não exigir parametros
|
|
52
|
-
return { name: id, expression: selectedOption.expression, params: [] };
|
|
53
|
-
}
|
|
54
|
-
if (type === FilterItemType.MULTI_SELECT) {
|
|
55
|
-
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
56
|
-
}
|
|
57
|
-
if (type === FilterItemType.PERIOD) {
|
|
58
|
-
let { end, start } = value;
|
|
59
|
-
if (typeof end === "string") {
|
|
60
|
-
end = new Date(end);
|
|
61
|
-
}
|
|
62
|
-
if (typeof start === "string") {
|
|
63
|
-
start = new Date(start);
|
|
64
|
-
}
|
|
65
|
-
const params = [];
|
|
66
|
-
let expression;
|
|
67
|
-
if (end && start) {
|
|
68
|
-
expression = props.expression.fullfill;
|
|
69
|
-
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
if (start) {
|
|
73
|
-
expression = props.expression.onlystart;
|
|
74
|
-
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
expression = props.expression.onlyend;
|
|
78
|
-
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return { name: id, expression, params };
|
|
82
|
-
}
|
|
83
|
-
if (type === FilterItemType.SEARCH) {
|
|
84
|
-
const expression = props.expression;
|
|
85
|
-
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
86
|
-
}
|
|
87
|
-
if (type === FilterItemType.TEXT) {
|
|
88
|
-
const expression = props.expression;
|
|
89
|
-
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
90
|
-
}
|
|
91
|
-
if (type === FilterItemType.NUMBER) {
|
|
92
|
-
const expression = props.expression;
|
|
93
|
-
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
94
|
-
}
|
|
95
|
-
//No mapeamento dos outros tipos precisamos saber o tipo de dado.
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
97
|
+
isActiveFilter(item) {
|
|
98
|
+
return (item.visible && item.value != undefined) || item.type === FilterItemType.DEFAULT_FILTER;
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
if (this.
|
|
102
|
-
this.
|
|
103
|
-
.then((filters) => {
|
|
104
|
-
this.filterConfig = filters;
|
|
105
|
-
})
|
|
106
|
-
.catch(reason => {
|
|
107
|
-
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
if (this.dataUnit == undefined) {
|
|
111
|
-
let parent = this._element.parentElement;
|
|
112
|
-
while (parent) {
|
|
113
|
-
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
114
|
-
const snkDataUnit = parent;
|
|
115
|
-
this.dataUnit = snkDataUnit.dataUnit;
|
|
116
|
-
if (this.dataUnit) {
|
|
117
|
-
this.dataUnit.addFilterProvider(this);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
121
|
-
this.dataUnit = evt.detail;
|
|
122
|
-
this.dataUnit.addFilterProvider(this);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
parent = parent.parentElement;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
this.dataUnit.addFilterProvider(this);
|
|
100
|
+
registryFilterProvider() {
|
|
101
|
+
this.dataUnit.addFilterProvider(this);
|
|
102
|
+
if (this.filterConfig) {
|
|
103
|
+
this.dataUnit.loadData();
|
|
132
104
|
}
|
|
133
105
|
}
|
|
134
106
|
getFilterItems() {
|
|
@@ -136,9 +108,8 @@ export class SnkFilterBar {
|
|
|
136
108
|
const unpinnedItems = [];
|
|
137
109
|
this.filterConfig
|
|
138
110
|
.filter(item => item.visible)
|
|
139
|
-
.sort((a, b) => this._filtersComparator(a, b))
|
|
140
111
|
.forEach((item, index) => {
|
|
141
|
-
const filterItem = (h("snk-filter-item", { id: `filter-${item.id}`, config:
|
|
112
|
+
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 }));
|
|
142
113
|
if (item.fixed || item.hardFixed) {
|
|
143
114
|
pinnedItems.push(filterItem);
|
|
144
115
|
}
|
|
@@ -161,9 +132,6 @@ export class SnkFilterBar {
|
|
|
161
132
|
this._updateSequence.push(item.id);
|
|
162
133
|
}
|
|
163
134
|
}
|
|
164
|
-
filterChangeListener(evt) {
|
|
165
|
-
this.updateFilter(evt.detail);
|
|
166
|
-
}
|
|
167
135
|
normalizeItem(item) {
|
|
168
136
|
const normalized = Object.assign({}, item);
|
|
169
137
|
const optionals = ["props", "value", "hardFixed", "fixed"];
|
|
@@ -177,87 +145,207 @@ export class SnkFilterBar {
|
|
|
177
145
|
}
|
|
178
146
|
return normalized;
|
|
179
147
|
}
|
|
180
|
-
updateFilter(newItem
|
|
181
|
-
let needLoad = false;
|
|
182
|
-
let updated = false;
|
|
148
|
+
updateFilter(newItem) {
|
|
183
149
|
this.filterConfig = this.filterConfig.map(item => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
if (item.id === newItem.id) {
|
|
193
|
-
const normalizedOne = this.normalizeItem(item);
|
|
194
|
-
const normalizedTwo = this.normalizeItem(newItem);
|
|
195
|
-
updated = ObjectUtils.objectToString(normalizedOne) != ObjectUtils.objectToString(normalizedTwo);
|
|
196
|
-
needLoad = ObjectUtils.objectToString(normalizedOne.value) !== ObjectUtils.objectToString(normalizedTwo.value);
|
|
197
|
-
return newItem;
|
|
150
|
+
newItem = this.normalizeItem(newItem);
|
|
151
|
+
if (item.id === newItem.id) {
|
|
152
|
+
if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
|
|
153
|
+
this.calculateUpdateSequence(newItem);
|
|
198
154
|
}
|
|
155
|
+
return newItem;
|
|
199
156
|
}
|
|
200
157
|
return item;
|
|
201
|
-
});
|
|
202
|
-
if (needLoad) {
|
|
203
|
-
this.dataUnit.loadData();
|
|
204
|
-
}
|
|
205
|
-
if (updated) {
|
|
206
|
-
this.calculateUpdateSequence(newItem);
|
|
207
|
-
this._application.saveFilterBarConfig(this.filterConfig, this.configName);
|
|
208
|
-
}
|
|
209
|
-
return needLoad;
|
|
158
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
210
159
|
}
|
|
211
160
|
getAddListItems() {
|
|
212
161
|
const hiddenItems = this.filterConfig
|
|
213
|
-
.filter(item => !item.visible)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
]);
|
|
162
|
+
.filter(item => !item.visible && this.isListable(item));
|
|
163
|
+
const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
|
|
164
|
+
if (this.allowDefault) {
|
|
165
|
+
footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
|
|
166
|
+
}
|
|
167
|
+
return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
|
|
168
|
+
.concat(footerItems);
|
|
221
169
|
}
|
|
222
170
|
getActiveClass() {
|
|
223
171
|
const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
|
|
224
172
|
return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
|
|
225
173
|
}
|
|
174
|
+
isListable(item, allowPersonalized = false) {
|
|
175
|
+
return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
|
|
176
|
+
}
|
|
226
177
|
getAppliedListItems() {
|
|
227
178
|
const appliedItems = this.filterConfig
|
|
228
|
-
.filter(item => item.
|
|
229
|
-
.sort(this._filtersComparator);
|
|
179
|
+
.filter(item => this.isActiveFilter(item) && this.isListable(item, true));
|
|
230
180
|
return appliedItems.map(filter => {
|
|
231
181
|
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
232
182
|
}).concat([
|
|
233
183
|
{ name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
|
|
234
184
|
]);
|
|
235
185
|
}
|
|
186
|
+
addPersonalizedFilters(personalizedItems) {
|
|
187
|
+
const activeFilters = {};
|
|
188
|
+
personalizedItems.forEach(item => {
|
|
189
|
+
if (item.active) {
|
|
190
|
+
activeFilters[item.id] = true;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
194
|
+
var _a, _b;
|
|
195
|
+
if (item.type === FilterItemType.PERSONALIZED) {
|
|
196
|
+
const visible = activeFilters[item.id];
|
|
197
|
+
if (!item.visible && visible) {
|
|
198
|
+
this.calculateUpdateSequence(item);
|
|
199
|
+
if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
|
|
200
|
+
this._pendingFilters.push(item.id);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
|
|
204
|
+
}
|
|
205
|
+
return item;
|
|
206
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
207
|
+
}
|
|
208
|
+
openDefaultFilterModal() {
|
|
209
|
+
const filterModal = document.createElement("snk-filter-modal");
|
|
210
|
+
const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
|
|
211
|
+
filterModal.getMessage = (key, props) => this.getMessage(key, props);
|
|
212
|
+
filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
|
|
213
|
+
filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
|
|
214
|
+
filterModal.items = defaultFilter.map(item => {
|
|
215
|
+
return { id: item.id, active: true, enabled: false, label: item.label };
|
|
216
|
+
});
|
|
217
|
+
filterModal.processModalAction = (_action) => {
|
|
218
|
+
this._application.closeModal();
|
|
219
|
+
};
|
|
220
|
+
this._application.showModal(filterModal);
|
|
221
|
+
}
|
|
222
|
+
openPersonalizedModal() {
|
|
223
|
+
const filterModal = document.createElement("snk-filter-modal");
|
|
224
|
+
const personalizedFilter = this.filterConfig
|
|
225
|
+
.filter(item => item.type === FilterItemType.PERSONALIZED)
|
|
226
|
+
.sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
|
|
227
|
+
filterModal.getMessage = (key, props) => this.getMessage(key, props);
|
|
228
|
+
filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
|
|
229
|
+
filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
|
|
230
|
+
filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
|
|
231
|
+
filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
|
|
232
|
+
filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
|
|
233
|
+
filterModal.useSearch = true;
|
|
234
|
+
filterModal.items = personalizedFilter.map(item => {
|
|
235
|
+
return { id: item.id, active: item.visible, enabled: true, label: item.label };
|
|
236
|
+
});
|
|
237
|
+
filterModal.processModalAction = (action) => {
|
|
238
|
+
if (action === ModalAction.CANCEL) {
|
|
239
|
+
// O Botão de cancelar, tem efeito específico:
|
|
240
|
+
// - Desmarcar todos os filtros personalizados.
|
|
241
|
+
filterModal.items = filterModal.items.map(item => {
|
|
242
|
+
return Object.assign(Object.assign({}, item), { active: false });
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
if (action === ModalAction.OK) {
|
|
247
|
+
this.addPersonalizedFilters(filterModal.items);
|
|
248
|
+
}
|
|
249
|
+
this._application.closeModal();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
this._application.showModal(filterModal);
|
|
253
|
+
}
|
|
254
|
+
clearFilters() {
|
|
255
|
+
let changed = false;
|
|
256
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
257
|
+
if (item.value != undefined) {
|
|
258
|
+
changed = true;
|
|
259
|
+
}
|
|
260
|
+
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
261
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
|
262
|
+
return changed;
|
|
263
|
+
}
|
|
264
|
+
loadPermitions() {
|
|
265
|
+
this._application.isUserSup().then(value => this.allowDefault = value);
|
|
266
|
+
}
|
|
267
|
+
loadConfigFromApplication() {
|
|
268
|
+
this._application.getFilterBarConfig(this.configName)
|
|
269
|
+
.then((filters) => {
|
|
270
|
+
this.filterConfig = filters.map(item => this.normalizeItem(item));
|
|
271
|
+
if (this.dataUnit) {
|
|
272
|
+
this.dataUnit.loadData();
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
.catch(reason => {
|
|
276
|
+
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
attachDataUnit() {
|
|
280
|
+
if (this.dataUnit == undefined) {
|
|
281
|
+
let parent = this._element.parentElement;
|
|
282
|
+
while (parent) {
|
|
283
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
284
|
+
const snkDataUnit = parent;
|
|
285
|
+
this.dataUnit = snkDataUnit.dataUnit;
|
|
286
|
+
if (this.dataUnit) {
|
|
287
|
+
this.registryFilterProvider();
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
291
|
+
this.dataUnit = evt.detail;
|
|
292
|
+
this.registryFilterProvider();
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
parent = parent.parentElement;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
this.registryFilterProvider();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
filterChangeListener(evt) {
|
|
305
|
+
this.updateFilter(evt.detail);
|
|
306
|
+
}
|
|
236
307
|
addFilterHandler(itemName) {
|
|
237
308
|
const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
|
|
238
|
-
if (
|
|
309
|
+
if (itemName === PERSONALIZED_FILTER) {
|
|
310
|
+
this.openPersonalizedModal();
|
|
311
|
+
}
|
|
312
|
+
else if (itemName === DEFAULT_FILTER) {
|
|
313
|
+
this.openDefaultFilterModal();
|
|
314
|
+
}
|
|
315
|
+
else if (filterItem) {
|
|
239
316
|
this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
|
|
240
317
|
window.requestAnimationFrame(() => {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
|
|
318
|
+
const filterItemElement = this._element.querySelector("#filter-" + itemName);
|
|
319
|
+
if (filterItemElement) {
|
|
320
|
+
filterItemElement.showUp();
|
|
244
321
|
}
|
|
245
322
|
});
|
|
246
323
|
}
|
|
247
324
|
}
|
|
248
325
|
appliedFilterHandler(itemName) {
|
|
249
326
|
if (itemName === CLEAR_ALL_FILTERS) {
|
|
250
|
-
if (this.
|
|
327
|
+
if (this.clearFilters()) {
|
|
251
328
|
this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
|
|
252
329
|
}
|
|
253
330
|
}
|
|
254
331
|
else {
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
332
|
+
const filterItemElement = this._element.querySelector("#filter-" + itemName);
|
|
333
|
+
if (filterItemElement) {
|
|
334
|
+
filterItemElement.showUp(true);
|
|
258
335
|
}
|
|
259
336
|
}
|
|
260
337
|
}
|
|
338
|
+
componentWillLoad() {
|
|
339
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
340
|
+
if (this._application) {
|
|
341
|
+
this.loadPermitions();
|
|
342
|
+
this.loadConfigFromApplication();
|
|
343
|
+
}
|
|
344
|
+
this.attachDataUnit();
|
|
345
|
+
}
|
|
346
|
+
componentDidRender() {
|
|
347
|
+
this.processPendingFilter();
|
|
348
|
+
}
|
|
261
349
|
render() {
|
|
262
350
|
if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
|
|
263
351
|
return undefined;
|
|
@@ -340,7 +428,18 @@ export class SnkFilterBar {
|
|
|
340
428
|
}
|
|
341
429
|
};
|
|
342
430
|
}
|
|
431
|
+
static get states() {
|
|
432
|
+
return {
|
|
433
|
+
"allowDefault": {}
|
|
434
|
+
};
|
|
435
|
+
}
|
|
343
436
|
static get elementRef() { return "_element"; }
|
|
437
|
+
static get watchers() {
|
|
438
|
+
return [{
|
|
439
|
+
"propName": "filterConfig",
|
|
440
|
+
"methodName": "observeFilterConfig"
|
|
441
|
+
}];
|
|
442
|
+
}
|
|
344
443
|
static get listeners() {
|
|
345
444
|
return [{
|
|
346
445
|
"name": "filterChange",
|
|
@@ -137,7 +137,7 @@ export class SnkGrid {
|
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
"statusResolver": {
|
|
140
|
-
"type": "
|
|
140
|
+
"type": "unknown",
|
|
141
141
|
"mutable": false,
|
|
142
142
|
"complexType": {
|
|
143
143
|
"original": "IStatusResolver",
|
|
@@ -154,9 +154,7 @@ export class SnkGrid {
|
|
|
154
154
|
"docs": {
|
|
155
155
|
"tags": [],
|
|
156
156
|
"text": "Configura\u00E7\u00E3o do valor da coluna de status.\nExemplo: { \"RECDESP\": { \"-1\" : \"#BD0025\", \"1\" : \"#157A00\" } }"
|
|
157
|
-
}
|
|
158
|
-
"attribute": "status-resolver",
|
|
159
|
-
"reflect": false
|
|
157
|
+
}
|
|
160
158
|
}
|
|
161
159
|
};
|
|
162
160
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { ResourceFetcher } from "./resource-fetcher";
|
|
2
2
|
function normalizeValue(value) {
|
|
3
|
+
if (value == undefined) {
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
3
6
|
if (value instanceof Date) {
|
|
4
7
|
return value.toISOString();
|
|
5
8
|
}
|
|
6
9
|
if (typeof value === "object") {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
if (value instanceof Array) {
|
|
11
|
+
return value.map(item => normalizeValue(item));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const normalized = Object.assign({}, value);
|
|
15
|
+
Object.keys(value).forEach(prop => {
|
|
16
|
+
if (value[prop]) {
|
|
17
|
+
normalized[prop] = normalizeValue(value[prop]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
delete normalized[prop];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return normalized;
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
return value;
|
|
19
27
|
}
|
|
@@ -7,12 +7,24 @@ const snkFilterBarMessages = {
|
|
|
7
7
|
"applyFilter": "Aplicar",
|
|
8
8
|
"findFilter": "Buscar filtros...",
|
|
9
9
|
"findField": "Buscar filtros...",
|
|
10
|
+
"modalFindFilter": "Buscar filtro",
|
|
10
11
|
"emptyFiltersList": "Não há filtros disponíveis",
|
|
11
12
|
"emptyAppliedFiltersList": "Não há filtros aplicados",
|
|
12
13
|
"customFilter": "Filtro personalizado",
|
|
13
|
-
"defaultFilter": "Filtro
|
|
14
|
+
"defaultFilter": "Filtro padrão",
|
|
14
15
|
"failToLoadConfig": "Falha ao buscar configuração de filtros",
|
|
15
16
|
"clearAllFilters": "Limpar todos os filtros",
|
|
16
|
-
"successfullyCleaned": "Filtro limpo com sucesso!"
|
|
17
|
+
"successfullyCleaned": "Filtro limpo com sucesso!",
|
|
18
|
+
"activeFilter": "{{ACTIVE_FILTERS}} filtro aplicado",
|
|
19
|
+
"activeFilters": "{{ACTIVE_FILTERS}} filtros aplicados",
|
|
20
|
+
"noActiveFilters": "Nenhum filtro aplicado",
|
|
21
|
+
"modalDefaultFilterTitle": "Filtro padrão",
|
|
22
|
+
"modalInfoTextEditDefault": "Use o layout antigo para editar o seu filtro padrão, em breve traremos uma nova experiência.",
|
|
23
|
+
"modalInfoTextCreateDefault": "Use o layout antigo para criar o seu filtro padrão, em breve traremos uma nova experiência.",
|
|
24
|
+
"modalPersonalizedFilterTitle": "Filtro personalizado",
|
|
25
|
+
"modalPersonalizedFilterSubTitle": "Gerencie seus filtros",
|
|
26
|
+
"modalInfoTextCreateEditPersonalized": "Use o layout antigo para criar ou editar filtros, em breve traremos uma nova experiência",
|
|
27
|
+
"modalOkButtonLabel": "Aplicar",
|
|
28
|
+
"modalCancelButtonLabel": "Limpar"
|
|
17
29
|
};
|
|
18
30
|
export default snkFilterBarMessages;
|