@sankhyalabs/sankhyablocks 5.9.2 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-91adf3fe.js → ConfigStorage-f68c3607.js} +5 -71
- package/dist/cjs/{SnkFormConfigManager-e1a10283.js → SnkFormConfigManager-69df3f74.js} +2 -2
- package/dist/cjs/{SnkMessageBuilder-1760d2c9.js → SnkMessageBuilder-cf80308c.js} +6 -1
- package/dist/cjs/filter-bar-config-fetcher-a14536bf.js +115 -0
- package/dist/cjs/{form-config-fetcher-fa19680a.js → form-config-fetcher-92bc8fe7.js} +2 -65
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/resource-fetcher-2979b54b.js +68 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +7 -4
- package/dist/cjs/snk-data-exporter.cjs.entry.js +4 -4
- package/dist/cjs/{snk-data-unit-f27603c9.js → snk-data-unit-bd271acd.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +8 -5
- package/dist/cjs/snk-entity-list.cjs.entry.js +111 -0
- package/dist/cjs/snk-filter-bar.cjs.entry.js +4 -2
- package/dist/cjs/snk-filter-detail.cjs.entry.js +44 -3
- package/dist/cjs/snk-filter-item.cjs.entry.js +9 -4
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +30 -2
- package/dist/cjs/snk-filter-modal.cjs.entry.js +26 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
- package/dist/cjs/snk-form.cjs.entry.js +6 -3
- package/dist/cjs/snk-grid-config.cjs.entry.js +5 -2
- package/dist/cjs/snk-grid.cjs.entry.js +12 -8
- package/dist/cjs/{snk-guides-viewer-5f2eb52b.js → snk-guides-viewer-b2d40bc4.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -4
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +2 -2
- package/dist/collection/components/snk-entity-list/snk-entity-list.css +35 -0
- package/dist/collection/components/snk-entity-list/snk-entity-list.js +250 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +45 -4
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +9 -4
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +26 -3
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +28 -3
- package/dist/collection/components/snk-grid/snk-grid.js +7 -6
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +48 -5
- package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
- package/dist/collection/lib/message/resources/snk-entity-list.msg.js +3 -0
- package/dist/components/ConfigStorage.js +3 -69
- package/dist/components/SnkMessageBuilder.js +6 -1
- package/dist/components/filter-bar-config-fetcher.js +113 -0
- package/dist/components/form-config-fetcher.js +2 -64
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/resource-fetcher.js +66 -0
- package/dist/components/snk-application2.js +1 -1
- package/dist/components/snk-data-exporter2.js +2 -2
- package/dist/components/snk-entity-list.d.ts +11 -0
- package/dist/components/snk-entity-list.js +131 -0
- package/dist/components/snk-filter-detail2.js +42 -4
- package/dist/components/snk-filter-item2.js +9 -4
- package/dist/components/snk-filter-modal-item2.js +28 -3
- package/dist/components/snk-filter-modal.js +26 -3
- package/dist/components/snk-grid2.js +7 -6
- package/dist/esm/{ConfigStorage-ac77ff39.js → ConfigStorage-e6c17998.js} +3 -69
- package/dist/esm/{SnkFormConfigManager-40609500.js → SnkFormConfigManager-e60367a0.js} +2 -2
- package/dist/esm/{SnkMessageBuilder-4caf8b4f.js → SnkMessageBuilder-1a169545.js} +6 -1
- package/dist/esm/filter-bar-config-fetcher-edc48f4b.js +113 -0
- package/dist/esm/{form-config-fetcher-018e7e73.js → form-config-fetcher-cac8cd96.js} +2 -64
- package/dist/esm/loader.js +1 -1
- package/dist/esm/resource-fetcher-02642924.js +66 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +6 -3
- package/dist/esm/snk-data-exporter.entry.js +4 -4
- package/dist/esm/{snk-data-unit-640399b3.js → snk-data-unit-476024e9.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +8 -5
- package/dist/esm/snk-entity-list.entry.js +107 -0
- package/dist/esm/snk-filter-bar.entry.js +4 -2
- package/dist/esm/snk-filter-detail.entry.js +45 -4
- package/dist/esm/snk-filter-item.entry.js +9 -4
- package/dist/esm/snk-filter-modal-item.entry.js +31 -3
- package/dist/esm/snk-filter-modal.entry.js +26 -3
- package/dist/esm/snk-form-config.entry.js +2 -1
- package/dist/esm/snk-form.entry.js +6 -3
- package/dist/esm/snk-grid-config.entry.js +5 -2
- package/dist/esm/snk-grid.entry.js +12 -8
- package/dist/esm/{snk-guides-viewer-11ca46dc.js → snk-guides-viewer-11a02781.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +7 -4
- package/dist/sankhyablocks/p-0409d41b.entry.js +1 -0
- package/dist/sankhyablocks/p-1c5d5e5c.entry.js +1 -0
- package/dist/sankhyablocks/p-1c836fad.entry.js +1 -0
- package/dist/sankhyablocks/p-1e6a95f5.entry.js +1 -0
- package/dist/sankhyablocks/p-2ea933b2.js +17 -0
- package/dist/sankhyablocks/{p-6981c03e.js → p-3e17b147.js} +1 -1
- package/dist/sankhyablocks/p-471568c7.entry.js +1 -0
- package/dist/sankhyablocks/p-4eae2812.entry.js +1 -0
- package/dist/sankhyablocks/p-554e2f83.entry.js +1 -0
- package/dist/sankhyablocks/p-587bd851.entry.js +1 -0
- package/dist/sankhyablocks/p-656eab86.entry.js +1 -0
- package/dist/sankhyablocks/p-6c2c71ca.js +1 -0
- package/dist/sankhyablocks/p-78de64fb.entry.js +1 -0
- package/dist/sankhyablocks/p-79f78e10.js +10 -0
- package/dist/sankhyablocks/{p-7f2e267a.js → p-7f0afee1.js} +1 -1
- package/dist/sankhyablocks/p-b1c02726.js +1 -0
- package/dist/sankhyablocks/{p-e0aa5838.js → p-b25450ab.js} +1 -1
- package/dist/sankhyablocks/p-c20dd153.entry.js +1 -0
- package/dist/sankhyablocks/{p-29c1889f.js → p-c74fca58.js} +1 -1
- package/dist/sankhyablocks/p-c8095917.entry.js +1 -0
- package/dist/sankhyablocks/p-c842c6f1.entry.js +1 -0
- package/dist/sankhyablocks/p-e642bf7a.entry.js +1 -0
- package/dist/sankhyablocks/{p-57b74971.entry.js → p-f5e607e7.entry.js} +3 -3
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +1 -1
- package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +48 -0
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +2 -0
- package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +6 -0
- package/dist/types/components.d.ts +54 -2
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +1 -0
- package/dist/types/lib/message/resources/snk-entity-list.msg.d.ts +1 -0
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-08779202.entry.js +0 -1
- package/dist/sankhyablocks/p-0bb49e4a.entry.js +0 -1
- package/dist/sankhyablocks/p-0d81236c.js +0 -26
- package/dist/sankhyablocks/p-355e7ab0.entry.js +0 -1
- package/dist/sankhyablocks/p-3794686e.entry.js +0 -1
- package/dist/sankhyablocks/p-4181c36d.entry.js +0 -1
- package/dist/sankhyablocks/p-52ed2a18.js +0 -1
- package/dist/sankhyablocks/p-59705471.entry.js +0 -1
- package/dist/sankhyablocks/p-6f0b3cc0.entry.js +0 -1
- package/dist/sankhyablocks/p-747ea2c3.entry.js +0 -1
- package/dist/sankhyablocks/p-7621806d.entry.js +0 -1
- package/dist/sankhyablocks/p-86f75e7a.entry.js +0 -1
- package/dist/sankhyablocks/p-9043c45f.entry.js +0 -1
- package/dist/sankhyablocks/p-b9fb86fe.entry.js +0 -1
- package/dist/sankhyablocks/p-c7ee03cd.entry.js +0 -1
@@ -0,0 +1,250 @@
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
2
|
+
import { ApplicationContext } from "@sankhyalabs/core";
|
3
|
+
export class SnkEntityList {
|
4
|
+
constructor() {
|
5
|
+
this._searchValue = undefined;
|
6
|
+
this._ezListSource = [];
|
7
|
+
this.config = undefined;
|
8
|
+
this.rightListSlotBuilder = undefined;
|
9
|
+
this.maxHeightList = "";
|
10
|
+
}
|
11
|
+
async reloadList() {
|
12
|
+
this.loadListSource();
|
13
|
+
this.saveConfig.emit(this.config);
|
14
|
+
}
|
15
|
+
observeConfig() {
|
16
|
+
var _a, _b;
|
17
|
+
(_b = (_a = this._searchElement) === null || _a === void 0 ? void 0 : _a['clearValue']) === null || _b === void 0 ? void 0 : _b.call(_a);
|
18
|
+
}
|
19
|
+
ezListChangeListener(evt) {
|
20
|
+
var _a, _b, _c, _d;
|
21
|
+
(_c = ((_a = this.config.value) !== null && _a !== void 0 ? _a : (_b = this.config.value) === null || _b === void 0 ? void 0 : _b.elements)) === null || _c === void 0 ? void 0 : _c.forEach(value => {
|
22
|
+
var _a, _b;
|
23
|
+
if (value && value.id === ((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.id)) {
|
24
|
+
value.check = (_b = evt.detail) === null || _b === void 0 ? void 0 : _b.check;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
this.saveConfig.emit(this.config);
|
28
|
+
this.valueChanged.emit((_d = this.config) === null || _d === void 0 ? void 0 : _d.value);
|
29
|
+
}
|
30
|
+
loadListSource() {
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
32
|
+
this._ezListSource = [];
|
33
|
+
(_h = ((_e = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : (_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.elements) !== null && _e !== void 0 ? _e : (_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.value) === null || _g === void 0 ? void 0 : _g.members)) === null || _h === void 0 ? void 0 : _h.forEach(value => {
|
34
|
+
if (value) {
|
35
|
+
this._ezListSource.push({
|
36
|
+
label: `${value.id} - ${value.label}`,
|
37
|
+
check: value.check,
|
38
|
+
id: value.id
|
39
|
+
});
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
componentDidLoad() {
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
45
|
+
let configValue = (_f = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.elements) !== null && _c !== void 0 ? _c : (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.members) !== null && _f !== void 0 ? _f : (_g = this.config) === null || _g === void 0 ? void 0 : _g.value;
|
46
|
+
let configValueArray = [];
|
47
|
+
if (Array.isArray(configValue)) {
|
48
|
+
configValueArray = configValue;
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
configValueArray.push((_j = (_h = this.config) === null || _h === void 0 ? void 0 : _h.value) === null || _j === void 0 ? void 0 : _j.members);
|
52
|
+
}
|
53
|
+
this.config.value = configValueArray;
|
54
|
+
this._entityName = (_m = (_l = (_k = this.config) === null || _k === void 0 ? void 0 : _k.props) === null || _l === void 0 ? void 0 : _l.searchContext) === null || _m === void 0 ? void 0 : _m.entity;
|
55
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
56
|
+
this.loadListSource();
|
57
|
+
}
|
58
|
+
optionLoader({ mode, argument }) {
|
59
|
+
var _a, _b, _c, _d;
|
60
|
+
if (this._application === undefined) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
const searchOptions = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.searchContext) === null || _c === void 0 ? void 0 : _c.searchOptions;
|
64
|
+
const options = {
|
65
|
+
entityDescription: (_d = this.config) === null || _d === void 0 ? void 0 : _d.label,
|
66
|
+
entity: this._entityName,
|
67
|
+
searchOptions: searchOptions
|
68
|
+
};
|
69
|
+
return this._application.executePreparedSearch(mode, argument, options);
|
70
|
+
}
|
71
|
+
onEzSearchChange(evt) {
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
73
|
+
if (evt.detail != undefined && ((_e = ((_c = (_a = this.config.value) !== null && _a !== void 0 ? _a : (_b = this.config.value) === null || _b === void 0 ? void 0 : _b.elements) !== null && _c !== void 0 ? _c : (_d = this.config.value) === null || _d === void 0 ? void 0 : _d.members)) === null || _e === void 0 ? void 0 : _e.find(i => { var _a; return (i === null || i === void 0 ? void 0 : i.id) == ((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value); })) === undefined) {
|
74
|
+
this.config = Object.assign(Object.assign({}, this.config), { value: [
|
75
|
+
...((_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : []),
|
76
|
+
{
|
77
|
+
id: evt.detail.value,
|
78
|
+
check: true,
|
79
|
+
label: evt.detail.label
|
80
|
+
}
|
81
|
+
] });
|
82
|
+
this.loadListSource();
|
83
|
+
this.saveConfig.emit(this.config);
|
84
|
+
this.valueChanged.emit((_h = this.config) === null || _h === void 0 ? void 0 : _h.value);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
getMessage(key, params) {
|
88
|
+
var _a;
|
89
|
+
return (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder.getMessage(key, params);
|
90
|
+
}
|
91
|
+
render() {
|
92
|
+
var _a;
|
93
|
+
return (h(Host, null, h("ez-search", { ref: elem => this._searchElement = elem, optionLoader: argument => this.optionLoader(argument), value: this._searchValue, label: (_a = this.config) === null || _a === void 0 ? void 0 : _a.label, onEzChange: evt => this.onEzSearchChange(evt) }), h("label", { class: "label" }, this.getMessage("snkEntityList.selected")), h("div", { style: this.maxHeightList ? { 'max-height': this.maxHeightList } : {}, class: { "snk-entity-list--overflow": !!this.maxHeightList } }, h("ez-list", { ref: (el) => this._ezList = el, id: "snkEntityList", listMode: "check", dataSource: this._ezListSource, hoverFeedback: true, itemSlotBuilder: this.rightListSlotBuilder, onEzCheckChange: evt => this.ezListChangeListener(evt) }))));
|
94
|
+
}
|
95
|
+
static get is() { return "snk-entity-list"; }
|
96
|
+
static get encapsulation() { return "scoped"; }
|
97
|
+
static get originalStyleUrls() {
|
98
|
+
return {
|
99
|
+
"$": ["snk-entity-list.css"]
|
100
|
+
};
|
101
|
+
}
|
102
|
+
static get styleUrls() {
|
103
|
+
return {
|
104
|
+
"$": ["snk-entity-list.css"]
|
105
|
+
};
|
106
|
+
}
|
107
|
+
static get properties() {
|
108
|
+
return {
|
109
|
+
"config": {
|
110
|
+
"type": "unknown",
|
111
|
+
"mutable": true,
|
112
|
+
"complexType": {
|
113
|
+
"original": "SnkFilterItemConfig",
|
114
|
+
"resolved": "SnkFilterItemConfig",
|
115
|
+
"references": {
|
116
|
+
"SnkFilterItemConfig": {
|
117
|
+
"location": "import",
|
118
|
+
"path": "../snk-filter-bar/filter-item/snk-filter-item"
|
119
|
+
}
|
120
|
+
}
|
121
|
+
},
|
122
|
+
"required": false,
|
123
|
+
"optional": false,
|
124
|
+
"docs": {
|
125
|
+
"tags": [],
|
126
|
+
"text": "Configura\u00E7\u00F5es para carregar os dados do componente"
|
127
|
+
}
|
128
|
+
},
|
129
|
+
"rightListSlotBuilder": {
|
130
|
+
"type": "unknown",
|
131
|
+
"mutable": true,
|
132
|
+
"complexType": {
|
133
|
+
"original": "(item: ListItem, group?: ListGroup) => HTMLElement | string",
|
134
|
+
"resolved": "(item: ListItem, group?: ListGroup) => string | HTMLElement",
|
135
|
+
"references": {
|
136
|
+
"ListItem": {
|
137
|
+
"location": "import",
|
138
|
+
"path": "../snk-filter-bar/filter-list/snk-filter-list"
|
139
|
+
},
|
140
|
+
"ListGroup": {
|
141
|
+
"location": "import",
|
142
|
+
"path": "@sankhyalabs/ezui/dist/types/components/ez-list/ez-list"
|
143
|
+
},
|
144
|
+
"HTMLElement": {
|
145
|
+
"location": "global"
|
146
|
+
}
|
147
|
+
}
|
148
|
+
},
|
149
|
+
"required": false,
|
150
|
+
"optional": false,
|
151
|
+
"docs": {
|
152
|
+
"tags": [],
|
153
|
+
"text": "M\u00E9todo que possibilita alterar como o item da lista vai ser apresentado.\nObserva\u00E7\u00E3o: No React ele se transforma em VNode e n\u00E3o HTMLElement."
|
154
|
+
}
|
155
|
+
},
|
156
|
+
"maxHeightList": {
|
157
|
+
"type": "string",
|
158
|
+
"mutable": false,
|
159
|
+
"complexType": {
|
160
|
+
"original": "string",
|
161
|
+
"resolved": "string",
|
162
|
+
"references": {}
|
163
|
+
},
|
164
|
+
"required": false,
|
165
|
+
"optional": false,
|
166
|
+
"docs": {
|
167
|
+
"tags": [],
|
168
|
+
"text": "Permite definir uma altura m\u00E1xima para o ez-list, adicionando um scroll ao atingir esta medida"
|
169
|
+
},
|
170
|
+
"attribute": "max-height-list",
|
171
|
+
"reflect": false,
|
172
|
+
"defaultValue": "\"\""
|
173
|
+
}
|
174
|
+
};
|
175
|
+
}
|
176
|
+
static get states() {
|
177
|
+
return {
|
178
|
+
"_searchValue": {},
|
179
|
+
"_ezListSource": {}
|
180
|
+
};
|
181
|
+
}
|
182
|
+
static get events() {
|
183
|
+
return [{
|
184
|
+
"method": "valueChanged",
|
185
|
+
"name": "valueChanged",
|
186
|
+
"bubbles": true,
|
187
|
+
"cancelable": true,
|
188
|
+
"composed": true,
|
189
|
+
"docs": {
|
190
|
+
"tags": [],
|
191
|
+
"text": "Emite um evento customizado ao realizar altera\u00E7\u00E3o nos valores do componente"
|
192
|
+
},
|
193
|
+
"complexType": {
|
194
|
+
"original": "CustomEvent",
|
195
|
+
"resolved": "CustomEvent<any>",
|
196
|
+
"references": {
|
197
|
+
"CustomEvent": {
|
198
|
+
"location": "global"
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}, {
|
203
|
+
"method": "saveConfig",
|
204
|
+
"name": "saveConfig",
|
205
|
+
"bubbles": true,
|
206
|
+
"cancelable": true,
|
207
|
+
"composed": true,
|
208
|
+
"docs": {
|
209
|
+
"tags": [],
|
210
|
+
"text": "Evento emitido ao realizar alguma a\u00E7\u00E3o que altera os dados do config.value permitindo salvar estas informa\u00E7\u00F5es"
|
211
|
+
},
|
212
|
+
"complexType": {
|
213
|
+
"original": "SnkFilterItemConfig",
|
214
|
+
"resolved": "SnkFilterItemConfig",
|
215
|
+
"references": {
|
216
|
+
"SnkFilterItemConfig": {
|
217
|
+
"location": "import",
|
218
|
+
"path": "../snk-filter-bar/filter-item/snk-filter-item"
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}];
|
223
|
+
}
|
224
|
+
static get methods() {
|
225
|
+
return {
|
226
|
+
"reloadList": {
|
227
|
+
"complexType": {
|
228
|
+
"signature": "() => Promise<void>",
|
229
|
+
"parameters": [],
|
230
|
+
"references": {
|
231
|
+
"Promise": {
|
232
|
+
"location": "global"
|
233
|
+
}
|
234
|
+
},
|
235
|
+
"return": "Promise<void>"
|
236
|
+
},
|
237
|
+
"docs": {
|
238
|
+
"text": "",
|
239
|
+
"tags": []
|
240
|
+
}
|
241
|
+
}
|
242
|
+
};
|
243
|
+
}
|
244
|
+
static get watchers() {
|
245
|
+
return [{
|
246
|
+
"propName": "config",
|
247
|
+
"methodName": "observeConfig"
|
248
|
+
}];
|
249
|
+
}
|
250
|
+
}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { h, Host, Fragment } from '@stencil/core';
|
2
2
|
import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
|
3
3
|
import FilterItemType from './filter-item-type.enum';
|
4
|
-
import { ElementIDUtils, DataType } from '@sankhyalabs/core';
|
4
|
+
import { ElementIDUtils, DataType, ApplicationContext } from '@sankhyalabs/core';
|
5
|
+
import FilterBarConfigFetcher from '../../../lib/http/data-fetcher/fetchers/filter-bar-config-fetcher';
|
5
6
|
export class SnkFilterDetail {
|
6
7
|
constructor() {
|
7
8
|
this.config = undefined;
|
@@ -12,10 +13,15 @@ export class SnkFilterDetail {
|
|
12
13
|
*/
|
13
14
|
async show() {
|
14
15
|
var _a, _b;
|
15
|
-
(_b = (_a = this._editor)["show"]) === null || _b === void 0 ? void 0 : _b.call(_a);
|
16
|
+
(_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a["show"]) === null || _b === void 0 ? void 0 : _b.call(_a);
|
17
|
+
}
|
18
|
+
observeConfig() {
|
19
|
+
var _a, _b;
|
20
|
+
(_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a["reloadList"]) === null || _b === void 0 ? void 0 : _b.call(_a);
|
16
21
|
}
|
17
22
|
componentDidLoad() {
|
18
23
|
if (this._element) {
|
24
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
19
25
|
ElementIDUtils.addIDInfo(this._element);
|
20
26
|
const dataElementIdDoFilterItem = this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
|
21
27
|
this._idContentEditor = `${dataElementIdDoFilterItem}_${this.config.id}`;
|
@@ -38,6 +44,8 @@ export class SnkFilterDetail {
|
|
38
44
|
return "snk-filter-number";
|
39
45
|
case FilterItemType.PERSONALIZED:
|
40
46
|
return "snk-filter-personalized";
|
47
|
+
case FilterItemType.MULTI_LIST:
|
48
|
+
return "snk-entity-list";
|
41
49
|
}
|
42
50
|
return "snk-filter-text";
|
43
51
|
}
|
@@ -108,16 +116,43 @@ export class SnkFilterDetail {
|
|
108
116
|
}
|
109
117
|
/* WARNING: Temporário.*/
|
110
118
|
clear() {
|
111
|
-
|
119
|
+
var _a, _b;
|
120
|
+
if (FilterItemType.MULTI_LIST === this.config.type) {
|
121
|
+
(_a = this.config.value) === null || _a === void 0 ? void 0 : _a.forEach(value => {
|
122
|
+
if (!!value)
|
123
|
+
value.check = false;
|
124
|
+
});
|
125
|
+
(_b = this._editor) === null || _b === void 0 ? void 0 : _b['reloadList']();
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
|
129
|
+
}
|
112
130
|
}
|
113
131
|
onKeyDonwListener(event) {
|
114
132
|
if (event.key === "Enter") {
|
115
133
|
this._applyButton.setFocus().then(() => this.apply());
|
116
134
|
}
|
117
135
|
}
|
136
|
+
buildRightSlot(item) {
|
137
|
+
return h("ez-icon", { iconName: "delete", onClick: () => this.removeValueFromConfig(item) });
|
138
|
+
}
|
139
|
+
removeValueFromConfig(item) {
|
140
|
+
var _a, _b, _c, _d, _e, _f;
|
141
|
+
const index = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.findIndex(i => (i === null || i === void 0 ? void 0 : i.id) === item.id);
|
142
|
+
(_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.splice(index, 1);
|
143
|
+
(_f = (_e = this._editor) === null || _e === void 0 ? void 0 : _e["reloadList"]) === null || _f === void 0 ? void 0 : _f.call(_e);
|
144
|
+
}
|
145
|
+
saveConfig(newConfig) {
|
146
|
+
var _a;
|
147
|
+
(_a = this._application) === null || _a === void 0 ? void 0 : _a.getResourceID().then(resourceId => {
|
148
|
+
const fetcher = new FilterBarConfigFetcher();
|
149
|
+
fetcher.saveEntityListConfig(newConfig, resourceId, this._application.configName);
|
150
|
+
this.config = newConfig;
|
151
|
+
});
|
152
|
+
}
|
118
153
|
render() {
|
119
154
|
const ContentEditor = this.getContentEditor();
|
120
|
-
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, onKeyDown: evt => this.onKeyDonwListener(evt), "data-element-id": this._idContentEditor, getMessage: this.getMessage }), 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", { ref: ref => this._applyButton = ref, label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
|
155
|
+
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, { maxHeightList: '240px', ref: ref => this._editor = ref, value: this.config.value, config: this.config, onKeyDown: evt => this.onKeyDonwListener(evt), "data-element-id": this._idContentEditor, getMessage: this.getMessage, onSaveConfig: evt => this.saveConfig(evt.detail), rightListSlotBuilder: item => this.buildRightSlot(item) }), 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", { ref: ref => this._applyButton = ref, label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
|
121
156
|
}
|
122
157
|
static get is() { return "snk-filter-detail"; }
|
123
158
|
static get properties() {
|
@@ -203,4 +238,10 @@ export class SnkFilterDetail {
|
|
203
238
|
};
|
204
239
|
}
|
205
240
|
static get elementRef() { return "_element"; }
|
241
|
+
static get watchers() {
|
242
|
+
return [{
|
243
|
+
"propName": "config",
|
244
|
+
"methodName": "observeConfig"
|
245
|
+
}];
|
246
|
+
}
|
206
247
|
}
|
@@ -111,6 +111,7 @@ export class SnkFilterItem {
|
|
111
111
|
}
|
112
112
|
}
|
113
113
|
getLabel(isTooltipLabel = false) {
|
114
|
+
var _a;
|
114
115
|
const { type, value, label, props } = this.config;
|
115
116
|
if (value) {
|
116
117
|
if (type === FilterItemType.BINARY_SELECT) {
|
@@ -167,16 +168,19 @@ export class SnkFilterItem {
|
|
167
168
|
return label;
|
168
169
|
}
|
169
170
|
if (type === FilterItemType.MULTI_LIST) {
|
170
|
-
const selectedOptions = value.filter(item => item.check);
|
171
|
+
const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
|
171
172
|
const checkedAmount = selectedOptions.length;
|
173
|
+
if (checkedAmount === 0) {
|
174
|
+
return `${label}`;
|
175
|
+
}
|
172
176
|
if (checkedAmount > 1) {
|
173
177
|
if (isTooltipLabel) {
|
174
|
-
const selectedOptionsDescrptions = selectedOptions.map(item => item.
|
178
|
+
const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
|
175
179
|
return `${label}: ${selectedOptionsDescrptions.join(',')}`;
|
176
180
|
}
|
177
181
|
return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
|
178
182
|
}
|
179
|
-
return `${label}: ${
|
183
|
+
return `${label}: ${selectedOptions[0].label}`;
|
180
184
|
}
|
181
185
|
return `${label}: ${value}`;
|
182
186
|
}
|
@@ -226,8 +230,9 @@ export class SnkFilterItem {
|
|
226
230
|
return undefined;
|
227
231
|
}
|
228
232
|
render() {
|
233
|
+
var _a, _b, _c, _d;
|
229
234
|
const leftIcon = this.getLeftIconName();
|
230
|
-
return (h(Host, Object.assign({}, this.applyTooltip()), h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon", id: "removeFilter" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id, "data-element-id": this._idSnkFilterDetail }))));
|
235
|
+
return (h(Host, Object.assign({}, this.applyTooltip()), h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: (FilterItemType.MULTI_LIST != this.config.type && this.config.value != undefined) || (((_d = (_c = ((_b = (_a = this.config.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : this.config.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) > 0) }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon", id: "removeFilter" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id, "data-element-id": this._idSnkFilterDetail }))));
|
231
236
|
}
|
232
237
|
static get is() { return "snk-filter-item"; }
|
233
238
|
static get properties() {
|
@@ -36,7 +36,15 @@ export class SnkFilterModal {
|
|
36
36
|
this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
|
37
37
|
}
|
38
38
|
handleClearFilters(filterList) {
|
39
|
-
this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
39
|
+
this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: FilterItemType.MULTI_LIST === filter.type ? this.uncheckFilterValues(filter.value) : undefined })) : filter);
|
40
|
+
}
|
41
|
+
uncheckFilterValues(valueList) {
|
42
|
+
valueList.forEach(value => {
|
43
|
+
if (!!value) {
|
44
|
+
value.check = false;
|
45
|
+
}
|
46
|
+
});
|
47
|
+
return valueList;
|
40
48
|
}
|
41
49
|
renderFilterItem(filterItem, fullRow) {
|
42
50
|
return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, onFilterChange: (event) => this.handleFilterChange(event.detail) }));
|
@@ -69,12 +77,27 @@ export class SnkFilterModal {
|
|
69
77
|
const fullLine = filters.length === 1;
|
70
78
|
return (h("div", { class: "ez-row" }, filters.map((filter) => this.renderFilterItem(filter, fullLine))));
|
71
79
|
}
|
80
|
+
getIformedFiltersCount(listItems) {
|
81
|
+
let countInformedItens = 0;
|
82
|
+
listItems.forEach(item => {
|
83
|
+
var _a, _b, _c, _d, _e;
|
84
|
+
if (FilterItemType.MULTI_LIST === item.type) {
|
85
|
+
countInformedItens += (_e = (_d = (_c = ((_b = (_a = item.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : item.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
if (!!item.value) {
|
89
|
+
countInformedItens++;
|
90
|
+
}
|
91
|
+
});
|
92
|
+
return countInformedItens;
|
93
|
+
}
|
72
94
|
renderCollapsibleFilterBox(label, listItems) {
|
73
95
|
if (!listItems.length)
|
74
96
|
return null;
|
75
|
-
const appliedFilters =
|
97
|
+
const appliedFilters = this.getIformedFiltersCount(listItems);
|
76
98
|
const lines = this.mountFiltersLines(listItems);
|
77
|
-
return (h("ez-collapsible-box", { className: "snk-filter__modal-collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters &&
|
99
|
+
return (h("ez-collapsible-box", { className: "snk-filter__modal-collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters &&
|
100
|
+
h("ez-badge", { className: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters }), lines.map(this.renderFilterLine.bind(this)), h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { className: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => this.handleClearFilters(listItems) }))));
|
78
101
|
}
|
79
102
|
componentWillRender() {
|
80
103
|
this._modalTitle = this.getCustomMessage('title');
|
@@ -1,14 +1,18 @@
|
|
1
1
|
import { h, Host } from '@stencil/core';
|
2
|
-
import { ElementIDUtils } from '@sankhyalabs/core';
|
2
|
+
import { ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
|
3
3
|
import FilterItemType from "../../filter-item/filter-item-type.enum";
|
4
4
|
import FilterType from '../../types/filter-type.enum';
|
5
5
|
import { EPresentationMode } from '../../filter-item/editors/enum/presentationMode';
|
6
|
+
import FilterBarConfigFetcher from '../../../../lib/http/data-fetcher/fetchers/filter-bar-config-fetcher';
|
6
7
|
export class SnkFilterModalItem {
|
7
8
|
constructor() {
|
8
9
|
this.filterItem = undefined;
|
9
10
|
}
|
10
11
|
observeFilterItem(newValue) {
|
12
|
+
var _a, _b;
|
13
|
+
(_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a['reloadList']) === null || _b === void 0 ? void 0 : _b.call(_a);
|
11
14
|
this.filterChange.emit(newValue);
|
15
|
+
this.saveConfig();
|
12
16
|
}
|
13
17
|
getContentEditorConfig() {
|
14
18
|
const variations = { presentationMode: EPresentationMode.MODAL };
|
@@ -26,13 +30,16 @@ export class SnkFilterModalItem {
|
|
26
30
|
case FilterItemType.PERSONALIZED:
|
27
31
|
return { tag: "snk-filter-personalized" };
|
28
32
|
case FilterItemType.MULTI_LIST:
|
29
|
-
return { tag: "snk-entity-list" };
|
33
|
+
return { tag: "snk-entity-list", variations: { maxHeightList: "640px", rightListSlotBuilder: item => this.buildRightSlot(item) } };
|
30
34
|
}
|
31
35
|
return { tag: "snk-filter-text" };
|
32
36
|
}
|
33
37
|
updateFilterValue(newValue) {
|
34
38
|
const isVisble = !this.filterItem.visible ? newValue !== undefined : true;
|
35
39
|
this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: newValue, visible: isVisble });
|
40
|
+
if (FilterItemType.MULTI_LIST === this.filterItem.type) {
|
41
|
+
this.saveConfig();
|
42
|
+
}
|
36
43
|
}
|
37
44
|
canShowDetailModal() {
|
38
45
|
return this.filterItem.filterType !== FilterType.OTHER_FILTERS && this.filterItem.type !== FilterItemType.BINARY_SELECT;
|
@@ -42,11 +49,29 @@ export class SnkFilterModalItem {
|
|
42
49
|
ElementIDUtils.addIDInfo(this._element);
|
43
50
|
const dataElementIdDoFilterItem = this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
|
44
51
|
this._idContentEditor = `${dataElementIdDoFilterItem}_${this.filterItem.id}`;
|
52
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
45
53
|
}
|
46
54
|
}
|
55
|
+
buildRightSlot(item) {
|
56
|
+
return h("ez-icon", { iconName: "delete", onClick: () => this.removeValueFromConfig(item) });
|
57
|
+
}
|
58
|
+
removeValueFromConfig(item) {
|
59
|
+
var _a, _b, _c, _d, _e, _f;
|
60
|
+
const index = (_b = (_a = this.filterItem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.findIndex(i => (i === null || i === void 0 ? void 0 : i.id) === item.id);
|
61
|
+
(_d = (_c = this.filterItem) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.splice(index, 1);
|
62
|
+
(_f = (_e = this._editor) === null || _e === void 0 ? void 0 : _e["reloadList"]) === null || _f === void 0 ? void 0 : _f.call(_e);
|
63
|
+
this.saveConfig();
|
64
|
+
}
|
65
|
+
saveConfig() {
|
66
|
+
var _a;
|
67
|
+
(_a = this._application) === null || _a === void 0 ? void 0 : _a.getResourceID().then(resourceId => {
|
68
|
+
const fetcher = new FilterBarConfigFetcher();
|
69
|
+
fetcher.saveEntityListConfig(this.filterItem, resourceId, this._application.configName);
|
70
|
+
});
|
71
|
+
}
|
47
72
|
render() {
|
48
73
|
const { tag: ContentEditor, variations } = this.getContentEditorConfig();
|
49
|
-
return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-title ez-title--small ez-title--primary grow" }, this.filterItem.detailModal))), h(ContentEditor, Object.assign({ config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, variations)))));
|
74
|
+
return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-title ez-title--small ez-title--primary grow" }, this.filterItem.detailModal))), h(ContentEditor, Object.assign({ ref: ref => this._editor = ref, config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, variations)))));
|
50
75
|
}
|
51
76
|
static get is() { return "snk-filter-modal-item"; }
|
52
77
|
static get originalStyleUrls() {
|
@@ -98,7 +98,8 @@ export class SnkGrid {
|
|
98
98
|
});
|
99
99
|
evt.stopPropagation();
|
100
100
|
}
|
101
|
-
buildColumnsMetadata(
|
101
|
+
buildColumnsMetadata(gridColumns) {
|
102
|
+
const columnsMetadata = [];
|
102
103
|
gridColumns === null || gridColumns === void 0 ? void 0 : gridColumns.forEach((column) => {
|
103
104
|
var _a, _b;
|
104
105
|
/**
|
@@ -146,17 +147,17 @@ export class SnkGrid {
|
|
146
147
|
return offset;
|
147
148
|
}
|
148
149
|
async dataExporterProviderStore() {
|
149
|
-
var _a
|
150
|
-
const columnsMetadata = [];
|
150
|
+
var _a;
|
151
151
|
const selectedIDs = await ((_a = this._snkDataUnit) === null || _a === void 0 ? void 0 : _a.getSelectedRecordsIDsInfo());
|
152
|
-
await ((_b = this._grid) === null || _b === void 0 ? void 0 : _b.getColumnsState().then(this.buildColumnsMetadata.bind(this, columnsMetadata)));
|
153
152
|
const dataExporterProvider = {
|
154
153
|
getFilters: () => {
|
155
154
|
var _a;
|
156
155
|
return (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getAppliedFilters();
|
157
156
|
},
|
158
|
-
getColumnsMetadata: () => {
|
159
|
-
|
157
|
+
getColumnsMetadata: async () => {
|
158
|
+
var _a;
|
159
|
+
const columnsState = await ((_a = this._grid) === null || _a === void 0 ? void 0 : _a.getColumnsState());
|
160
|
+
return this.buildColumnsMetadata(columnsState);
|
160
161
|
},
|
161
162
|
getOrders: () => {
|
162
163
|
var _a;
|
@@ -1,5 +1,18 @@
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
2
|
+
var t = {};
|
3
|
+
for (var p in s)
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
5
|
+
t[p] = s[p];
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
9
|
+
t[p[i]] = s[p[i]];
|
10
|
+
}
|
11
|
+
return t;
|
12
|
+
};
|
13
|
+
import FilterItemType from "../../../../components/snk-filter-bar/filter-item/filter-item-type.enum";
|
1
14
|
import { ResourceFetcher } from "./resource-fetcher";
|
2
|
-
function normalizeValue(value) {
|
15
|
+
function normalizeValue(value, type) {
|
3
16
|
if (value == undefined) {
|
4
17
|
return value;
|
5
18
|
}
|
@@ -8,13 +21,19 @@ function normalizeValue(value) {
|
|
8
21
|
}
|
9
22
|
if (typeof value === "object") {
|
10
23
|
if (value instanceof Array) {
|
11
|
-
return value.map(item =>
|
24
|
+
return value.map(item => {
|
25
|
+
if (FilterItemType.MULTI_LIST === type) {
|
26
|
+
const { label: _ } = item, values = __rest(item, ["label"]);
|
27
|
+
return normalizeValue(values);
|
28
|
+
}
|
29
|
+
return normalizeValue(item);
|
30
|
+
});
|
12
31
|
}
|
13
32
|
else {
|
14
33
|
const normalized = Object.assign({}, value);
|
15
34
|
Object.keys(value).forEach(prop => {
|
16
35
|
if (value[prop]) {
|
17
|
-
normalized[prop] = normalizeValue(value[prop]);
|
36
|
+
normalized[prop] = normalizeValue(value[prop], type);
|
18
37
|
}
|
19
38
|
else {
|
20
39
|
delete normalized[prop];
|
@@ -28,10 +47,10 @@ function normalizeValue(value) {
|
|
28
47
|
export default class FilterBarConfigFetcher extends ResourceFetcher {
|
29
48
|
saveConfig(items, resourceID, configName) {
|
30
49
|
const state = items.map(item => {
|
31
|
-
const { id, value, fixed, visible } = item;
|
50
|
+
const { id, value, fixed, visible, type } = item;
|
32
51
|
const stateItem = { id };
|
33
52
|
if (value) {
|
34
|
-
stateItem["value"] = normalizeValue(value);
|
53
|
+
stateItem["value"] = normalizeValue(value, type);
|
35
54
|
}
|
36
55
|
if (fixed) {
|
37
56
|
stateItem["fixed"] = fixed;
|
@@ -59,6 +78,30 @@ export default class FilterBarConfigFetcher extends ResourceFetcher {
|
|
59
78
|
});
|
60
79
|
});
|
61
80
|
}
|
81
|
+
saveEntityListConfig(item, resourceID, configName) {
|
82
|
+
return new Promise((accept, reject) => {
|
83
|
+
this.getConfig(resourceID, configName).then(config => {
|
84
|
+
const state = config.map(({ id, value, fixed, visible, type }) => {
|
85
|
+
return Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true }));
|
86
|
+
});
|
87
|
+
const index = state.findIndex(({ id }) => id === item.id);
|
88
|
+
const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
|
89
|
+
if (index > -1) {
|
90
|
+
state[index] = newItem;
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
state.push(newItem);
|
94
|
+
}
|
95
|
+
this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
|
96
|
+
accept(resp);
|
97
|
+
}).catch(exception => {
|
98
|
+
reject(exception);
|
99
|
+
});
|
100
|
+
}).catch(exception => {
|
101
|
+
reject(exception);
|
102
|
+
});
|
103
|
+
});
|
104
|
+
}
|
62
105
|
getPath(resourceID, name) {
|
63
106
|
if (name) {
|
64
107
|
return `cfg://filter/FilterBarState:${resourceID}/${name}`;
|
@@ -14,6 +14,7 @@ import { snkFilterFieldSearchMessages } from "./resources/snk-filter-field-searc
|
|
14
14
|
import { snkSimpleBarMessages } from './resources/snk-simple-bar.msg.js';
|
15
15
|
import { snkAttachMessages } from "./resources/snk-attach.msg";
|
16
16
|
import { snkPersonalizedFilterMessages } from "./resources/snk-personalized-filter.msg.js";
|
17
|
+
import { snkEntityListMessages } from "./resources/snk-entity-list.msg.js";
|
17
18
|
export class SnkMessageBuilder {
|
18
19
|
constructor(domainName) {
|
19
20
|
this._defaults = {
|
@@ -36,7 +37,8 @@ export class SnkMessageBuilder {
|
|
36
37
|
snkFilterFieldSearch: snkFilterFieldSearchMessages,
|
37
38
|
snkSimpleBar: snkSimpleBarMessages,
|
38
39
|
snkAttach: snkAttachMessages,
|
39
|
-
snkPersonalizedFilter: snkPersonalizedFilterMessages
|
40
|
+
snkPersonalizedFilter: snkPersonalizedFilterMessages,
|
41
|
+
snkEntityList: snkEntityListMessages
|
40
42
|
};
|
41
43
|
this._currentOperation = OperationMap.CLEAN;
|
42
44
|
this._domainName = domainName;
|