@sankhyalabs/sankhyablocks 1.3.34 → 1.4.0-beta.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/SnkMessageBuilder-7717f1e4.js +326 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-b8158822.js +6 -0
- package/dist/cjs/dom-36862b77.js +75 -0
- package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
- package/dist/cjs/index-02201bc9.js +2397 -0
- package/dist/cjs/index-b0b676c5.js +3298 -0
- package/dist/cjs/loader.cjs.js +19 -3
- package/dist/cjs/sankhyablocks.cjs.js +117 -5
- package/dist/cjs/shadow-css-346c0795.js +389 -0
- package/dist/cjs/snk-application.cjs.entry.js +720 -168
- package/dist/cjs/snk-crud.cjs.entry.js +70 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +280 -0
- package/dist/cjs/snk-filter-bar.cjs.entry.js +278 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +49 -0
- package/dist/cjs/snk-filter-item.cjs.entry.js +154 -0
- package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +23 -0
- package/dist/cjs/snk-filter-number.cjs.entry.js +24 -0
- package/dist/cjs/snk-filter-period.cjs.entry.js +37 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
- package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
- package/dist/cjs/snk-form.cjs.entry.js +133 -0
- package/dist/cjs/snk-grid.cjs.entry.js +79 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
- package/dist/cjs/snk-taskbar.cjs.entry.js +160 -0
- package/dist/cjs/taskbar-elements-283c737e.js +93 -0
- package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
- package/dist/collection/collection-manifest.json +17 -2
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
- package/dist/collection/components/snk-application/snk-application.js +1126 -621
- package/dist/collection/components/snk-crud/snk-crud.css +6 -0
- package/dist/collection/components/snk-crud/snk-crud.js +203 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +544 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +64 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +65 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +78 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +255 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +233 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +114 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +353 -0
- package/dist/collection/components/snk-form/snk-form.css +34 -0
- package/dist/collection/components/snk-form/snk-form.js +258 -0
- package/dist/collection/components/snk-grid/snk-grid.css +18 -0
- package/dist/collection/components/snk-grid/snk-grid.js +205 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +86 -0
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +307 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +37 -12
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +54 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
- package/dist/collection/lib/index.js +1 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +121 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +18 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
- package/dist/components/SnkMessageBuilder.js +303 -0
- package/dist/components/filter-item-type.enum.js +12 -0
- package/dist/components/index.d.ts +18 -5
- package/dist/components/index.js +22 -0
- package/dist/components/index2.js +2384 -0
- package/dist/components/snk-application2.js +700 -139
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +133 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +303 -0
- package/dist/components/snk-filter-bar.d.ts +11 -0
- package/dist/components/snk-filter-bar.js +6 -0
- package/dist/components/snk-filter-bar2.js +310 -0
- package/dist/components/snk-filter-binary-select.d.ts +11 -0
- package/dist/components/snk-filter-binary-select.js +63 -0
- package/dist/components/snk-filter-detail.d.ts +11 -0
- package/dist/components/snk-filter-detail.js +6 -0
- package/dist/components/snk-filter-detail2.js +63 -0
- package/dist/components/snk-filter-item.d.ts +11 -0
- package/dist/components/snk-filter-item.js +6 -0
- package/dist/components/snk-filter-item2.js +175 -0
- package/dist/components/snk-filter-list.d.ts +11 -0
- package/dist/components/snk-filter-list.js +6 -0
- package/dist/components/snk-filter-list2.js +111 -0
- package/dist/components/snk-filter-multi-select.d.ts +11 -0
- package/dist/components/snk-filter-multi-select.js +39 -0
- package/dist/components/snk-filter-number.d.ts +11 -0
- package/dist/components/snk-filter-number.js +40 -0
- package/dist/components/snk-filter-period.d.ts +11 -0
- package/dist/components/snk-filter-period.js +53 -0
- package/dist/components/snk-filter-search.d.ts +11 -0
- package/dist/components/snk-filter-search.js +62 -0
- package/dist/components/snk-filter-text.d.ts +11 -0
- package/dist/components/snk-filter-text.js +38 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +159 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +127 -0
- package/dist/components/snk-pesquisa2.js +1 -1
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +264 -0
- package/dist/components/taskbar-processor.js +45 -0
- package/dist/components/teste-pesquisa.js +1 -1
- package/dist/esm/SnkMessageBuilder-a7da466b.js +303 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-b3f2ee8d.js +4 -0
- package/dist/esm/dom-665d6011.js +73 -0
- package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/esm/index-2b4d2d14.js +3262 -0
- package/dist/esm/index-f1d3e4da.js +2384 -0
- package/dist/esm/loader.js +19 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +117 -5
- package/dist/esm/shadow-css-b18e99d7.js +387 -0
- package/dist/esm/snk-application.entry.js +692 -140
- package/dist/esm/snk-crud.entry.js +66 -0
- package/dist/esm/snk-data-unit.entry.js +276 -0
- package/dist/esm/snk-filter-bar.entry.js +274 -0
- package/dist/esm/snk-filter-binary-select.entry.js +43 -0
- package/dist/esm/snk-filter-detail.entry.js +45 -0
- package/dist/esm/snk-filter-item.entry.js +150 -0
- package/dist/esm/snk-filter-list.entry.js +87 -0
- package/dist/esm/snk-filter-multi-select.entry.js +19 -0
- package/dist/esm/snk-filter-number.entry.js +20 -0
- package/dist/esm/snk-filter-period.entry.js +33 -0
- package/dist/esm/snk-filter-search.entry.js +40 -0
- package/dist/esm/snk-filter-text.entry.js +18 -0
- package/dist/esm/snk-form.entry.js +129 -0
- package/dist/esm/snk-grid.entry.js +75 -0
- package/dist/esm/snk-pesquisa.entry.js +2 -2
- package/dist/esm/snk-taskbar.entry.js +156 -0
- package/dist/esm/taskbar-elements-35d64ff9.js +90 -0
- package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
- package/dist/esm/teste-pesquisa.entry.js +2 -2
- package/dist/sankhyablocks/SnkMessageBuilder-a7da466b.js +303 -0
- package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
- package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
- package/dist/sankhyablocks/dom-665d6011.js +73 -0
- package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
- package/dist/sankhyablocks/index-f1d3e4da.js +2384 -0
- package/dist/sankhyablocks/index.esm.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
- package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
- package/dist/sankhyablocks/snk-application.entry.js +8148 -0
- package/dist/sankhyablocks/snk-crud.entry.js +66 -0
- package/dist/sankhyablocks/snk-data-unit.entry.js +276 -0
- package/dist/sankhyablocks/snk-filter-bar.entry.js +274 -0
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
- package/dist/sankhyablocks/snk-filter-detail.entry.js +45 -0
- package/dist/sankhyablocks/snk-filter-item.entry.js +150 -0
- package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +19 -0
- package/dist/sankhyablocks/snk-filter-number.entry.js +20 -0
- package/dist/sankhyablocks/snk-filter-period.entry.js +33 -0
- package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
- package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
- package/dist/sankhyablocks/snk-form.entry.js +129 -0
- package/dist/sankhyablocks/snk-grid.entry.js +75 -0
- package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
- package/dist/sankhyablocks/snk-taskbar.entry.js +156 -0
- package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +90 -0
- package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +45 -0
- package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
- package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +145 -15
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +14 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +14 -0
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +40 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +51 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +29 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +84 -0
- package/dist/types/components.d.ts +696 -8
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
- package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +5 -5
- package/react/components.d.ts +0 -2
- package/react/components.js +0 -2
- package/react/components.js.map +1 -1
- package/dist/cjs/index-1133bc2a.js +0 -1235
- package/dist/esm/index-ffda6382.js +0 -1208
- package/dist/sankhyablocks/p-2a7b4cb3.entry.js +0 -1
- package/dist/sankhyablocks/p-9520d78a.entry.js +0 -1
- package/dist/sankhyablocks/p-98e8490d.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
+
import { h, Host } from '@stencil/core';
|
|
3
|
+
import { TaskbarElement, buildElem, AuthorizationElements, buildCustomButton, VisibleWhenForbidden } from './elements/taskbar-elements';
|
|
4
|
+
export class SnkTaskbar {
|
|
5
|
+
constructor() {
|
|
6
|
+
this._titleKeyByElement = {
|
|
7
|
+
[TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
|
|
8
|
+
[TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
|
|
9
|
+
[TaskbarElement.NEXT]: "snkTaskbar.titleNext",
|
|
10
|
+
[TaskbarElement.REFRESH]: "snkTaskbar.titleRefresh",
|
|
11
|
+
[TaskbarElement.CLONE]: "snkTaskbar.titleClone",
|
|
12
|
+
[TaskbarElement.REMOVE]: "snkTaskbar.titleRemove",
|
|
13
|
+
[TaskbarElement.MORE_OPTIONS]: "snkTaskbar.titleMoreOptions",
|
|
14
|
+
[TaskbarElement.INSERT]: "snkTaskbar.titleInsert",
|
|
15
|
+
[TaskbarElement.CANCEL]: "snkTaskbar.titleCancel",
|
|
16
|
+
[TaskbarElement.SAVE]: "snkTaskbar.titleSave",
|
|
17
|
+
[TaskbarElement.GRID_MODE]: "snkTaskbar.titleGridMode",
|
|
18
|
+
[TaskbarElement.CONFIG_GRID]: "snkTaskbar.titleConfigGrid",
|
|
19
|
+
[TaskbarElement.FORM_MODE]: "snkTaskbar.titleFormMode"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
observeButtons() {
|
|
23
|
+
this._definitions = undefined;
|
|
24
|
+
}
|
|
25
|
+
// Internal methods
|
|
26
|
+
elementsFromString(strButtons) {
|
|
27
|
+
const elements = [];
|
|
28
|
+
if (strButtons) {
|
|
29
|
+
strButtons.split(",").forEach(buttonName => {
|
|
30
|
+
buttonName = buttonName.trim();
|
|
31
|
+
if (VisibleWhenForbidden[buttonName] || this.isAllowed(buttonName)) {
|
|
32
|
+
elements.push(buttonName.trim());
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return elements;
|
|
37
|
+
}
|
|
38
|
+
isAllowed(buttonName) {
|
|
39
|
+
if (AuthorizationElements[buttonName]) {
|
|
40
|
+
return this._permissions ? this._permissions.isSup || this._permissions[buttonName] : false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
46
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
47
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
48
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
|
|
49
|
+
*/
|
|
50
|
+
getTitle(element) {
|
|
51
|
+
let key;
|
|
52
|
+
if (this.isAllowed(element)) {
|
|
53
|
+
key = this._titleKeyByElement[element];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
key = "snkTaskbar.forbidden";
|
|
57
|
+
}
|
|
58
|
+
return key ? this._application.messagesBuilder.getMessage(key, {}) : "";
|
|
59
|
+
}
|
|
60
|
+
elementClick(elem) {
|
|
61
|
+
if (this.dataUnit) {
|
|
62
|
+
switch (elem) {
|
|
63
|
+
case TaskbarElement.PREVIOUS:
|
|
64
|
+
this.dataUnit.previousRecord();
|
|
65
|
+
break;
|
|
66
|
+
case TaskbarElement.NEXT:
|
|
67
|
+
this.dataUnit.nextRecord();
|
|
68
|
+
break;
|
|
69
|
+
case TaskbarElement.REFRESH:
|
|
70
|
+
this.dataUnit.loadData();
|
|
71
|
+
break;
|
|
72
|
+
case TaskbarElement.CLONE:
|
|
73
|
+
this.dataUnit.copySelected();
|
|
74
|
+
break;
|
|
75
|
+
case TaskbarElement.REMOVE:
|
|
76
|
+
this.dataUnit.removeSelectedRecords();
|
|
77
|
+
break;
|
|
78
|
+
case TaskbarElement.INSERT:
|
|
79
|
+
this.dataUnit.addRecord();
|
|
80
|
+
break;
|
|
81
|
+
case TaskbarElement.CANCEL:
|
|
82
|
+
this.dataUnit.cancelEdition();
|
|
83
|
+
break;
|
|
84
|
+
case TaskbarElement.SAVE:
|
|
85
|
+
this.dataUnit.saveData();
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
this.actionClick.emit(elem);
|
|
90
|
+
}
|
|
91
|
+
isEnabled(elem) {
|
|
92
|
+
if (!this.isAllowed(elem)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return !(this.disabledButtons && this.disabledButtons.includes(elem));
|
|
96
|
+
}
|
|
97
|
+
getElement(index, def) {
|
|
98
|
+
let className = def === this.primaryButton ? "ez-button--primary " : "";
|
|
99
|
+
if (index > 1) {
|
|
100
|
+
className += "ez-padding-left--medium";
|
|
101
|
+
}
|
|
102
|
+
if (TaskbarElement[def.toString()]) {
|
|
103
|
+
return buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return buildCustomButton(def, className, elem => this.elementClick(elem), elem => this.isEnabled(elem));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Lifecycle
|
|
110
|
+
componentWillLoad() {
|
|
111
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
112
|
+
if (this._application) {
|
|
113
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this._permissions = {};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
componentWillRender() {
|
|
120
|
+
if (this._definitions == undefined && this._permissions) {
|
|
121
|
+
this._definitions = this.elementsFromString(this.buttons);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
render() {
|
|
125
|
+
if (this._definitions === undefined) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
let index = 0;
|
|
129
|
+
return (h(Host, null, this._definitions.map((elem) => {
|
|
130
|
+
if (elem === TaskbarElement.DIVIDER) {
|
|
131
|
+
index = 0;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
index++;
|
|
135
|
+
}
|
|
136
|
+
if (TaskbarElement[elem]) {
|
|
137
|
+
return this.getElement(index, TaskbarElement[elem]);
|
|
138
|
+
}
|
|
139
|
+
if (this.customButtons.has(elem)) {
|
|
140
|
+
return this.getElement(index, this.customButtons.get(elem));
|
|
141
|
+
}
|
|
142
|
+
return h("slot", { name: elem });
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
static get is() { return "snk-taskbar"; }
|
|
146
|
+
static get encapsulation() { return "scoped"; }
|
|
147
|
+
static get originalStyleUrls() {
|
|
148
|
+
return {
|
|
149
|
+
"$": ["snk-taskbar.css"]
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
static get styleUrls() {
|
|
153
|
+
return {
|
|
154
|
+
"$": ["snk-taskbar.css"]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
static get properties() {
|
|
158
|
+
return {
|
|
159
|
+
"buttons": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "string",
|
|
164
|
+
"resolved": "string",
|
|
165
|
+
"references": {}
|
|
166
|
+
},
|
|
167
|
+
"required": false,
|
|
168
|
+
"optional": false,
|
|
169
|
+
"docs": {
|
|
170
|
+
"tags": [],
|
|
171
|
+
"text": "Lista separada por virgula, contendo todos os elementos a serem criados"
|
|
172
|
+
},
|
|
173
|
+
"attribute": "buttons",
|
|
174
|
+
"reflect": false
|
|
175
|
+
},
|
|
176
|
+
"customButtons": {
|
|
177
|
+
"type": "unknown",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "Map<string, CustomButton>",
|
|
181
|
+
"resolved": "Map<string, CustomButton>",
|
|
182
|
+
"references": {
|
|
183
|
+
"Map": {
|
|
184
|
+
"location": "global"
|
|
185
|
+
},
|
|
186
|
+
"CustomButton": {
|
|
187
|
+
"location": "local"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"required": false,
|
|
192
|
+
"optional": false,
|
|
193
|
+
"docs": {
|
|
194
|
+
"tags": [],
|
|
195
|
+
"text": "Mapa com defini\u00E7\u00E3o de bot\u00F5es personalizados. A chave do mapa deve ser \npassada na lista \"buttons\" no lugar onde o bot\u00E3o ir\u00E1 aparecer."
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"actionsList": {
|
|
199
|
+
"type": "unknown",
|
|
200
|
+
"mutable": false,
|
|
201
|
+
"complexType": {
|
|
202
|
+
"original": "Array<Action>",
|
|
203
|
+
"resolved": "Action[]",
|
|
204
|
+
"references": {
|
|
205
|
+
"Array": {
|
|
206
|
+
"location": "global"
|
|
207
|
+
},
|
|
208
|
+
"Action": {
|
|
209
|
+
"location": "local"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"required": false,
|
|
214
|
+
"optional": false,
|
|
215
|
+
"docs": {
|
|
216
|
+
"tags": [],
|
|
217
|
+
"text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\""
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"primaryButton": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"mutable": false,
|
|
223
|
+
"complexType": {
|
|
224
|
+
"original": "string",
|
|
225
|
+
"resolved": "string",
|
|
226
|
+
"references": {}
|
|
227
|
+
},
|
|
228
|
+
"required": false,
|
|
229
|
+
"optional": false,
|
|
230
|
+
"docs": {
|
|
231
|
+
"tags": [],
|
|
232
|
+
"text": "Qual bot\u00E3o deve ter apar\u00EAncia prim\u00E1ria"
|
|
233
|
+
},
|
|
234
|
+
"attribute": "primary-button",
|
|
235
|
+
"reflect": false
|
|
236
|
+
},
|
|
237
|
+
"disabledButtons": {
|
|
238
|
+
"type": "unknown",
|
|
239
|
+
"mutable": false,
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "Array<string>",
|
|
242
|
+
"resolved": "string[]",
|
|
243
|
+
"references": {
|
|
244
|
+
"Array": {
|
|
245
|
+
"location": "global"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
"required": false,
|
|
250
|
+
"optional": false,
|
|
251
|
+
"docs": {
|
|
252
|
+
"tags": [],
|
|
253
|
+
"text": "Array contendo todos os bot\u00F5es a serem desabilitados"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"dataUnit": {
|
|
257
|
+
"type": "unknown",
|
|
258
|
+
"mutable": false,
|
|
259
|
+
"complexType": {
|
|
260
|
+
"original": "DataUnit",
|
|
261
|
+
"resolved": "DataUnit",
|
|
262
|
+
"references": {
|
|
263
|
+
"DataUnit": {
|
|
264
|
+
"location": "import",
|
|
265
|
+
"path": "@sankhyalabs/core"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"required": false,
|
|
270
|
+
"optional": false,
|
|
271
|
+
"docs": {
|
|
272
|
+
"tags": [],
|
|
273
|
+
"text": "Inst\u00E2ncia do DataUnit"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
static get states() {
|
|
279
|
+
return {
|
|
280
|
+
"_permissions": {}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
static get events() {
|
|
284
|
+
return [{
|
|
285
|
+
"method": "actionClick",
|
|
286
|
+
"name": "actionClick",
|
|
287
|
+
"bubbles": true,
|
|
288
|
+
"cancelable": true,
|
|
289
|
+
"composed": true,
|
|
290
|
+
"docs": {
|
|
291
|
+
"tags": [],
|
|
292
|
+
"text": "Emitido sempre que houver click de bot\u00E3o ou a\u00E7\u00E3o"
|
|
293
|
+
},
|
|
294
|
+
"complexType": {
|
|
295
|
+
"original": "string",
|
|
296
|
+
"resolved": "string",
|
|
297
|
+
"references": {}
|
|
298
|
+
}
|
|
299
|
+
}];
|
|
300
|
+
}
|
|
301
|
+
static get watchers() {
|
|
302
|
+
return [{
|
|
303
|
+
"propName": "buttons",
|
|
304
|
+
"methodName": "observeButtons"
|
|
305
|
+
}];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataType, DataUnit, UserInterface } from '@sankhyalabs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { h } from '@stencil/core';
|
|
3
3
|
export class TestePesquisa {
|
|
4
4
|
componentWillLoad() {
|
|
5
5
|
this.dataUnit = new DataUnit("testes_com_formulario");
|
|
@@ -19,15 +19,18 @@ export class TestePesquisa {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
render() {
|
|
22
|
-
return (h("snk-application", null,
|
|
23
|
-
h("ez-form", { dataUnit: this.dataUnit })));
|
|
22
|
+
return (h("snk-application", null, h("ez-form", { dataUnit: this.dataUnit })));
|
|
24
23
|
}
|
|
25
24
|
static get is() { return "teste-pesquisa"; }
|
|
26
25
|
static get encapsulation() { return "shadow"; }
|
|
27
|
-
static get originalStyleUrls() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
static get originalStyleUrls() {
|
|
27
|
+
return {
|
|
28
|
+
"$": ["teste-pesquisa.css"]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static get styleUrls() {
|
|
32
|
+
return {
|
|
33
|
+
"$": ["teste-pesquisa.css"]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
33
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorException } from '@sankhyalabs/core';
|
|
1
|
+
import { ErrorException, WarningException } from '@sankhyalabs/core';
|
|
2
2
|
import { batchRequests } from 'graphql-request';
|
|
3
3
|
import UrlUtils from "../../../lib/utils/urlutils";
|
|
4
4
|
import { StringUtils } from '@sankhyalabs/core';
|
|
@@ -33,6 +33,27 @@ export class DataFetcher {
|
|
|
33
33
|
DataFetcher.requestListener.splice(index, 1);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
processErrorInfo(errors) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const POSITION_ERROR_INFO = 0;
|
|
39
|
+
const errorTitle = "Falha detectada";
|
|
40
|
+
const error = errors[POSITION_ERROR_INFO];
|
|
41
|
+
if (error.length > 0) { //As informações do erro vem no primeiro indice de um array
|
|
42
|
+
const errorInfo = error[POSITION_ERROR_INFO];
|
|
43
|
+
const errorMessage = (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.message) ? errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.message : "Não há mensagem de erro";
|
|
44
|
+
const errorLevel = ((_a = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.extensions) === null || _a === void 0 ? void 0 : _a.level) ? errorInfo.extensions.level : "ERROR";
|
|
45
|
+
const errorCode = ((_b = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.extensions) === null || _b === void 0 ? void 0 : _b.code) ? errorInfo.extensions.code : "";
|
|
46
|
+
switch (errorLevel) {
|
|
47
|
+
case "WARNING":
|
|
48
|
+
return new WarningException(errorTitle, errorMessage, errorCode);
|
|
49
|
+
default:
|
|
50
|
+
return new ErrorException(errorTitle, errorMessage, errorCode);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return new ErrorException(errorTitle, "Não há informações sobre o erro");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
36
57
|
async callGraphQL(req) {
|
|
37
58
|
var _a;
|
|
38
59
|
const reqKey = this.getReqKey(req);
|
|
@@ -43,7 +64,8 @@ export class DataFetcher {
|
|
|
43
64
|
let query = this.getQueryTemplate(req);
|
|
44
65
|
const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
|
|
45
66
|
if (res.errors.length > 0) {
|
|
46
|
-
|
|
67
|
+
const error = this.processErrorInfo(res.errors);
|
|
68
|
+
reject(error);
|
|
47
69
|
}
|
|
48
70
|
else {
|
|
49
71
|
resolve(res.data[0][reqKey]);
|
|
@@ -60,23 +82,26 @@ export class DataFetcher {
|
|
|
60
82
|
resolveURL() {
|
|
61
83
|
return UrlUtils.getUrlBase();
|
|
62
84
|
}
|
|
63
|
-
getContext() {
|
|
85
|
+
getContext(module) {
|
|
64
86
|
const urlParams = UrlUtils.getQueryParams(location.search);
|
|
65
87
|
return {
|
|
66
|
-
baseUrl: `${this.resolveURL()}/
|
|
88
|
+
baseUrl: `${this.resolveURL()}/${module}/service.sbr`,
|
|
67
89
|
appName: "SankhyaBlocks",
|
|
68
90
|
mgeSession: `${window['skw_session'] || urlParams.mgeSession}`,
|
|
69
91
|
globalID: "85C0093DFA240EAB699B4E47A10215BD",
|
|
92
|
+
//FIXME: Precisamos ajustar para buscar o resourceId pela aplicação
|
|
70
93
|
resourceID: "br.com.sankhya.mov.bancaria"
|
|
71
94
|
};
|
|
72
95
|
}
|
|
73
96
|
async callServiceBroker(serviceName, payload) {
|
|
74
97
|
return new Promise((accept, reject) => {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
98
|
+
const parts = serviceName.split("@");
|
|
99
|
+
const [module, name] = parts.length === 2 ? parts : ['mge', serviceName];
|
|
100
|
+
const ctx = this.getContext(module);
|
|
101
|
+
const url = `${ctx.baseUrl}?serviceName=${name}&counter=21&application=${ctx.appName}&outputType=json&preventTransform=false&mgeSession=${ctx.mgeSession}&resourceID=${ctx.resourceID}&globalID=${ctx.globalID}&allowConcurrentCalls=true`;
|
|
77
102
|
document.cookie = `JSESSIONID=${ctx.mgeSession};`;
|
|
78
103
|
const http = new XMLHttpRequest();
|
|
79
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url }));
|
|
104
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url: url, requestBody: payload }));
|
|
80
105
|
http.open("POST", url, true);
|
|
81
106
|
http.withCredentials = true;
|
|
82
107
|
http.send(payload);
|
|
@@ -95,11 +120,11 @@ export class DataFetcher {
|
|
|
95
120
|
console.warn(`callServiceBroker error to parser response to JSON ${e}`);
|
|
96
121
|
reject(this.responseText);
|
|
97
122
|
}
|
|
98
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
123
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
|
|
99
124
|
}
|
|
100
125
|
else if (this.readyState == 4 && this.status != 200) {
|
|
101
126
|
reject(this.responseText);
|
|
102
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
127
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
|
|
103
128
|
}
|
|
104
129
|
};
|
|
105
130
|
});
|
|
@@ -155,7 +180,7 @@ export class DataFetcher {
|
|
|
155
180
|
if (window['skw_session']) {
|
|
156
181
|
url += `?mgeSession=${window['skw_session']}`;
|
|
157
182
|
}
|
|
158
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url }));
|
|
183
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url: url, requestBody: request }));
|
|
159
184
|
try {
|
|
160
185
|
res = await batchRequests(url, request, { 'Content-Type': `application/json; charset=${window['SERVER_ENCODING'] || 'UTF-8'}` });
|
|
161
186
|
res.forEach((resItem, index) => {
|
|
@@ -186,11 +211,11 @@ export class DataFetcher {
|
|
|
186
211
|
});
|
|
187
212
|
}
|
|
188
213
|
else {
|
|
189
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
214
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: request }));
|
|
190
215
|
throw new ErrorException("Falha de comunicação", err.message);
|
|
191
216
|
}
|
|
192
217
|
}
|
|
193
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
218
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: request }));
|
|
194
219
|
return { data: dataResponse, errors: errorsResponse };
|
|
195
220
|
}
|
|
196
221
|
isHttpError(err) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DataFetcher } from "../DataFetcher";
|
|
1
|
+
import { ChangeOperation, DataType, DataUnit, StringUtils } from "@sankhyalabs/core";
|
|
3
2
|
import { gql } from "graphql-request";
|
|
3
|
+
import { DataFetcher } from "../DataFetcher";
|
|
4
4
|
export default class DataUnitFetcher {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.templateByQuery = new Map();
|
|
7
|
+
this._loadDataTimeout = {};
|
|
7
8
|
this.buldTemplates();
|
|
8
9
|
}
|
|
9
10
|
buldTemplates() {
|
|
@@ -32,9 +33,9 @@ export default class DataUnitFetcher {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}`);
|
|
35
|
-
this.templateByQuery.set("fetchData", gql `query($dataunit: String! $limit: Int $offset:Int $
|
|
36
|
+
this.templateByQuery.set("fetchData", gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
|
|
36
37
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
37
|
-
data(limit: $limit offset: $offset filters: $
|
|
38
|
+
data(limit: $limit offset: $offset filters: $filters sort: $sort){
|
|
38
39
|
limit
|
|
39
40
|
offset
|
|
40
41
|
total
|
|
@@ -63,7 +64,7 @@ export default class DataUnitFetcher {
|
|
|
63
64
|
getDataUnit(entityName, resourceID) {
|
|
64
65
|
const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
|
|
65
66
|
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
66
|
-
dataUnit.dataLoader = (dataUnit,
|
|
67
|
+
dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
|
|
67
68
|
dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
68
69
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
69
70
|
return dataUnit;
|
|
@@ -100,25 +101,39 @@ export default class DataUnitFetcher {
|
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
|
-
loadData(dataUnit,
|
|
104
|
+
loadData(dataUnit, request) {
|
|
105
|
+
const duName = dataUnit.name;
|
|
106
|
+
if (this._loadDataTimeout[duName]) {
|
|
107
|
+
clearTimeout(this._loadDataTimeout[duName]);
|
|
108
|
+
delete this._loadDataTimeout[duName];
|
|
109
|
+
}
|
|
104
110
|
return new Promise((resolve, reject) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
111
|
+
this._loadDataTimeout[duName] = setTimeout(() => {
|
|
112
|
+
delete this._loadDataTimeout[duName];
|
|
113
|
+
this.doLoadData(dataUnit, request)
|
|
114
|
+
.then(result => resolve(result))
|
|
115
|
+
.catch(reason => reject(reason));
|
|
116
|
+
}, 200);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
doLoadData(dataUnit, request) {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
var _a;
|
|
122
|
+
const { sort, filters, limit, offset, quickFilter } = request;
|
|
123
|
+
const variables = { dataunit: dataUnit.name, sort, filters };
|
|
124
|
+
variables.limit = limit;
|
|
125
|
+
variables.offset = offset;
|
|
126
|
+
if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
|
|
112
127
|
if (variables.filter === undefined) {
|
|
113
128
|
variables.filter = [];
|
|
114
129
|
}
|
|
115
130
|
const quickFilterCriteria = {
|
|
116
131
|
name: "__QUICK_FILTER__",
|
|
117
132
|
expression: "__QUICK_FILTER__",
|
|
118
|
-
params: [{ name: "term", dataType: DataType.TEXT, value:
|
|
133
|
+
params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
|
|
119
134
|
};
|
|
120
|
-
if (((
|
|
121
|
-
quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value:
|
|
135
|
+
if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
136
|
+
quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
|
|
122
137
|
}
|
|
123
138
|
variables.filter.push(quickFilterCriteria);
|
|
124
139
|
}
|
|
@@ -128,16 +143,32 @@ export default class DataUnitFetcher {
|
|
|
128
143
|
query: this.templateByQuery.get("fetchData"),
|
|
129
144
|
})
|
|
130
145
|
.then((resp) => {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
const { limit, offset, total, hasMore, records } = resp.data;
|
|
147
|
+
let paginationInfo;
|
|
148
|
+
if (limit) {
|
|
149
|
+
const firstRecord = total == 0 ? 0 : offset + 1;
|
|
150
|
+
const lastRecord = offset + Math.min(records.length, limit);
|
|
151
|
+
const currentPage = offset / limit;
|
|
152
|
+
paginationInfo = {
|
|
153
|
+
firstRecord,
|
|
154
|
+
lastRecord,
|
|
155
|
+
total,
|
|
156
|
+
currentPage,
|
|
157
|
+
hasMore
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const processedRecords = [];
|
|
161
|
+
records.forEach((responseRecord) => {
|
|
134
162
|
const duRecord = { __record__id__: responseRecord.id };
|
|
135
163
|
responseRecord.fields.forEach(({ name, value }) => {
|
|
136
164
|
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
137
165
|
});
|
|
138
|
-
|
|
166
|
+
processedRecords.push(duRecord);
|
|
167
|
+
});
|
|
168
|
+
resolve({
|
|
169
|
+
paginationInfo,
|
|
170
|
+
records: processedRecords
|
|
139
171
|
});
|
|
140
|
-
resolve(Object.assign(Object.assign({}, pageResult), { records }));
|
|
141
172
|
})
|
|
142
173
|
.catch((error) => {
|
|
143
174
|
reject(error);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ResourceFetcher } from "./resource-fetcher";
|
|
2
|
+
function normalizeValue(value) {
|
|
3
|
+
if (value instanceof Date) {
|
|
4
|
+
return value.toISOString();
|
|
5
|
+
}
|
|
6
|
+
if (typeof value === "object") {
|
|
7
|
+
const normalized = Object.assign({}, value);
|
|
8
|
+
Object.keys(value).forEach(prop => {
|
|
9
|
+
if (value[prop]) {
|
|
10
|
+
normalized[prop] = normalizeValue(value[prop]);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
delete normalized[prop];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return normalized;
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export default class FilterBarConfigFetcher extends ResourceFetcher {
|
|
21
|
+
saveConfig(items, resourceID, configName) {
|
|
22
|
+
const state = items.map(item => {
|
|
23
|
+
const { id, value, fixed, visible } = item;
|
|
24
|
+
const stateItem = { id };
|
|
25
|
+
if (value) {
|
|
26
|
+
stateItem["value"] = normalizeValue(value);
|
|
27
|
+
}
|
|
28
|
+
if (fixed) {
|
|
29
|
+
stateItem["fixed"] = fixed;
|
|
30
|
+
}
|
|
31
|
+
if (visible) {
|
|
32
|
+
stateItem["visible"] = true;
|
|
33
|
+
}
|
|
34
|
+
return stateItem;
|
|
35
|
+
});
|
|
36
|
+
return this.saveResource(state, `cfg://filter/FilterBarState:${resourceID}/${configName}`);
|
|
37
|
+
}
|
|
38
|
+
getConfig(resourceID, configName) {
|
|
39
|
+
return new Promise((accept, reject) => {
|
|
40
|
+
this.loadResource(`cfg://filter/FilterBarState:${resourceID}/${configName}`)
|
|
41
|
+
.then((configAsString) => {
|
|
42
|
+
let fieldsList;
|
|
43
|
+
if (configAsString) {
|
|
44
|
+
const filterBarConfig = JSON.parse(configAsString);
|
|
45
|
+
fieldsList = filterBarConfig.items;
|
|
46
|
+
}
|
|
47
|
+
accept(fieldsList || []);
|
|
48
|
+
})
|
|
49
|
+
.catch((error) => {
|
|
50
|
+
reject(error);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -4,15 +4,16 @@ export default class GridConfigFetcher extends ResourceFetcher {
|
|
|
4
4
|
super(...arguments);
|
|
5
5
|
this.GRID_CONFIG_VERSION = "V3:";
|
|
6
6
|
}
|
|
7
|
-
getConfig(resourceID) {
|
|
7
|
+
getConfig(_gridName, resourceID) {
|
|
8
8
|
const completePath = `cfg://grid/${this.GRID_CONFIG_VERSION}${resourceID}`;
|
|
9
9
|
return new Promise((resolve, reject) => {
|
|
10
10
|
this.loadResource(completePath)
|
|
11
11
|
.then(loadedResource => {
|
|
12
|
+
let config = undefined;
|
|
12
13
|
if (loadedResource) {
|
|
13
|
-
|
|
14
|
-
resolve(config);
|
|
14
|
+
config = JSON.parse(loadedResource);
|
|
15
15
|
}
|
|
16
|
+
resolve(config);
|
|
16
17
|
}).catch((error) => {
|
|
17
18
|
reject(error);
|
|
18
19
|
});
|