@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-33766.1 → 0.0.0-bugfix-dev-KB-39469.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-302bbbd4.js → ConfigStorage-d4c99a5e.js} +2 -2
- package/dist/cjs/{DataFetcher-ba94ed5b.js → DataFetcher-99f0f6ed.js} +5 -3
- package/dist/cjs/{ISave-d68ce3cd.js → ISave-e91b70a7.js} +1 -0
- package/dist/cjs/{SnkFormConfigManager-71c4768e.js → SnkFormConfigManager-3621bfc4.js} +2 -2
- package/dist/cjs/{SnkMessageBuilder-7293d0ad.js → SnkMessageBuilder-e7dcf408.js} +13 -0
- package/dist/cjs/{auth-fetcher-c8467c07.js → auth-fetcher-5161d082.js} +1 -1
- package/dist/cjs/{form-config-fetcher-df043d3d.js → form-config-fetcher-9f1a13ca.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{dataunit-fetcher-bd4c52da.js → pesquisa-fetcher-c416a6b7.js} +238 -28
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_2.cjs.entry.js +21 -6
- package/dist/cjs/snk-application.cjs.entry.js +37 -8
- package/dist/cjs/snk-attach.cjs.entry.js +389 -58
- package/dist/cjs/snk-crud.cjs.entry.js +11 -9
- package/dist/cjs/snk-data-exporter.cjs.entry.js +4 -4
- 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 +8 -9
- package/dist/cjs/snk-entity-list.cjs.entry.js +5 -3
- package/dist/cjs/snk-filter-bar.cjs.entry.js +28 -6
- package/dist/cjs/snk-filter-item.cjs.entry.js +3 -0
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- 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-form-config.cjs.entry.js +2 -2
- package/dist/cjs/snk-form.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid-config.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +5 -4
- package/dist/cjs/{snk-guides-viewer-dce60912.js → snk-guides-viewer-3ab9623e.js} +8 -9
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -8
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +19 -8
- package/dist/cjs/snk-taskbar.cjs.entry.js +51 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/__mocks__/snk-application.js +7 -0
- package/dist/collection/components/snk-application/snk-application.js +43 -0
- 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 +23 -3
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.css +11 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +2 -2
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +1 -1
- package/dist/collection/components/snk-entity-list/snk-entity-list.js +5 -3
- 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 +39 -2
- package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
- package/dist/collection/components/snk-grid/snk-grid.js +19 -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 +17 -1
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +17 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +88 -3
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +1 -1
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +5 -3
- 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 +31 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +37 -23
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +21 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +10 -4
- package/dist/collection/lib/index.js +1 -1
- package/dist/collection/lib/message/resources/snk-attach.msg.js +13 -0
- package/dist/components/DataFetcher.js +5 -3
- package/dist/components/SnkMessageBuilder.js +13 -0
- package/dist/components/dataunit-fetcher.js +79 -31
- package/dist/components/snk-actions-button2.js +1 -0
- package/dist/components/snk-application2.js +32 -1
- package/dist/components/snk-attach2.js +394 -57
- package/dist/components/snk-crud.js +7 -3
- package/dist/components/snk-data-exporter2.js +1 -1
- package/dist/components/snk-detail-view2.js +3 -3
- package/dist/components/snk-entity-list.js +5 -3
- package/dist/components/snk-filter-bar2.js +26 -3
- 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-grid2.js +3 -1
- package/dist/components/snk-pesquisa2.js +1 -1
- package/dist/components/snk-simple-crud2.js +15 -1
- package/dist/components/snk-taskbar2.js +55 -4
- package/dist/components/taskbar-actions-button2.js +17 -1
- package/dist/esm/{ConfigStorage-4151acc8.js → ConfigStorage-39ed8aeb.js} +2 -2
- package/dist/esm/{DataFetcher-aa159c5a.js → DataFetcher-a650ae58.js} +5 -3
- package/dist/esm/{ISave-4412b20c.js → ISave-d8c8bc59.js} +1 -0
- package/dist/esm/{SnkFormConfigManager-5c7d3771.js → SnkFormConfigManager-692e20c7.js} +2 -2
- package/dist/esm/{SnkMessageBuilder-ca843d1b.js → SnkMessageBuilder-0fb796b9.js} +13 -0
- package/dist/esm/{auth-fetcher-c05dc474.js → auth-fetcher-17dc5b5e.js} +1 -1
- package/dist/esm/{form-config-fetcher-36219cd3.js → form-config-fetcher-f121f880.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{dataunit-fetcher-65714f21.js → pesquisa-fetcher-ab16a2e8.js} +238 -29
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_2.entry.js +21 -6
- package/dist/esm/snk-application.entry.js +36 -7
- package/dist/esm/snk-attach.entry.js +390 -59
- package/dist/esm/snk-crud.entry.js +11 -9
- package/dist/esm/snk-data-exporter.entry.js +4 -4
- 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 +8 -9
- package/dist/esm/snk-entity-list.entry.js +5 -3
- package/dist/esm/snk-filter-bar.entry.js +28 -6
- package/dist/esm/snk-filter-item.entry.js +3 -0
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- 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-form-config.entry.js +2 -2
- package/dist/esm/snk-form.entry.js +4 -4
- package/dist/esm/snk-grid-config.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +5 -4
- package/dist/esm/{snk-guides-viewer-8b9564bd.js → snk-guides-viewer-462b4c9e.js} +8 -9
- package/dist/esm/snk-guides-viewer.entry.js +7 -8
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +17 -6
- package/dist/esm/snk-taskbar.entry.js +52 -4
- package/dist/sankhyablocks/p-007f1026.entry.js +1 -0
- package/dist/sankhyablocks/p-0264dba5.entry.js +1 -0
- package/dist/sankhyablocks/{p-ff6064e7.js → p-05243555.js} +1 -1
- package/dist/sankhyablocks/p-0ae89faa.entry.js +1 -0
- package/dist/sankhyablocks/{p-cb7419e0.entry.js → p-0b0b36ac.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9e7d65a4.js → p-21749402.js} +1 -1
- package/dist/sankhyablocks/p-33718dfc.entry.js +1 -0
- package/dist/sankhyablocks/p-33bc44a6.entry.js +1 -0
- package/dist/sankhyablocks/p-48afb1d3.entry.js +1 -0
- package/dist/sankhyablocks/p-50783a8b.js +1 -0
- package/dist/sankhyablocks/{p-aa95fb2c.js → p-67aedbe0.js} +1 -1
- package/dist/sankhyablocks/p-70a4af56.entry.js +1 -0
- package/dist/sankhyablocks/{p-573a07c5.js → p-725d04ba.js} +1 -1
- package/dist/sankhyablocks/{p-e0fd9555.entry.js → p-827e4b01.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6977a26c.entry.js → p-86801b08.entry.js} +1 -1
- package/dist/sankhyablocks/p-88c7dd9a.entry.js +1 -0
- package/dist/sankhyablocks/p-93d7e848.entry.js +1 -0
- package/dist/sankhyablocks/{p-7f3c7b09.entry.js → p-9d608b62.entry.js} +1 -1
- package/dist/sankhyablocks/{p-0d7863ed.js → p-a13ccb86.js} +1 -1
- package/dist/sankhyablocks/p-a3a9d37d.js +1 -0
- package/dist/sankhyablocks/{p-9695f78b.js → p-be75153c.js} +1 -1
- package/dist/sankhyablocks/p-bf2acf72.entry.js +1 -0
- package/dist/sankhyablocks/p-c093edc7.entry.js +1 -0
- package/dist/sankhyablocks/p-c4874327.entry.js +1 -0
- package/dist/sankhyablocks/p-c6247955.js +65 -0
- package/dist/sankhyablocks/{p-247a8b36.entry.js → p-d1791da2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-761ed32f.entry.js → p-e3bd000e.entry.js} +1 -1
- package/dist/sankhyablocks/p-ed2dce4b.entry.js +1 -0
- package/dist/sankhyablocks/{p-32f0935f.js → p-f3d1c48e.js} +1 -1
- package/dist/sankhyablocks/{p-1d75d9f9.entry.js → p-fcdcb0e2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c223b7b2.entry.js → p-fd0a8d68.entry.js} +3 -3
- package/dist/sankhyablocks/{p-0874adb5.entry.js → p-fdc4cb9b.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/__mocks__/snk-application.d.ts +3 -0
- 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-crud/snk-crud.d.ts +5 -0
- 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 +7 -0
- package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +3 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +5 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -1
- package/dist/types/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.d.ts +1 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +20 -1
- package/dist/types/components.d.ts +106 -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/http/data-fetcher/fetchers/parameters-fecher.d.ts +1 -0
- package/dist/types/lib/index.d.ts +1 -1
- package/package.json +15 -6
- 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-28564b5e.entry.js +0 -1
- package/dist/sankhyablocks/p-29804fc5.js +0 -60
- package/dist/sankhyablocks/p-4775a293.entry.js +0 -1
- package/dist/sankhyablocks/p-55930465.entry.js +0 -1
- package/dist/sankhyablocks/p-69efa80d.entry.js +0 -1
- package/dist/sankhyablocks/p-7d8d7fe9.entry.js +0 -1
- package/dist/sankhyablocks/p-95a3778f.entry.js +0 -1
- package/dist/sankhyablocks/p-a9e5b094.entry.js +0 -1
- package/dist/sankhyablocks/p-b05ab13d.entry.js +0 -1
- package/dist/sankhyablocks/p-b146a9f0.entry.js +0 -1
- package/dist/sankhyablocks/p-bedb8ad6.entry.js +0 -1
- package/dist/sankhyablocks/p-cdd66657.entry.js +0 -1
- package/dist/sankhyablocks/p-d4f9ee17.entry.js +0 -1
- package/dist/sankhyablocks/p-d9bb09b3.js +0 -6
- package/dist/sankhyablocks/p-e6380c60.js +0 -1
- package/dist/sankhyablocks/p-ebbc17c6.js +0 -1
- 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,9 +1,13 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
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.js';
|
|
4
|
+
import { a as PreloadManager, D as DataUnitFetcher } from './dataunit-fetcher.js';
|
|
5
|
+
import './index2.js';
|
|
4
6
|
import { a as SaveErrorsEnum, d as defineCustomElement$8 } from './snk-actions-button2.js';
|
|
7
|
+
import './filter-item-type.enum.js';
|
|
8
|
+
import './form-config-fetcher.js';
|
|
5
9
|
import { V as VIEW_MODE } from './constants.js';
|
|
6
|
-
import {
|
|
10
|
+
import { A as AutorizationType } from './auth-fetcher.js';
|
|
7
11
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
|
8
12
|
import { d as defineCustomElement$7 } from './snk-data-exporter2.js';
|
|
9
13
|
import { d as defineCustomElement$6 } from './snk-data-unit2.js';
|
|
@@ -12,7 +16,101 @@ import { d as defineCustomElement$4 } from './snk-simple-bar2.js';
|
|
|
12
16
|
import { d as defineCustomElement$3 } from './snk-simple-crud2.js';
|
|
13
17
|
import { d as defineCustomElement$1 } from './taskbar-actions-button2.js';
|
|
14
18
|
|
|
19
|
+
const SERVICE$1 = {
|
|
20
|
+
save: "Attach.save",
|
|
21
|
+
delete: "Attach.remove",
|
|
22
|
+
view: "Attach.view",
|
|
23
|
+
repository: "RepositorioArquivoSP.abreArquivo"
|
|
24
|
+
};
|
|
15
25
|
class AttachFetcher {
|
|
26
|
+
constructor(dataUnitName) {
|
|
27
|
+
this.dataUnitName = dataUnitName;
|
|
28
|
+
}
|
|
29
|
+
async save({ dataUnit: dataUnitName, record, updatingFields: fields, operation }) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const isInsert = operation == "INSERT";
|
|
32
|
+
const dataBody = isInsert ? fields : record;
|
|
33
|
+
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)) {
|
|
34
|
+
throw new Error(SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED);
|
|
35
|
+
}
|
|
36
|
+
const reqBody = {
|
|
37
|
+
"anexo": {
|
|
38
|
+
"codata": isInsert ? fields === null || fields === void 0 ? void 0 : fields.REGISTER_KEY : record === null || record === void 0 ? void 0 : record.CODATA,
|
|
39
|
+
"sequencia": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.SEQUENCIA) || "0",
|
|
40
|
+
"tipo": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.TIPO) || "N",
|
|
41
|
+
"descricao": dataBody === null || dataBody === void 0 ? void 0 : dataBody.DESCRICAO,
|
|
42
|
+
"arquivo": (_b = (_a = fields.CAMINHO_ARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name,
|
|
43
|
+
"ehInclusao": isInsert ? "S" : "N",
|
|
44
|
+
"ehArquivoRepositorio": "N"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
DataFetcher.get().callServiceBroker(SERVICE$1.save, JSON.stringify(reqBody))
|
|
49
|
+
.then(result => {
|
|
50
|
+
var _a;
|
|
51
|
+
return resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { __owner__dataunit__name__: (_a = this.dataUnitName) !== null && _a !== void 0 ? _a : dataUnitName })]);
|
|
52
|
+
})
|
|
53
|
+
.catch(error => reject(error));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async edit(change) {
|
|
57
|
+
throw new Error("Method not implemented.");
|
|
58
|
+
}
|
|
59
|
+
async delete(record) {
|
|
60
|
+
var request = {
|
|
61
|
+
anexo: {
|
|
62
|
+
codata: record.CODATA,
|
|
63
|
+
tipo: record.TIPO,
|
|
64
|
+
descricao: record.DESCRICAO,
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE$1.delete, JSON.stringify(request));
|
|
68
|
+
return Promise.resolve(result);
|
|
69
|
+
}
|
|
70
|
+
async getDownloadKey(record) {
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
if (record.EHARQUIVOREPOSITORIO == 'S') {
|
|
73
|
+
const request = {
|
|
74
|
+
config: {
|
|
75
|
+
path: record.ARQUIVO,
|
|
76
|
+
tipoconteudo: record.TIPOCONTEUDO
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE$1.repository, JSON.stringify(request));
|
|
80
|
+
return Promise.resolve({
|
|
81
|
+
chave: {
|
|
82
|
+
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
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const criteria = {
|
|
87
|
+
anexo: {
|
|
88
|
+
codata: record.CODATA,
|
|
89
|
+
codemp: record.CODEMP,
|
|
90
|
+
sequencia: record.SEQUENCIA,
|
|
91
|
+
tipo: record.TIPO,
|
|
92
|
+
descricao: record.DESCRICAO,
|
|
93
|
+
tipoConteudo: record.TIPOCONTEUDO
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE$1.view, JSON.stringify(criteria));
|
|
97
|
+
if (result === null || result === void 0 ? void 0 : result.chaveAnexo) {
|
|
98
|
+
return Promise.resolve({
|
|
99
|
+
chave: {
|
|
100
|
+
valor: (_c = result === null || result === void 0 ? void 0 : result.chaveAnexo) === null || _c === void 0 ? void 0 : _c.idChaveAnexo
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return Promise.reject(new Error("File not found."));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const SERVICE = {
|
|
109
|
+
save: "AnexoSistemaSP.salvar",
|
|
110
|
+
delete: "AnexoSistemaSP.excluir",
|
|
111
|
+
download: "AnexoSistemaSP.baixar",
|
|
112
|
+
};
|
|
113
|
+
class AnexoSistemaFetcher {
|
|
16
114
|
constructor(entityName, registerKey, dataUnitName) {
|
|
17
115
|
var _a;
|
|
18
116
|
this.entityName = entityName;
|
|
@@ -30,14 +128,13 @@ class AttachFetcher {
|
|
|
30
128
|
}
|
|
31
129
|
async save(change) {
|
|
32
130
|
var _a, _b;
|
|
33
|
-
const serviceName = "AnexoSistemaSP.salvar";
|
|
34
131
|
let { updatingFields: fields } = change;
|
|
35
132
|
fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
|
|
36
133
|
try {
|
|
37
134
|
this.validateFields(fields);
|
|
38
135
|
const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
|
|
39
136
|
const reqBody = {
|
|
40
|
-
serviceName,
|
|
137
|
+
serviceName: SERVICE.save,
|
|
41
138
|
requestBody: {
|
|
42
139
|
params: {
|
|
43
140
|
resourceID: this.resourceID,
|
|
@@ -53,7 +150,7 @@ class AttachFetcher {
|
|
|
53
150
|
}
|
|
54
151
|
}
|
|
55
152
|
};
|
|
56
|
-
const result = await DataFetcher.get().callServiceBroker(
|
|
153
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
|
|
57
154
|
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 })]);
|
|
58
155
|
}
|
|
59
156
|
catch (error) {
|
|
@@ -62,7 +159,6 @@ class AttachFetcher {
|
|
|
62
159
|
}
|
|
63
160
|
async edit(change) {
|
|
64
161
|
var _a, _b, _c;
|
|
65
|
-
const serviceName = "AnexoSistemaSP.salvar";
|
|
66
162
|
let { updatingFields: fields, record } = change;
|
|
67
163
|
const getFieldValue = (fieldValue) => {
|
|
68
164
|
if (fields[fieldValue] !== undefined)
|
|
@@ -76,7 +172,7 @@ class AttachFetcher {
|
|
|
76
172
|
try {
|
|
77
173
|
this.validateFields(fields);
|
|
78
174
|
const reqBody = {
|
|
79
|
-
serviceName,
|
|
175
|
+
serviceName: SERVICE.save,
|
|
80
176
|
requestBody: {
|
|
81
177
|
params: {
|
|
82
178
|
resourceID: this.resourceID,
|
|
@@ -94,7 +190,7 @@ class AttachFetcher {
|
|
|
94
190
|
}
|
|
95
191
|
}
|
|
96
192
|
};
|
|
97
|
-
const result = await DataFetcher.get().callServiceBroker(
|
|
193
|
+
const result = await DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
|
|
98
194
|
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 })]);
|
|
99
195
|
}
|
|
100
196
|
catch (error) {
|
|
@@ -103,10 +199,9 @@ class AttachFetcher {
|
|
|
103
199
|
}
|
|
104
200
|
delete(record) {
|
|
105
201
|
var _a;
|
|
106
|
-
const serviceName = "AnexoSistemaSP.excluir";
|
|
107
202
|
const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
|
|
108
203
|
const reqBody = {
|
|
109
|
-
serviceName,
|
|
204
|
+
serviceName: SERVICE.delete,
|
|
110
205
|
requestBody: {
|
|
111
206
|
paramsDelete: {
|
|
112
207
|
keyAttach: record.CHAVEARQUIVO,
|
|
@@ -118,17 +213,16 @@ class AttachFetcher {
|
|
|
118
213
|
}
|
|
119
214
|
};
|
|
120
215
|
return new Promise((resolve, reject) => {
|
|
121
|
-
DataFetcher.get().callServiceBroker(
|
|
216
|
+
DataFetcher.get().callServiceBroker(SERVICE.delete, JSON.stringify(reqBody))
|
|
122
217
|
.then(result => resolve(result))
|
|
123
218
|
.catch(error => reject(error));
|
|
124
219
|
});
|
|
125
220
|
}
|
|
126
221
|
getDownloadKey(record) {
|
|
127
222
|
var _a;
|
|
128
|
-
const serviceName = "AnexoSistemaSP.baixar";
|
|
129
223
|
const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
|
|
130
224
|
const reqBody = {
|
|
131
|
-
serviceName,
|
|
225
|
+
serviceName: SERVICE.download,
|
|
132
226
|
requestBody: {
|
|
133
227
|
paramsDown: {
|
|
134
228
|
nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
|
|
@@ -140,34 +234,37 @@ class AttachFetcher {
|
|
|
140
234
|
}
|
|
141
235
|
};
|
|
142
236
|
return new Promise((resolve, reject) => {
|
|
143
|
-
DataFetcher.get().callServiceBroker(
|
|
237
|
+
DataFetcher.get().callServiceBroker(SERVICE.download, JSON.stringify(reqBody))
|
|
144
238
|
.then(result => resolve(result))
|
|
145
239
|
.catch(error => reject(error));
|
|
146
240
|
});
|
|
147
241
|
}
|
|
148
242
|
}
|
|
149
243
|
|
|
150
|
-
class
|
|
244
|
+
class AnexoSistemaDataUnitFactory {
|
|
151
245
|
constructor(entityName, getMessage) {
|
|
152
246
|
this.entityName = entityName;
|
|
153
247
|
this.getMessage = getMessage;
|
|
154
248
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
155
249
|
}
|
|
156
|
-
initLoaders(dataUnit,
|
|
250
|
+
initLoaders(dataUnit, fetcher, onSuccess) {
|
|
157
251
|
if (!this.loader)
|
|
158
252
|
this.loader = dataUnit.dataLoader;
|
|
159
253
|
dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
|
|
160
|
-
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes,
|
|
254
|
+
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
|
|
161
255
|
if (recordIds.length)
|
|
162
256
|
onSuccess();
|
|
163
257
|
return recordIds;
|
|
164
258
|
});
|
|
165
|
-
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids,
|
|
259
|
+
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
|
|
166
260
|
if (recordIds.length)
|
|
167
261
|
onSuccess();
|
|
168
262
|
return recordIds;
|
|
169
263
|
});
|
|
170
264
|
}
|
|
265
|
+
metadataLoader(dataUnit) {
|
|
266
|
+
throw new Error("Method not implemented.");
|
|
267
|
+
}
|
|
171
268
|
dataLoader(dataUnit, request) {
|
|
172
269
|
return new Promise(resolve => {
|
|
173
270
|
this.loader(dataUnit, request).then(response => {
|
|
@@ -183,11 +280,11 @@ class AttachmentDataUnitBuilder {
|
|
|
183
280
|
});
|
|
184
281
|
});
|
|
185
282
|
}
|
|
186
|
-
saveLoader(changes,
|
|
283
|
+
saveLoader(changes, fetcher) {
|
|
187
284
|
return new Promise((resolve) => {
|
|
188
285
|
var _a;
|
|
189
286
|
const change = Array.isArray(changes) ? changes[0] : {};
|
|
190
|
-
const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ?
|
|
287
|
+
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);
|
|
191
288
|
savePromise(change).then((records) => {
|
|
192
289
|
resolve(records);
|
|
193
290
|
}).catch((error) => {
|
|
@@ -207,11 +304,11 @@ class AttachmentDataUnitBuilder {
|
|
|
207
304
|
});
|
|
208
305
|
});
|
|
209
306
|
}
|
|
210
|
-
removeLoader(dataUnit, ids,
|
|
307
|
+
removeLoader(dataUnit, ids, fetcher) {
|
|
211
308
|
return new Promise((resolve) => {
|
|
212
309
|
const { records } = dataUnit.getSelectionInfo();
|
|
213
310
|
const recordToDelete = records[0];
|
|
214
|
-
|
|
311
|
+
fetcher.delete(recordToDelete).then(() => {
|
|
215
312
|
PreloadManager.removeRecords(dataUnit, [recordToDelete]);
|
|
216
313
|
return resolve(ids);
|
|
217
314
|
});
|
|
@@ -252,6 +349,175 @@ class AttachmentDataUnitBuilder {
|
|
|
252
349
|
}
|
|
253
350
|
}
|
|
254
351
|
|
|
352
|
+
const application$1 = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
353
|
+
const getMessage$1 = (key) => {
|
|
354
|
+
var _a, _b;
|
|
355
|
+
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);
|
|
356
|
+
};
|
|
357
|
+
const attachCrudConfig = {
|
|
358
|
+
grid: {
|
|
359
|
+
columns: [
|
|
360
|
+
{ name: "CODATA", orderIndex: 0, width: 0 },
|
|
361
|
+
{ name: "DESCRICAO", orderIndex: 1, width: 0 },
|
|
362
|
+
{ name: "ARQUIVO", orderIndex: 2, width: 0 },
|
|
363
|
+
{ name: "DTALTER", orderIndex: 3, width: 0 },
|
|
364
|
+
{ name: "USUARIO", orderIndex: 4, width: 0 },
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
form: {
|
|
368
|
+
emptyConfig: false,
|
|
369
|
+
fields: [
|
|
370
|
+
{
|
|
371
|
+
name: "DESCRICAO",
|
|
372
|
+
label: getMessage$1("snkAttach.attachMetadata.lblDescription"),
|
|
373
|
+
visible: true,
|
|
374
|
+
readOnly: false,
|
|
375
|
+
required: true,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: "CAMINHO_ARQUIVO",
|
|
379
|
+
label: getMessage$1("snkAttach.attachMetadata.lblFile"),
|
|
380
|
+
visible: true,
|
|
381
|
+
readOnly: false,
|
|
382
|
+
required: true,
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
const attachFetcherMetadataBuilder = {
|
|
388
|
+
name: "Attach",
|
|
389
|
+
label: "Attach List",
|
|
390
|
+
fields: [
|
|
391
|
+
{ name: "CODATA", label: getMessage$1("snkAttach.attachMetadata.lblCode"), dataType: DataType.TEXT },
|
|
392
|
+
{ name: "DESCRICAO", label: getMessage$1("snkAttach.attachMetadata.lblDescription"), dataType: DataType.TEXT },
|
|
393
|
+
{ name: "ARQUIVO", label: getMessage$1("snkAttach.attachMetadata.lblFileOrLink"), dataType: DataType.TEXT },
|
|
394
|
+
{ name: "USUARIO", label: getMessage$1("snkAttach.attachMetadata.lblUser"), dataType: DataType.TEXT },
|
|
395
|
+
{ name: "DTALTER", label: getMessage$1("snkAttach.attachMetadata.lblDate"), dataType: DataType.TEXT },
|
|
396
|
+
{
|
|
397
|
+
name: "CAMINHO_ARQUIVO",
|
|
398
|
+
label: getMessage$1("snkAttach.attachMetadata.lblFileUpload"),
|
|
399
|
+
dataType: DataType.OBJECT,
|
|
400
|
+
userInterface: UserInterface.FILE,
|
|
401
|
+
readOnly: false,
|
|
402
|
+
required: true,
|
|
403
|
+
visible: true,
|
|
404
|
+
properties: {
|
|
405
|
+
subTitle: getMessage$1("snkAttach.attachMetadata.lblSubTitle"),
|
|
406
|
+
MAX_FILES: 1,
|
|
407
|
+
STORAGESTRATEGY: "SESSION",
|
|
408
|
+
INTERNAL_FILENAME: "Attach.upload",
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
],
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const SERVICE_LOAD = "Attach.load";
|
|
415
|
+
class AttachFetcherDataUnitFactory {
|
|
416
|
+
constructor(getMessage) {
|
|
417
|
+
this.getMessage = getMessage;
|
|
418
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
419
|
+
}
|
|
420
|
+
initLoaders(dataUnit, fetcher, onSuccess) {
|
|
421
|
+
dataUnit.metadataLoader = (dataUnit) => this.metadataLoader(dataUnit);
|
|
422
|
+
dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
|
|
423
|
+
dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
|
|
424
|
+
if (recordIds.length)
|
|
425
|
+
onSuccess();
|
|
426
|
+
return recordIds;
|
|
427
|
+
});
|
|
428
|
+
dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
|
|
429
|
+
if (recordIds.length)
|
|
430
|
+
onSuccess();
|
|
431
|
+
return recordIds;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
metadataLoader(_) {
|
|
435
|
+
return Promise.resolve(attachFetcherMetadataBuilder);
|
|
436
|
+
}
|
|
437
|
+
async dataLoader(_, request) {
|
|
438
|
+
if (!request.source) {
|
|
439
|
+
return Promise.resolve({ records: [] });
|
|
440
|
+
}
|
|
441
|
+
const criteria = {
|
|
442
|
+
criteria: {
|
|
443
|
+
codata: request.source,
|
|
444
|
+
tipoAnexo: "N"
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const applicationDataFetcher = await this._application.getDataFetcher();
|
|
448
|
+
const { anexos: { anexo = [] } } = await applicationDataFetcher.callServiceBroker(SERVICE_LOAD, JSON.stringify(criteria));
|
|
449
|
+
const records = [];
|
|
450
|
+
anexo.forEach((param) => {
|
|
451
|
+
records.push(Object.assign({ __record__id__: StringUtils.generateUUID(), CAMINHO_ARQUIVO: [{
|
|
452
|
+
name: param === null || param === void 0 ? void 0 : param.ARQUIVO,
|
|
453
|
+
}] }, param));
|
|
454
|
+
});
|
|
455
|
+
return Promise.resolve({ records });
|
|
456
|
+
}
|
|
457
|
+
saveLoader(changes, fetcher) {
|
|
458
|
+
return new Promise((resolve) => {
|
|
459
|
+
const change = Array.isArray(changes) ? changes[0] : {};
|
|
460
|
+
fetcher.save(change)
|
|
461
|
+
.then(resolve)
|
|
462
|
+
.catch((error) => {
|
|
463
|
+
if (error.message === SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED) {
|
|
464
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.title'), this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.message'));
|
|
465
|
+
return resolve([]);
|
|
466
|
+
}
|
|
467
|
+
if (error.message === SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
|
|
468
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
|
|
469
|
+
return resolve([]);
|
|
470
|
+
}
|
|
471
|
+
if (error.message === SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
|
|
472
|
+
this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
|
|
473
|
+
return resolve([]);
|
|
474
|
+
}
|
|
475
|
+
if (error.message) {
|
|
476
|
+
this._application.error((error.title || error.name), error.message);
|
|
477
|
+
return resolve([]);
|
|
478
|
+
}
|
|
479
|
+
resolve([]);
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
removeLoader(dataUnit, ids, fetcher) {
|
|
484
|
+
return new Promise((resolve) => {
|
|
485
|
+
dataUnit.getSelectionInfo().records.forEach(async (record) => {
|
|
486
|
+
this._application.hasAccess(AutorizationType.REMOVE)
|
|
487
|
+
.then(async (hasAccess) => {
|
|
488
|
+
if (hasAccess) {
|
|
489
|
+
await fetcher.delete(record);
|
|
490
|
+
resolve(ids);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
getFilters() {
|
|
497
|
+
throw new Error('Method not implemented.');
|
|
498
|
+
}
|
|
499
|
+
getInterceptions(dataUnit, action, crudRef) {
|
|
500
|
+
return new Promise((resolve) => {
|
|
501
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
502
|
+
if (!dataUnit.isDirty())
|
|
503
|
+
return resolve(action);
|
|
504
|
+
return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
|
|
505
|
+
if (cancellationConfirmed) {
|
|
506
|
+
crudRef.goToView(VIEW_MODE.GRID);
|
|
507
|
+
return resolve(action);
|
|
508
|
+
}
|
|
509
|
+
return resolve(undefined);
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
if (action.type === Action.DATA_SAVED) {
|
|
513
|
+
dataUnit.loadData();
|
|
514
|
+
return resolve(action);
|
|
515
|
+
}
|
|
516
|
+
resolve(action);
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
255
521
|
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
256
522
|
const getMessage = (key) => {
|
|
257
523
|
var _a, _b;
|
|
@@ -298,7 +564,7 @@ const buildTaskBarManager = () => {
|
|
|
298
564
|
};
|
|
299
565
|
};
|
|
300
566
|
|
|
301
|
-
const
|
|
567
|
+
const anexoSistemaCrudConfig = {
|
|
302
568
|
grid: {
|
|
303
569
|
columns: [
|
|
304
570
|
{ name: "ARQUIVOOULINK", orderIndex: 0, width: 0 },
|
|
@@ -345,40 +611,60 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
345
611
|
super();
|
|
346
612
|
this.__registerHost();
|
|
347
613
|
this.back = createEvent(this, "back", 7);
|
|
348
|
-
this.handleTaskbarClick = ({ detail: taskbar }) => {
|
|
614
|
+
this.handleTaskbarClick = async ({ detail: taskbar }) => {
|
|
349
615
|
if (["DOWNLOAD", "LINK"].includes(taskbar))
|
|
350
|
-
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
|
+
}
|
|
351
620
|
};
|
|
352
621
|
this.handleBack = () => {
|
|
353
|
-
this.
|
|
622
|
+
this._currentDataUnit.cancelEdition().then((cancelationConfirmed) => {
|
|
354
623
|
if (cancelationConfirmed)
|
|
355
624
|
this.back.emit();
|
|
356
625
|
});
|
|
357
626
|
};
|
|
358
627
|
this.handleFinish = () => {
|
|
359
|
-
if (!this.
|
|
628
|
+
if (!this._currentDataUnit.isDirty())
|
|
360
629
|
return this.back.emit();
|
|
361
|
-
this.
|
|
630
|
+
this._currentDataUnit.saveData().then(() => {
|
|
362
631
|
this.showFinishedToast();
|
|
363
632
|
this.back.emit();
|
|
364
633
|
});
|
|
365
634
|
};
|
|
635
|
+
this.fetcherType = "AnexoSistema";
|
|
636
|
+
this.fetcher = undefined;
|
|
637
|
+
this.dataUnit = undefined;
|
|
638
|
+
this.dataUnitBuilder = undefined;
|
|
366
639
|
this.registerKey = undefined;
|
|
367
640
|
this.entityName = undefined;
|
|
368
641
|
this.messagesBuilder = undefined;
|
|
369
|
-
this.
|
|
642
|
+
this._currentFetcher = undefined;
|
|
643
|
+
this._currentDataUnit = undefined;
|
|
370
644
|
this.crudConfig = undefined;
|
|
371
645
|
}
|
|
372
646
|
registerKeyWatcher(newRegisterKey, oldRegisterKey) {
|
|
373
|
-
var _a;
|
|
374
|
-
if (this.
|
|
647
|
+
var _a, _b, _c, _d;
|
|
648
|
+
if (this._currentDataUnit == null) {
|
|
375
649
|
this.loadAttachmentDataUnit();
|
|
376
650
|
}
|
|
377
651
|
if (oldRegisterKey !== newRegisterKey) {
|
|
378
652
|
this.returnToGridMode();
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
});
|
|
382
668
|
}
|
|
383
669
|
}
|
|
384
670
|
/**
|
|
@@ -401,44 +687,90 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
401
687
|
window.open(`${selectedRecord.LINK}`);
|
|
402
688
|
return;
|
|
403
689
|
}
|
|
404
|
-
this.
|
|
405
|
-
|
|
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" : ""}`);
|
|
406
699
|
});
|
|
407
700
|
}
|
|
408
701
|
returnToGridMode() {
|
|
409
|
-
|
|
702
|
+
var _a;
|
|
703
|
+
(_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.clearSelection();
|
|
410
704
|
if (this._crudElement)
|
|
411
705
|
this._crudElement.goToView(VIEW_MODE.GRID);
|
|
412
706
|
}
|
|
413
707
|
loadAttachmentDataUnit() {
|
|
414
|
-
var _a;
|
|
415
708
|
try {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
});
|
|
429
|
-
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
|
+
}
|
|
430
721
|
}
|
|
431
722
|
catch (error) {
|
|
432
723
|
throw new Error('There was an error while creating the data unit');
|
|
433
724
|
}
|
|
434
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
|
+
}
|
|
435
767
|
disableEditFieldsNotInForm() {
|
|
436
768
|
var _a;
|
|
437
769
|
(_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid.columns.forEach(column => {
|
|
438
770
|
var _a;
|
|
439
771
|
const fieldName = column.name;
|
|
440
772
|
if (!((_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.form.fields.some(field => field.name === fieldName))) {
|
|
441
|
-
this.
|
|
773
|
+
this._currentDataUnit.disableField(fieldName);
|
|
442
774
|
}
|
|
443
775
|
});
|
|
444
776
|
}
|
|
@@ -446,25 +778,30 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
446
778
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
447
779
|
}
|
|
448
780
|
componentWillRender() {
|
|
449
|
-
if (this.
|
|
781
|
+
if (this._currentDataUnit == null) {
|
|
450
782
|
this.loadAttachmentDataUnit();
|
|
451
783
|
}
|
|
452
784
|
}
|
|
453
785
|
render() {
|
|
454
786
|
var _a, _b;
|
|
455
|
-
if (!this.
|
|
787
|
+
if (!this._currentDataUnit)
|
|
456
788
|
return null;
|
|
457
|
-
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")))))))));
|
|
458
790
|
}
|
|
459
791
|
static get watchers() { return {
|
|
460
792
|
"registerKey": ["registerKeyWatcher"]
|
|
461
793
|
}; }
|
|
462
794
|
static get style() { return snkAttachCss; }
|
|
463
795
|
}, [2, "snk-attach", {
|
|
796
|
+
"fetcherType": [1, "fetcher-type"],
|
|
797
|
+
"fetcher": [16],
|
|
798
|
+
"dataUnit": [16],
|
|
799
|
+
"dataUnitBuilder": [16],
|
|
464
800
|
"registerKey": [1, "register-key"],
|
|
465
801
|
"entityName": [1, "entity-name"],
|
|
466
802
|
"messagesBuilder": [1040],
|
|
467
|
-
"
|
|
803
|
+
"_currentFetcher": [32],
|
|
804
|
+
"_currentDataUnit": [32],
|
|
468
805
|
"crudConfig": [32]
|
|
469
806
|
}]);
|
|
470
807
|
function defineCustomElement() {
|