@sankhyalabs/sankhyablocks 5.4.2 → 5.5.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/{SnkMessageBuilder-115e8a80.js → SnkMessageBuilder-26da04f7.js} +35 -1
- package/dist/cjs/{constants-ae0ed870.js → constants-3787fa32.js} +1 -0
- package/dist/cjs/dataunit-fetcher-8f5ade55.js +319 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +3 -315
- package/dist/cjs/snk-attach.cjs.entry.js +449 -0
- package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
- package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +22 -13
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-aa613f3b.js → snk-data-unit-c43df27b.js} +4 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -5
- package/dist/cjs/snk-field-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +11 -4
- package/dist/cjs/{snk-guides-viewer-7db960c2.js → snk-guides-viewer-e6a65393.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
- package/dist/cjs/snk-select-box.cjs.entry.js +1 -1
- package/dist/cjs/{snk-simple-crud.cjs.entry.js → snk-simple-bar_2.cjs.entry.js} +47 -5
- package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +5 -4
- package/dist/cjs/taskbar-elements-80285601.js +313 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/snk-attach/interfaces/index.js +1 -0
- package/dist/collection/components/snk-attach/snk-attach.css +8 -0
- package/dist/collection/components/snk-attach/snk-attach.js +202 -0
- package/dist/collection/components/snk-attach/structure/crud-config-builder.js +37 -0
- package/dist/collection/components/snk-attach/structure/data-unit-builder.js +106 -0
- package/dist/collection/components/snk-attach/structure/index.js +3 -0
- package/dist/collection/components/snk-attach/structure/taskbar-builder.js +47 -0
- package/dist/collection/components/snk-configurator/snk-configurator.js +3 -3
- package/dist/collection/components/snk-crud/snk-crud.js +22 -11
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.js +11 -3
- package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +37 -2
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +65 -2
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +4 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/attach-fetcher.js +136 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/ISave.js +6 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/index.js +3 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +5 -1
- package/dist/collection/lib/message/resources/snk-attach.msg.js +27 -0
- package/dist/collection/lib/message/resources/snk-simple-bar.msg.js +3 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -0
- package/dist/collection/lib/utils/constants.js +1 -0
- package/dist/components/SnkMessageBuilder.js +35 -1
- package/dist/components/constants.js +1 -0
- package/dist/components/dataunit-fetcher.js +317 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/snk-application2.js +2 -314
- package/dist/components/snk-attach.d.ts +11 -0
- package/dist/components/snk-attach.js +6 -0
- package/dist/components/snk-attach2.js +498 -0
- package/dist/components/snk-crud.js +77 -48
- package/dist/components/snk-data-unit2.js +4 -0
- package/dist/components/snk-filter-bar2.js +1 -1
- package/dist/components/snk-grid2.js +11 -4
- package/dist/components/snk-simple-bar.js +1 -41
- package/dist/components/snk-simple-bar2.js +59 -0
- package/dist/components/snk-simple-crud.js +1 -328
- package/dist/{esm/snk-simple-crud.entry.js → components/snk-simple-crud2.js} +73 -18
- package/dist/components/snk-taskbar2.js +7 -2
- package/dist/esm/{SnkMessageBuilder-a15d22f8.js → SnkMessageBuilder-7a9392e6.js} +35 -1
- package/dist/esm/{constants-15617e7d.js → constants-e916ccc3.js} +1 -0
- package/dist/esm/dataunit-fetcher-d32c6a47.js +317 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +3 -315
- package/dist/esm/snk-attach.entry.js +445 -0
- package/dist/esm/snk-config-options.entry.js +1 -1
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +23 -14
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-5ed93c0e.js → snk-data-unit-f9e4c694.js} +4 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +4 -5
- package/dist/esm/snk-field-config.entry.js +1 -1
- package/dist/esm/snk-filter-bar.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-grid-config.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +11 -4
- package/dist/esm/{snk-guides-viewer-1e7c21f6.js → snk-guides-viewer-62a9f74d.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +3 -4
- package/dist/esm/snk-select-box.entry.js +1 -1
- package/dist/esm/snk-simple-bar_2.entry.js +324 -0
- package/dist/esm/snk-tab-config.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +5 -4
- package/dist/esm/taskbar-elements-055ba1ad.js +309 -0
- package/dist/sankhyablocks/p-17375123.js +1 -0
- package/dist/sankhyablocks/{p-b80cf644.entry.js → p-1c0ee011.entry.js} +1 -1
- package/dist/sankhyablocks/p-4512cc6c.entry.js +1 -0
- package/dist/sankhyablocks/p-5cbbe1f7.entry.js +1 -0
- package/dist/sankhyablocks/p-63d01871.entry.js +1 -0
- package/dist/sankhyablocks/{p-0a1e7f75.entry.js → p-6ac29569.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f4d36823.entry.js → p-6f0b3cc0.entry.js} +1 -1
- package/dist/sankhyablocks/p-741b00ef.entry.js +1 -0
- package/dist/sankhyablocks/{p-6516f35a.entry.js → p-86f75e7a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-32599159.entry.js → p-8b02b276.entry.js} +1 -1
- package/dist/sankhyablocks/p-92a0fca4.js +1 -0
- package/dist/sankhyablocks/p-999d1953.entry.js +1 -0
- package/dist/sankhyablocks/{p-9bfa3cfb.entry.js → p-a412992c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-703dddb9.js → p-aeffd219.js} +1 -1
- package/dist/sankhyablocks/p-b2523981.entry.js +11 -0
- package/dist/sankhyablocks/p-c3efd4eb.entry.js +1 -0
- package/dist/sankhyablocks/{p-3169584f.entry.js → p-e0b4aec3.entry.js} +1 -1
- package/dist/sankhyablocks/p-ebe876f5.entry.js +1 -0
- package/dist/sankhyablocks/p-ed438690.js +1 -0
- package/dist/sankhyablocks/p-f2223502.js +1 -0
- package/dist/sankhyablocks/p-f3d0c744.entry.js +1 -0
- package/dist/sankhyablocks/p-f821768b.js +74 -0
- package/dist/sankhyablocks/{p-f29caa0a.entry.js → p-f8c66aa3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-adf50831.entry.js → p-fac37198.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-attach/interfaces/index.d.ts +10 -0
- package/dist/types/components/snk-attach/snk-attach.d.ts +45 -0
- package/dist/types/components/snk-attach/structure/crud-config-builder.d.ts +7 -0
- package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +16 -0
- package/dist/types/components/snk-attach/structure/index.d.ts +3 -0
- package/dist/types/components/snk-attach/structure/taskbar-builder.d.ts +8 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +5 -0
- package/dist/types/components/snk-simple-bar/snk-simple-bar.d.ts +14 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +1 -0
- package/dist/types/components.d.ts +67 -0
- package/dist/types/global.d.ts +9 -0
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +8 -2
- package/dist/types/lib/http/data-fetcher/fetchers/attach-fetcher.d.ts +14 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.d.ts +9 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.d.ts +13 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/ISave.d.ts +26 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/index.d.ts +3 -0
- package/dist/types/lib/message/resources/snk-attach.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-simple-bar.msg.d.ts +1 -0
- package/dist/types/lib/utils/constants.d.ts +2 -1
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/index-fc7ca86c.js +0 -200
- package/dist/cjs/snk-simple-bar.cjs.entry.js +0 -30
- package/dist/cjs/taskbar-elements-5e87cf44.js +0 -115
- package/dist/esm/index-e467ade5.js +0 -198
- package/dist/esm/snk-simple-bar.entry.js +0 -26
- package/dist/esm/taskbar-elements-10d80c79.js +0 -112
- package/dist/sankhyablocks/p-1393dc00.entry.js +0 -1
- package/dist/sankhyablocks/p-1c17eecf.entry.js +0 -1
- package/dist/sankhyablocks/p-2ecf14ff.js +0 -1
- package/dist/sankhyablocks/p-340d6fb0.entry.js +0 -84
- package/dist/sankhyablocks/p-74724fa7.js +0 -1
- package/dist/sankhyablocks/p-79f01b63.entry.js +0 -1
- package/dist/sankhyablocks/p-81e85890.entry.js +0 -1
- package/dist/sankhyablocks/p-94e6fc90.entry.js +0 -1
- package/dist/sankhyablocks/p-98f7f796.js +0 -1
- package/dist/sankhyablocks/p-b3e71248.entry.js +0 -1
- package/dist/sankhyablocks/p-bc281de0.js +0 -1
- package/dist/sankhyablocks/p-d61759a5.entry.js +0 -1
- package/dist/sankhyablocks/p-d65809d5.entry.js +0 -1
- package/dist/sankhyablocks/p-f587a454.js +0 -1
- package/dist/types/components/snk-application/snk-application.d.ts +0 -259
- package/dist/types/components/snk-crud/snk-crud.d.ts +0 -73
- package/dist/types/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender.d.ts +0 -40
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +0 -27
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +0 -23
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +0 -23
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +0 -29
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +0 -25
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +0 -19
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -38
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +0 -74
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +0 -53
- package/dist/types/components/snk-grid/snk-grid.d.ts +0 -95
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -59
@@ -0,0 +1,498 @@
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
2
|
+
import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
3
|
+
import { D as DataFetcher } from './DataFetcher.js';
|
4
|
+
import { V as VIEW_MODE } from './constants.js';
|
5
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher.js';
|
6
|
+
import { T as TaskbarElement, d as defineCustomElement$1 } from './snk-taskbar2.js';
|
7
|
+
import { d as defineCustomElement$6 } from './snk-data-exporter2.js';
|
8
|
+
import { d as defineCustomElement$5 } from './snk-data-unit2.js';
|
9
|
+
import { d as defineCustomElement$4 } from './snk-exporter-email-sender2.js';
|
10
|
+
import { d as defineCustomElement$3 } from './snk-simple-bar2.js';
|
11
|
+
import { d as defineCustomElement$2 } from './snk-simple-crud2.js';
|
12
|
+
|
13
|
+
var SaveErrorsEnum;
|
14
|
+
(function (SaveErrorsEnum) {
|
15
|
+
SaveErrorsEnum["LINK_AND_FILE_AT_THE_SAME_TIME"] = "LINK_AND_FILE_AT_THE_SAME_TIME";
|
16
|
+
SaveErrorsEnum["ANY_LINK_OR_FILE_FILLED"] = "ANY_LINK_OR_FILE_FILLED";
|
17
|
+
SaveErrorsEnum["UNKNOWN"] = "UNKNOWN";
|
18
|
+
})(SaveErrorsEnum || (SaveErrorsEnum = {}));
|
19
|
+
|
20
|
+
class AttachFetcher {
|
21
|
+
constructor(entityName, registerKey, dataUnitName) {
|
22
|
+
var _a;
|
23
|
+
this.entityName = entityName;
|
24
|
+
this.registerKey = registerKey;
|
25
|
+
this.dataUnitName = dataUnitName;
|
26
|
+
this.validateFields = (fields) => {
|
27
|
+
if (!!fields.LINK && !!fields.NOMEARQUIVO)
|
28
|
+
throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
|
29
|
+
if (!fields.LINK && !fields.NOMEARQUIVO)
|
30
|
+
throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
|
31
|
+
if (!this.registerKey)
|
32
|
+
throw new Error('Register key can not be null');
|
33
|
+
};
|
34
|
+
this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
|
35
|
+
}
|
36
|
+
async save(change) {
|
37
|
+
var _a, _b;
|
38
|
+
const serviceName = "AnexoSistemaSP.salvar";
|
39
|
+
let { updatingFields: fields } = change;
|
40
|
+
fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
|
41
|
+
try {
|
42
|
+
this.validateFields(fields);
|
43
|
+
const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
|
44
|
+
const reqBody = {
|
45
|
+
serviceName,
|
46
|
+
requestBody: {
|
47
|
+
params: {
|
48
|
+
resourceID: this.resourceID,
|
49
|
+
description: fields.DESCRICAO,
|
50
|
+
fileSelect: fileInfo ? 1 : 0,
|
51
|
+
keySession: (_b = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.properties) === null || _b === void 0 ? void 0 : _b.fileNameTmp,
|
52
|
+
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
53
|
+
link: fields.LINK,
|
54
|
+
nameEntity: this.entityName,
|
55
|
+
pkEntity: this.registerKey,
|
56
|
+
typeAcess: fields.TIPOACESSO,
|
57
|
+
typeApres: fields.TIPOAPRES,
|
58
|
+
}
|
59
|
+
}
|
60
|
+
};
|
61
|
+
const result = await DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody));
|
62
|
+
return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
|
63
|
+
}
|
64
|
+
catch (error) {
|
65
|
+
return Promise.reject(error);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
async edit(change) {
|
69
|
+
var _a, _b, _c;
|
70
|
+
const serviceName = "AnexoSistemaSP.salvar";
|
71
|
+
let { updatingFields: fields, record } = change;
|
72
|
+
const getFieldValue = (fieldValue) => {
|
73
|
+
if (fields[fieldValue] !== undefined)
|
74
|
+
return fields[fieldValue];
|
75
|
+
return record[fieldValue];
|
76
|
+
};
|
77
|
+
const attachField = getFieldValue('NOMEARQUIVO');
|
78
|
+
const hasNewAttachment = (_b = (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.downloadURL;
|
79
|
+
fields = Object.assign(Object.assign({}, fields), { DESCRICAO: getFieldValue('DESCRICAO'), LINK: getFieldValue('LINK'), TIPOACESSO: getFieldValue('TIPOACESSO'), TIPOAPRES: getFieldValue('TIPOAPRES'), CHAVEARQUIVO: record.CHAVEARQUIVO, NOMEARQUIVO: attachField === null || attachField === void 0 ? void 0 : attachField[0] });
|
80
|
+
const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
|
81
|
+
try {
|
82
|
+
this.validateFields(fields);
|
83
|
+
const reqBody = {
|
84
|
+
serviceName,
|
85
|
+
requestBody: {
|
86
|
+
params: {
|
87
|
+
resourceID: this.resourceID,
|
88
|
+
nuAttach: record === null || record === void 0 ? void 0 : record.NUATTACH,
|
89
|
+
description: fields.DESCRICAO,
|
90
|
+
fileSelect: hasNewAttachment ? 1 : 0,
|
91
|
+
keySession: (_c = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.properties) === null || _c === void 0 ? void 0 : _c.fileNameTmp,
|
92
|
+
keyAttach: fields.CHAVEARQUIVO,
|
93
|
+
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
94
|
+
link: fields.LINK,
|
95
|
+
nameEntity: this.entityName,
|
96
|
+
pkEntity: this.registerKey,
|
97
|
+
typeAcess: fields.TIPOACESSO,
|
98
|
+
typeApres: fields.TIPOAPRES,
|
99
|
+
}
|
100
|
+
}
|
101
|
+
};
|
102
|
+
const result = await DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody));
|
103
|
+
return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
|
104
|
+
}
|
105
|
+
catch (error) {
|
106
|
+
return Promise.reject(error);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
delete(record) {
|
110
|
+
var _a;
|
111
|
+
const serviceName = "AnexoSistemaSP.excluir";
|
112
|
+
const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
|
113
|
+
const reqBody = {
|
114
|
+
serviceName,
|
115
|
+
requestBody: {
|
116
|
+
paramsDelete: {
|
117
|
+
keyAttach: record.CHAVEARQUIVO,
|
118
|
+
nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
|
119
|
+
nameEntity: record.NOMEINSTANCIA,
|
120
|
+
nuAttach: record.NUATTACH,
|
121
|
+
pkEntity: record.PKREGISTRO
|
122
|
+
}
|
123
|
+
}
|
124
|
+
};
|
125
|
+
return new Promise((resolve, reject) => {
|
126
|
+
DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody))
|
127
|
+
.then(result => resolve(result))
|
128
|
+
.catch(error => reject(error));
|
129
|
+
});
|
130
|
+
}
|
131
|
+
getDownloadKey(record) {
|
132
|
+
var _a;
|
133
|
+
const serviceName = "AnexoSistemaSP.baixar";
|
134
|
+
const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
|
135
|
+
const reqBody = {
|
136
|
+
serviceName,
|
137
|
+
requestBody: {
|
138
|
+
paramsDown: {
|
139
|
+
nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
|
140
|
+
nameEntity: record.NOMEINSTANCIA,
|
141
|
+
nuAttach: record.NUATTACH,
|
142
|
+
pkEntity: record.PKREGISTRO,
|
143
|
+
keyAttach: record.CHAVEARQUIVO,
|
144
|
+
}
|
145
|
+
}
|
146
|
+
};
|
147
|
+
return new Promise((resolve, reject) => {
|
148
|
+
DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody))
|
149
|
+
.then(result => resolve(result))
|
150
|
+
.catch(error => reject(error));
|
151
|
+
});
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
class AttachmentDataUnitBuilder {
|
156
|
+
constructor(entityName, getMessage) {
|
157
|
+
this.entityName = entityName;
|
158
|
+
this.getMessage = getMessage;
|
159
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
160
|
+
}
|
161
|
+
initLoaders(dataUnit, attachFetcher, onSuccess) {
|
162
|
+
if (!this.loader)
|
163
|
+
this.loader = dataUnit.dataLoader;
|
164
|
+
dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
|
165
|
+
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, attachFetcher).then((recordIds) => {
|
166
|
+
if (recordIds.length)
|
167
|
+
onSuccess();
|
168
|
+
return recordIds;
|
169
|
+
});
|
170
|
+
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, attachFetcher).then((recordIds) => {
|
171
|
+
if (recordIds.length)
|
172
|
+
onSuccess();
|
173
|
+
return recordIds;
|
174
|
+
});
|
175
|
+
}
|
176
|
+
dataLoader(dataUnit, request) {
|
177
|
+
return new Promise(resolve => {
|
178
|
+
this.loader(dataUnit, request).then(response => {
|
179
|
+
const records = ((response === null || response === void 0 ? void 0 : response.records) || []).map(record => {
|
180
|
+
let fileInfo;
|
181
|
+
if (!record.LINK)
|
182
|
+
fileInfo = [{
|
183
|
+
name: record.NOMEARQUIVO,
|
184
|
+
}];
|
185
|
+
return Object.assign(Object.assign({}, record), { ARQUIVOOULINK: !!record.LINK ? record.LINK : record.NOMEARQUIVO, NOMEARQUIVO: fileInfo });
|
186
|
+
});
|
187
|
+
resolve(Object.assign(Object.assign({}, response), { records }));
|
188
|
+
});
|
189
|
+
});
|
190
|
+
}
|
191
|
+
saveLoader(changes, attachFetcher) {
|
192
|
+
return new Promise((resolve) => {
|
193
|
+
var _a;
|
194
|
+
const change = Array.isArray(changes) ? changes[0] : {};
|
195
|
+
const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ? attachFetcher.edit.bind(attachFetcher) : attachFetcher.save.bind(attachFetcher);
|
196
|
+
savePromise(change).then((records) => {
|
197
|
+
resolve(records);
|
198
|
+
}).catch((error) => {
|
199
|
+
if (error.message === SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
|
200
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
|
201
|
+
return resolve([]);
|
202
|
+
}
|
203
|
+
if (error.message === SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
|
204
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
|
205
|
+
return resolve([]);
|
206
|
+
}
|
207
|
+
if (error.message) {
|
208
|
+
this._application.error((error.title || error.name), error.message);
|
209
|
+
return resolve([]);
|
210
|
+
}
|
211
|
+
resolve([]);
|
212
|
+
});
|
213
|
+
});
|
214
|
+
}
|
215
|
+
removeLoader(dataUnit, ids, attachFetcher) {
|
216
|
+
return new Promise((resolve) => {
|
217
|
+
const { records } = dataUnit.getSelectionInfo();
|
218
|
+
attachFetcher.delete(records[0]).then(() => {
|
219
|
+
resolve(ids);
|
220
|
+
});
|
221
|
+
resolve([]);
|
222
|
+
});
|
223
|
+
}
|
224
|
+
getFilters(registerKey) {
|
225
|
+
return [
|
226
|
+
{
|
227
|
+
name: 'AttachmentsByPK',
|
228
|
+
expression: 'this.PKREGISTRO = :PKREGISTRO',
|
229
|
+
params: [{
|
230
|
+
name: "PKREGISTRO",
|
231
|
+
dataType: DataType.TEXT,
|
232
|
+
value: `${registerKey}_${this.entityName}`
|
233
|
+
}]
|
234
|
+
}
|
235
|
+
];
|
236
|
+
}
|
237
|
+
getInterceptions(dataUnit, action, crudRef) {
|
238
|
+
return new Promise((resolve) => {
|
239
|
+
if (action.type === Action.EDITION_CANCELED) {
|
240
|
+
if (!dataUnit.isDirty())
|
241
|
+
return resolve(action);
|
242
|
+
return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
|
243
|
+
if (cancellationConfirmed) {
|
244
|
+
crudRef.goToView(VIEW_MODE.GRID);
|
245
|
+
return resolve(action);
|
246
|
+
}
|
247
|
+
return resolve(undefined);
|
248
|
+
});
|
249
|
+
}
|
250
|
+
if (action.type === Action.DATA_SAVED) {
|
251
|
+
dataUnit.loadData();
|
252
|
+
return resolve(action);
|
253
|
+
}
|
254
|
+
resolve(action);
|
255
|
+
});
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
260
|
+
const getMessage = (key) => {
|
261
|
+
var _a, _b;
|
262
|
+
return (_b = (_a = application === null || application === void 0 ? void 0 : application.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage) === null || _b === void 0 ? void 0 : _b.call(_a, key, null);
|
263
|
+
};
|
264
|
+
const TaskbarAttachButtons = {
|
265
|
+
DOWNLOAD: {
|
266
|
+
hint: getMessage("snkAttach.taskbar.titleDownload"),
|
267
|
+
name: "DOWNLOAD",
|
268
|
+
iconName: 'file-download'
|
269
|
+
},
|
270
|
+
LINK: {
|
271
|
+
hint: getMessage("snkAttach.taskbar.titleLink"),
|
272
|
+
name: "LINK",
|
273
|
+
iconName: "launch"
|
274
|
+
}
|
275
|
+
};
|
276
|
+
const buildTaskBarManager = () => {
|
277
|
+
const disabledButtonsWithoutSelection = [
|
278
|
+
TaskbarElement.REMOVE,
|
279
|
+
"DOWNLOAD",
|
280
|
+
"LINK"
|
281
|
+
];
|
282
|
+
return {
|
283
|
+
getButtons: (_, dataState, currentButtons) => {
|
284
|
+
if ((dataState === null || dataState === void 0 ? void 0 : dataState.insertionMode) || (dataState === null || dataState === void 0 ? void 0 : dataState.isDirty))
|
285
|
+
return currentButtons.reverse();
|
286
|
+
else
|
287
|
+
currentButtons.splice(currentButtons.indexOf(TaskbarElement.REFRESH), 1);
|
288
|
+
const { selectedRecord } = dataState || {};
|
289
|
+
const taskbarTobeAdded = !!(selectedRecord === null || selectedRecord === void 0 ? void 0 : selectedRecord.LINK) ? TaskbarAttachButtons.LINK : TaskbarAttachButtons.DOWNLOAD;
|
290
|
+
currentButtons.splice(currentButtons.indexOf(TaskbarElement.DIVIDER) + 1, 0, TaskbarElement.REMOVE, taskbarTobeAdded, TaskbarElement.DIVIDER);
|
291
|
+
const updatedButtons = Array.from(new Set(currentButtons.filter(button => button !== TaskbarElement.CLONE)));
|
292
|
+
updatedButtons.splice(updatedButtons.indexOf(taskbarTobeAdded) + 1, 0, TaskbarElement.DIVIDER);
|
293
|
+
return updatedButtons;
|
294
|
+
},
|
295
|
+
isEnabled: (_, dataState, currentButton) => {
|
296
|
+
const hasSelectedRecord = (dataState === null || dataState === void 0 ? void 0 : dataState.selectedRecord) !== undefined;
|
297
|
+
const disabledButton = disabledButtonsWithoutSelection.includes(currentButton);
|
298
|
+
if (disabledButton && !hasSelectedRecord)
|
299
|
+
return false;
|
300
|
+
return true;
|
301
|
+
}
|
302
|
+
};
|
303
|
+
};
|
304
|
+
|
305
|
+
const crudConfig = {
|
306
|
+
grid: {
|
307
|
+
columns: [
|
308
|
+
{ name: "ARQUIVOOULINK", orderIndex: 0, width: 0 },
|
309
|
+
{ name: "DESCRICAO", orderIndex: 1, width: 0 },
|
310
|
+
{ name: "DHCAD", orderIndex: 2, width: 0 },
|
311
|
+
{ name: "DHALTER", orderIndex: 3, width: 0 },
|
312
|
+
{ name: "TIPOAPRES", orderIndex: 4, width: 0 },
|
313
|
+
{ name: "TIPOACESSO", orderIndex: 5, width: 0 },
|
314
|
+
{ name: "CODUSU", orderIndex: 6, width: 0 },
|
315
|
+
{ name: "CODUSUALT", orderIndex: 7, width: 0 }
|
316
|
+
]
|
317
|
+
},
|
318
|
+
form: {
|
319
|
+
emptyConfig: false,
|
320
|
+
fields: [
|
321
|
+
{
|
322
|
+
name: "DESCRICAO",
|
323
|
+
required: true
|
324
|
+
},
|
325
|
+
{
|
326
|
+
name: "TIPOAPRES",
|
327
|
+
required: true,
|
328
|
+
},
|
329
|
+
{
|
330
|
+
name: "TIPOACESSO",
|
331
|
+
required: true,
|
332
|
+
},
|
333
|
+
{
|
334
|
+
name: "LINK"
|
335
|
+
},
|
336
|
+
{
|
337
|
+
name: "NOMEARQUIVO"
|
338
|
+
}
|
339
|
+
]
|
340
|
+
},
|
341
|
+
};
|
342
|
+
|
343
|
+
const snkAttachCss = ".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%}";
|
344
|
+
|
345
|
+
const RESOURCE_ID = 'AnexoSistema';
|
346
|
+
const DATA_UNIT_NAME = 'br.com.sankhya.core.v3.anexoSistema';
|
347
|
+
const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
348
|
+
constructor() {
|
349
|
+
super();
|
350
|
+
this.__registerHost();
|
351
|
+
this.back = createEvent(this, "back", 7);
|
352
|
+
this.handleTaskbarClick = ({ detail: taskbar }) => {
|
353
|
+
if (["DOWNLOAD", "LINK"].includes(taskbar))
|
354
|
+
return this.downloadAttachment(this.dataUnit.getSelectedRecord());
|
355
|
+
};
|
356
|
+
this.handleBack = () => {
|
357
|
+
this.dataUnit.cancelEdition().then((cancelationConfirmed) => {
|
358
|
+
if (cancelationConfirmed)
|
359
|
+
this.back.emit();
|
360
|
+
});
|
361
|
+
};
|
362
|
+
this.handleFinish = () => {
|
363
|
+
if (!this.dataUnit.isDirty())
|
364
|
+
return this.back.emit();
|
365
|
+
this.dataUnit.saveData().then(() => {
|
366
|
+
this.showFinishedToast();
|
367
|
+
this.back.emit();
|
368
|
+
});
|
369
|
+
};
|
370
|
+
this.registerKey = undefined;
|
371
|
+
this.entityName = undefined;
|
372
|
+
this.messagesBuilder = undefined;
|
373
|
+
this.dataUnit = undefined;
|
374
|
+
this.crudConfig = {};
|
375
|
+
}
|
376
|
+
registerKeyWatcher(newRegisterKey, oldRegisterKey) {
|
377
|
+
var _a;
|
378
|
+
if (oldRegisterKey !== newRegisterKey) {
|
379
|
+
this.returnToGridMode();
|
380
|
+
this._attachFetcher = new AttachFetcher(this.entityName, this.registerKey, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
381
|
+
this._dataUnitBuilder.initLoaders(this.dataUnit, this._attachFetcher, () => { this.returnToGridMode(); });
|
382
|
+
this.dataUnit.loadData();
|
383
|
+
}
|
384
|
+
}
|
385
|
+
/**
|
386
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
387
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
388
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
389
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-attach.msg.ts"
|
390
|
+
*/
|
391
|
+
getMessage(key, params) {
|
392
|
+
if (this.messagesBuilder)
|
393
|
+
return this.messagesBuilder.getMessage(key, params);
|
394
|
+
}
|
395
|
+
showFinishedToast() {
|
396
|
+
this._application.info(this.getMessage('snkAttach.finishedMessage'), { iconName: "check" });
|
397
|
+
}
|
398
|
+
downloadAttachment(selectedRecord) {
|
399
|
+
if (!selectedRecord)
|
400
|
+
throw new Error('Nenhum registro selecionado');
|
401
|
+
if (selectedRecord.LINK) {
|
402
|
+
window.open(`${selectedRecord.LINK}`);
|
403
|
+
return;
|
404
|
+
}
|
405
|
+
this._attachFetcher.getDownloadKey(selectedRecord).then(({ chave }) => {
|
406
|
+
window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${chave.valor}&forcarDownload=S`);
|
407
|
+
});
|
408
|
+
}
|
409
|
+
returnToGridMode() {
|
410
|
+
this.dataUnit.clearSelection();
|
411
|
+
if (this._crudElement)
|
412
|
+
this._crudElement.goToView(VIEW_MODE.GRID);
|
413
|
+
}
|
414
|
+
loadAttachmentDataUnit() {
|
415
|
+
var _a;
|
416
|
+
try {
|
417
|
+
const dataUnit = this.dataUnit || new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
|
418
|
+
this._attachFetcher = new AttachFetcher(this.entityName, this.registerKey, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
419
|
+
if (!dataUnit.metadata)
|
420
|
+
dataUnit.loadMetadata().then(() => {
|
421
|
+
this.crudConfig = crudConfig;
|
422
|
+
});
|
423
|
+
this._dataUnitBuilder = new AttachmentDataUnitBuilder(this.entityName, this.getMessage.bind(this));
|
424
|
+
dataUnit.addFilterProvider({ getFilter: () => this._dataUnitBuilder.getFilters(this.registerKey) });
|
425
|
+
dataUnit.addInterceptor({ interceptAction: (action) => this._dataUnitBuilder.getInterceptions(dataUnit, action, this._crudElement) });
|
426
|
+
this.dataUnit = dataUnit;
|
427
|
+
this.dataUnit.loadData();
|
428
|
+
return this.dataUnit;
|
429
|
+
}
|
430
|
+
catch (error) {
|
431
|
+
throw new Error('There was an error while creating the data unit');
|
432
|
+
}
|
433
|
+
}
|
434
|
+
componentWillLoad() {
|
435
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
436
|
+
this.loadAttachmentDataUnit();
|
437
|
+
}
|
438
|
+
render() {
|
439
|
+
if (!this.dataUnit)
|
440
|
+
return null;
|
441
|
+
return (h("main", null, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this.dataUnit, taskbarManager: buildTaskBarManager(), gridConfig: this.crudConfig.grid, formConfig: this.crudConfig.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
|
442
|
+
}
|
443
|
+
static get watchers() { return {
|
444
|
+
"registerKey": ["registerKeyWatcher"]
|
445
|
+
}; }
|
446
|
+
static get style() { return snkAttachCss; }
|
447
|
+
}, [2, "snk-attach", {
|
448
|
+
"registerKey": [1, "register-key"],
|
449
|
+
"entityName": [1, "entity-name"],
|
450
|
+
"messagesBuilder": [1040],
|
451
|
+
"dataUnit": [32],
|
452
|
+
"crudConfig": [32]
|
453
|
+
}]);
|
454
|
+
function defineCustomElement() {
|
455
|
+
if (typeof customElements === "undefined") {
|
456
|
+
return;
|
457
|
+
}
|
458
|
+
const components = ["snk-attach", "snk-data-exporter", "snk-data-unit", "snk-exporter-email-sender", "snk-simple-bar", "snk-simple-crud", "snk-taskbar"];
|
459
|
+
components.forEach(tagName => { switch (tagName) {
|
460
|
+
case "snk-attach":
|
461
|
+
if (!customElements.get(tagName)) {
|
462
|
+
customElements.define(tagName, SnkAttach);
|
463
|
+
}
|
464
|
+
break;
|
465
|
+
case "snk-data-exporter":
|
466
|
+
if (!customElements.get(tagName)) {
|
467
|
+
defineCustomElement$6();
|
468
|
+
}
|
469
|
+
break;
|
470
|
+
case "snk-data-unit":
|
471
|
+
if (!customElements.get(tagName)) {
|
472
|
+
defineCustomElement$5();
|
473
|
+
}
|
474
|
+
break;
|
475
|
+
case "snk-exporter-email-sender":
|
476
|
+
if (!customElements.get(tagName)) {
|
477
|
+
defineCustomElement$4();
|
478
|
+
}
|
479
|
+
break;
|
480
|
+
case "snk-simple-bar":
|
481
|
+
if (!customElements.get(tagName)) {
|
482
|
+
defineCustomElement$3();
|
483
|
+
}
|
484
|
+
break;
|
485
|
+
case "snk-simple-crud":
|
486
|
+
if (!customElements.get(tagName)) {
|
487
|
+
defineCustomElement$2();
|
488
|
+
}
|
489
|
+
break;
|
490
|
+
case "snk-taskbar":
|
491
|
+
if (!customElements.get(tagName)) {
|
492
|
+
defineCustomElement$1();
|
493
|
+
}
|
494
|
+
break;
|
495
|
+
} });
|
496
|
+
}
|
497
|
+
|
498
|
+
export { SnkAttach as S, defineCustomElement as d };
|