@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-61886.0 → 0.0.0-bugfix-dev-KB-65826.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/{IExporterProvider-0c814e9a.js → IExporterProvider-c78cb1b8.js} +3 -3
- package/dist/cjs/{SnkMessageBuilder-4a95fe86.js → SnkMessageBuilder-722b104e.js} +2 -0
- package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-data-exporter.cjs.entry.js +114 -11
- package/dist/cjs/{snk-data-unit-5be491da.js → snk-data-unit-56babf28.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid.cjs.entry.js +3 -3
- package/dist/cjs/{snk-guides-viewer-5d5f0f25.js → snk-guides-viewer-9867335b.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -3
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -2
- package/dist/cjs/{taskbar-elements-d9392685.js → taskbar-elements-9ad1f9c0.js} +1 -1
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +7 -1
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +7 -1
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +2 -2
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +23 -6
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
- package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +13 -0
- package/dist/collection/lib/@types/index.js +5 -0
- package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
- package/dist/components/IExporterProvider.js +2 -2
- package/dist/components/ISave.js +6 -1
- package/dist/components/SnkMessageBuilder.js +2 -0
- package/dist/components/snk-data-exporter2.js +112 -9
- package/dist/esm/{IExporterProvider-c0194569.js → IExporterProvider-343272b3.js} +3 -3
- package/dist/esm/{SnkMessageBuilder-3a767111.js → SnkMessageBuilder-89925609.js} +2 -0
- package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
- package/dist/esm/snk-actions-button_4.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +2 -2
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-data-exporter.entry.js +114 -11
- package/dist/esm/{snk-data-unit-9110a07b.js → snk-data-unit-56b5efc4.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-grid.entry.js +3 -3
- package/dist/esm/{snk-guides-viewer-ef8c4eec.js → snk-guides-viewer-daab6211.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +3 -3
- package/dist/esm/snk-taskbar.entry.js +2 -2
- package/dist/esm/{taskbar-elements-ad766858.js → taskbar-elements-d59867f1.js} +1 -1
- package/dist/sankhyablocks/{p-9b1c0824.entry.js → p-0f4de966.entry.js} +1 -1
- package/dist/sankhyablocks/{p-2ac8bd11.entry.js → p-11865302.entry.js} +1 -1
- package/dist/sankhyablocks/{p-039c7148.entry.js → p-2d649237.entry.js} +1 -1
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/{p-a64baa0f.entry.js → p-4f72727a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-04821c60.entry.js → p-550fee49.entry.js} +1 -1
- package/dist/sankhyablocks/{p-d26365ad.js → p-63a04cfb.js} +1 -1
- package/dist/sankhyablocks/{p-8322ccdb.entry.js → p-66c223ac.entry.js} +1 -1
- package/dist/sankhyablocks/p-7a337364.js +1 -0
- package/dist/sankhyablocks/{p-61dd89eb.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/{p-543537ca.js → p-88a77075.js} +1 -1
- package/dist/sankhyablocks/{p-3f1efb97.entry.js → p-8a5910a7.entry.js} +1 -1
- package/dist/sankhyablocks/{p-babe7665.js → p-9e99a92a.js} +1 -1
- package/dist/sankhyablocks/{p-5646ee8c.entry.js → p-b1ee6b27.entry.js} +1 -1
- package/dist/sankhyablocks/{p-294df368.entry.js → p-b2b1f1c5.entry.js} +1 -1
- package/dist/sankhyablocks/p-d98faa55.entry.js +1 -0
- package/dist/sankhyablocks/{p-58687027.entry.js → p-f2809746.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +1 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +1 -0
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +1 -0
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
- package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +2 -0
- package/dist/types/lib/@types/index.d.ts +5 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-4ce73e88.js +0 -1
- package/dist/sankhyablocks/p-70a6e662.entry.js +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
|
|
2
2
|
import { ApplicationContext, ObjectUtils, UserInterface, DataType, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
-
import { D as DataExporterOption, a as
|
|
4
|
+
import { D as DataExporterOption, a as DataExporterType, b as DataExporterFormat } from './index-3aa4977a.js';
|
|
5
5
|
import { R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-8457af36.js';
|
|
6
6
|
import { D as DataFetcher } from './DataFetcher-c1baf61d.js';
|
|
7
|
-
import { S as SnkDataUnit } from './snk-data-unit-
|
|
7
|
+
import { S as SnkDataUnit } from './snk-data-unit-56b5efc4.js';
|
|
8
8
|
import './pesquisa-fetcher-03c8f919.js';
|
|
9
9
|
import './ISave-d8c8bc59.js';
|
|
10
10
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
@@ -13,7 +13,7 @@ import './dataunit-fetcher-3fbf9d12.js';
|
|
|
13
13
|
import './filter-item-type.enum-d45e026f.js';
|
|
14
14
|
import './form-config-fetcher-30fb808f.js';
|
|
15
15
|
import './PrintUtils-3e4ff0f5.js';
|
|
16
|
-
import './SnkMessageBuilder-
|
|
16
|
+
import './SnkMessageBuilder-89925609.js';
|
|
17
17
|
import './RecordIDUtils-87d02110.js';
|
|
18
18
|
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
|
19
19
|
import '@sankhyalabs/core/dist/utils/SortingUtils';
|
|
@@ -39,6 +39,9 @@ class ItemBuilder {
|
|
|
39
39
|
items.push(this.getExportToXLS(groupName));
|
|
40
40
|
}
|
|
41
41
|
this.setExportCurrentPage(option, items);
|
|
42
|
+
if (this._selectedNumber > 0) {
|
|
43
|
+
this.setExportAllRecords(option, items);
|
|
44
|
+
}
|
|
42
45
|
this.setExportByEmail(option, items);
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
@@ -69,6 +72,34 @@ class ItemBuilder {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Método responsável por inserir os itens de exportação para todos os registros.
|
|
77
|
+
* @param option - Nome da opção que será inserida no array.
|
|
78
|
+
* @param items - Array que será alimentado com as opções permitidas.
|
|
79
|
+
*/
|
|
80
|
+
setExportAllRecords(option, items) {
|
|
81
|
+
var _a;
|
|
82
|
+
const pageOptions = [DataExporterOption.EXPORT_ALL_RECORDS_TO_PDF, DataExporterOption.EXPORT_ALL_RECORDS_TO_XLS];
|
|
83
|
+
if (option === DataExporterOption.EXPORT_ALL_RECORDS) {
|
|
84
|
+
items.push(this.getAllRecords());
|
|
85
|
+
}
|
|
86
|
+
if (pageOptions.includes(option)) {
|
|
87
|
+
let item = items.find((item) => item.id === DataExporterOption.EXPORT_ALL_RECORDS);
|
|
88
|
+
if (item == undefined) {
|
|
89
|
+
items.push(this.getAllRecords());
|
|
90
|
+
item = items.find((item) => item.id === DataExporterOption.EXPORT_ALL_RECORDS);
|
|
91
|
+
}
|
|
92
|
+
if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
93
|
+
item.children = [];
|
|
94
|
+
}
|
|
95
|
+
if (option === DataExporterOption.EXPORT_ALL_RECORDS_TO_PDF) {
|
|
96
|
+
item.children.push(this.getExportAllRecordsToPDF());
|
|
97
|
+
}
|
|
98
|
+
if (option === DataExporterOption.EXPORT_ALL_RECORDS_TO_XLS) {
|
|
99
|
+
item.children.push(this.getExportAllRecordsToXLS());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
72
103
|
/**
|
|
73
104
|
* Método responsável por inserir os itens de exportação por e-mail.
|
|
74
105
|
* @param option - Nome da opção que será inserida no array.
|
|
@@ -114,6 +145,17 @@ class ItemBuilder {
|
|
|
114
145
|
group: this._getMessage("snkDataExporter.group.custom")
|
|
115
146
|
};
|
|
116
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Método responsável por capturar o objeto com todos os dados de exportação.
|
|
150
|
+
* @returns Retorna o objeto com todos os dados de exportação.
|
|
151
|
+
*/
|
|
152
|
+
getAllRecords() {
|
|
153
|
+
return {
|
|
154
|
+
id: DataExporterOption.EXPORT_ALL_RECORDS,
|
|
155
|
+
label: this._getMessage("snkDataExporter.label.allRecords"),
|
|
156
|
+
group: this._getMessage("snkDataExporter.group.custom")
|
|
157
|
+
};
|
|
158
|
+
}
|
|
117
159
|
/**
|
|
118
160
|
* Método responsável por capturar o objeto com os dados de exportação personalizada em PDF.
|
|
119
161
|
* @returns Retorna o objeto com os dados de exportação personalizada em PDF.
|
|
@@ -134,6 +176,26 @@ class ItemBuilder {
|
|
|
134
176
|
label: `${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`
|
|
135
177
|
};
|
|
136
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Método responsável por capturar o objeto com todos os dados de exportação em PDF.
|
|
181
|
+
* @returns Retorna o objeto com todos os dados de exportação em PDF.
|
|
182
|
+
*/
|
|
183
|
+
getExportAllRecordsToPDF() {
|
|
184
|
+
return {
|
|
185
|
+
id: DataExporterOption.EXPORT_ALL_RECORDS_TO_PDF,
|
|
186
|
+
label: "PDF (.pdf)"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Método responsável por capturar o objeto com todos os dados de exportação em XLS.
|
|
191
|
+
* @returns Retorna o objeto com todos os dados de exportação em XLS.
|
|
192
|
+
*/
|
|
193
|
+
getExportAllRecordsToXLS() {
|
|
194
|
+
return {
|
|
195
|
+
id: DataExporterOption.EXPORT_ALL_RECORDS_TO_XLS,
|
|
196
|
+
label: `${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
137
199
|
/**
|
|
138
200
|
* Método responsável por capturar o objeto com os dados de exportação por e-mail.
|
|
139
201
|
* @returns Retorna o objeto com os dados de exportação por e-mail.
|
|
@@ -187,6 +249,20 @@ function getFormatResponse(result) {
|
|
|
187
249
|
return ObjectUtils.stringToObject(response);
|
|
188
250
|
}
|
|
189
251
|
|
|
252
|
+
const DOC_MAX_WIDTH = 800;
|
|
253
|
+
function getVisibleColumns(columns) {
|
|
254
|
+
const visibleColumns = [];
|
|
255
|
+
let totalWidth = 0;
|
|
256
|
+
for (const column of columns) {
|
|
257
|
+
totalWidth += column.width;
|
|
258
|
+
if (totalWidth >= DOC_MAX_WIDTH) {
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
visibleColumns.push(column);
|
|
262
|
+
}
|
|
263
|
+
return visibleColumns;
|
|
264
|
+
}
|
|
265
|
+
|
|
190
266
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
191
267
|
var t = {};
|
|
192
268
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -202,10 +278,15 @@ class ServerSideExporterStrategy {
|
|
|
202
278
|
constructor(provider) {
|
|
203
279
|
this._provider = provider;
|
|
204
280
|
}
|
|
281
|
+
async getParsedColumns() {
|
|
282
|
+
const columns = await this._provider.getColumnsMetadata();
|
|
283
|
+
const visibleColumns = getVisibleColumns(columns);
|
|
284
|
+
return visibleColumns;
|
|
285
|
+
}
|
|
205
286
|
async getParams(resolveProps) {
|
|
206
287
|
var _a, _b, _c, _d, _e, _f;
|
|
207
288
|
const filters = (_b = (_a = this._provider).getFilters) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
208
|
-
const columns = await this.
|
|
289
|
+
const columns = await this.getParsedColumns();
|
|
209
290
|
const sort = (_d = (_c = this._provider).getOrders) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
210
291
|
const resourceURI = (_f = (_e = this._provider).getResourceURI) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
211
292
|
const selectedIDs = this._provider.getSelectedIDs();
|
|
@@ -256,10 +337,15 @@ class ClientSideExporterStrategy {
|
|
|
256
337
|
constructor(provider) {
|
|
257
338
|
this._provider = provider;
|
|
258
339
|
}
|
|
340
|
+
async getParsedColumns() {
|
|
341
|
+
const columns = await this._provider.getColumnsMetadata();
|
|
342
|
+
const visibleColumns = getVisibleColumns(columns);
|
|
343
|
+
return visibleColumns;
|
|
344
|
+
}
|
|
259
345
|
async executeExport(resolveProps) {
|
|
260
346
|
const { methodName, titleGrid } = resolveProps;
|
|
261
347
|
const records = await this._provider.getRecords();
|
|
262
|
-
const columns = await this.
|
|
348
|
+
const columns = await this.getParsedColumns();
|
|
263
349
|
const [serviceName, processor] = this.getExecutor(methodName);
|
|
264
350
|
const payload = {
|
|
265
351
|
serviceName,
|
|
@@ -353,7 +439,9 @@ const SnkDataExporter = class {
|
|
|
353
439
|
DataExporterOption.EXPORT_PDF_TO_EMAIL,
|
|
354
440
|
DataExporterOption.EXPORT_XLS_TO_EMAIL,
|
|
355
441
|
DataExporterOption.EXPORT_PAGE_TO_PDF,
|
|
356
|
-
DataExporterOption.EXPORT_PAGE_TO_XLS
|
|
442
|
+
DataExporterOption.EXPORT_PAGE_TO_XLS,
|
|
443
|
+
DataExporterOption.EXPORT_ALL_RECORDS_TO_PDF,
|
|
444
|
+
DataExporterOption.EXPORT_ALL_RECORDS_TO_XLS,
|
|
357
445
|
];
|
|
358
446
|
this._items = [];
|
|
359
447
|
this._showDropdown = false;
|
|
@@ -444,7 +532,16 @@ const SnkDataExporter = class {
|
|
|
444
532
|
return DataExporterOption[key] === option;
|
|
445
533
|
});
|
|
446
534
|
}
|
|
447
|
-
|
|
535
|
+
getExportType(option) {
|
|
536
|
+
if (option === DataExporterOption.EXPORT_ALL_RECORDS_TO_PDF || option === DataExporterOption.EXPORT_ALL_RECORDS_TO_XLS) {
|
|
537
|
+
return 'all';
|
|
538
|
+
}
|
|
539
|
+
if (option === DataExporterOption.EXPORT_PAGE_TO_PDF || option === DataExporterOption.EXPORT_PAGE_TO_XLS) {
|
|
540
|
+
return 'page';
|
|
541
|
+
}
|
|
542
|
+
return 'selection';
|
|
543
|
+
}
|
|
544
|
+
async dispatchExporter(option) {
|
|
448
545
|
var _a, _b, _c;
|
|
449
546
|
const optionKey = this.getOptionKey(option);
|
|
450
547
|
const fileType = (_a = DataExporterType[optionKey]) !== null && _a !== void 0 ? _a : DataExporterType.EXPORT_TO_PDF;
|
|
@@ -454,11 +551,17 @@ const SnkDataExporter = class {
|
|
|
454
551
|
fileName: this._appLabel,
|
|
455
552
|
titleGrid: this._appLabel,
|
|
456
553
|
exportOption: option,
|
|
457
|
-
limit: (_c = (_b = this.provider) === null || _b === void 0 ? void 0 : _b.getExportLimit) === null || _c === void 0 ? void 0 : _c.call(_b)
|
|
554
|
+
limit: (_c = (_b = this.provider) === null || _b === void 0 ? void 0 : _b.getExportLimit) === null || _c === void 0 ? void 0 : _c.call(_b),
|
|
555
|
+
type: this.getExportType(option),
|
|
458
556
|
};
|
|
459
|
-
this.resolveExporter(params, (response) => {
|
|
460
|
-
|
|
461
|
-
|
|
557
|
+
await this.resolveExporter(params, (response) => {
|
|
558
|
+
if (response.canExport || fileType === DataExporterType.EXPORT_TO_PDF) {
|
|
559
|
+
fileViewer(Object.assign(Object.assign({}, response), { fileType,
|
|
560
|
+
isDownload }));
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
ApplicationUtils.error(this.getMessage("snkDataExporter.title.permission"), this.getMessage("snkDataExporter.message.exportPermission"));
|
|
564
|
+
}
|
|
462
565
|
});
|
|
463
566
|
}
|
|
464
567
|
async processExporter(evt) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-a7d3d3f1.js';
|
|
2
2
|
import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
|
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
-
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-
|
|
4
|
+
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-89925609.js';
|
|
5
5
|
import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher-3fbf9d12.js';
|
|
6
6
|
import { g as getSelectedIDs } from './RecordIDUtils-87d02110.js';
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { S as snk_data_unit } from './snk-data-unit-
|
|
1
|
+
export { S as snk_data_unit } from './snk-data-unit-56b5efc4.js';
|
|
2
2
|
import './index-a7d3d3f1.js';
|
|
3
3
|
import '@sankhyalabs/core';
|
|
4
4
|
import '@sankhyalabs/ezui/dist/collection/utils';
|
|
5
|
-
import './SnkMessageBuilder-
|
|
5
|
+
import './SnkMessageBuilder-89925609.js';
|
|
6
6
|
import './dataunit-fetcher-3fbf9d12.js';
|
|
7
7
|
import './DataFetcher-c1baf61d.js';
|
|
8
8
|
import './PrintUtils-3e4ff0f5.js';
|
|
@@ -4,17 +4,17 @@ import { S as SnkFormConfigManager } from './SnkFormConfigManager-5b0d69cd.js';
|
|
|
4
4
|
import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
|
|
5
5
|
import './DataFetcher-c1baf61d.js';
|
|
6
6
|
import './pesquisa-fetcher-03c8f919.js';
|
|
7
|
-
import { P as PresentationMode } from './index-
|
|
7
|
+
import { P as PresentationMode } from './index-3aa4977a.js';
|
|
8
8
|
import './ISave-d8c8bc59.js';
|
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
11
11
|
import './dataunit-fetcher-3fbf9d12.js';
|
|
12
12
|
import './filter-item-type.enum-d45e026f.js';
|
|
13
13
|
import './form-config-fetcher-30fb808f.js';
|
|
14
|
-
import { T as TaskbarElement } from './taskbar-elements-
|
|
14
|
+
import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
|
|
15
15
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
|
16
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
|
17
|
-
import { S as SnkMessageBuilder } from './SnkMessageBuilder-
|
|
16
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-daab6211.js';
|
|
17
|
+
import { S as SnkMessageBuilder } from './SnkMessageBuilder-89925609.js';
|
|
18
18
|
import './ConfigStorage-86187da3.js';
|
|
19
19
|
import './PrintUtils-3e4ff0f5.js';
|
|
20
20
|
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, F as Fragment, g as getElement } from './index-a7d3d3f1.js';
|
|
2
2
|
import { Action, ElementIDUtils, ApplicationContext, StringUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { T as TaskbarElement } from './taskbar-elements-
|
|
3
|
+
import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-86187da3.js';
|
|
5
|
-
import { P as PresentationMode } from './index-
|
|
5
|
+
import { P as PresentationMode } from './index-3aa4977a.js';
|
|
6
6
|
import { T as TaskbarProcessor, o as openFieldSearch, b as buildFieldSearch } from './field-search-efbe307f.js';
|
|
7
7
|
import { s as store } from './index-bdf75557.js';
|
|
8
|
-
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, a as CrudUtils, R as RmPrecisionCustomValueFormatter } from './IExporterProvider-
|
|
8
|
+
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, a as CrudUtils, R as RmPrecisionCustomValueFormatter } from './IExporterProvider-343272b3.js';
|
|
9
9
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
|
10
10
|
import './DataFetcher-c1baf61d.js';
|
|
11
11
|
import './pesquisa-fetcher-03c8f919.js';
|
|
@@ -3,11 +3,11 @@ import { Action, ElementIDUtils } from '@sankhyalabs/core';
|
|
|
3
3
|
import { S as SnkFormConfigManager } from './SnkFormConfigManager-5b0d69cd.js';
|
|
4
4
|
import { buildFormMetadata, FormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
|
|
5
5
|
import { o as openFieldSearch, T as TaskbarProcessor, b as buildFieldSearch } from './field-search-efbe307f.js';
|
|
6
|
-
import { T as TaskbarElement } from './taskbar-elements-
|
|
6
|
+
import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
|
|
7
7
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
|
8
8
|
import './DataFetcher-c1baf61d.js';
|
|
9
9
|
import './pesquisa-fetcher-03c8f919.js';
|
|
10
|
-
import { P as PresentationMode } from './index-
|
|
10
|
+
import { P as PresentationMode } from './index-3aa4977a.js';
|
|
11
11
|
import './ISave-d8c8bc59.js';
|
|
12
12
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
13
13
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as snk_guides_viewer } from './snk-guides-viewer-
|
|
1
|
+
export { S as snk_guides_viewer } from './snk-guides-viewer-daab6211.js';
|
|
2
2
|
import './index-a7d3d3f1.js';
|
|
3
3
|
import '@sankhyalabs/core';
|
|
4
4
|
import './SnkFormConfigManager-5b0d69cd.js';
|
|
@@ -10,8 +10,8 @@ import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
|
10
10
|
import './filter-item-type.enum-d45e026f.js';
|
|
11
11
|
import '@sankhyalabs/ezui/dist/collection/utils/form';
|
|
12
12
|
import './field-search-efbe307f.js';
|
|
13
|
-
import './taskbar-elements-
|
|
14
|
-
import './index-
|
|
13
|
+
import './taskbar-elements-d59867f1.js';
|
|
14
|
+
import './index-3aa4977a.js';
|
|
15
15
|
import './index-bdf75557.js';
|
|
16
16
|
import './constants-8457af36.js';
|
|
17
17
|
import './pesquisa-fetcher-03c8f919.js';
|
|
@@ -2,11 +2,11 @@ import { r as registerInstance, c as createEvent, h, g as getElement } from './i
|
|
|
2
2
|
import { UserInterface, StringUtils, ApplicationContext, ObjectUtils, DataType, JSUtils, FloatingManager, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { CSSVarsUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { d as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants-8457af36.js';
|
|
5
|
-
import { T as TaskbarElement } from './taskbar-elements-
|
|
5
|
+
import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
|
|
6
6
|
import './DataFetcher-c1baf61d.js';
|
|
7
7
|
import './pesquisa-fetcher-03c8f919.js';
|
|
8
|
-
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, R as RmPrecisionCustomValueFormatter, a as CrudUtils } from './IExporterProvider-
|
|
9
|
-
import { D as DataExporterOption, P as PresentationMode } from './index-
|
|
8
|
+
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, R as RmPrecisionCustomValueFormatter, a as CrudUtils } from './IExporterProvider-343272b3.js';
|
|
9
|
+
import { D as DataExporterOption, P as PresentationMode } from './index-3aa4977a.js';
|
|
10
10
|
import './ISave-d8c8bc59.js';
|
|
11
11
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
12
12
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
|
|
2
2
|
import { Action, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { A as AuthorizationConfig } from './AuthorizationConfig-dcbd207a.js';
|
|
4
|
-
import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-
|
|
5
|
-
import { P as PresentationMode } from './index-
|
|
4
|
+
import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-d59867f1.js';
|
|
5
|
+
import { P as PresentationMode } from './index-3aa4977a.js';
|
|
6
6
|
import './index-bdf75557.js';
|
|
7
7
|
|
|
8
8
|
const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,c as s,h as e,g as i}from"./p-d2d301a6.js";import{DateUtils as n,StringUtils as r,ObjectUtils as a,WaitingChangeException as o,WarningException as c,ErrorException as h,KeyboardManager as l,OnboardingUtils as u,DependencyType as p,ArrayUtils as d,SearchUtils as w,ElementIDUtils as m,ApplicationContext as f,DataType as y,ErrorTracking as P}from"@sankhyalabs/core";import{ApplicationUtils as v}from"@sankhyalabs/ezui/dist/collection/utils";import{C as g}from"./p-aff76a53.js";import{d as _,D as A,U as I}from"./p-dc7c9047.js";import{A as S,a as C}from"./p-913a9979.js";import{D as N}from"./p-672302c3.js";import{P as b}from"./p-af8efd95.js";import{S as L}from"./p-
|
|
1
|
+
import{r as t,c as s,h as e,g as i}from"./p-d2d301a6.js";import{DateUtils as n,StringUtils as r,ObjectUtils as a,WaitingChangeException as o,WarningException as c,ErrorException as h,KeyboardManager as l,OnboardingUtils as u,DependencyType as p,ArrayUtils as d,SearchUtils as w,ElementIDUtils as m,ApplicationContext as f,DataType as y,ErrorTracking as P}from"@sankhyalabs/core";import{ApplicationUtils as v}from"@sankhyalabs/ezui/dist/collection/utils";import{C as g}from"./p-aff76a53.js";import{d as _,D as A,U as I}from"./p-dc7c9047.js";import{A as S,a as C}from"./p-913a9979.js";import{D as N}from"./p-672302c3.js";import{P as b}from"./p-af8efd95.js";import{S as L}from"./p-7a337364.js";import"./p-df5451c7.js";import"./p-ff1990ad.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class D{static webConnectionCaller(t,s,e){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,s,e)}}const T=k;function k(t,s){const e=E();return(k=function(t){return e[t-=378]})(t,s)}function E(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(E=function(){return t})()}!function(){const t=k,s=E();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class O{[T(397)](t){const s=T;if(typeof(t=utxt(t[s(390)]))==s(392)&&(t=JSON[s(400)](t)),null==t)throw Error(s(395));const e=new U("S"===t[s(402)]||!0===t[s(402)]);return Array[s(394)](t[s(391)])&&t[s(391)][s(385)]((t=>e.putAccess(t[s(382)],String(t.status)==s(398)))),e}}class U{constructor(t){const s=T;this.isSup=t,this[s(384)]={}}[T(378)](t,s){this[T(384)][t]=s}[T(393)](t){const s=T;if(this[s(402)])return!0;let e=!0;return this[s(384)][s(380)](t)&&(e=this.actions[t]),e}isUserSup(){return this.isSup}}class j{constructor(){this._embeddedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[s,e]=t.split("__=__");this._embeddedParams.set(s,e)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",_.gql`query($name: String!) {
|
|
2
2
|
$queryAlias$: fetchResource(name: $name){
|
|
3
3
|
name
|
|
4
4
|
resource
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{S as snk_guides_viewer}from"./p-
|
|
1
|
+
export{S as snk_guides_viewer}from"./p-63a04cfb.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-060fdb6c.js";import"./p-aff76a53.js";import"./p-df5451c7.js";import"./p-dc7c9047.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-c2495304.js";import"./p-7e7a7473.js";import"./p-30cf616e.js";import"./p-6dc031de.js";import"./p-b0ef4383.js";import"./p-af8efd95.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-672302c3.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnit as l}from"@sankhyalabs/core";import{D as h}from"./p-dc7c9047.js";import"./p-af8efd95.js";import"./p-38289a55.js";import{S as d}from"./p-21749402.js";import{P as c,b as u,c as v,d as m,D as A,I as O}from"./p-672302c3.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{d as p}from"./p-b0ef4383.js";import{A as w}from"./p-913a9979.js";import{T as I}from"./p-61dd89eb.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-6dc031de.js";class _{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(d.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{h.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await h.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await h.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await h.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const S="AnexoSistemaSP.salvar",k="AnexoSistemaSP.excluir",y="AnexoSistemaSP.baixar";class b{constructor(t,i,e){var a;this.entityName=t,this.registerKey=i,this.dataUnitName=e,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(d.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(d.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(a=window.workspace)||void 0===a?void 0:a.resourceID)}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:S,requestBody:{params:{resourceID:this.resourceID,description:a.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await h.get().callServiceBroker(S,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),l=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const d=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:S,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:l?1:0,keySession:null===(a=null==d?void 0:d.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==d?void 0:d.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await h.get().callServiceBroker(S,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==d?void 0:d.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:k,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(k,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:y,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(y,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class f{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(c.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const E=a.getContextValue("__SNK__APPLICATION__"),N=t=>{var i,e;return null===(e=null===(i=null==E?void 0:E.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},g={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},C={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:N("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:N("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:N("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:N("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:N("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class P{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(C)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}let e=u(this._records,t,i.filters);return e=v(e,t,i.sort),Promise.resolve({records:e,paginationInfo:m(e,i.offset,i.limit)})}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===d.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(w.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const T=a.getContextValue("__SNK__APPLICATION__"),L=t=>{var i,e;return null===(e=null===(i=null==T?void 0:T.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},R={DOWNLOAD:{hint:L("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:L("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},x=()=>{const t=[I.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();e.splice(e.indexOf(I.REFRESH),1);const{selectedRecord:a}=i||{},s=(null==a?void 0:a.LINK)?R.LINK:R.DOWNLOAD;e.splice(e.indexOf(I.DIVIDER)+1,0,I.REMOVE,s,I.DIVIDER);const n=Array.from(new Set(e.filter((t=>t!==I.CLONE))));return n.splice(n.indexOf(s)+1,0,I.DIVIDER),n},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},D={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},j=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData())}async initAttach(){var t,i,e,a,s,n;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData());if("Attach"===this.fetcherType&&(null===(a=this.registerKey)||void 0===a?void 0:a.split("_").length)>1)return;await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadMetadata()),await(null===(n=this._currentDataUnit)||void 0===n?void 0:n.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(p.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i,e;this._currentDataUnit=(new A).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnit.metadata||(await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadMetadata()),this.crudConfig=Object.assign({},D)),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()),this.disableEditFieldsNotInForm()}async loadAttach(){var t,i;this._currentFetcher=new _,this._currentDataUnit=new l(O.IN_MEMORY_DATA_UNIT_NAME),this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=Object.assign({},g),null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=Object.assign({},g),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm())}initDataUnitLoaders(){var t,i,e;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnitBuilder=new f(this.entityName,this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new _,this._currentDataUnitBuilder=new P(this.getMessage.bind(this)),null===(e=this._currentDataUnitBuilder)||void 0===e||e.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this._currentDataUnit.disableField(e)}))}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}render(){var t,i;return this._currentDataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:x(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this)},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};j.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{j as snk_attach}
|
|
1
|
+
import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnit as l}from"@sankhyalabs/core";import{D as h}from"./p-dc7c9047.js";import"./p-af8efd95.js";import"./p-30cf616e.js";import{S as d}from"./p-21749402.js";import{P as c,b as u,c as v,d as m,D as A,I as O}from"./p-672302c3.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{d as p}from"./p-b0ef4383.js";import{A as w}from"./p-913a9979.js";import{T as I}from"./p-7e7a7473.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-6dc031de.js";class _{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(d.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{h.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await h.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await h.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await h.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const S="AnexoSistemaSP.salvar",k="AnexoSistemaSP.excluir",y="AnexoSistemaSP.baixar";class b{constructor(t,i,e){var a;this.entityName=t,this.registerKey=i,this.dataUnitName=e,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(d.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(d.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(a=window.workspace)||void 0===a?void 0:a.resourceID)}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:S,requestBody:{params:{resourceID:this.resourceID,description:a.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await h.get().callServiceBroker(S,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),l=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const d=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:S,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:l?1:0,keySession:null===(a=null==d?void 0:d.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==d?void 0:d.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await h.get().callServiceBroker(S,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==d?void 0:d.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:k,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(k,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:y,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(y,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class f{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(c.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const E=a.getContextValue("__SNK__APPLICATION__"),N=t=>{var i,e;return null===(e=null===(i=null==E?void 0:E.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},g={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},C={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:N("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:N("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:N("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:N("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:N("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class P{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(C)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}let e=u(this._records,t,i.filters);return e=v(e,t,i.sort),Promise.resolve({records:e,paginationInfo:m(e,i.offset,i.limit)})}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===d.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(w.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const T=a.getContextValue("__SNK__APPLICATION__"),L=t=>{var i,e;return null===(e=null===(i=null==T?void 0:T.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},R={DOWNLOAD:{hint:L("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:L("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},x=()=>{const t=[I.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();e.splice(e.indexOf(I.REFRESH),1);const{selectedRecord:a}=i||{},s=(null==a?void 0:a.LINK)?R.LINK:R.DOWNLOAD;e.splice(e.indexOf(I.DIVIDER)+1,0,I.REMOVE,s,I.DIVIDER);const n=Array.from(new Set(e.filter((t=>t!==I.CLONE))));return n.splice(n.indexOf(s)+1,0,I.DIVIDER),n},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},D={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},j=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData())}async initAttach(){var t,i,e,a,s,n;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData());if("Attach"===this.fetcherType&&(null===(a=this.registerKey)||void 0===a?void 0:a.split("_").length)>1)return;await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadMetadata()),await(null===(n=this._currentDataUnit)||void 0===n?void 0:n.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(p.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i,e;this._currentDataUnit=(new A).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnit.metadata||(await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadMetadata()),this.crudConfig=Object.assign({},D)),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()),this.disableEditFieldsNotInForm()}async loadAttach(){var t,i;this._currentFetcher=new _,this._currentDataUnit=new l(O.IN_MEMORY_DATA_UNIT_NAME),this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=Object.assign({},g),null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=Object.assign({},g),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm())}initDataUnitLoaders(){var t,i,e;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnitBuilder=new f(this.entityName,this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new _,this._currentDataUnitBuilder=new P(this.getMessage.bind(this)),null===(e=this._currentDataUnitBuilder)||void 0===e||e.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this._currentDataUnit.disableField(e)}))}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}render(){var t,i;return this._currentDataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:x(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this)},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};j.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{j as snk_attach}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o,r,e,t;!function(o){o.PRIMARY="primary",o.SECONDARY="secondary",o.SINGLE_TASKBAR="singleTaskbar"}(o||(o={})),function(o){o.EXPORT_TO_PDF="exportToPDF",o.EXPORT_TO_XLS="exportToXLS",o.EXPORT_CURRENT_PAGE="exportCurrentPage",o.EXPORT_ALL_RECORDS="exportAllRecords",o.EXPORT_PAGE_TO_PDF="exportPageToPDF",o.EXPORT_PAGE_TO_XLS="exportPageToXLS",o.EXPORT_ALL_RECORDS_TO_PDF="exportAllRecordsToPDF",o.EXPORT_ALL_RECORDS_TO_XLS="exportAllRecordsToXLS",o.EXPORT_BY_EMAIL="exportToEmail",o.EXPORT_PDF_TO_EMAIL="exportPDFToEmail",o.EXPORT_XLS_TO_EMAIL="exportXLSToEmail"}(r||(r={})),function(o){o.PDF="exportPDFToEmail",o.XLS="exportXLSToEmail",o.XLSX="exportXLSToEmail"}(e||(e={})),function(o){o.EXPORT_TO_PDF="PDF",o.EXPORT_TO_XLS="XLS",o.EXPORT_PAGE_TO_PDF="PDF",o.EXPORT_PAGE_TO_XLS="XLS",o.EXPORT_ALL_RECORDS_TO_PDF="PDF",o.EXPORT_ALL_RECORDS_TO_XLS="XLS",o.EXPORT_PDF_TO_EMAIL="PDF",o.EXPORT_XLS_TO_EMAIL="XLS"}(t||(t={}));export{r as D,o as P,t as a,e as b}
|