@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-48463.1 → 0.0.0-bugfix-dev-KB-49699.0
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-d4c99a5e.js → ConfigStorage-34be11ce.js} +68 -5
- package/dist/cjs/{SnkFormConfigManager-0ffd098d.js → SnkFormConfigManager-6211fb28.js} +6 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +8 -2
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +5 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-filter-bar.cjs.entry.js +8 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-form.cjs.entry.js +9 -2
- package/dist/cjs/snk-grid.cjs.entry.js +12 -3
- package/dist/cjs/{snk-guides-viewer-c7293cfa.js → snk-guides-viewer-508bb6fe.js} +9 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +70 -11
- package/dist/cjs/snk-taskbar.cjs.entry.js +12 -10
- package/dist/cjs/{taskbar-elements-1e4fb2e0.js → taskbar-elements-3ecd1278.js} +1 -1
- package/dist/collection/components/snk-application/snk-application.js +42 -2
- package/dist/collection/components/snk-crud/snk-crud.js +55 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +24 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +24 -0
- package/dist/collection/components/snk-form/snk-form.js +24 -0
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -1
- package/dist/collection/components/snk-grid/snk-grid.js +44 -1
- package/dist/collection/components/snk-simple-crud/regular-buttons.js +3 -0
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +120 -7
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -1
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +12 -8
- package/dist/collection/lib/configs/ConfigStorage.js +63 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +6 -3
- package/dist/components/ConfigStorage.js +68 -5
- package/dist/components/SnkFormConfigManager.js +5 -0
- package/dist/components/snk-application2.js +9 -1
- package/dist/components/snk-crud.js +7 -1
- package/dist/components/snk-detail-view2.js +8 -0
- package/dist/components/snk-filter-bar2.js +8 -0
- package/dist/components/snk-form.js +8 -0
- package/dist/components/snk-grid2.js +12 -1
- package/dist/components/snk-simple-crud2.js +70 -8
- package/dist/components/snk-taskbar2.js +12 -10
- package/dist/esm/{ConfigStorage-39ed8aeb.js → ConfigStorage-101a2b4c.js} +68 -5
- package/dist/esm/{SnkFormConfigManager-dd450734.js → SnkFormConfigManager-d86ba46f.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +8 -2
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +5 -2
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-filter-bar.entry.js +8 -1
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-form.entry.js +9 -2
- package/dist/esm/snk-grid.entry.js +12 -3
- package/dist/esm/{snk-guides-viewer-47443f7c.js → snk-guides-viewer-18859840.js} +9 -2
- package/dist/esm/snk-guides-viewer.entry.js +4 -4
- package/dist/esm/snk-personalized-filter.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +70 -11
- package/dist/esm/snk-taskbar.entry.js +12 -10
- package/dist/esm/{taskbar-elements-846c027c.js → taskbar-elements-2473c8ac.js} +1 -1
- package/dist/sankhyablocks/p-1f3174cb.entry.js +1 -0
- package/dist/sankhyablocks/p-1fa5a18c.entry.js +11 -0
- package/dist/sankhyablocks/p-5c0b53ce.js +56 -0
- package/dist/sankhyablocks/p-5dbc1a3f.js +1 -0
- package/dist/sankhyablocks/p-60fa6c7a.js +1 -0
- package/dist/sankhyablocks/p-64c1b368.entry.js +1 -0
- package/dist/sankhyablocks/p-650f7216.entry.js +1 -0
- package/dist/sankhyablocks/{p-9d608b62.entry.js → p-6b28cc74.entry.js} +1 -1
- package/dist/sankhyablocks/{p-827e4b01.entry.js → p-7ddd95b6.entry.js} +1 -1
- package/dist/sankhyablocks/p-ae4fc9a9.js +1 -0
- package/dist/sankhyablocks/{p-9fb97691.entry.js → p-b41a622a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-0c9dd95e.entry.js → p-b4de81ac.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3c5b7cfc.entry.js → p-ba4871b5.entry.js} +1 -1
- package/dist/sankhyablocks/p-d01ceda6.entry.js +1 -0
- package/dist/sankhyablocks/p-d304659d.entry.js +1 -0
- package/dist/sankhyablocks/{p-99b1926b.entry.js → p-e4fb3308.entry.js} +1 -1
- package/dist/sankhyablocks/p-fbfab20b.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +8 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +12 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +5 -0
- package/dist/types/components/snk-form/snk-form.d.ts +5 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +1 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +9 -0
- package/dist/types/components/snk-simple-crud/regular-buttons.d.ts +3 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +19 -2
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +1 -0
- package/dist/types/components.d.ts +104 -0
- package/dist/types/lib/configs/ConfigStorage.d.ts +21 -1
- package/dist/types/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.d.ts +2 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-30735d1e.entry.js +0 -1
- package/dist/sankhyablocks/p-3e2e2424.entry.js +0 -1
- package/dist/sankhyablocks/p-67aedbe0.js +0 -56
- package/dist/sankhyablocks/p-6ae58da0.js +0 -1
- package/dist/sankhyablocks/p-746fc99e.entry.js +0 -1
- package/dist/sankhyablocks/p-8c13d8d6.entry.js +0 -1
- package/dist/sankhyablocks/p-8c49760e.js +0 -1
- package/dist/sankhyablocks/p-9ea14b61.js +0 -1
- package/dist/sankhyablocks/p-c4bcdd4b.entry.js +0 -11
- package/dist/sankhyablocks/p-fca66dda.entry.js +0 -1
- package/dist/sankhyablocks/p-fd216f2e.entry.js +0 -1
|
@@ -11,6 +11,7 @@ export class SnkForm {
|
|
|
11
11
|
this.configName = undefined;
|
|
12
12
|
this.recordsValidator = undefined;
|
|
13
13
|
this.messagesBuilder = undefined;
|
|
14
|
+
this.formLegacyConfigName = undefined;
|
|
14
15
|
this.resourceID = undefined;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
@@ -58,8 +59,14 @@ export class SnkForm {
|
|
|
58
59
|
this.resourceID = await ResourceIDUtils.getResourceID();
|
|
59
60
|
}
|
|
60
61
|
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID);
|
|
62
|
+
this.addFormLegacyConfig();
|
|
61
63
|
this._configManager.loadConfig();
|
|
62
64
|
}
|
|
65
|
+
addFormLegacyConfig() {
|
|
66
|
+
if (this.formLegacyConfigName) {
|
|
67
|
+
this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
63
70
|
render() {
|
|
64
71
|
if (!this._dataUnit || !this._dataState) {
|
|
65
72
|
return undefined;
|
|
@@ -138,6 +145,23 @@ export class SnkForm {
|
|
|
138
145
|
"text": "Respons\u00E1vel por flexibilizar e padronizar o uso de mensagens nos blocos de constru\u00E7\u00E3o."
|
|
139
146
|
}
|
|
140
147
|
},
|
|
148
|
+
"formLegacyConfigName": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"mutable": false,
|
|
151
|
+
"complexType": {
|
|
152
|
+
"original": "string",
|
|
153
|
+
"resolved": "string",
|
|
154
|
+
"references": {}
|
|
155
|
+
},
|
|
156
|
+
"required": false,
|
|
157
|
+
"optional": false,
|
|
158
|
+
"docs": {
|
|
159
|
+
"tags": [],
|
|
160
|
+
"text": "Chave da configura\u00E7\u00E3o legado do formul\u00E1rio."
|
|
161
|
+
},
|
|
162
|
+
"attribute": "form-legacy-config-name",
|
|
163
|
+
"reflect": false
|
|
164
|
+
},
|
|
141
165
|
"resourceID": {
|
|
142
166
|
"type": "string",
|
|
143
167
|
"mutable": false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigStorage } from
|
|
1
|
+
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
|
2
2
|
import { ObjectUtils, StringUtils } from "@sankhyalabs/core";
|
|
3
3
|
import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
|
|
4
4
|
export class SnkFormConfigManager {
|
|
@@ -7,6 +7,11 @@ export class SnkFormConfigManager {
|
|
|
7
7
|
this._configName = configName;
|
|
8
8
|
this._onConfigChange = onConfigChange;
|
|
9
9
|
}
|
|
10
|
+
addFormLegacyConfig(legacyConfigName) {
|
|
11
|
+
if (this._configName) {
|
|
12
|
+
ConfigStorage.addFormLegacyConfig(this._configName, legacyConfigName);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
10
15
|
async loadConfig() {
|
|
11
16
|
return new Promise(resolve => {
|
|
12
17
|
ConfigStorage.loadFormConfig(this._configName, this._resourceID)
|
|
@@ -55,6 +55,8 @@ export class SnkGrid {
|
|
|
55
55
|
this.gridHeaderCustomSlotId = 'GRID_HEADER_CUSTOM_ELEMENTS';
|
|
56
56
|
this.topTaskbarCustomSlotId = 'GRID_TASKBAR_CUSTOM_ELEMENTS';
|
|
57
57
|
this.disablePersonalizedFilter = undefined;
|
|
58
|
+
this.gridLegacyConfigName = undefined;
|
|
59
|
+
this.filterBarLegacyConfigName = undefined;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Exibe a janela de configurações da grade.
|
|
@@ -123,6 +125,11 @@ export class SnkGrid {
|
|
|
123
125
|
console.warn(error);
|
|
124
126
|
});
|
|
125
127
|
}
|
|
128
|
+
addGridLegacyConfigName() {
|
|
129
|
+
if (this.gridLegacyConfigName && this.configName) {
|
|
130
|
+
ConfigStorage.addGridLegacyConfig(this.configName, this.gridLegacyConfigName);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
126
133
|
gridConfigChangeHandler(evt) {
|
|
127
134
|
const config = evt.detail;
|
|
128
135
|
ConfigStorage.saveGridConfig(config, this.configName, this.resourceID);
|
|
@@ -247,6 +254,7 @@ export class SnkGrid {
|
|
|
247
254
|
}
|
|
248
255
|
componentWillLoad() {
|
|
249
256
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
257
|
+
//TODO: substituir pelo metodo nativo closest
|
|
250
258
|
let parent = this._element.parentElement;
|
|
251
259
|
while (parent) {
|
|
252
260
|
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
@@ -276,6 +284,7 @@ export class SnkGrid {
|
|
|
276
284
|
}
|
|
277
285
|
parent = parent.parentElement;
|
|
278
286
|
}
|
|
287
|
+
this.addGridLegacyConfigName();
|
|
279
288
|
this.loadConfig();
|
|
280
289
|
}
|
|
281
290
|
getHeaderDisabledButtons() {
|
|
@@ -390,7 +399,7 @@ export class SnkGrid {
|
|
|
390
399
|
return undefined;
|
|
391
400
|
}
|
|
392
401
|
return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, this._showSnkFilterBar &&
|
|
393
|
-
h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
|
|
402
|
+
h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
|
|
394
403
|
}
|
|
395
404
|
static get is() { return "snk-grid"; }
|
|
396
405
|
static get encapsulation() { return "scoped"; }
|
|
@@ -767,6 +776,40 @@ export class SnkGrid {
|
|
|
767
776
|
},
|
|
768
777
|
"attribute": "disable-personalized-filter",
|
|
769
778
|
"reflect": false
|
|
779
|
+
},
|
|
780
|
+
"gridLegacyConfigName": {
|
|
781
|
+
"type": "string",
|
|
782
|
+
"mutable": false,
|
|
783
|
+
"complexType": {
|
|
784
|
+
"original": "string",
|
|
785
|
+
"resolved": "string",
|
|
786
|
+
"references": {}
|
|
787
|
+
},
|
|
788
|
+
"required": false,
|
|
789
|
+
"optional": false,
|
|
790
|
+
"docs": {
|
|
791
|
+
"tags": [],
|
|
792
|
+
"text": "Chave da configura\u00E7\u00E3o legado da grade."
|
|
793
|
+
},
|
|
794
|
+
"attribute": "grid-legacy-config-name",
|
|
795
|
+
"reflect": false
|
|
796
|
+
},
|
|
797
|
+
"filterBarLegacyConfigName": {
|
|
798
|
+
"type": "string",
|
|
799
|
+
"mutable": false,
|
|
800
|
+
"complexType": {
|
|
801
|
+
"original": "string",
|
|
802
|
+
"resolved": "string",
|
|
803
|
+
"references": {}
|
|
804
|
+
},
|
|
805
|
+
"required": false,
|
|
806
|
+
"optional": false,
|
|
807
|
+
"docs": {
|
|
808
|
+
"tags": [],
|
|
809
|
+
"text": "Chave da configura\u00E7\u00E3o legado da barra de filtros."
|
|
810
|
+
},
|
|
811
|
+
"attribute": "filter-bar-legacy-config-name",
|
|
812
|
+
"reflect": false
|
|
770
813
|
}
|
|
771
814
|
};
|
|
772
815
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
|
|
2
|
+
const REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
|
|
3
|
+
export { REGULAR_DEFAULT_BTNS, REGULAR_SELECTED_BTNS };
|
|
@@ -9,10 +9,9 @@ import SnkMultiSelectionListDataSource from '../snk-grid/filtercolumn/SnkMultiSe
|
|
|
9
9
|
import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/field-search';
|
|
10
10
|
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
|
11
11
|
import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
|
|
12
|
+
import { REGULAR_DEFAULT_BTNS, REGULAR_SELECTED_BTNS } from './regular-buttons';
|
|
12
13
|
export class SnkSimpleCrud {
|
|
13
14
|
constructor() {
|
|
14
|
-
this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
|
|
15
|
-
this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
|
|
16
15
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
|
17
16
|
this._keyDownHandler = (event) => this.keyDownListener(event);
|
|
18
17
|
this._taskbarProcessor = new TaskbarProcessor({
|
|
@@ -42,9 +41,12 @@ export class SnkSimpleCrud {
|
|
|
42
41
|
this.actionsList = undefined;
|
|
43
42
|
this.configName = undefined;
|
|
44
43
|
this.showConfiguratorButtons = undefined;
|
|
44
|
+
this.gridLegacyConfigName = undefined;
|
|
45
|
+
this.formLegacyConfigName = undefined;
|
|
46
|
+
this.ignoreReadOnlyFormFields = false;
|
|
45
47
|
}
|
|
46
48
|
getButtons(selected, changeModeBtn) {
|
|
47
|
-
return this.addConfigButton(this.resolveInMemoryBtns(selected ?
|
|
49
|
+
return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
|
|
48
50
|
.concat(changeModeBtn));
|
|
49
51
|
}
|
|
50
52
|
addConfigButton(buttons) {
|
|
@@ -95,6 +97,44 @@ export class SnkSimpleCrud {
|
|
|
95
97
|
this.dataStateChange.emit(newValue);
|
|
96
98
|
}
|
|
97
99
|
}
|
|
100
|
+
async observeFormLegacy() {
|
|
101
|
+
await this.handleUpdateFormLegacyConfig();
|
|
102
|
+
}
|
|
103
|
+
async observeGridLegacy() {
|
|
104
|
+
await this.handleUpdateGridLegacyConfig();
|
|
105
|
+
}
|
|
106
|
+
async handleUpdateGridLegacyConfig() {
|
|
107
|
+
if (this.gridLegacyConfigName) {
|
|
108
|
+
this.addGridLegacyConfigName();
|
|
109
|
+
if (this._gridConfigAlreadyLoaded) {
|
|
110
|
+
await this.loadGridConfig(true);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async handleUpdateFormLegacyConfig() {
|
|
115
|
+
var _a, _b, _c;
|
|
116
|
+
if (this.formLegacyConfigName) {
|
|
117
|
+
const legacyConfig = await this.fetchFormLegacyConfig();
|
|
118
|
+
if (!legacyConfig)
|
|
119
|
+
return;
|
|
120
|
+
const rawFields = (_c = (_b = (_a = legacyConfig === null || legacyConfig === void 0 ? void 0 : legacyConfig.formConfig) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.field) !== null && _c !== void 0 ? _c : [];
|
|
121
|
+
const fields = Array.isArray(rawFields) ? rawFields : [rawFields];
|
|
122
|
+
const newConfig = { emptyConfig: false, fields: fields };
|
|
123
|
+
this.setFormConfig(newConfig, true);
|
|
124
|
+
this._formConfigManager.setConfig(this.formConfig);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async fetchFormLegacyConfig() {
|
|
128
|
+
const payload = {
|
|
129
|
+
'requestBody': {
|
|
130
|
+
'config': {
|
|
131
|
+
'chave': this.formLegacyConfigName,
|
|
132
|
+
'tipo': 'T',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
return await this.application.callServiceBroker('SystemUtilsSP.getConf', JSON.stringify(payload));
|
|
137
|
+
}
|
|
98
138
|
openConfig(viewMode) {
|
|
99
139
|
this._snkConfigurator.close();
|
|
100
140
|
if (viewMode === VIEW_MODE.GRID) {
|
|
@@ -113,10 +153,18 @@ export class SnkSimpleCrud {
|
|
|
113
153
|
});
|
|
114
154
|
}
|
|
115
155
|
openFormConfig() {
|
|
156
|
+
//No momento não daremos suporte para configuraçao de formulário quando houver legacy config
|
|
157
|
+
if (this.formLegacyConfigName)
|
|
158
|
+
return;
|
|
116
159
|
this._showFormConfig = true;
|
|
117
160
|
}
|
|
118
|
-
|
|
119
|
-
if (this.
|
|
161
|
+
addGridLegacyConfigName() {
|
|
162
|
+
if (this.gridLegacyConfigName && this.configName) {
|
|
163
|
+
ConfigStorage.addGridLegacyConfig(this.configName, this.gridLegacyConfigName);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
loadGridConfig(forceUpdate) {
|
|
167
|
+
if ((this.gridConfig != undefined || this._gridConfigAlreadyLoaded) && !forceUpdate) {
|
|
120
168
|
return;
|
|
121
169
|
}
|
|
122
170
|
this._gridConfigAlreadyLoaded = true;
|
|
@@ -151,6 +199,7 @@ export class SnkSimpleCrud {
|
|
|
151
199
|
if (this.gridConfig != undefined || this._gridConfigAlreadyLoaded) {
|
|
152
200
|
return;
|
|
153
201
|
}
|
|
202
|
+
await this.addGridLegacyConfigName();
|
|
154
203
|
this.loadGridConfig();
|
|
155
204
|
this.loadFormConfig();
|
|
156
205
|
}
|
|
@@ -410,7 +459,9 @@ export class SnkSimpleCrud {
|
|
|
410
459
|
this.gridConfig = config;
|
|
411
460
|
CrudUtils.assertDefaultSorting(this.gridConfig, this.dataUnit);
|
|
412
461
|
}
|
|
413
|
-
setFormConfig(config) {
|
|
462
|
+
setFormConfig(config, forceUpdate) {
|
|
463
|
+
if (this.formConfig && !forceUpdate)
|
|
464
|
+
return;
|
|
414
465
|
this.formConfig = config;
|
|
415
466
|
}
|
|
416
467
|
closeGridConfig() {
|
|
@@ -419,6 +470,10 @@ export class SnkSimpleCrud {
|
|
|
419
470
|
closeFormConfig() {
|
|
420
471
|
this._showFormConfig = false;
|
|
421
472
|
}
|
|
473
|
+
//No momento não daremos suporte para configuração de formulário quando houver formLegacyConfigName
|
|
474
|
+
handleShowFormConfig() {
|
|
475
|
+
return this._showFormConfig && !this.formLegacyConfigName;
|
|
476
|
+
}
|
|
422
477
|
/* istanbul ignore next */
|
|
423
478
|
render() {
|
|
424
479
|
var _a, _b, _c;
|
|
@@ -427,7 +482,7 @@ export class SnkSimpleCrud {
|
|
|
427
482
|
}
|
|
428
483
|
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
|
429
484
|
? undefined
|
|
430
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.
|
|
485
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: (_b = this._formConfigManager) === null || _b === void 0 ? void 0 : _b.getConfig(this.ignoreReadOnlyFormFields ? (_c = this.dataState) === null || _c === void 0 ? void 0 : _c.insertionMode : false, this.dataUnit), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this._resourceID }))));
|
|
431
486
|
}
|
|
432
487
|
static get is() { return "snk-simple-crud"; }
|
|
433
488
|
static get encapsulation() { return "scoped"; }
|
|
@@ -695,6 +750,58 @@ export class SnkSimpleCrud {
|
|
|
695
750
|
},
|
|
696
751
|
"attribute": "show-configurator-buttons",
|
|
697
752
|
"reflect": false
|
|
753
|
+
},
|
|
754
|
+
"gridLegacyConfigName": {
|
|
755
|
+
"type": "string",
|
|
756
|
+
"mutable": false,
|
|
757
|
+
"complexType": {
|
|
758
|
+
"original": "string",
|
|
759
|
+
"resolved": "string",
|
|
760
|
+
"references": {}
|
|
761
|
+
},
|
|
762
|
+
"required": false,
|
|
763
|
+
"optional": false,
|
|
764
|
+
"docs": {
|
|
765
|
+
"tags": [],
|
|
766
|
+
"text": "Chave da configura\u00E7\u00E3o legado da grade."
|
|
767
|
+
},
|
|
768
|
+
"attribute": "grid-legacy-config-name",
|
|
769
|
+
"reflect": false
|
|
770
|
+
},
|
|
771
|
+
"formLegacyConfigName": {
|
|
772
|
+
"type": "string",
|
|
773
|
+
"mutable": false,
|
|
774
|
+
"complexType": {
|
|
775
|
+
"original": "string",
|
|
776
|
+
"resolved": "string",
|
|
777
|
+
"references": {}
|
|
778
|
+
},
|
|
779
|
+
"required": false,
|
|
780
|
+
"optional": false,
|
|
781
|
+
"docs": {
|
|
782
|
+
"tags": [],
|
|
783
|
+
"text": "Chave da configura\u00E7\u00E3o legado do formul\u00E1rio."
|
|
784
|
+
},
|
|
785
|
+
"attribute": "form-legacy-config-name",
|
|
786
|
+
"reflect": false
|
|
787
|
+
},
|
|
788
|
+
"ignoreReadOnlyFormFields": {
|
|
789
|
+
"type": "boolean",
|
|
790
|
+
"mutable": false,
|
|
791
|
+
"complexType": {
|
|
792
|
+
"original": "boolean",
|
|
793
|
+
"resolved": "boolean",
|
|
794
|
+
"references": {}
|
|
795
|
+
},
|
|
796
|
+
"required": false,
|
|
797
|
+
"optional": false,
|
|
798
|
+
"docs": {
|
|
799
|
+
"tags": [],
|
|
800
|
+
"text": "Ignora os campos \"somente leitura\" no modo de inser\u00E7\u00E3o."
|
|
801
|
+
},
|
|
802
|
+
"attribute": "ignore-read-only-form-fields",
|
|
803
|
+
"reflect": false,
|
|
804
|
+
"defaultValue": "false"
|
|
698
805
|
}
|
|
699
806
|
};
|
|
700
807
|
}
|
|
@@ -958,6 +1065,12 @@ export class SnkSimpleCrud {
|
|
|
958
1065
|
}, {
|
|
959
1066
|
"propName": "dataState",
|
|
960
1067
|
"methodName": "observeDataState"
|
|
1068
|
+
}, {
|
|
1069
|
+
"propName": "formLegacyConfigName",
|
|
1070
|
+
"methodName": "observeFormLegacy"
|
|
1071
|
+
}, {
|
|
1072
|
+
"propName": "gridLegacyConfigName",
|
|
1073
|
+
"methodName": "observeGridLegacy"
|
|
961
1074
|
}];
|
|
962
1075
|
}
|
|
963
1076
|
static get listeners() {
|
|
@@ -88,7 +88,7 @@ export const buildElem = (element, className, dataElementId, getTitle, action, i
|
|
|
88
88
|
case TaskbarElement.MORE_OPTIONS:
|
|
89
89
|
return actionButton(element, className, dataElementId, title, isEnabled, actions, action);
|
|
90
90
|
case TaskbarElement.DIVIDER:
|
|
91
|
-
return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-
|
|
91
|
+
return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium", "data-taskbar-divider": true });
|
|
92
92
|
case TaskbarElement.DATA_EXPORTER:
|
|
93
93
|
const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[configName];
|
|
94
94
|
return h("snk-data-exporter", { class: className, provider: provider, "data-element-id": dataElementId, "data-taskbar-element": element });
|
|
@@ -48,7 +48,13 @@ export class SnkTaskbar {
|
|
|
48
48
|
}
|
|
49
49
|
observeButtons() {
|
|
50
50
|
this._definitions = undefined;
|
|
51
|
-
requestAnimationFrame(() => {
|
|
51
|
+
requestAnimationFrame(() => {
|
|
52
|
+
requestAnimationFrame(() => { var _a; return (_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.forceUpdate(); });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
observeDisabledButtons() {
|
|
56
|
+
var _a;
|
|
57
|
+
(_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.forceUpdate();
|
|
52
58
|
}
|
|
53
59
|
// Internal methods
|
|
54
60
|
elementsFromString(strButtons) {
|
|
@@ -203,7 +209,7 @@ export class SnkTaskbar {
|
|
|
203
209
|
this._customElementsId.push(elementId);
|
|
204
210
|
(_a = this._overFlowWatcher) === null || _a === void 0 ? void 0 : _a.addNotOverFlowElement(elementId);
|
|
205
211
|
}
|
|
206
|
-
return h("span", { key: elementId, id: elementId });
|
|
212
|
+
return h("span", { class: "ez-padding-left--medium", key: elementId, id: elementId });
|
|
207
213
|
}
|
|
208
214
|
getCustomElements() {
|
|
209
215
|
var _a, _b;
|
|
@@ -327,12 +333,7 @@ export class SnkTaskbar {
|
|
|
327
333
|
let index = 0;
|
|
328
334
|
return (h(Host, { class: this.getHostClasses() }, this.removeEmpty(this._definitions.map((elem) => {
|
|
329
335
|
var _a, _b;
|
|
330
|
-
|
|
331
|
-
index = 0;
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
index++;
|
|
335
|
-
}
|
|
336
|
+
index++;
|
|
336
337
|
if (TaskbarElement[elem]) {
|
|
337
338
|
return this.getElement(index, TaskbarElement[elem]);
|
|
338
339
|
}
|
|
@@ -665,6 +666,9 @@ export class SnkTaskbar {
|
|
|
665
666
|
return [{
|
|
666
667
|
"propName": "buttons",
|
|
667
668
|
"methodName": "observeButtons"
|
|
669
|
+
}, {
|
|
670
|
+
"propName": "disabledButtons",
|
|
671
|
+
"methodName": "observeDisabledButtons"
|
|
668
672
|
}];
|
|
669
673
|
}
|
|
670
674
|
}
|
|
@@ -2,18 +2,37 @@ import { FormConfigFetcher } from "../http/data-fetcher/fetchers/form-config-fet
|
|
|
2
2
|
import GridConfigFetcher from "../http/data-fetcher/fetchers/grid-config-fetcher";
|
|
3
3
|
import FilterBarConfigFetcher from "../http/data-fetcher/fetchers/filter-bar-config-fetcher";
|
|
4
4
|
import PersonalizedFilterFetcher from "../http/data-fetcher/fetchers/personalized-filter-fetcher";
|
|
5
|
-
var CONFIG_SOURCE;
|
|
5
|
+
export var CONFIG_SOURCE;
|
|
6
6
|
(function (CONFIG_SOURCE) {
|
|
7
7
|
CONFIG_SOURCE["form"] = "form";
|
|
8
8
|
CONFIG_SOURCE["grid"] = "grid";
|
|
9
9
|
CONFIG_SOURCE["filterBar"] = "filterBar";
|
|
10
10
|
})(CONFIG_SOURCE || (CONFIG_SOURCE = {}));
|
|
11
11
|
export class ConfigStorage {
|
|
12
|
-
static
|
|
12
|
+
static addFilterBarLegacyConfig(configName, legacyConfigName) {
|
|
13
|
+
this.validateConfigName(configName, legacyConfigName);
|
|
14
|
+
this.filterBarLegacyConfig.set(configName, legacyConfigName);
|
|
15
|
+
}
|
|
16
|
+
static addFormLegacyConfig(configName, legacyConfigName) {
|
|
17
|
+
this.validateConfigName(configName, legacyConfigName);
|
|
18
|
+
this.formLegacyConfig.set(configName, legacyConfigName);
|
|
19
|
+
}
|
|
20
|
+
static addGridLegacyConfig(configName, legacyConfigName) {
|
|
21
|
+
this.validateConfigName(configName, legacyConfigName);
|
|
22
|
+
this.gridLegacyConfig.set(configName, legacyConfigName);
|
|
23
|
+
}
|
|
24
|
+
static preload(resourceID, configName, legacyConfigs) {
|
|
25
|
+
if (configName && (legacyConfigs === null || legacyConfigs === void 0 ? void 0 : legacyConfigs.gridLegacyConfig)) {
|
|
26
|
+
ConfigStorage.addGridLegacyConfig(configName, legacyConfigs.gridLegacyConfig);
|
|
27
|
+
}
|
|
28
|
+
if (configName && (legacyConfigs === null || legacyConfigs === void 0 ? void 0 : legacyConfigs.formLegacyConfig)) {
|
|
29
|
+
ConfigStorage.addFormLegacyConfig(configName, legacyConfigs.formLegacyConfig);
|
|
30
|
+
}
|
|
13
31
|
ConfigStorage.loadFormConfig(configName, resourceID);
|
|
14
32
|
ConfigStorage.loadGridConfig(configName, resourceID);
|
|
15
33
|
}
|
|
16
34
|
static async loadFilterBarConfig(name, resourceID, urlParams) {
|
|
35
|
+
urlParams = this.handleLegacyConfig(name, CONFIG_SOURCE.filterBar, urlParams);
|
|
17
36
|
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
|
|
18
37
|
if (!ConfigStorage.configById.has(cacheID)) {
|
|
19
38
|
ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
|
|
@@ -21,6 +40,7 @@ export class ConfigStorage {
|
|
|
21
40
|
return ConfigStorage.configById.get(cacheID);
|
|
22
41
|
}
|
|
23
42
|
static async loadFormConfig(name, resourceID) {
|
|
43
|
+
name = this.handleLegacyConfigAsString(name, CONFIG_SOURCE.form);
|
|
24
44
|
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
|
|
25
45
|
if (!ConfigStorage.configById.has(cacheID)) {
|
|
26
46
|
ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
|
|
@@ -28,6 +48,7 @@ export class ConfigStorage {
|
|
|
28
48
|
return ConfigStorage.configById.get(cacheID);
|
|
29
49
|
}
|
|
30
50
|
static async loadGridConfig(name, resourceID) {
|
|
51
|
+
name = this.handleLegacyConfigAsString(name, CONFIG_SOURCE.grid);
|
|
31
52
|
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
|
|
32
53
|
if (!ConfigStorage.configById.has(cacheID)) {
|
|
33
54
|
ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
|
|
@@ -39,6 +60,7 @@ export class ConfigStorage {
|
|
|
39
60
|
return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
|
|
40
61
|
}
|
|
41
62
|
static async saveFormConfig(config, name, resourceID) {
|
|
63
|
+
name = this.handleLegacyConfigAsString(name, CONFIG_SOURCE.form);
|
|
42
64
|
await this.deleteFormConfigCache(name, resourceID);
|
|
43
65
|
return this.formConfigFetcher.saveConfig(config, name, resourceID);
|
|
44
66
|
}
|
|
@@ -53,7 +75,8 @@ export class ConfigStorage {
|
|
|
53
75
|
return this.gridConfigFetcher.saveConfig(config, name, resourceID);
|
|
54
76
|
}
|
|
55
77
|
static async loadPersonalizedFilter(filterId, resourceID, configName) {
|
|
56
|
-
|
|
78
|
+
const legacyConfigName = this.filterBarLegacyConfig.get(configName);
|
|
79
|
+
return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName, legacyConfigName);
|
|
57
80
|
}
|
|
58
81
|
static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
|
|
59
82
|
//Ao criar ou alterar um filtro personalizado,
|
|
@@ -76,6 +99,38 @@ export class ConfigStorage {
|
|
|
76
99
|
static async deleteFilterBarConfigCache(name, resourceID) {
|
|
77
100
|
await this.deleteConfigCache(name, resourceID, CONFIG_SOURCE.filterBar);
|
|
78
101
|
}
|
|
102
|
+
static validateConfigName(configName, legacyConfigName) {
|
|
103
|
+
if (!configName)
|
|
104
|
+
throw Error(this.CONFIG_NAME_ERROR_MESSAGE);
|
|
105
|
+
if (!legacyConfigName)
|
|
106
|
+
throw Error(this.LEGACY_CONFIG_NAME_ERROR_MESSAGE);
|
|
107
|
+
}
|
|
108
|
+
static handleLegacyConfig(configName, configSource, urlParams) {
|
|
109
|
+
let legacyConfigName;
|
|
110
|
+
switch (configSource) {
|
|
111
|
+
case CONFIG_SOURCE.filterBar:
|
|
112
|
+
legacyConfigName = this.filterBarLegacyConfig.get(configName);
|
|
113
|
+
break;
|
|
114
|
+
case CONFIG_SOURCE.grid:
|
|
115
|
+
legacyConfigName = this.gridLegacyConfig.get(configName);
|
|
116
|
+
break;
|
|
117
|
+
case CONFIG_SOURCE.form:
|
|
118
|
+
legacyConfigName = this.formLegacyConfig.get(configName);
|
|
119
|
+
}
|
|
120
|
+
const params = urlParams ? Object.assign({}, urlParams) : {};
|
|
121
|
+
if (legacyConfigName) {
|
|
122
|
+
params['legacyResourceID'] = legacyConfigName;
|
|
123
|
+
}
|
|
124
|
+
return params;
|
|
125
|
+
}
|
|
126
|
+
static handleLegacyConfigAsString(name, source) {
|
|
127
|
+
const params = this.handleLegacyConfig(name, source);
|
|
128
|
+
const legacyResourceID = params['legacyResourceID'];
|
|
129
|
+
if (legacyResourceID) {
|
|
130
|
+
name = name + `?legacyResourceID=${legacyResourceID}`;
|
|
131
|
+
}
|
|
132
|
+
return name;
|
|
133
|
+
}
|
|
79
134
|
static async deleteConfigCache(name, resourceID, source) {
|
|
80
135
|
const cacheID = ConfigStorage.buildCacheID(name, source, resourceID);
|
|
81
136
|
this.configById.delete(cacheID);
|
|
@@ -87,6 +142,11 @@ export class ConfigStorage {
|
|
|
87
142
|
return `req_${source}_${name}_${resourceID}`;
|
|
88
143
|
}
|
|
89
144
|
}
|
|
145
|
+
ConfigStorage.CONFIG_NAME_ERROR_MESSAGE = "ConfigName precisa ser informado.";
|
|
146
|
+
ConfigStorage.LEGACY_CONFIG_NAME_ERROR_MESSAGE = "LegacyConfigName precisa ser informado.";
|
|
147
|
+
ConfigStorage.filterBarLegacyConfig = new Map();
|
|
148
|
+
ConfigStorage.formLegacyConfig = new Map();
|
|
149
|
+
ConfigStorage.gridLegacyConfig = new Map();
|
|
90
150
|
ConfigStorage.configById = new Map();
|
|
91
151
|
ConfigStorage.filterBarConfigFetcher = new FilterBarConfigFetcher();
|
|
92
152
|
ConfigStorage.formConfigFetcher = new FormConfigFetcher();
|
|
@@ -52,7 +52,7 @@ export default class PersonalizedFilterFetcher {
|
|
|
52
52
|
assistent
|
|
53
53
|
}
|
|
54
54
|
}`);
|
|
55
|
-
this.templateByQuery.set("savePersonalizedFilter", gql `
|
|
55
|
+
this.templateByQuery.set("savePersonalizedFilter", gql `
|
|
56
56
|
mutation($name: String!, $filterAssistent: InputFilterAssistent!) {
|
|
57
57
|
$queryAlias$: savePersonalizedFilter(name: $name, filterAssistent: $filterAssistent) {
|
|
58
58
|
id
|
|
@@ -74,11 +74,11 @@ export default class PersonalizedFilterFetcher {
|
|
|
74
74
|
}
|
|
75
75
|
}`);
|
|
76
76
|
}
|
|
77
|
-
async loadPersonalizedFilter(resourceID, filterID, configName) {
|
|
77
|
+
async loadPersonalizedFilter(resourceID, filterID, configName, legacyConfigName) {
|
|
78
78
|
return new Promise((resolve, reject) => {
|
|
79
79
|
DataFetcher.get()
|
|
80
80
|
.callGraphQL({
|
|
81
|
-
values: { name: this.resolveURI(resourceID, configName) + "/" + filterID },
|
|
81
|
+
values: { name: this.resolveURI(resourceID, configName) + "/" + filterID + this.resolveLegacyConfigName(legacyConfigName) },
|
|
82
82
|
query: this.templateByQuery.get("fetchFilterAssistent"),
|
|
83
83
|
})
|
|
84
84
|
.then((resp) => {
|
|
@@ -90,6 +90,9 @@ export default class PersonalizedFilterFetcher {
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
+
resolveLegacyConfigName(legacyConfigName) {
|
|
94
|
+
return legacyConfigName ? `?legacyResourceID=${legacyConfigName}` : '';
|
|
95
|
+
}
|
|
93
96
|
async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
|
|
94
97
|
if (!personalizedFilter || Object.keys(personalizedFilter).length == 0) {
|
|
95
98
|
return Promise.reject(new Error("personalizedFilter não pode ser vazio"));
|