@sankhyalabs/sankhyablocks 8.1.0-rc.3 → 8.2.0-dev.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-73e7afff.js → ConfigStorage-12397f18.js} +163 -51
- package/dist/cjs/{DataFetcher-004811c6.js → DataFetcher-f2da1f79.js} +68 -30
- package/dist/cjs/ISave-d68ce3cd.js +8 -0
- package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
- package/dist/cjs/{SnkFormConfigManager-d1f1a222.js → SnkFormConfigManager-13f79e37.js} +19 -21
- package/dist/cjs/{auth-fetcher-58237931.js → auth-fetcher-319a4cb2.js} +2 -2
- package/dist/cjs/{dataunit-fetcher-029eafbd.js → dataunit-fetcher-e72068c1.js} +1 -1
- package/dist/cjs/{form-config-fetcher-181767c9.js → form-config-fetcher-5d62ab62.js} +66 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-9a97994a.js → pesquisa-fetcher-8c363096.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +18 -11
- package/dist/cjs/snk-application.cjs.entry.js +49 -44
- package/dist/cjs/snk-attach.cjs.entry.js +7 -13
- package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
- package/dist/cjs/snk-crud.cjs.entry.js +25 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-e89e07bd.js → snk-data-unit-80a00ae4.js} +4 -3
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +14 -12
- package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
- package/dist/cjs/snk-filter-bar.cjs.entry.js +14 -17
- package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -15
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -19
- package/dist/cjs/snk-form-config.cjs.entry.js +6 -17
- package/dist/cjs/snk-form-view.cjs.entry.js +6 -1
- package/dist/cjs/snk-form.cjs.entry.js +12 -8
- package/dist/cjs/snk-grid-config.cjs.entry.js +5 -6
- package/dist/cjs/snk-grid.cjs.entry.js +17 -20
- package/dist/cjs/{snk-guides-viewer-27f87d90.js → snk-guides-viewer-a7cd6fda.js} +17 -7
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -8
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +13 -16
- package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +20 -72
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
- package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
- package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
- package/dist/collection/components/snk-application/snk-application.js +60 -65
- package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
- package/dist/collection/components/snk-crud/snk-crud.js +40 -6
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +42 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +27 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +47 -28
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -4
- package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +2 -12
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +28 -12
- package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
- package/dist/collection/components/snk-form/snk-form.js +46 -2
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
- package/dist/collection/components/snk-grid/snk-grid.js +51 -15
- package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +22 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +19 -1
- package/dist/collection/lib/configs/ConfigStorage.js +33 -44
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -59
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +39 -30
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
- package/dist/collection/lib/index.js +10 -0
- package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
- package/dist/collection/lib/utils/urlutils.js +29 -0
- package/dist/components/ConfigStorage.js +161 -48
- package/dist/components/DataFetcher.js +68 -30
- package/dist/components/ResourceIDUtils.js +10 -0
- package/dist/components/SnkFormConfigManager.js +17 -19
- package/dist/components/auth-fetcher.js +1 -1
- package/dist/components/form-config-fetcher.js +64 -2
- package/dist/components/snk-actions-button2.js +23 -9
- package/dist/components/snk-application2.js +134 -128
- package/dist/components/snk-attach2.js +1 -8
- package/dist/components/snk-configurator2.js +3 -1
- package/dist/components/snk-crud.js +23 -6
- package/dist/components/snk-data-unit2.js +5 -3
- package/dist/components/snk-detail-view2.js +20 -8
- package/dist/components/snk-entity-list.js +0 -4
- package/dist/components/snk-filter-bar2.js +12 -12
- package/dist/components/snk-filter-detail2.js +2 -12
- package/dist/components/snk-filter-modal-item2.js +5 -16
- package/dist/components/snk-form-config2.js +5 -15
- package/dist/components/snk-form-view2.js +6 -1
- package/dist/components/snk-form.js +9 -2
- package/dist/components/snk-grid-config2.js +4 -2
- package/dist/components/snk-grid2.js +17 -16
- package/dist/components/snk-personalized-filter2.js +11 -11
- package/dist/components/snk-simple-crud2.js +8 -60
- package/dist/components/snk-taskbar2.js +3 -1
- package/dist/esm/{ConfigStorage-19a7260b.js → ConfigStorage-932ab366.js} +162 -49
- package/dist/esm/{DataFetcher-e0fc5549.js → DataFetcher-7e18aa30.js} +68 -30
- package/dist/esm/ISave-4412b20c.js +8 -0
- package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
- package/dist/esm/{SnkFormConfigManager-1a42eb02.js → SnkFormConfigManager-bb9afc3f.js} +19 -21
- package/dist/esm/{auth-fetcher-83a946f8.js → auth-fetcher-6d9664b7.js} +1 -1
- package/dist/esm/{dataunit-fetcher-6a695723.js → dataunit-fetcher-91a4eb82.js} +1 -1
- package/dist/esm/{form-config-fetcher-9e167008.js → form-config-fetcher-aaaa79a6.js} +65 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-9118eb7a.js → pesquisa-fetcher-56b30fb4.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button.entry.js +18 -11
- package/dist/esm/snk-application.entry.js +49 -44
- package/dist/esm/snk-attach.entry.js +3 -9
- package/dist/esm/snk-configurator.entry.js +2 -1
- package/dist/esm/snk-crud.entry.js +25 -10
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-8c4d944d.js → snk-data-unit-3ab57d1a.js} +4 -3
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +14 -12
- package/dist/esm/snk-entity-list.entry.js +0 -4
- package/dist/esm/snk-filter-bar.entry.js +14 -17
- package/dist/esm/snk-filter-detail.entry.js +2 -16
- package/dist/esm/snk-filter-modal-item.entry.js +6 -20
- package/dist/esm/snk-form-config.entry.js +7 -18
- package/dist/esm/snk-form-view.entry.js +6 -1
- package/dist/esm/snk-form.entry.js +12 -8
- package/dist/esm/snk-grid-config.entry.js +5 -6
- package/dist/esm/snk-grid.entry.js +17 -20
- package/dist/esm/{snk-guides-viewer-c47cd45e.js → snk-guides-viewer-cc709b5f.js} +17 -7
- package/dist/esm/snk-guides-viewer.entry.js +8 -8
- package/dist/esm/snk-personalized-filter.entry.js +13 -16
- package/dist/esm/snk-print-selector.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +10 -62
- package/dist/esm/snk-taskbar.entry.js +2 -1
- package/dist/sankhyablocks/p-01739b21.entry.js +1 -0
- package/dist/sankhyablocks/{p-e7e54737.entry.js → p-03bb1aea.entry.js} +1 -1
- package/dist/sankhyablocks/p-05dbc70e.entry.js +1 -0
- package/dist/sankhyablocks/{p-0a4c753d.js → p-14eac6fe.js} +1 -1
- package/dist/sankhyablocks/{p-2ac9c585.js → p-2d333d22.js} +1 -1
- package/dist/sankhyablocks/p-41e897f1.js +56 -0
- package/dist/sankhyablocks/p-48a40939.js +1 -0
- package/dist/sankhyablocks/p-611aa624.entry.js +1 -0
- package/dist/sankhyablocks/p-66bb8c20.entry.js +1 -0
- package/dist/sankhyablocks/p-688dcb4c.js +1 -0
- package/dist/sankhyablocks/p-6f154396.entry.js +1 -0
- package/dist/sankhyablocks/p-787071a8.js +1 -0
- package/dist/sankhyablocks/p-8481bb59.entry.js +1 -0
- package/dist/sankhyablocks/p-8818d8f6.entry.js +1 -0
- package/dist/sankhyablocks/p-93f6ca04.entry.js +1 -0
- package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
- package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
- package/dist/sankhyablocks/p-a52a6c9d.js +26 -0
- package/dist/sankhyablocks/p-b6003974.entry.js +1 -0
- package/dist/sankhyablocks/p-c555075c.entry.js +1 -0
- package/dist/sankhyablocks/{p-e5845241.entry.js → p-d13c00b6.entry.js} +1 -1
- package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
- package/dist/sankhyablocks/p-d53a9169.entry.js +1 -0
- package/dist/sankhyablocks/p-d7638f45.entry.js +11 -0
- package/dist/sankhyablocks/p-e086cc2a.entry.js +1 -0
- package/dist/sankhyablocks/p-e64f3e17.entry.js +1 -0
- package/dist/sankhyablocks/p-ed41b38c.js +1 -0
- package/dist/sankhyablocks/p-ed705cbb.entry.js +1 -0
- package/dist/sankhyablocks/p-efc10705.entry.js +1 -0
- package/dist/sankhyablocks/p-f74fe358.js +1 -0
- package/dist/sankhyablocks/{p-df8621b4.js → p-f8e6b97e.js} +1 -1
- package/dist/sankhyablocks/p-f91e0c5d.entry.js +1 -0
- package/dist/sankhyablocks/p-fa523d6b.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
- package/dist/types/components/snk-application/snk-application.d.ts +8 -13
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +5 -0
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +8 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +5 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +9 -2
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
- package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
- package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
- package/dist/types/components/snk-form/snk-form.d.ts +9 -1
- package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +5 -1
- package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
- package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +4 -0
- package/dist/types/components.d.ts +125 -21
- package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +0 -7
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
- package/dist/types/lib/index.d.ts +11 -0
- package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
- package/dist/types/lib/utils/urlutils.d.ts +14 -0
- package/package.json +2 -2
- package/dist/cjs/filter-bar-config-fetcher-2b8ed9d0.js +0 -155
- package/dist/cjs/resource-fetcher-c0332609.js +0 -68
- package/dist/components/filter-bar-config-fetcher.js +0 -153
- package/dist/components/resource-fetcher.js +0 -66
- package/dist/esm/filter-bar-config-fetcher-06e02851.js +0 -153
- package/dist/esm/resource-fetcher-768d5556.js +0 -66
- package/dist/sankhyablocks/p-0ed0fc02.entry.js +0 -1
- package/dist/sankhyablocks/p-216f081a.entry.js +0 -1
- package/dist/sankhyablocks/p-22c6fe1a.entry.js +0 -1
- package/dist/sankhyablocks/p-34a1357a.entry.js +0 -1
- package/dist/sankhyablocks/p-4721c3db.js +0 -1
- package/dist/sankhyablocks/p-564efc43.js +0 -1
- package/dist/sankhyablocks/p-6759adae.entry.js +0 -1
- package/dist/sankhyablocks/p-7b8b8ae9.js +0 -10
- package/dist/sankhyablocks/p-7e285d6c.entry.js +0 -11
- package/dist/sankhyablocks/p-815a42c0.entry.js +0 -1
- package/dist/sankhyablocks/p-8a41172a.entry.js +0 -1
- package/dist/sankhyablocks/p-8f8184ff.js +0 -56
- package/dist/sankhyablocks/p-976e56e9.js +0 -1
- package/dist/sankhyablocks/p-98f9d076.js +0 -17
- package/dist/sankhyablocks/p-bc735728.entry.js +0 -1
- package/dist/sankhyablocks/p-be684b38.entry.js +0 -1
- package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
- package/dist/sankhyablocks/p-c0f656af.entry.js +0 -1
- package/dist/sankhyablocks/p-c32b9d7c.entry.js +0 -1
- package/dist/sankhyablocks/p-c57bd935.entry.js +0 -1
- package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
- package/dist/sankhyablocks/p-cfd7da4a.entry.js +0 -1
- package/dist/sankhyablocks/p-d1b89765.js +0 -1
- package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
- package/dist/sankhyablocks/p-e28129aa.entry.js +0 -1
- package/dist/sankhyablocks/p-f31bfdee.entry.js +0 -1
- package/dist/sankhyablocks/p-f88c45bf.js +0 -1
- package/dist/sankhyablocks/p-fe010e54.entry.js +0 -1
@@ -1,155 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const filterItemType_enum = require('./filter-item-type.enum-aa823a00.js');
|
4
|
-
const resourceFetcher = require('./resource-fetcher-c0332609.js');
|
5
|
-
|
6
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
7
|
-
var t = {};
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
9
|
-
t[p] = s[p];
|
10
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
11
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
12
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
13
|
-
t[p[i]] = s[p[i]];
|
14
|
-
}
|
15
|
-
return t;
|
16
|
-
};
|
17
|
-
function normalizeValue(value, type) {
|
18
|
-
if (value == undefined) {
|
19
|
-
return value;
|
20
|
-
}
|
21
|
-
if (value instanceof Date) {
|
22
|
-
return value.toISOString();
|
23
|
-
}
|
24
|
-
if (typeof value === "object") {
|
25
|
-
if (value instanceof Array) {
|
26
|
-
return value.map(item => {
|
27
|
-
if (filterItemType_enum.FilterItemType.MULTI_LIST === type) {
|
28
|
-
const values = __rest(item, ["label"]);
|
29
|
-
return normalizeValue(values);
|
30
|
-
}
|
31
|
-
return normalizeValue(item);
|
32
|
-
});
|
33
|
-
}
|
34
|
-
else {
|
35
|
-
const normalized = Object.assign({}, value);
|
36
|
-
Object.keys(value).forEach(prop => {
|
37
|
-
if (value[prop] !== undefined) {
|
38
|
-
normalized[prop] = normalizeValue(value[prop], type);
|
39
|
-
}
|
40
|
-
else {
|
41
|
-
delete normalized[prop];
|
42
|
-
}
|
43
|
-
});
|
44
|
-
return normalized;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
return value;
|
48
|
-
}
|
49
|
-
class FilterBarConfigFetcher extends resourceFetcher.ResourceFetcher {
|
50
|
-
normalize(items) {
|
51
|
-
return items.map(item => {
|
52
|
-
const { id, value, fixed, visible, type, groupedItems } = item;
|
53
|
-
const stateItem = { id };
|
54
|
-
if (value) {
|
55
|
-
stateItem["value"] = normalizeValue(value, type);
|
56
|
-
}
|
57
|
-
if (fixed) {
|
58
|
-
stateItem["fixed"] = fixed;
|
59
|
-
}
|
60
|
-
if (groupedItems) {
|
61
|
-
if (groupedItems.length === 0) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
if (groupedItems.filter(item => item.visible).length > 0) {
|
65
|
-
stateItem["visible"] = true;
|
66
|
-
}
|
67
|
-
stateItem["groupedItems"] = this.normalize(groupedItems);
|
68
|
-
}
|
69
|
-
else {
|
70
|
-
if (visible) {
|
71
|
-
stateItem["visible"] = true;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
return stateItem;
|
75
|
-
}).filter(item => item != undefined);
|
76
|
-
}
|
77
|
-
saveConfig(items, resourceID, configName) {
|
78
|
-
return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
|
79
|
-
}
|
80
|
-
getConfig(resourceID, configName, urlParams) {
|
81
|
-
return new Promise((accept, reject) => {
|
82
|
-
this.loadResource(this.getPath(resourceID, configName, urlParams))
|
83
|
-
.then((configAsString) => {
|
84
|
-
let fieldsList;
|
85
|
-
if (configAsString) {
|
86
|
-
const filterBarConfig = JSON.parse(configAsString);
|
87
|
-
fieldsList = this.buildFieldList(filterBarConfig.items);
|
88
|
-
}
|
89
|
-
accept(fieldsList || []);
|
90
|
-
})
|
91
|
-
.catch((error) => {
|
92
|
-
reject(error);
|
93
|
-
});
|
94
|
-
});
|
95
|
-
}
|
96
|
-
saveEntityListConfig(item, resourceID, configName) {
|
97
|
-
return new Promise((accept, reject) => {
|
98
|
-
this.getConfig(resourceID, configName).then(config => {
|
99
|
-
const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
|
100
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
|
101
|
-
});
|
102
|
-
const index = state.findIndex(({ id }) => id === item.id);
|
103
|
-
const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
|
104
|
-
if (index > -1) {
|
105
|
-
state[index] = newItem;
|
106
|
-
}
|
107
|
-
else {
|
108
|
-
state.push(newItem);
|
109
|
-
}
|
110
|
-
this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
|
111
|
-
accept(resp);
|
112
|
-
}).catch(exception => {
|
113
|
-
reject(exception);
|
114
|
-
});
|
115
|
-
}).catch(exception => {
|
116
|
-
reject(exception);
|
117
|
-
});
|
118
|
-
});
|
119
|
-
}
|
120
|
-
buildFieldList(items) {
|
121
|
-
return items.map(item => {
|
122
|
-
var _a, _b;
|
123
|
-
if (item.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
|
124
|
-
const multiListValue = item.value;
|
125
|
-
item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
|
126
|
-
}
|
127
|
-
return item;
|
128
|
-
});
|
129
|
-
}
|
130
|
-
getPath(resourceID, name, urlParams) {
|
131
|
-
let path = `cfg://filter/FilterBarState:${resourceID}`;
|
132
|
-
if (name) {
|
133
|
-
path += `.${name}`;
|
134
|
-
}
|
135
|
-
if (urlParams) {
|
136
|
-
path += this.buildQueryString(urlParams);
|
137
|
-
}
|
138
|
-
return path;
|
139
|
-
}
|
140
|
-
buildQueryString(urlParams) {
|
141
|
-
let queryString = '?';
|
142
|
-
for (let key in urlParams) {
|
143
|
-
if (!urlParams.hasOwnProperty(key)) {
|
144
|
-
continue;
|
145
|
-
}
|
146
|
-
if (queryString.length > 1) {
|
147
|
-
queryString += '&';
|
148
|
-
}
|
149
|
-
queryString += key + '=' + urlParams[key];
|
150
|
-
}
|
151
|
-
return queryString;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
exports.FilterBarConfigFetcher = FilterBarConfigFetcher;
|
@@ -1,68 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const DataFetcher = require('./DataFetcher-004811c6.js');
|
4
|
-
|
5
|
-
class ResourceFetcher {
|
6
|
-
constructor() {
|
7
|
-
this.templateByQuery = new Map();
|
8
|
-
this.buldTemplates();
|
9
|
-
}
|
10
|
-
buldTemplates() {
|
11
|
-
this.templateByQuery.set("fetchResource", DataFetcher.dist.gql `query($name: String!) {
|
12
|
-
$queryAlias$: fetchResource(name: $name){
|
13
|
-
resource
|
14
|
-
}
|
15
|
-
}`);
|
16
|
-
this.templateByQuery.set("saveResource", DataFetcher.dist.gql `mutation($resource: InputResource!) {
|
17
|
-
$queryAlias$: saveResource(resource: $resource){
|
18
|
-
name
|
19
|
-
resource
|
20
|
-
}
|
21
|
-
}`);
|
22
|
-
}
|
23
|
-
loadResource(name) {
|
24
|
-
if (ResourceFetcher._loadingResource.has(name)) {
|
25
|
-
return ResourceFetcher._loadingResource.get(name);
|
26
|
-
}
|
27
|
-
const promiseLoadResource = new Promise((resolve, reject) => {
|
28
|
-
DataFetcher.DataFetcher.get()
|
29
|
-
.callGraphQL({
|
30
|
-
values: { name },
|
31
|
-
query: this.templateByQuery.get("fetchResource"),
|
32
|
-
})
|
33
|
-
.then((result) => {
|
34
|
-
resolve(result === null || result === void 0 ? void 0 : result.resource);
|
35
|
-
ResourceFetcher._loadingResource.delete(name);
|
36
|
-
})
|
37
|
-
.catch((error) => {
|
38
|
-
reject(error);
|
39
|
-
ResourceFetcher._loadingResource.delete(name);
|
40
|
-
});
|
41
|
-
});
|
42
|
-
ResourceFetcher._loadingResource.set(name, promiseLoadResource);
|
43
|
-
return promiseLoadResource;
|
44
|
-
}
|
45
|
-
saveResource(resource, name) {
|
46
|
-
return new Promise((resolve, reject) => {
|
47
|
-
DataFetcher.DataFetcher.get()
|
48
|
-
.callGraphQL({
|
49
|
-
values: {
|
50
|
-
resource: {
|
51
|
-
name: name,
|
52
|
-
resource: JSON.stringify(resource)
|
53
|
-
}
|
54
|
-
},
|
55
|
-
query: this.templateByQuery.get("saveResource")
|
56
|
-
})
|
57
|
-
.then((resp) => {
|
58
|
-
resolve(resp);
|
59
|
-
})
|
60
|
-
.catch((error) => {
|
61
|
-
reject(error);
|
62
|
-
});
|
63
|
-
});
|
64
|
-
}
|
65
|
-
}
|
66
|
-
ResourceFetcher._loadingResource = new Map();
|
67
|
-
|
68
|
-
exports.ResourceFetcher = ResourceFetcher;
|
@@ -1,153 +0,0 @@
|
|
1
|
-
import { F as FilterItemType } from './filter-item-type.enum.js';
|
2
|
-
import { R as ResourceFetcher } from './resource-fetcher.js';
|
3
|
-
|
4
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
5
|
-
var t = {};
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
7
|
-
t[p] = s[p];
|
8
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
9
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
10
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
11
|
-
t[p[i]] = s[p[i]];
|
12
|
-
}
|
13
|
-
return t;
|
14
|
-
};
|
15
|
-
function normalizeValue(value, type) {
|
16
|
-
if (value == undefined) {
|
17
|
-
return value;
|
18
|
-
}
|
19
|
-
if (value instanceof Date) {
|
20
|
-
return value.toISOString();
|
21
|
-
}
|
22
|
-
if (typeof value === "object") {
|
23
|
-
if (value instanceof Array) {
|
24
|
-
return value.map(item => {
|
25
|
-
if (FilterItemType.MULTI_LIST === type) {
|
26
|
-
const values = __rest(item, ["label"]);
|
27
|
-
return normalizeValue(values);
|
28
|
-
}
|
29
|
-
return normalizeValue(item);
|
30
|
-
});
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
const normalized = Object.assign({}, value);
|
34
|
-
Object.keys(value).forEach(prop => {
|
35
|
-
if (value[prop] !== undefined) {
|
36
|
-
normalized[prop] = normalizeValue(value[prop], type);
|
37
|
-
}
|
38
|
-
else {
|
39
|
-
delete normalized[prop];
|
40
|
-
}
|
41
|
-
});
|
42
|
-
return normalized;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return value;
|
46
|
-
}
|
47
|
-
class FilterBarConfigFetcher extends ResourceFetcher {
|
48
|
-
normalize(items) {
|
49
|
-
return items.map(item => {
|
50
|
-
const { id, value, fixed, visible, type, groupedItems } = item;
|
51
|
-
const stateItem = { id };
|
52
|
-
if (value) {
|
53
|
-
stateItem["value"] = normalizeValue(value, type);
|
54
|
-
}
|
55
|
-
if (fixed) {
|
56
|
-
stateItem["fixed"] = fixed;
|
57
|
-
}
|
58
|
-
if (groupedItems) {
|
59
|
-
if (groupedItems.length === 0) {
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
if (groupedItems.filter(item => item.visible).length > 0) {
|
63
|
-
stateItem["visible"] = true;
|
64
|
-
}
|
65
|
-
stateItem["groupedItems"] = this.normalize(groupedItems);
|
66
|
-
}
|
67
|
-
else {
|
68
|
-
if (visible) {
|
69
|
-
stateItem["visible"] = true;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
return stateItem;
|
73
|
-
}).filter(item => item != undefined);
|
74
|
-
}
|
75
|
-
saveConfig(items, resourceID, configName) {
|
76
|
-
return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
|
77
|
-
}
|
78
|
-
getConfig(resourceID, configName, urlParams) {
|
79
|
-
return new Promise((accept, reject) => {
|
80
|
-
this.loadResource(this.getPath(resourceID, configName, urlParams))
|
81
|
-
.then((configAsString) => {
|
82
|
-
let fieldsList;
|
83
|
-
if (configAsString) {
|
84
|
-
const filterBarConfig = JSON.parse(configAsString);
|
85
|
-
fieldsList = this.buildFieldList(filterBarConfig.items);
|
86
|
-
}
|
87
|
-
accept(fieldsList || []);
|
88
|
-
})
|
89
|
-
.catch((error) => {
|
90
|
-
reject(error);
|
91
|
-
});
|
92
|
-
});
|
93
|
-
}
|
94
|
-
saveEntityListConfig(item, resourceID, configName) {
|
95
|
-
return new Promise((accept, reject) => {
|
96
|
-
this.getConfig(resourceID, configName).then(config => {
|
97
|
-
const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
|
98
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
|
99
|
-
});
|
100
|
-
const index = state.findIndex(({ id }) => id === item.id);
|
101
|
-
const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
|
102
|
-
if (index > -1) {
|
103
|
-
state[index] = newItem;
|
104
|
-
}
|
105
|
-
else {
|
106
|
-
state.push(newItem);
|
107
|
-
}
|
108
|
-
this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
|
109
|
-
accept(resp);
|
110
|
-
}).catch(exception => {
|
111
|
-
reject(exception);
|
112
|
-
});
|
113
|
-
}).catch(exception => {
|
114
|
-
reject(exception);
|
115
|
-
});
|
116
|
-
});
|
117
|
-
}
|
118
|
-
buildFieldList(items) {
|
119
|
-
return items.map(item => {
|
120
|
-
var _a, _b;
|
121
|
-
if (item.type === FilterItemType.MULTI_LIST) {
|
122
|
-
const multiListValue = item.value;
|
123
|
-
item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
|
124
|
-
}
|
125
|
-
return item;
|
126
|
-
});
|
127
|
-
}
|
128
|
-
getPath(resourceID, name, urlParams) {
|
129
|
-
let path = `cfg://filter/FilterBarState:${resourceID}`;
|
130
|
-
if (name) {
|
131
|
-
path += `.${name}`;
|
132
|
-
}
|
133
|
-
if (urlParams) {
|
134
|
-
path += this.buildQueryString(urlParams);
|
135
|
-
}
|
136
|
-
return path;
|
137
|
-
}
|
138
|
-
buildQueryString(urlParams) {
|
139
|
-
let queryString = '?';
|
140
|
-
for (let key in urlParams) {
|
141
|
-
if (!urlParams.hasOwnProperty(key)) {
|
142
|
-
continue;
|
143
|
-
}
|
144
|
-
if (queryString.length > 1) {
|
145
|
-
queryString += '&';
|
146
|
-
}
|
147
|
-
queryString += key + '=' + urlParams[key];
|
148
|
-
}
|
149
|
-
return queryString;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
export { FilterBarConfigFetcher as F };
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import { d as dist, D as DataFetcher } from './DataFetcher.js';
|
2
|
-
|
3
|
-
class ResourceFetcher {
|
4
|
-
constructor() {
|
5
|
-
this.templateByQuery = new Map();
|
6
|
-
this.buldTemplates();
|
7
|
-
}
|
8
|
-
buldTemplates() {
|
9
|
-
this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
|
10
|
-
$queryAlias$: fetchResource(name: $name){
|
11
|
-
resource
|
12
|
-
}
|
13
|
-
}`);
|
14
|
-
this.templateByQuery.set("saveResource", dist.gql `mutation($resource: InputResource!) {
|
15
|
-
$queryAlias$: saveResource(resource: $resource){
|
16
|
-
name
|
17
|
-
resource
|
18
|
-
}
|
19
|
-
}`);
|
20
|
-
}
|
21
|
-
loadResource(name) {
|
22
|
-
if (ResourceFetcher._loadingResource.has(name)) {
|
23
|
-
return ResourceFetcher._loadingResource.get(name);
|
24
|
-
}
|
25
|
-
const promiseLoadResource = new Promise((resolve, reject) => {
|
26
|
-
DataFetcher.get()
|
27
|
-
.callGraphQL({
|
28
|
-
values: { name },
|
29
|
-
query: this.templateByQuery.get("fetchResource"),
|
30
|
-
})
|
31
|
-
.then((result) => {
|
32
|
-
resolve(result === null || result === void 0 ? void 0 : result.resource);
|
33
|
-
ResourceFetcher._loadingResource.delete(name);
|
34
|
-
})
|
35
|
-
.catch((error) => {
|
36
|
-
reject(error);
|
37
|
-
ResourceFetcher._loadingResource.delete(name);
|
38
|
-
});
|
39
|
-
});
|
40
|
-
ResourceFetcher._loadingResource.set(name, promiseLoadResource);
|
41
|
-
return promiseLoadResource;
|
42
|
-
}
|
43
|
-
saveResource(resource, name) {
|
44
|
-
return new Promise((resolve, reject) => {
|
45
|
-
DataFetcher.get()
|
46
|
-
.callGraphQL({
|
47
|
-
values: {
|
48
|
-
resource: {
|
49
|
-
name: name,
|
50
|
-
resource: JSON.stringify(resource)
|
51
|
-
}
|
52
|
-
},
|
53
|
-
query: this.templateByQuery.get("saveResource")
|
54
|
-
})
|
55
|
-
.then((resp) => {
|
56
|
-
resolve(resp);
|
57
|
-
})
|
58
|
-
.catch((error) => {
|
59
|
-
reject(error);
|
60
|
-
});
|
61
|
-
});
|
62
|
-
}
|
63
|
-
}
|
64
|
-
ResourceFetcher._loadingResource = new Map();
|
65
|
-
|
66
|
-
export { ResourceFetcher as R };
|
@@ -1,153 +0,0 @@
|
|
1
|
-
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
2
|
-
import { R as ResourceFetcher } from './resource-fetcher-768d5556.js';
|
3
|
-
|
4
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
5
|
-
var t = {};
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
7
|
-
t[p] = s[p];
|
8
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
9
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
10
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
11
|
-
t[p[i]] = s[p[i]];
|
12
|
-
}
|
13
|
-
return t;
|
14
|
-
};
|
15
|
-
function normalizeValue(value, type) {
|
16
|
-
if (value == undefined) {
|
17
|
-
return value;
|
18
|
-
}
|
19
|
-
if (value instanceof Date) {
|
20
|
-
return value.toISOString();
|
21
|
-
}
|
22
|
-
if (typeof value === "object") {
|
23
|
-
if (value instanceof Array) {
|
24
|
-
return value.map(item => {
|
25
|
-
if (FilterItemType.MULTI_LIST === type) {
|
26
|
-
const values = __rest(item, ["label"]);
|
27
|
-
return normalizeValue(values);
|
28
|
-
}
|
29
|
-
return normalizeValue(item);
|
30
|
-
});
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
const normalized = Object.assign({}, value);
|
34
|
-
Object.keys(value).forEach(prop => {
|
35
|
-
if (value[prop] !== undefined) {
|
36
|
-
normalized[prop] = normalizeValue(value[prop], type);
|
37
|
-
}
|
38
|
-
else {
|
39
|
-
delete normalized[prop];
|
40
|
-
}
|
41
|
-
});
|
42
|
-
return normalized;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return value;
|
46
|
-
}
|
47
|
-
class FilterBarConfigFetcher extends ResourceFetcher {
|
48
|
-
normalize(items) {
|
49
|
-
return items.map(item => {
|
50
|
-
const { id, value, fixed, visible, type, groupedItems } = item;
|
51
|
-
const stateItem = { id };
|
52
|
-
if (value) {
|
53
|
-
stateItem["value"] = normalizeValue(value, type);
|
54
|
-
}
|
55
|
-
if (fixed) {
|
56
|
-
stateItem["fixed"] = fixed;
|
57
|
-
}
|
58
|
-
if (groupedItems) {
|
59
|
-
if (groupedItems.length === 0) {
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
if (groupedItems.filter(item => item.visible).length > 0) {
|
63
|
-
stateItem["visible"] = true;
|
64
|
-
}
|
65
|
-
stateItem["groupedItems"] = this.normalize(groupedItems);
|
66
|
-
}
|
67
|
-
else {
|
68
|
-
if (visible) {
|
69
|
-
stateItem["visible"] = true;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
return stateItem;
|
73
|
-
}).filter(item => item != undefined);
|
74
|
-
}
|
75
|
-
saveConfig(items, resourceID, configName) {
|
76
|
-
return this.saveResource(this.normalize(items), this.getPath(resourceID, configName));
|
77
|
-
}
|
78
|
-
getConfig(resourceID, configName, urlParams) {
|
79
|
-
return new Promise((accept, reject) => {
|
80
|
-
this.loadResource(this.getPath(resourceID, configName, urlParams))
|
81
|
-
.then((configAsString) => {
|
82
|
-
let fieldsList;
|
83
|
-
if (configAsString) {
|
84
|
-
const filterBarConfig = JSON.parse(configAsString);
|
85
|
-
fieldsList = this.buildFieldList(filterBarConfig.items);
|
86
|
-
}
|
87
|
-
accept(fieldsList || []);
|
88
|
-
})
|
89
|
-
.catch((error) => {
|
90
|
-
reject(error);
|
91
|
-
});
|
92
|
-
});
|
93
|
-
}
|
94
|
-
saveEntityListConfig(item, resourceID, configName) {
|
95
|
-
return new Promise((accept, reject) => {
|
96
|
-
this.getConfig(resourceID, configName).then(config => {
|
97
|
-
const state = config.map(({ id, value, fixed, visible, type, groupedItems }) => {
|
98
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true })), { groupedItems });
|
99
|
-
});
|
100
|
-
const index = state.findIndex(({ id }) => id === item.id);
|
101
|
-
const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
|
102
|
-
if (index > -1) {
|
103
|
-
state[index] = newItem;
|
104
|
-
}
|
105
|
-
else {
|
106
|
-
state.push(newItem);
|
107
|
-
}
|
108
|
-
this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
|
109
|
-
accept(resp);
|
110
|
-
}).catch(exception => {
|
111
|
-
reject(exception);
|
112
|
-
});
|
113
|
-
}).catch(exception => {
|
114
|
-
reject(exception);
|
115
|
-
});
|
116
|
-
});
|
117
|
-
}
|
118
|
-
buildFieldList(items) {
|
119
|
-
return items.map(item => {
|
120
|
-
var _a, _b;
|
121
|
-
if (item.type === FilterItemType.MULTI_LIST) {
|
122
|
-
const multiListValue = item.value;
|
123
|
-
item.value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
|
124
|
-
}
|
125
|
-
return item;
|
126
|
-
});
|
127
|
-
}
|
128
|
-
getPath(resourceID, name, urlParams) {
|
129
|
-
let path = `cfg://filter/FilterBarState:${resourceID}`;
|
130
|
-
if (name) {
|
131
|
-
path += `.${name}`;
|
132
|
-
}
|
133
|
-
if (urlParams) {
|
134
|
-
path += this.buildQueryString(urlParams);
|
135
|
-
}
|
136
|
-
return path;
|
137
|
-
}
|
138
|
-
buildQueryString(urlParams) {
|
139
|
-
let queryString = '?';
|
140
|
-
for (let key in urlParams) {
|
141
|
-
if (!urlParams.hasOwnProperty(key)) {
|
142
|
-
continue;
|
143
|
-
}
|
144
|
-
if (queryString.length > 1) {
|
145
|
-
queryString += '&';
|
146
|
-
}
|
147
|
-
queryString += key + '=' + urlParams[key];
|
148
|
-
}
|
149
|
-
return queryString;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
export { FilterBarConfigFetcher as F };
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import { d as dist, D as DataFetcher } from './DataFetcher-e0fc5549.js';
|
2
|
-
|
3
|
-
class ResourceFetcher {
|
4
|
-
constructor() {
|
5
|
-
this.templateByQuery = new Map();
|
6
|
-
this.buldTemplates();
|
7
|
-
}
|
8
|
-
buldTemplates() {
|
9
|
-
this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
|
10
|
-
$queryAlias$: fetchResource(name: $name){
|
11
|
-
resource
|
12
|
-
}
|
13
|
-
}`);
|
14
|
-
this.templateByQuery.set("saveResource", dist.gql `mutation($resource: InputResource!) {
|
15
|
-
$queryAlias$: saveResource(resource: $resource){
|
16
|
-
name
|
17
|
-
resource
|
18
|
-
}
|
19
|
-
}`);
|
20
|
-
}
|
21
|
-
loadResource(name) {
|
22
|
-
if (ResourceFetcher._loadingResource.has(name)) {
|
23
|
-
return ResourceFetcher._loadingResource.get(name);
|
24
|
-
}
|
25
|
-
const promiseLoadResource = new Promise((resolve, reject) => {
|
26
|
-
DataFetcher.get()
|
27
|
-
.callGraphQL({
|
28
|
-
values: { name },
|
29
|
-
query: this.templateByQuery.get("fetchResource"),
|
30
|
-
})
|
31
|
-
.then((result) => {
|
32
|
-
resolve(result === null || result === void 0 ? void 0 : result.resource);
|
33
|
-
ResourceFetcher._loadingResource.delete(name);
|
34
|
-
})
|
35
|
-
.catch((error) => {
|
36
|
-
reject(error);
|
37
|
-
ResourceFetcher._loadingResource.delete(name);
|
38
|
-
});
|
39
|
-
});
|
40
|
-
ResourceFetcher._loadingResource.set(name, promiseLoadResource);
|
41
|
-
return promiseLoadResource;
|
42
|
-
}
|
43
|
-
saveResource(resource, name) {
|
44
|
-
return new Promise((resolve, reject) => {
|
45
|
-
DataFetcher.get()
|
46
|
-
.callGraphQL({
|
47
|
-
values: {
|
48
|
-
resource: {
|
49
|
-
name: name,
|
50
|
-
resource: JSON.stringify(resource)
|
51
|
-
}
|
52
|
-
},
|
53
|
-
query: this.templateByQuery.get("saveResource")
|
54
|
-
})
|
55
|
-
.then((resp) => {
|
56
|
-
resolve(resp);
|
57
|
-
})
|
58
|
-
.catch((error) => {
|
59
|
-
reject(error);
|
60
|
-
});
|
61
|
-
});
|
62
|
-
}
|
63
|
-
}
|
64
|
-
ResourceFetcher._loadingResource = new Map();
|
65
|
-
|
66
|
-
export { ResourceFetcher as R };
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as e,h as i}from"./p-d2d301a6.js";import{ApplicationContext as s,DataType as n,Action as a}from"@sankhyalabs/core";import{D as r}from"./p-df8621b4.js";import{c as o}from"./p-4a78e118.js";import{D as h}from"./p-2ac9c585.js";import{T as d}from"./p-a2493d11.js";import"./p-112455b1.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-5534e08c.js";import"./p-6dc031de.js";var l;!function(t){t.LINK_AND_FILE_AT_THE_SAME_TIME="LINK_AND_FILE_AT_THE_SAME_TIME",t.ANY_LINK_OR_FILE_FILLED="ANY_LINK_OR_FILE_FILLED",t.UNKNOWN="UNKNOWN"}(l||(l={}));class c{constructor(t,e,i){var s;this.entityName=t,this.registerKey=e,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(l.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(l.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}async save(t){var e,i;const s="AnexoSistemaSP.salvar";let{updatingFields:n}=t;n=Object.assign(Object.assign({},n),{NOMEARQUIVO:null===(e=n.NOMEARQUIVO)||void 0===e?void 0:e[0]});try{this.validateFields(n);const t=n.LINK?null:n.NOMEARQUIVO,e={serviceName:s,requestBody:{params:{resourceID:this.resourceID,description:n.DESCRICAO,fileSelect:t?1:0,keySession:null===(i=null==t?void 0:t.properties)||void 0===i?void 0:i.fileNameTmp,nameAttach:null==t?void 0:t.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},a=await r.get().callServiceBroker(s,JSON.stringify(e));return Promise.resolve([Object.assign(Object.assign(Object.assign({},a),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var e,i,s;const n="AnexoSistemaSP.salvar";let{updatingFields:a,record:o}=t;const h=t=>void 0!==a[t]?a[t]:o[t],d=h("NOMEARQUIVO"),l=null===(i=null===(e=a.NOMEARQUIVO)||void 0===e?void 0:e[0])||void 0===i?void 0:i.downloadURL;a=Object.assign(Object.assign({},a),{DESCRICAO:h("DESCRICAO"),LINK:h("LINK"),TIPOACESSO:h("TIPOACESSO"),TIPOAPRES:h("TIPOAPRES"),CHAVEARQUIVO:o.CHAVEARQUIVO,NOMEARQUIVO:null==d?void 0:d[0]});const c=a.LINK?null:a.NOMEARQUIVO;try{this.validateFields(a);const t={serviceName:n,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==o?void 0:o.NUATTACH,description:a.DESCRICAO,fileSelect:l?1:0,keySession:null===(s=null==c?void 0:c.properties)||void 0===s?void 0:s.fileNameTmp,keyAttach:a.CHAVEARQUIVO,nameAttach:null==c?void 0:c.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},e=await r.get().callServiceBroker(n,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},e),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==c?void 0:c.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var e;const i="AnexoSistemaSP.excluir",s=(null===(e=t.NOMEARQUIVO)||void 0===e?void 0:e[0])||{},n={serviceName:i,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,e)=>{r.get().callServiceBroker(i,JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}getDownloadKey(t){var e;const i="AnexoSistemaSP.baixar",s=(null===(e=t.NOMEARQUIVO)||void 0===e?void 0:e[0])||{},n={serviceName:i,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,e)=>{r.get().callServiceBroker(i,JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}class m{constructor(t,e){this.entityName=t,this.getMessage=e,this._application=s.getContextValue("__SNK__APPLICATION__")}initLoaders(t,e,i){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,e)=>this.dataLoader(t,e),t.saveLoader=(t,s)=>this.saveLoader(s,e).then((t=>(t.length&&i(),t))),t.removeLoader=(t,s)=>this.removeLoader(t,s,e).then((t=>(t.length&&i(),t)))}dataLoader(t,e){return new Promise((i=>{this.loader(t,e).then((t=>{const e=((null==t?void 0:t.records)||[]).map((t=>{let e;return t.LINK||(e=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:e})}));i(Object.assign(Object.assign({},t),{records:e}))}))}))}saveLoader(t,e){return new Promise((i=>{var s;const n=Array.isArray(t)?t[0]:{};((null===(s=null==n?void 0:n.record)||void 0===s?void 0:s.NUATTACH)>=0?e.edit.bind(e):e.save.bind(e))(n).then((t=>{i(t)})).catch((t=>t.message===l.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),i([])):t.message===l.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),i([])):t.message?(this._application.error(t.title||t.name,t.message),i([])):void i([])))}))}removeLoader(t,e,i){return new Promise((s=>{const{records:n}=t.getSelectionInfo();i.delete(n[0]).then((()=>s(e)))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:n.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,e,i){return new Promise((s=>e.type===a.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(i.goToView(o.GRID),s(e)):s(void 0))):s(e):e.type===a.DATA_SAVED?(t.loadData(),s(e)):void s(e)))}}const u=s.getContextValue("__SNK__APPLICATION__"),v=t=>{var e,i;return null===(i=null===(e=null==u?void 0:u.messagesBuilder)||void 0===e?void 0:e.getMessage)||void 0===i?void 0:i.call(e,t,null)},A={DOWNLOAD:{hint:v("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:v("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},O=()=>{const t=[d.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,e,i)=>{if((null==e?void 0:e.insertionMode)||(null==e?void 0:e.isDirty))return i.reverse();i.splice(i.indexOf(d.REFRESH),1);const{selectedRecord:s}=e||{},n=(null==s?void 0:s.LINK)?A.LINK:A.DOWNLOAD;i.splice(i.indexOf(d.DIVIDER)+1,0,d.REMOVE,n,d.DIVIDER);const a=Array.from(new Set(i.filter((t=>t!==d.CLONE))));return a.splice(a.indexOf(n)+1,0,d.DIVIDER),a},isEnabled:(e,i,s)=>{const n=void 0!==(null==i?void 0:i.selectedRecord);return!(t.includes(s)&&!n)}}},I={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},p=class{constructor(i){t(this,i),this.back=e(this,"back",7),this.handleTaskbarClick=({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this.dataUnit.getSelectedRecord())},this.handleBack=()=>{this.dataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this.dataUnit.isDirty())return this.back.emit();this.dataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this.dataUnit=void 0,this.crudConfig=void 0}registerKeyWatcher(t,e){var i;e!==t&&(this.returnToGridMode(),this._attachFetcher=new c(this.entityName,this.registerKey,null===(i=this.dataUnit)||void 0===i?void 0:i.name),this._dataUnitBuilder.initLoaders(this.dataUnit,this._attachFetcher,(()=>{this.returnToGridMode()})),this.dataUnit.loadData())}getMessage(t,e){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,e)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._attachFetcher.getDownloadKey(t).then((({chave:t})=>{window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${t.valor}&forcarDownload=S`)}))}returnToGridMode(){this.dataUnit.clearSelection(),this._crudElement&&this._crudElement.goToView(o.GRID)}loadAttachmentDataUnit(){var t;try{const e=this.dataUnit||(new h).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema");return this._attachFetcher=new c(this.entityName,this.registerKey,null===(t=this.dataUnit)||void 0===t?void 0:t.name),e.metadata||e.loadMetadata().then((()=>{this.crudConfig=I})),this._dataUnitBuilder=new m(this.entityName,this.getMessage.bind(this)),e.addFilterProvider({getFilter:()=>this._dataUnitBuilder.getFilters(this.registerKey)}),e.addInterceptor({interceptAction:t=>this._dataUnitBuilder.getInterceptions(e,t,this._crudElement)}),this.dataUnit=e,this.dataUnit.loadData(),this.dataUnit}catch(t){throw new Error("There was an error while creating the data unit")}}componentWillLoad(){this._application=s.getContextValue("__SNK__APPLICATION__"),this.loadAttachmentDataUnit()}render(){var t,e;return this.dataUnit?i("main",null,i("header",{class:"snk-attach__header"},i("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},i("div",{slot:"rightSlot"},i("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),i("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},i("div",{class:"ez-box__container"},i("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this.dataUnit,taskbarManager:O(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(e=this.crudConfig)||void 0===e?void 0:e.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick},i("div",{slot:"snkSimpleCrudHeader"},i("div",{class:"ez-flex ez-flex--column"},i("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),i("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};p.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}";export{p as snk_attach}
|