@sankhyalabs/sankhyablocks 8.15.0-dev.8 → 8.15.0-rc.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/{ISave-d68ce3cd.js → ISave-e91b70a7.js} +1 -0
- package/dist/cjs/{SnkMessageBuilder-7293d0ad.js → SnkMessageBuilder-e7dcf408.js} +13 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{dataunit-fetcher-14108bec.js → pesquisa-fetcher-e4a7c4c3.js} +235 -26
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_2.cjs.entry.js +5 -4
- package/dist/cjs/snk-application.cjs.entry.js +12 -4
- package/dist/cjs/snk-attach.cjs.entry.js +388 -57
- package/dist/cjs/snk-crud.cjs.entry.js +3 -4
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-1bc69073.js → snk-data-unit-82c08a8c.js} +1 -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-filter-bar.cjs.entry.js +8 -1
- package/dist/cjs/snk-filter-item.cjs.entry.js +3 -0
- package/dist/cjs/snk-filter-modal.cjs.entry.js +2 -1
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +2 -1
- package/dist/cjs/{snk-guides-viewer-c8b9374f.js → snk-guides-viewer-d32c096f.js} +2 -3
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +17 -6
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +52 -9
- package/dist/collection/components/snk-attach/snk-attach.js +188 -39
- package/dist/collection/components/snk-attach/structure/{crud-config-builder.js → builder/anexo-sistema-crud-config.builder.js} +1 -1
- package/dist/collection/components/snk-attach/structure/builder/attach-crud-config.builder.js +62 -0
- package/dist/collection/components/snk-attach/structure/{taskbar-builder.js → builder/taskbar-builder.js} +1 -1
- package/dist/collection/components/snk-attach/structure/fetcher/facade/fetcher.facade.js +1 -0
- package/dist/collection/components/snk-attach/structure/{data-unit-builder.js → fetcher/factory/anexo-sistema-data-unit.factory.js} +14 -11
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +111 -0
- package/dist/collection/components/snk-attach/structure/index.js +6 -3
- package/dist/collection/components/snk-crud/snk-crud.js +1 -1
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +2 -1
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +3 -0
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +19 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -0
- package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +2 -4
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +53 -1
- package/dist/collection/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.js +3 -1
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/{attach-fetcher.js → AttachFetcher/anexo-sistema-fetcher.js} +16 -15
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.js +90 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/index.js +2 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDelete.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDownloadKey.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +29 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +37 -23
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +7 -1
- package/dist/collection/lib/index.js +1 -1
- package/dist/collection/lib/message/resources/snk-attach.msg.js +13 -0
- package/dist/components/SnkMessageBuilder.js +13 -0
- package/dist/components/dataunit-fetcher.js +74 -27
- package/dist/components/snk-actions-button2.js +1 -0
- package/dist/components/snk-application2.js +11 -1
- package/dist/components/snk-attach2.js +394 -57
- package/dist/components/snk-crud.js +1 -1
- package/dist/components/snk-data-exporter2.js +1 -1
- package/dist/components/snk-filter-bar2.js +9 -1
- package/dist/components/snk-filter-item2.js +3 -0
- package/dist/components/snk-filter-modal.js +4 -2
- package/dist/components/snk-filter-multi-select.js +2 -1
- package/dist/components/snk-pesquisa2.js +1 -1
- package/dist/components/snk-simple-crud2.js +15 -1
- package/dist/components/taskbar-actions-button2.js +3 -1
- package/dist/esm/{ISave-4412b20c.js → ISave-d8c8bc59.js} +1 -0
- package/dist/esm/{SnkMessageBuilder-ca843d1b.js → SnkMessageBuilder-0fb796b9.js} +13 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{dataunit-fetcher-cbec1594.js → pesquisa-fetcher-fa0c2540.js} +235 -27
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_2.entry.js +5 -4
- package/dist/esm/snk-application.entry.js +11 -3
- package/dist/esm/snk-attach.entry.js +389 -58
- package/dist/esm/snk-crud.entry.js +3 -4
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-6208ebf0.js → snk-data-unit-5d201fb3.js} +1 -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-filter-bar.entry.js +8 -1
- package/dist/esm/snk-filter-item.entry.js +3 -0
- package/dist/esm/snk-filter-modal.entry.js +2 -1
- package/dist/esm/snk-filter-multi-select.entry.js +2 -1
- package/dist/esm/{snk-guides-viewer-8da24475.js → snk-guides-viewer-f49613c6.js} +2 -3
- package/dist/esm/snk-guides-viewer.entry.js +3 -4
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +15 -4
- package/dist/sankhyablocks/p-02e3a45b.entry.js +1 -0
- package/dist/sankhyablocks/{p-ff6064e7.js → p-05243555.js} +1 -1
- package/dist/sankhyablocks/p-0ec5b2e5.js +1 -0
- package/dist/sankhyablocks/{p-9e7d65a4.js → p-21749402.js} +1 -1
- package/dist/sankhyablocks/p-2582537c.entry.js +1 -0
- package/dist/sankhyablocks/p-282789a6.entry.js +1 -0
- package/dist/sankhyablocks/p-3b0e4e08.js +65 -0
- package/dist/sankhyablocks/{p-0874adb5.entry.js → p-40915359.entry.js} +1 -1
- package/dist/sankhyablocks/p-62896624.entry.js +1 -0
- package/dist/sankhyablocks/p-70a4af56.entry.js +1 -0
- package/dist/sankhyablocks/{p-6977a26c.entry.js → p-86801b08.entry.js} +1 -1
- package/dist/sankhyablocks/p-9b5944a4.entry.js +1 -0
- package/dist/sankhyablocks/p-9bdbc7d8.entry.js +1 -0
- package/dist/sankhyablocks/p-ac384baf.entry.js +1 -0
- package/dist/sankhyablocks/p-bf2acf72.entry.js +1 -0
- package/dist/sankhyablocks/p-c4874327.entry.js +1 -0
- package/dist/sankhyablocks/{p-247a8b36.entry.js → p-d1791da2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ba3d3fa9.entry.js → p-e817f254.entry.js} +3 -3
- package/dist/sankhyablocks/{p-32f0935f.js → p-f3d1c48e.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +7 -0
- package/dist/types/components/snk-attach/{structure/crud-config-builder.d.ts → interfaces/ICrudConfig.d.ts} +1 -2
- package/dist/types/components/snk-attach/interfaces/TFetcherType.d.ts +1 -0
- package/dist/types/components/snk-attach/snk-attach.d.ts +27 -6
- package/dist/types/components/snk-attach/structure/builder/anexo-sistema-crud-config.builder.d.ts +2 -0
- package/dist/types/components/snk-attach/structure/builder/attach-crud-config.builder.d.ts +31 -0
- package/dist/types/components/snk-attach/structure/{taskbar-builder.d.ts → builder/taskbar-builder.d.ts} +1 -1
- package/dist/types/components/snk-attach/structure/fetcher/facade/fetcher.facade.d.ts +11 -0
- package/dist/types/components/snk-attach/structure/fetcher/factory/anexo-sistema-data-unit.factory.d.ts +17 -0
- package/dist/types/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.d.ts +15 -0
- package/dist/types/components/snk-attach/structure/index.d.ts +6 -3
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -1
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +5 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +5 -0
- package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +3 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -1
- package/dist/types/components.d.ts +74 -2
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/{attach-fetcher.d.ts → AttachFetcher/anexo-sistema-fetcher.d.ts} +3 -2
- package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.d.ts +11 -0
- package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.d.ts +8 -0
- package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/index.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +1 -0
- package/dist/types/lib/index.d.ts +1 -1
- package/package.json +7 -5
- package/dist/cjs/pesquisa-fetcher-ef050a47.js +0 -167
- package/dist/esm/pesquisa-fetcher-dd3ca0a5.js +0 -165
- package/dist/sankhyablocks/p-20726710.entry.js +0 -1
- package/dist/sankhyablocks/p-25927311.entry.js +0 -1
- package/dist/sankhyablocks/p-3891ae6f.js +0 -60
- package/dist/sankhyablocks/p-4775a293.entry.js +0 -1
- package/dist/sankhyablocks/p-7d8d7fe9.entry.js +0 -1
- package/dist/sankhyablocks/p-8d70b5d5.entry.js +0 -1
- package/dist/sankhyablocks/p-a9e4bb55.entry.js +0 -1
- package/dist/sankhyablocks/p-a9e5b094.entry.js +0 -1
- package/dist/sankhyablocks/p-aa0ae6bc.entry.js +0 -1
- package/dist/sankhyablocks/p-c4d19840.entry.js +0 -1
- package/dist/sankhyablocks/p-c6e477ff.js +0 -1
- package/dist/sankhyablocks/p-d81f20c4.entry.js +0 -1
- package/dist/sankhyablocks/p-d9bb09b3.js +0 -6
- package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +0 -15
- /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js → components/snk-attach/interfaces/ICrudConfig.js} +0 -0
- /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js → components/snk-attach/interfaces/TFetcherType.js} +0 -0
- /package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.js +0 -0
- /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDelete.d.ts +0 -0
- /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDownloadKey.d.ts +0 -0
- /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.d.ts +0 -0
@@ -1,20 +1,117 @@
|
|
1
1
|
import { r as registerInstance, c as createEvent, h } from './index-a7d3d3f1.js';
|
2
|
-
import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
2
|
+
import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnit } from '@sankhyalabs/core';
|
3
3
|
import { D as DataFetcher } from './DataFetcher-aa159c5a.js';
|
4
|
-
import {
|
4
|
+
import { D as DataUnitFetcher } from './pesquisa-fetcher-fa0c2540.js';
|
5
|
+
import './index-0ece87a6.js';
|
6
|
+
import { S as SaveErrorsEnum } from './ISave-d8c8bc59.js';
|
7
|
+
import './filter-item-type.enum-d45e026f.js';
|
8
|
+
import './form-config-fetcher-36219cd3.js';
|
5
9
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
6
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-cbec1594.js';
|
7
10
|
import { P as PreloadManager } from './PreloadManager-c1c2f2b4.js';
|
11
|
+
import { A as AutorizationType } from './auth-fetcher-c05dc474.js';
|
8
12
|
import { T as TaskbarElement } from './taskbar-elements-d4d0b424.js';
|
9
13
|
import './PrintUtils-3e4ff0f5.js';
|
10
14
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
15
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
12
16
|
import './ResourceIDUtils-a114189a.js';
|
13
17
|
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
14
|
-
import './index-0ece87a6.js';
|
15
18
|
import './index-bdf75557.js';
|
16
19
|
|
20
|
+
const SERVICE$1 = {
|
21
|
+
save: "Attach.save",
|
22
|
+
delete: "Attach.remove",
|
23
|
+
view: "Attach.view",
|
24
|
+
repository: "RepositorioArquivoSP.abreArquivo"
|
25
|
+
};
|
17
26
|
class AttachFetcher {
|
27
|
+
constructor(dataUnitName) {
|
28
|
+
this.dataUnitName = dataUnitName;
|
29
|
+
}
|
30
|
+
async save({ dataUnit: dataUnitName, record, updatingFields: fields, operation }) {
|
31
|
+
var _a, _b;
|
32
|
+
const isInsert = operation == "INSERT";
|
33
|
+
const dataBody = isInsert ? fields : record;
|
34
|
+
if (!isInsert && (fields === null || fields === void 0 ? void 0 : fields.DESCRICAO) && (fields === null || fields === void 0 ? void 0 : fields.DESCRICAO) !== (record === null || record === void 0 ? void 0 : record.DESCRICAO)) {
|
35
|
+
throw new Error(SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED);
|
36
|
+
}
|
37
|
+
const reqBody = {
|
38
|
+
"anexo": {
|
39
|
+
"codata": isInsert ? fields === null || fields === void 0 ? void 0 : fields.REGISTER_KEY : record === null || record === void 0 ? void 0 : record.CODATA,
|
40
|
+
"sequencia": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.SEQUENCIA) || "0",
|
41
|
+
"tipo": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.TIPO) || "N",
|
42
|
+
"descricao": dataBody === null || dataBody === void 0 ? void 0 : dataBody.DESCRICAO,
|
43
|
+
"arquivo": (_b = (_a = fields.CAMINHO_ARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name,
|
44
|
+
"ehInclusao": isInsert ? "S" : "N",
|
45
|
+
"ehArquivoRepositorio": "N"
|
46
|
+
}
|
47
|
+
};
|
48
|
+
return new Promise((resolve, reject) => {
|
49
|
+
DataFetcher.get().callServiceBroker(SERVICE$1.save, JSON.stringify(reqBody))
|
50
|
+
.then(result => {
|
51
|
+
var _a;
|
52
|
+
return resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { __owner__dataunit__name__: (_a = this.dataUnitName) !== null && _a !== void 0 ? _a : dataUnitName })]);
|
53
|
+
})
|
54
|
+
.catch(error => reject(error));
|
55
|
+
});
|
56
|
+
}
|
57
|
+
async edit(change) {
|
58
|
+
throw new Error("Method not implemented.");
|
59
|
+
}
|
60
|
+
async delete(record) {
|
61
|
+
var request = {
|
62
|
+
anexo: {
|
63
|
+
codata: record.CODATA,
|
64
|
+
tipo: record.TIPO,
|
65
|
+
descricao: record.DESCRICAO,
|
66
|
+
}
|
67
|
+
};
|
68
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE$1.delete, JSON.stringify(request));
|
69
|
+
return Promise.resolve(result);
|
70
|
+
}
|
71
|
+
async getDownloadKey(record) {
|
72
|
+
var _a, _b, _c;
|
73
|
+
if (record.EHARQUIVOREPOSITORIO == 'S') {
|
74
|
+
const request = {
|
75
|
+
config: {
|
76
|
+
path: record.ARQUIVO,
|
77
|
+
tipoconteudo: record.TIPOCONTEUDO
|
78
|
+
}
|
79
|
+
};
|
80
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE$1.repository, JSON.stringify(request));
|
81
|
+
return Promise.resolve({
|
82
|
+
chave: {
|
83
|
+
valor: (_b = (_a = result === null || result === void 0 ? void 0 : result.responseBody) === null || _a === void 0 ? void 0 : _a.chave) === null || _b === void 0 ? void 0 : _b.valor
|
84
|
+
}
|
85
|
+
});
|
86
|
+
}
|
87
|
+
const criteria = {
|
88
|
+
anexo: {
|
89
|
+
codata: record.CODATA,
|
90
|
+
codemp: record.CODEMP,
|
91
|
+
sequencia: record.SEQUENCIA,
|
92
|
+
tipo: record.TIPO,
|
93
|
+
descricao: record.DESCRICAO,
|
94
|
+
tipoConteudo: record.TIPOCONTEUDO
|
95
|
+
}
|
96
|
+
};
|
97
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE$1.view, JSON.stringify(criteria));
|
98
|
+
if (result === null || result === void 0 ? void 0 : result.chaveAnexo) {
|
99
|
+
return Promise.resolve({
|
100
|
+
chave: {
|
101
|
+
valor: (_c = result === null || result === void 0 ? void 0 : result.chaveAnexo) === null || _c === void 0 ? void 0 : _c.idChaveAnexo
|
102
|
+
}
|
103
|
+
});
|
104
|
+
}
|
105
|
+
return Promise.reject(new Error("File not found."));
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
const SERVICE = {
|
110
|
+
save: "AnexoSistemaSP.salvar",
|
111
|
+
delete: "AnexoSistemaSP.excluir",
|
112
|
+
download: "AnexoSistemaSP.baixar",
|
113
|
+
};
|
114
|
+
class AnexoSistemaFetcher {
|
18
115
|
constructor(entityName, registerKey, dataUnitName) {
|
19
116
|
var _a;
|
20
117
|
this.entityName = entityName;
|
@@ -32,14 +129,13 @@ class AttachFetcher {
|
|
32
129
|
}
|
33
130
|
async save(change) {
|
34
131
|
var _a, _b;
|
35
|
-
const serviceName = "AnexoSistemaSP.salvar";
|
36
132
|
let { updatingFields: fields } = change;
|
37
133
|
fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
|
38
134
|
try {
|
39
135
|
this.validateFields(fields);
|
40
136
|
const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
|
41
137
|
const reqBody = {
|
42
|
-
serviceName,
|
138
|
+
serviceName: SERVICE.save,
|
43
139
|
requestBody: {
|
44
140
|
params: {
|
45
141
|
resourceID: this.resourceID,
|
@@ -55,7 +151,7 @@ class AttachFetcher {
|
|
55
151
|
}
|
56
152
|
}
|
57
153
|
};
|
58
|
-
const result = await DataFetcher.get().callServiceBroker(
|
154
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
|
59
155
|
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 })]);
|
60
156
|
}
|
61
157
|
catch (error) {
|
@@ -64,7 +160,6 @@ class AttachFetcher {
|
|
64
160
|
}
|
65
161
|
async edit(change) {
|
66
162
|
var _a, _b, _c;
|
67
|
-
const serviceName = "AnexoSistemaSP.salvar";
|
68
163
|
let { updatingFields: fields, record } = change;
|
69
164
|
const getFieldValue = (fieldValue) => {
|
70
165
|
if (fields[fieldValue] !== undefined)
|
@@ -78,7 +173,7 @@ class AttachFetcher {
|
|
78
173
|
try {
|
79
174
|
this.validateFields(fields);
|
80
175
|
const reqBody = {
|
81
|
-
serviceName,
|
176
|
+
serviceName: SERVICE.save,
|
82
177
|
requestBody: {
|
83
178
|
params: {
|
84
179
|
resourceID: this.resourceID,
|
@@ -96,7 +191,7 @@ class AttachFetcher {
|
|
96
191
|
}
|
97
192
|
}
|
98
193
|
};
|
99
|
-
const result = await DataFetcher.get().callServiceBroker(
|
194
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
|
100
195
|
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 })]);
|
101
196
|
}
|
102
197
|
catch (error) {
|
@@ -105,10 +200,9 @@ class AttachFetcher {
|
|
105
200
|
}
|
106
201
|
delete(record) {
|
107
202
|
var _a;
|
108
|
-
const serviceName = "AnexoSistemaSP.excluir";
|
109
203
|
const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
|
110
204
|
const reqBody = {
|
111
|
-
serviceName,
|
205
|
+
serviceName: SERVICE.delete,
|
112
206
|
requestBody: {
|
113
207
|
paramsDelete: {
|
114
208
|
keyAttach: record.CHAVEARQUIVO,
|
@@ -120,17 +214,16 @@ class AttachFetcher {
|
|
120
214
|
}
|
121
215
|
};
|
122
216
|
return new Promise((resolve, reject) => {
|
123
|
-
DataFetcher.get().callServiceBroker(
|
217
|
+
DataFetcher.get().callServiceBroker(SERVICE.delete, JSON.stringify(reqBody))
|
124
218
|
.then(result => resolve(result))
|
125
219
|
.catch(error => reject(error));
|
126
220
|
});
|
127
221
|
}
|
128
222
|
getDownloadKey(record) {
|
129
223
|
var _a;
|
130
|
-
const serviceName = "AnexoSistemaSP.baixar";
|
131
224
|
const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
|
132
225
|
const reqBody = {
|
133
|
-
serviceName,
|
226
|
+
serviceName: SERVICE.download,
|
134
227
|
requestBody: {
|
135
228
|
paramsDown: {
|
136
229
|
nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
|
@@ -142,34 +235,37 @@ class AttachFetcher {
|
|
142
235
|
}
|
143
236
|
};
|
144
237
|
return new Promise((resolve, reject) => {
|
145
|
-
DataFetcher.get().callServiceBroker(
|
238
|
+
DataFetcher.get().callServiceBroker(SERVICE.download, JSON.stringify(reqBody))
|
146
239
|
.then(result => resolve(result))
|
147
240
|
.catch(error => reject(error));
|
148
241
|
});
|
149
242
|
}
|
150
243
|
}
|
151
244
|
|
152
|
-
class
|
245
|
+
class AnexoSistemaDataUnitFactory {
|
153
246
|
constructor(entityName, getMessage) {
|
154
247
|
this.entityName = entityName;
|
155
248
|
this.getMessage = getMessage;
|
156
249
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
157
250
|
}
|
158
|
-
initLoaders(dataUnit,
|
251
|
+
initLoaders(dataUnit, fetcher, onSuccess) {
|
159
252
|
if (!this.loader)
|
160
253
|
this.loader = dataUnit.dataLoader;
|
161
254
|
dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
|
162
|
-
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes,
|
255
|
+
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
|
163
256
|
if (recordIds.length)
|
164
257
|
onSuccess();
|
165
258
|
return recordIds;
|
166
259
|
});
|
167
|
-
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids,
|
260
|
+
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
|
168
261
|
if (recordIds.length)
|
169
262
|
onSuccess();
|
170
263
|
return recordIds;
|
171
264
|
});
|
172
265
|
}
|
266
|
+
metadataLoader(dataUnit) {
|
267
|
+
throw new Error("Method not implemented.");
|
268
|
+
}
|
173
269
|
dataLoader(dataUnit, request) {
|
174
270
|
return new Promise(resolve => {
|
175
271
|
this.loader(dataUnit, request).then(response => {
|
@@ -185,11 +281,11 @@ class AttachmentDataUnitBuilder {
|
|
185
281
|
});
|
186
282
|
});
|
187
283
|
}
|
188
|
-
saveLoader(changes,
|
284
|
+
saveLoader(changes, fetcher) {
|
189
285
|
return new Promise((resolve) => {
|
190
286
|
var _a;
|
191
287
|
const change = Array.isArray(changes) ? changes[0] : {};
|
192
|
-
const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ?
|
288
|
+
const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ? fetcher.edit.bind(fetcher) : fetcher.save.bind(fetcher);
|
193
289
|
savePromise(change).then((records) => {
|
194
290
|
resolve(records);
|
195
291
|
}).catch((error) => {
|
@@ -209,11 +305,11 @@ class AttachmentDataUnitBuilder {
|
|
209
305
|
});
|
210
306
|
});
|
211
307
|
}
|
212
|
-
removeLoader(dataUnit, ids,
|
308
|
+
removeLoader(dataUnit, ids, fetcher) {
|
213
309
|
return new Promise((resolve) => {
|
214
310
|
const { records } = dataUnit.getSelectionInfo();
|
215
311
|
const recordToDelete = records[0];
|
216
|
-
|
312
|
+
fetcher.delete(recordToDelete).then(() => {
|
217
313
|
PreloadManager.removeRecords(dataUnit, [recordToDelete]);
|
218
314
|
return resolve(ids);
|
219
315
|
});
|
@@ -254,6 +350,175 @@ class AttachmentDataUnitBuilder {
|
|
254
350
|
}
|
255
351
|
}
|
256
352
|
|
353
|
+
const application$1 = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
354
|
+
const getMessage$1 = (key) => {
|
355
|
+
var _a, _b;
|
356
|
+
return (_b = (_a = application$1 === null || application$1 === void 0 ? void 0 : application$1.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage) === null || _b === void 0 ? void 0 : _b.call(_a, key, null);
|
357
|
+
};
|
358
|
+
const attachCrudConfig = {
|
359
|
+
grid: {
|
360
|
+
columns: [
|
361
|
+
{ name: "CODATA", orderIndex: 0, width: 0 },
|
362
|
+
{ name: "DESCRICAO", orderIndex: 1, width: 0 },
|
363
|
+
{ name: "ARQUIVO", orderIndex: 2, width: 0 },
|
364
|
+
{ name: "DTALTER", orderIndex: 3, width: 0 },
|
365
|
+
{ name: "USUARIO", orderIndex: 4, width: 0 },
|
366
|
+
],
|
367
|
+
},
|
368
|
+
form: {
|
369
|
+
emptyConfig: false,
|
370
|
+
fields: [
|
371
|
+
{
|
372
|
+
name: "DESCRICAO",
|
373
|
+
label: getMessage$1("snkAttach.attachMetadata.lblDescription"),
|
374
|
+
visible: true,
|
375
|
+
readOnly: false,
|
376
|
+
required: true,
|
377
|
+
},
|
378
|
+
{
|
379
|
+
name: "CAMINHO_ARQUIVO",
|
380
|
+
label: getMessage$1("snkAttach.attachMetadata.lblFile"),
|
381
|
+
visible: true,
|
382
|
+
readOnly: false,
|
383
|
+
required: true,
|
384
|
+
},
|
385
|
+
],
|
386
|
+
},
|
387
|
+
};
|
388
|
+
const attachFetcherMetadataBuilder = {
|
389
|
+
name: "Attach",
|
390
|
+
label: "Attach List",
|
391
|
+
fields: [
|
392
|
+
{ name: "CODATA", label: getMessage$1("snkAttach.attachMetadata.lblCode"), dataType: DataType.TEXT },
|
393
|
+
{ name: "DESCRICAO", label: getMessage$1("snkAttach.attachMetadata.lblDescription"), dataType: DataType.TEXT },
|
394
|
+
{ name: "ARQUIVO", label: getMessage$1("snkAttach.attachMetadata.lblFileOrLink"), dataType: DataType.TEXT },
|
395
|
+
{ name: "USUARIO", label: getMessage$1("snkAttach.attachMetadata.lblUser"), dataType: DataType.TEXT },
|
396
|
+
{ name: "DTALTER", label: getMessage$1("snkAttach.attachMetadata.lblDate"), dataType: DataType.TEXT },
|
397
|
+
{
|
398
|
+
name: "CAMINHO_ARQUIVO",
|
399
|
+
label: getMessage$1("snkAttach.attachMetadata.lblFileUpload"),
|
400
|
+
dataType: DataType.OBJECT,
|
401
|
+
userInterface: UserInterface.FILE,
|
402
|
+
readOnly: false,
|
403
|
+
required: true,
|
404
|
+
visible: true,
|
405
|
+
properties: {
|
406
|
+
subTitle: getMessage$1("snkAttach.attachMetadata.lblSubTitle"),
|
407
|
+
MAX_FILES: 1,
|
408
|
+
STORAGESTRATEGY: "SESSION",
|
409
|
+
INTERNAL_FILENAME: "Attach.upload",
|
410
|
+
}
|
411
|
+
},
|
412
|
+
],
|
413
|
+
};
|
414
|
+
|
415
|
+
const SERVICE_LOAD = "Attach.load";
|
416
|
+
class AttachFetcherDataUnitFactory {
|
417
|
+
constructor(getMessage) {
|
418
|
+
this.getMessage = getMessage;
|
419
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
420
|
+
}
|
421
|
+
initLoaders(dataUnit, fetcher, onSuccess) {
|
422
|
+
dataUnit.metadataLoader = (dataUnit) => this.metadataLoader(dataUnit);
|
423
|
+
dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
|
424
|
+
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
|
425
|
+
if (recordIds.length)
|
426
|
+
onSuccess();
|
427
|
+
return recordIds;
|
428
|
+
});
|
429
|
+
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
|
430
|
+
if (recordIds.length)
|
431
|
+
onSuccess();
|
432
|
+
return recordIds;
|
433
|
+
});
|
434
|
+
}
|
435
|
+
metadataLoader(_) {
|
436
|
+
return Promise.resolve(attachFetcherMetadataBuilder);
|
437
|
+
}
|
438
|
+
async dataLoader(_, request) {
|
439
|
+
if (!request.source) {
|
440
|
+
return Promise.resolve({ records: [] });
|
441
|
+
}
|
442
|
+
const criteria = {
|
443
|
+
criteria: {
|
444
|
+
codata: request.source,
|
445
|
+
tipoAnexo: "N"
|
446
|
+
}
|
447
|
+
};
|
448
|
+
const applicationDataFetcher = await this._application.getDataFetcher();
|
449
|
+
const { anexos: { anexo = [] } } = await applicationDataFetcher.callServiceBroker(SERVICE_LOAD, JSON.stringify(criteria));
|
450
|
+
const records = [];
|
451
|
+
anexo.forEach((param) => {
|
452
|
+
records.push(Object.assign({ __record__id__: StringUtils.generateUUID(), CAMINHO_ARQUIVO: [{
|
453
|
+
name: param === null || param === void 0 ? void 0 : param.ARQUIVO,
|
454
|
+
}] }, param));
|
455
|
+
});
|
456
|
+
return Promise.resolve({ records });
|
457
|
+
}
|
458
|
+
saveLoader(changes, fetcher) {
|
459
|
+
return new Promise((resolve) => {
|
460
|
+
const change = Array.isArray(changes) ? changes[0] : {};
|
461
|
+
fetcher.save(change)
|
462
|
+
.then(resolve)
|
463
|
+
.catch((error) => {
|
464
|
+
if (error.message === SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED) {
|
465
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.title'), this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.message'));
|
466
|
+
return resolve([]);
|
467
|
+
}
|
468
|
+
if (error.message === SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
|
469
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
|
470
|
+
return resolve([]);
|
471
|
+
}
|
472
|
+
if (error.message === SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
|
473
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
|
474
|
+
return resolve([]);
|
475
|
+
}
|
476
|
+
if (error.message) {
|
477
|
+
this._application.error((error.title || error.name), error.message);
|
478
|
+
return resolve([]);
|
479
|
+
}
|
480
|
+
resolve([]);
|
481
|
+
});
|
482
|
+
});
|
483
|
+
}
|
484
|
+
removeLoader(dataUnit, ids, fetcher) {
|
485
|
+
return new Promise((resolve) => {
|
486
|
+
dataUnit.getSelectionInfo().records.forEach(async (record) => {
|
487
|
+
this._application.hasAccess(AutorizationType.REMOVE)
|
488
|
+
.then(async (hasAccess) => {
|
489
|
+
if (hasAccess) {
|
490
|
+
await fetcher.delete(record);
|
491
|
+
resolve(ids);
|
492
|
+
}
|
493
|
+
});
|
494
|
+
});
|
495
|
+
});
|
496
|
+
}
|
497
|
+
getFilters() {
|
498
|
+
throw new Error('Method not implemented.');
|
499
|
+
}
|
500
|
+
getInterceptions(dataUnit, action, crudRef) {
|
501
|
+
return new Promise((resolve) => {
|
502
|
+
if (action.type === Action.EDITION_CANCELED) {
|
503
|
+
if (!dataUnit.isDirty())
|
504
|
+
return resolve(action);
|
505
|
+
return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
|
506
|
+
if (cancellationConfirmed) {
|
507
|
+
crudRef.goToView(VIEW_MODE.GRID);
|
508
|
+
return resolve(action);
|
509
|
+
}
|
510
|
+
return resolve(undefined);
|
511
|
+
});
|
512
|
+
}
|
513
|
+
if (action.type === Action.DATA_SAVED) {
|
514
|
+
dataUnit.loadData();
|
515
|
+
return resolve(action);
|
516
|
+
}
|
517
|
+
resolve(action);
|
518
|
+
});
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
257
522
|
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
258
523
|
const getMessage = (key) => {
|
259
524
|
var _a, _b;
|
@@ -300,7 +565,7 @@ const buildTaskBarManager = () => {
|
|
300
565
|
};
|
301
566
|
};
|
302
567
|
|
303
|
-
const
|
568
|
+
const anexoSistemaCrudConfig = {
|
304
569
|
grid: {
|
305
570
|
columns: [
|
306
571
|
{ name: "ARQUIVOOULINK", orderIndex: 0, width: 0 },
|
@@ -346,40 +611,60 @@ const SnkAttach = class {
|
|
346
611
|
constructor(hostRef) {
|
347
612
|
registerInstance(this, hostRef);
|
348
613
|
this.back = createEvent(this, "back", 7);
|
349
|
-
this.handleTaskbarClick = ({ detail: taskbar }) => {
|
614
|
+
this.handleTaskbarClick = async ({ detail: taskbar }) => {
|
350
615
|
if (["DOWNLOAD", "LINK"].includes(taskbar))
|
351
|
-
return this.downloadAttachment(this.
|
616
|
+
return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());
|
617
|
+
if (this.fetcherType === "Attach" && ["SAVE"].includes(taskbar) && this._currentDataUnit.isDirty()) {
|
618
|
+
await this._currentDataUnit.setFieldValue("REGISTER_KEY", this.registerKey);
|
619
|
+
}
|
352
620
|
};
|
353
621
|
this.handleBack = () => {
|
354
|
-
this.
|
622
|
+
this._currentDataUnit.cancelEdition().then((cancelationConfirmed) => {
|
355
623
|
if (cancelationConfirmed)
|
356
624
|
this.back.emit();
|
357
625
|
});
|
358
626
|
};
|
359
627
|
this.handleFinish = () => {
|
360
|
-
if (!this.
|
628
|
+
if (!this._currentDataUnit.isDirty())
|
361
629
|
return this.back.emit();
|
362
|
-
this.
|
630
|
+
this._currentDataUnit.saveData().then(() => {
|
363
631
|
this.showFinishedToast();
|
364
632
|
this.back.emit();
|
365
633
|
});
|
366
634
|
};
|
635
|
+
this.fetcherType = "AnexoSistema";
|
636
|
+
this.fetcher = undefined;
|
637
|
+
this.dataUnit = undefined;
|
638
|
+
this.dataUnitBuilder = undefined;
|
367
639
|
this.registerKey = undefined;
|
368
640
|
this.entityName = undefined;
|
369
641
|
this.messagesBuilder = undefined;
|
370
|
-
this.
|
642
|
+
this._currentFetcher = undefined;
|
643
|
+
this._currentDataUnit = undefined;
|
371
644
|
this.crudConfig = undefined;
|
372
645
|
}
|
373
646
|
registerKeyWatcher(newRegisterKey, oldRegisterKey) {
|
374
|
-
var _a;
|
375
|
-
if (this.
|
647
|
+
var _a, _b, _c, _d;
|
648
|
+
if (this._currentDataUnit == null) {
|
376
649
|
this.loadAttachmentDataUnit();
|
377
650
|
}
|
378
651
|
if (oldRegisterKey !== newRegisterKey) {
|
379
652
|
this.returnToGridMode();
|
380
|
-
|
381
|
-
|
382
|
-
|
653
|
+
if (this.fetcherType === "AnexoSistema") {
|
654
|
+
this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
655
|
+
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
656
|
+
return (_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData();
|
657
|
+
}
|
658
|
+
if (this.fetcherType === "Attach") {
|
659
|
+
const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
|
660
|
+
if (hasMoreOneItem)
|
661
|
+
return;
|
662
|
+
}
|
663
|
+
return this._currentDataUnit
|
664
|
+
.loadMetadata()
|
665
|
+
.then(() => {
|
666
|
+
this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
667
|
+
});
|
383
668
|
}
|
384
669
|
}
|
385
670
|
/**
|
@@ -402,44 +687,90 @@ const SnkAttach = class {
|
|
402
687
|
window.open(`${selectedRecord.LINK}`);
|
403
688
|
return;
|
404
689
|
}
|
405
|
-
this.
|
406
|
-
|
690
|
+
this._currentFetcher
|
691
|
+
.getDownloadKey(selectedRecord)
|
692
|
+
.then(({ chave }) => {
|
693
|
+
var _a;
|
694
|
+
let forceDownload = false;
|
695
|
+
if (!((_a = selectedRecord === null || selectedRecord === void 0 ? void 0 : selectedRecord.ARQUIVO) === null || _a === void 0 ? void 0 : _a.endsWith(".pdf"))) {
|
696
|
+
forceDownload = true;
|
697
|
+
}
|
698
|
+
window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${chave.valor}${forceDownload ? "&forcarDownload=S" : ""}`);
|
407
699
|
});
|
408
700
|
}
|
409
701
|
returnToGridMode() {
|
410
|
-
|
702
|
+
var _a;
|
703
|
+
(_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.clearSelection();
|
411
704
|
if (this._crudElement)
|
412
705
|
this._crudElement.goToView(VIEW_MODE.GRID);
|
413
706
|
}
|
414
707
|
loadAttachmentDataUnit() {
|
415
|
-
var _a;
|
416
708
|
try {
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
});
|
430
|
-
return this.dataUnit;
|
709
|
+
switch (this.fetcherType) {
|
710
|
+
case "AnexoSistema":
|
711
|
+
this.loadAnexoSistema();
|
712
|
+
break;
|
713
|
+
case "Attach":
|
714
|
+
this.loadAttach();
|
715
|
+
break;
|
716
|
+
default:
|
717
|
+
this._currentFetcher = this.fetcher;
|
718
|
+
this._currentDataUnit = this.dataUnit;
|
719
|
+
this._currentDataUnitBuilder = this.dataUnitBuilder;
|
720
|
+
}
|
431
721
|
}
|
432
722
|
catch (error) {
|
433
723
|
throw new Error('There was an error while creating the data unit');
|
434
724
|
}
|
435
725
|
}
|
726
|
+
loadAnexoSistema() {
|
727
|
+
var _a;
|
728
|
+
this._currentDataUnit = this._currentDataUnit || new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
|
729
|
+
this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
730
|
+
if (!this._currentDataUnit.metadata) {
|
731
|
+
this._currentDataUnit
|
732
|
+
.loadMetadata()
|
733
|
+
.then(() => this.crudConfig = anexoSistemaCrudConfig);
|
734
|
+
}
|
735
|
+
this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
|
736
|
+
this._currentDataUnit.addFilterProvider({
|
737
|
+
getFilter: () => this._currentDataUnitBuilder.getFilters(this.registerKey)
|
738
|
+
});
|
739
|
+
this._currentDataUnit.addInterceptor({
|
740
|
+
interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
|
741
|
+
});
|
742
|
+
this._currentDataUnit.loadData().then(this.disableEditFieldsNotInForm.bind(this));
|
743
|
+
}
|
744
|
+
loadAttach() {
|
745
|
+
var _a;
|
746
|
+
this._currentFetcher = new AttachFetcher();
|
747
|
+
this._currentDataUnit = new DataUnit();
|
748
|
+
this._currentDataUnit.addInterceptor({
|
749
|
+
interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
|
750
|
+
});
|
751
|
+
this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
|
752
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
|
753
|
+
await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
754
|
+
this.returnToGridMode();
|
755
|
+
});
|
756
|
+
if (!this._currentDataUnit.metadata) {
|
757
|
+
this._currentDataUnit
|
758
|
+
.loadMetadata()
|
759
|
+
.then(() => {
|
760
|
+
this.crudConfig = attachCrudConfig;
|
761
|
+
this._currentDataUnit
|
762
|
+
.loadData(undefined, undefined, true, this.registerKey)
|
763
|
+
.then(this.disableEditFieldsNotInForm.bind(this));
|
764
|
+
});
|
765
|
+
}
|
766
|
+
}
|
436
767
|
disableEditFieldsNotInForm() {
|
437
768
|
var _a;
|
438
769
|
(_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid.columns.forEach(column => {
|
439
770
|
var _a;
|
440
771
|
const fieldName = column.name;
|
441
772
|
if (!((_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.form.fields.some(field => field.name === fieldName))) {
|
442
|
-
this.
|
773
|
+
this._currentDataUnit.disableField(fieldName);
|
443
774
|
}
|
444
775
|
});
|
445
776
|
}
|
@@ -447,15 +778,15 @@ const SnkAttach = class {
|
|
447
778
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
448
779
|
}
|
449
780
|
componentWillRender() {
|
450
|
-
if (this.
|
781
|
+
if (this._currentDataUnit == null) {
|
451
782
|
this.loadAttachmentDataUnit();
|
452
783
|
}
|
453
784
|
}
|
454
785
|
render() {
|
455
786
|
var _a, _b;
|
456
|
-
if (!this.
|
787
|
+
if (!this._currentDataUnit)
|
457
788
|
return null;
|
458
|
-
return (h("main", { class: "snk-attach__main" }, 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.
|
789
|
+
return (h("main", { class: "snk-attach__main" }, 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._currentDataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder }, 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")))))))));
|
459
790
|
}
|
460
791
|
static get watchers() { return {
|
461
792
|
"registerKey": ["registerKeyWatcher"]
|