@sankhyalabs/sankhyablocks 8.15.0-dev.53 → 8.15.0-dev.55
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-8d4e9d53.js → ConfigStorage-085c7117.js} +11 -12
- package/dist/cjs/{SnkMultiSelectionListDataSource-d15f7aac.js → IExporterProvider-955812ad.js} +52 -5
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-33995e92.js → SnkFormConfigManager-8986431f.js} +2 -2
- package/dist/cjs/{auth-fetcher-bb8e9ae4.js → auth-fetcher-eddaf17f.js} +1 -1
- package/dist/cjs/{DataFetcher-99f0f6ed.js → form-config-fetcher-cdd644a7.js} +251 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-bdbbe9ac.js → pesquisa-fetcher-6e934fb5.js} +30 -16
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +8 -9
- package/dist/cjs/snk-application.cjs.entry.js +22 -23
- package/dist/cjs/snk-attach.cjs.entry.js +12 -13
- package/dist/cjs/snk-crud.cjs.entry.js +4 -5
- package/dist/cjs/snk-data-exporter.cjs.entry.js +195 -78
- package/dist/cjs/{snk-data-unit-41c29713.js → snk-data-unit-abd2113f.js} +2 -37
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +6 -7
- package/dist/cjs/snk-filter-bar.cjs.entry.js +2 -3
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +2 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -2
- package/dist/cjs/snk-form.cjs.entry.js +3 -4
- package/dist/cjs/snk-grid.cjs.entry.js +65 -102
- package/dist/cjs/{snk-guides-viewer-a8dd24a3.js → snk-guides-viewer-4e8b517b.js} +4 -5
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +6 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +115 -32
- package/dist/cjs/snk-taskbar.cjs.entry.js +3 -2
- package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-d9392685.js} +2 -2
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +90 -0
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +68 -0
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +48 -1
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +53 -0
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +35 -45
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
- package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +3 -42
- package/dist/collection/components/snk-grid/snk-grid.js +3 -94
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +81 -9
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +8 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
- package/dist/components/ConfigStorage.js +1 -2
- package/dist/components/{field-search.js → IExporterProvider.js} +52 -7
- package/dist/components/ISave.js +42 -0
- package/dist/components/dataunit-fetcher.js +18 -4
- package/dist/components/form-config-fetcher.js +7022 -3
- package/dist/components/index2.js +198 -33
- package/dist/components/snk-actions-button2.js +3 -12
- package/dist/components/snk-application2.js +1 -1
- package/dist/components/snk-attach2.js +3 -4
- package/dist/components/snk-crud.js +3 -4
- package/dist/components/snk-data-exporter2.js +192 -79
- package/dist/components/snk-data-unit2.js +41 -39
- package/dist/components/snk-detail-view2.js +4 -5
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-grid2.js +63 -100
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +101 -16
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{ConfigStorage-6e241cd7.js → ConfigStorage-cc3f3dd3.js} +1 -2
- package/dist/esm/{SnkMultiSelectionListDataSource-7084f3b3.js → IExporterProvider-6ebf47ab.js} +52 -6
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-7a4e678f.js → SnkFormConfigManager-7edda7eb.js} +2 -2
- package/dist/esm/{auth-fetcher-8ec448b0.js → auth-fetcher-11dd9cae.js} +1 -1
- package/dist/esm/{DataFetcher-a650ae58.js → form-config-fetcher-13cd3285.js} +250 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-96d2f351.js → pesquisa-fetcher-4eed47c6.js} +18 -4
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +3 -4
- package/dist/esm/snk-application.entry.js +4 -5
- package/dist/esm/snk-attach.entry.js +4 -5
- package/dist/esm/snk-crud.entry.js +4 -5
- package/dist/esm/snk-data-exporter.entry.js +195 -78
- package/dist/esm/{snk-data-unit-de1d140d.js → snk-data-unit-29eba11a.js} +3 -38
- package/dist/esm/snk-data-unit.entry.js +2 -1
- package/dist/esm/snk-detail-view.entry.js +6 -7
- package/dist/esm/snk-filter-bar.entry.js +2 -3
- package/dist/esm/snk-filter-modal-item.entry.js +2 -3
- package/dist/esm/snk-form-config.entry.js +1 -2
- package/dist/esm/snk-form.entry.js +3 -4
- package/dist/esm/snk-grid.entry.js +63 -100
- package/dist/esm/{snk-guides-viewer-131e9660.js → snk-guides-viewer-2742a9db.js} +4 -5
- package/dist/esm/snk-guides-viewer.entry.js +6 -7
- package/dist/esm/snk-personalized-filter.entry.js +2 -3
- package/dist/esm/snk-simple-crud.entry.js +102 -19
- package/dist/esm/snk-taskbar.entry.js +3 -2
- package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-ad766858.js} +2 -2
- package/dist/sankhyablocks/p-07825198.js +1 -0
- package/dist/sankhyablocks/p-1d9d07b4.entry.js +1 -0
- package/dist/sankhyablocks/p-201e5588.entry.js +1 -0
- package/dist/sankhyablocks/p-33a6728e.js +26 -0
- package/dist/sankhyablocks/p-37afb96a.js +1 -0
- package/dist/sankhyablocks/p-411fe937.entry.js +1 -0
- package/dist/sankhyablocks/p-44d52fc6.js +1 -0
- package/dist/sankhyablocks/p-4ddf7add.entry.js +1 -0
- package/dist/sankhyablocks/p-7b797d8f.entry.js +1 -0
- package/dist/sankhyablocks/p-87cb937d.js +65 -0
- package/dist/sankhyablocks/{p-0624f62d.js → p-8a4c4b54.js} +6 -6
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/{p-125bb902.js → p-99b51d06.js} +1 -1
- package/dist/sankhyablocks/p-9ee96756.entry.js +1 -0
- package/dist/sankhyablocks/p-a4c94582.entry.js +1 -0
- package/dist/sankhyablocks/p-bf209f48.entry.js +1 -0
- package/dist/sankhyablocks/p-c2f3ebf3.entry.js +1 -0
- package/dist/sankhyablocks/p-c3c0ad0b.entry.js +1 -0
- package/dist/sankhyablocks/{p-619c5f6f.entry.js → p-c801a38a.entry.js} +2 -2
- package/dist/sankhyablocks/p-cfb98f51.entry.js +1 -0
- package/dist/sankhyablocks/{p-efeca7ba.js → p-d24c9dc6.js} +1 -1
- package/dist/sankhyablocks/p-e4225e8b.entry.js +1 -0
- package/dist/sankhyablocks/p-edd9dd1c.entry.js +1 -0
- package/dist/sankhyablocks/p-fa84e72f.entry.js +1 -0
- package/dist/sankhyablocks/p-fd44c905.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +13 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +11 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +21 -4
- package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
- package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +3 -1
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +0 -3
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +14 -2
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +16 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/form-config-fetcher-d73f4449.js +0 -256
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
- package/dist/components/DataFetcher.js +0 -7023
- package/dist/components/index3.js +0 -199
- package/dist/esm/form-config-fetcher-765b8498.js +0 -253
- package/dist/sankhyablocks/p-004c356e.js +0 -26
- package/dist/sankhyablocks/p-075bba4c.entry.js +0 -1
- package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
- package/dist/sankhyablocks/p-103c5956.entry.js +0 -1
- package/dist/sankhyablocks/p-1048bd26.entry.js +0 -1
- package/dist/sankhyablocks/p-13ae1a89.entry.js +0 -1
- package/dist/sankhyablocks/p-24ed6ad6.entry.js +0 -1
- package/dist/sankhyablocks/p-34a7f2ab.js +0 -65
- package/dist/sankhyablocks/p-52c8e589.js +0 -1
- package/dist/sankhyablocks/p-5833cff9.js +0 -1
- package/dist/sankhyablocks/p-5a2e016a.entry.js +0 -1
- package/dist/sankhyablocks/p-6f560924.entry.js +0 -1
- package/dist/sankhyablocks/p-8967fa78.js +0 -1
- package/dist/sankhyablocks/p-9b1beac5.entry.js +0 -1
- package/dist/sankhyablocks/p-a87149e4.entry.js +0 -1
- package/dist/sankhyablocks/p-ac77949b.entry.js +0 -1
- package/dist/sankhyablocks/p-b10b9934.entry.js +0 -1
- package/dist/sankhyablocks/p-be75153c.js +0 -1
- package/dist/sankhyablocks/p-bf39bdb8.entry.js +0 -1
- package/dist/sankhyablocks/p-f7d0fab9.entry.js +0 -1
- package/dist/sankhyablocks/p-f7d9d148.entry.js +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
- /package/dist/sankhyablocks/{p-ae4fc9a9.js → p-61dd89eb.js} +0 -0
package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
import { UserInterface } from "@sankhyalabs/core";
|
2
|
+
import { DataFetcher } from "../../../lib";
|
3
|
+
export default class ClientSideExporterStrategy {
|
4
|
+
constructor(provider) {
|
5
|
+
this._provider = provider;
|
6
|
+
}
|
7
|
+
async executeExport(resolveProps) {
|
8
|
+
const { methodName, titleGrid } = resolveProps;
|
9
|
+
const records = await this._provider.getRecords();
|
10
|
+
const columns = await this._provider.getColumnsMetadata();
|
11
|
+
const [serviceName, processor] = this.getExecutor(methodName);
|
12
|
+
const payload = {
|
13
|
+
serviceName,
|
14
|
+
requestBody: {
|
15
|
+
grid: {
|
16
|
+
titleGrid,
|
17
|
+
columns: this.buildColumnsObject(columns),
|
18
|
+
rows: this.buildRowsObject(columns, records),
|
19
|
+
customOptions: { xlsxExtension: false }
|
20
|
+
}
|
21
|
+
}
|
22
|
+
};
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
DataFetcher.get()
|
25
|
+
.callServiceBroker(serviceName, payload)
|
26
|
+
.then(result => resolve(processor(result)))
|
27
|
+
.catch(error => reject(error));
|
28
|
+
});
|
29
|
+
}
|
30
|
+
getExecutor(methodName) {
|
31
|
+
if (methodName === "exportToPDF") {
|
32
|
+
return [
|
33
|
+
"GridPDFBuilderSP.buildPDFFromJson",
|
34
|
+
responseBody => ({
|
35
|
+
fileSessionKey: responseBody.chavePDF.valor,
|
36
|
+
canPrint: responseBody.permiteImprimir.valor === "S",
|
37
|
+
canExport: responseBody.permiteExportar.valor === "S",
|
38
|
+
canSendEmail: responseBody.canSendEmail.valor === "S",
|
39
|
+
useAppPrint: true
|
40
|
+
})
|
41
|
+
];
|
42
|
+
}
|
43
|
+
return [
|
44
|
+
"GridXLSBuilderSP.buildXLSFromJson",
|
45
|
+
responseBody => ({
|
46
|
+
fileSessionKey: responseBody.chaveXLS.valor,
|
47
|
+
canPrint: false,
|
48
|
+
canExport: false,
|
49
|
+
useAppPrint: false,
|
50
|
+
canSendEmail: false
|
51
|
+
})
|
52
|
+
];
|
53
|
+
}
|
54
|
+
buildColumnsObject(columns) {
|
55
|
+
return {
|
56
|
+
column: columns.map((column, index) => {
|
57
|
+
const { label, id, width, userInterface } = column;
|
58
|
+
return Object.assign({ index: index + 1, id,
|
59
|
+
label,
|
60
|
+
width, presentationType: "P" }, (TYPE_MAP[userInterface] || { type: "S", align: "left" }));
|
61
|
+
})
|
62
|
+
};
|
63
|
+
}
|
64
|
+
buildRowsObject(columns, records) {
|
65
|
+
return {
|
66
|
+
row: records.map(rawRecord => {
|
67
|
+
const record = {};
|
68
|
+
columns.forEach((column, index) => record["c" + (index + 1)] = { $: this.formatValue(rawRecord, column) });
|
69
|
+
return record;
|
70
|
+
})
|
71
|
+
};
|
72
|
+
}
|
73
|
+
formatValue(record, column) {
|
74
|
+
if (this._provider.formatValue != undefined) {
|
75
|
+
return this._provider.formatValue(record, column);
|
76
|
+
}
|
77
|
+
return record[column.id] || "";
|
78
|
+
}
|
79
|
+
}
|
80
|
+
class FormatedRecord {
|
81
|
+
}
|
82
|
+
const TYPE_MAP = {
|
83
|
+
[UserInterface.DATE]: { type: "D", align: "center" },
|
84
|
+
[UserInterface.DATETIME]: { type: "H", align: "center" },
|
85
|
+
[UserInterface.TIME]: { type: "I", align: "right" },
|
86
|
+
[UserInterface.ELAPSEDTIME]: { type: "I", align: "right" },
|
87
|
+
[UserInterface.DECIMALNUMBER]: { type: "F", align: "right" },
|
88
|
+
[UserInterface.INTEGERNUMBER]: { type: "I", align: "right" },
|
89
|
+
[UserInterface.SEARCH]: { type: "S", align: "right" }
|
90
|
+
};
|
package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
2
|
+
var t = {};
|
3
|
+
for (var p in s)
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
5
|
+
t[p] = s[p];
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
9
|
+
t[p[i]] = s[p[i]];
|
10
|
+
}
|
11
|
+
return t;
|
12
|
+
};
|
13
|
+
import { ApplicationContext, ObjectUtils } from "@sankhyalabs/core";
|
14
|
+
import { DataFetcher } from '../../../lib/http/data-fetcher/DataFetcher';
|
15
|
+
import { DataExporterOption } from "../../../lib/@types";
|
16
|
+
export default class ServerSideExporterStrategy {
|
17
|
+
constructor(provider) {
|
18
|
+
this._provider = provider;
|
19
|
+
}
|
20
|
+
async getParams(resolveProps) {
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
22
|
+
const filters = (_b = (_a = this._provider).getFilters) === null || _b === void 0 ? void 0 : _b.call(_a);
|
23
|
+
const columns = await this._provider.getColumnsMetadata();
|
24
|
+
const sort = (_d = (_c = this._provider).getOrders) === null || _d === void 0 ? void 0 : _d.call(_c);
|
25
|
+
const resourceURI = (_f = (_e = this._provider).getResourceURI) === null || _f === void 0 ? void 0 : _f.call(_e);
|
26
|
+
const selectedIDs = this._provider.getSelectedIDs();
|
27
|
+
const option = resolveProps.exportOption;
|
28
|
+
const currentPageOptions = [
|
29
|
+
DataExporterOption.EXPORT_PAGE_TO_PDF,
|
30
|
+
DataExporterOption.EXPORT_PAGE_TO_XLS
|
31
|
+
];
|
32
|
+
delete resolveProps.exportOption;
|
33
|
+
let params = Object.assign({ filters,
|
34
|
+
columns,
|
35
|
+
sort,
|
36
|
+
resourceURI, selectedIDs: selectedIDs.slice(0, this._provider.getExportLimit()) }, resolveProps);
|
37
|
+
if (currentPageOptions.includes(option) || resolveProps.type == "page") {
|
38
|
+
const offset = this._provider.getOffset();
|
39
|
+
const limit = this._provider.getPageSize();
|
40
|
+
params = Object.assign(Object.assign({}, params), { offset,
|
41
|
+
limit, selectedIDs: [] });
|
42
|
+
}
|
43
|
+
else if (resolveProps.type == "all") {
|
44
|
+
params = Object.assign(Object.assign({}, params), { offset: 0, limit: this._provider.getExportLimit(), selectedIDs: [] });
|
45
|
+
}
|
46
|
+
return Promise.resolve(params);
|
47
|
+
}
|
48
|
+
async executeExport(resolveProps) {
|
49
|
+
const _a = await this.getParams(resolveProps), { methodName } = _a, requestBody = __rest(_a, ["methodName"]);
|
50
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
51
|
+
const serviceName = `${application.getModuleName()}@DataExporterSPBean.${methodName}`;
|
52
|
+
const payload = { serviceName, requestBody };
|
53
|
+
return new Promise((resolve, reject) => {
|
54
|
+
DataFetcher.get()
|
55
|
+
.callServiceBroker(serviceName, ObjectUtils.objectToString(payload))
|
56
|
+
.then(result => resolve(this.getFormatResponse(result)))
|
57
|
+
.catch(error => reject(error));
|
58
|
+
});
|
59
|
+
}
|
60
|
+
getFormatResponse(result) {
|
61
|
+
var _a;
|
62
|
+
const response = (_a = result === null || result === void 0 ? void 0 : result.json) === null || _a === void 0 ? void 0 : _a.$;
|
63
|
+
if (response == undefined) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
return ObjectUtils.stringToObject(response);
|
67
|
+
}
|
68
|
+
}
|
@@ -1 +1,48 @@
|
|
1
|
-
|
1
|
+
import { UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
2
|
+
import { DataType } from '@sankhyalabs/core';
|
3
|
+
export class CommonsExporter {
|
4
|
+
constructor(dataUnit, grid) {
|
5
|
+
this.dataUnit = dataUnit;
|
6
|
+
this.grid = grid;
|
7
|
+
}
|
8
|
+
async getColumnsMetadata() {
|
9
|
+
var _a;
|
10
|
+
const columnsState = await ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getColumnsState());
|
11
|
+
return this.buildColumnsMetadata(columnsState);
|
12
|
+
}
|
13
|
+
buildColumnsMetadata(gridColumns) {
|
14
|
+
const columnsMetadata = [];
|
15
|
+
gridColumns === null || gridColumns === void 0 ? void 0 : gridColumns.forEach((column) => {
|
16
|
+
var _a, _b;
|
17
|
+
/**
|
18
|
+
* TODO: Analisar e criar uma melhor forma de tratar essa validação do "RECDESP".
|
19
|
+
*/
|
20
|
+
if (column.hidden && column.name !== "RECDESP") {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
const fieldData = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(column.name);
|
24
|
+
const columnData = {
|
25
|
+
label: column.label,
|
26
|
+
id: column.name,
|
27
|
+
width: (fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface) === UserInterface.SEARCH ? 30 : column.width,
|
28
|
+
type: fieldData === null || fieldData === void 0 ? void 0 : fieldData.dataType,
|
29
|
+
userInterface: fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface
|
30
|
+
};
|
31
|
+
columnsMetadata.push(columnData);
|
32
|
+
if (((_b = fieldData === null || fieldData === void 0 ? void 0 : fieldData.properties) === null || _b === void 0 ? void 0 : _b.DESCRIPTIONFIELD) != undefined) {
|
33
|
+
const mergedFrom = fieldData.properties.mergedFrom;
|
34
|
+
const descriptionField = `${fieldData.properties.ENTITYNAME}.${fieldData.properties.DESCRIPTIONFIELD}`;
|
35
|
+
const descriptionColumn = {
|
36
|
+
label: fieldData.properties.DESCRIPTIONENTITY,
|
37
|
+
id: `${mergedFrom ? (mergedFrom + ".") : ""}${descriptionField}`,
|
38
|
+
width: 200,
|
39
|
+
type: DataType.TEXT,
|
40
|
+
userInterface: UserInterface.LONGTEXT,
|
41
|
+
descriptionFrom: fieldData.name
|
42
|
+
};
|
43
|
+
columnsMetadata.push(descriptionColumn);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
return columnsMetadata || [];
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { CommonsExporter } from "../interfaces/IExporterProvider";
|
2
|
+
import { UserInterface } from "@sankhyalabs/core";
|
3
|
+
import { getSelectedIDs } from "../utils/RecordIDUtils";
|
4
|
+
import { DataExporterOption } from "../../../lib/@types";
|
5
|
+
export default class ClientSideExporterProvider extends CommonsExporter {
|
6
|
+
getSelectedNumber() {
|
7
|
+
return this.dataUnit.getSelectionInfo().length;
|
8
|
+
}
|
9
|
+
getTotalRecords() {
|
10
|
+
var _a, _b, _c;
|
11
|
+
const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
|
12
|
+
return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
|
13
|
+
}
|
14
|
+
getSelectedIDs() {
|
15
|
+
return getSelectedIDs(this.dataUnit);
|
16
|
+
}
|
17
|
+
getRecordID() {
|
18
|
+
var _a, _b, _c;
|
19
|
+
return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
|
20
|
+
}
|
21
|
+
async getRecords() {
|
22
|
+
if (this.dataUnit.records.length === 0) {
|
23
|
+
return Promise.resolve([]);
|
24
|
+
}
|
25
|
+
const selectionInfo = this.dataUnit.getSelectionInfo();
|
26
|
+
const records = selectionInfo.isEmpty() || selectionInfo.isAllRecords() ? await selectionInfo.getAllRecords() : selectionInfo.records;
|
27
|
+
return Promise.resolve(records == undefined ? [] : records);
|
28
|
+
}
|
29
|
+
getHiddenOptions() {
|
30
|
+
return [
|
31
|
+
DataExporterOption.EXPORT_BY_EMAIL,
|
32
|
+
DataExporterOption.EXPORT_PDF_TO_EMAIL,
|
33
|
+
DataExporterOption.EXPORT_XLS_TO_EMAIL,
|
34
|
+
DataExporterOption.EXPORT_PAGE_TO_PDF,
|
35
|
+
DataExporterOption.EXPORT_PAGE_TO_XLS
|
36
|
+
];
|
37
|
+
}
|
38
|
+
formatValue(record, column) {
|
39
|
+
const { id, descriptionFrom } = column;
|
40
|
+
const value = record[descriptionFrom || id];
|
41
|
+
if (value == undefined) {
|
42
|
+
return "";
|
43
|
+
}
|
44
|
+
if (descriptionFrom != undefined) {
|
45
|
+
return value.label;
|
46
|
+
}
|
47
|
+
const fieldDescriptor = this.dataUnit.getField(id);
|
48
|
+
if (fieldDescriptor.userInterface === UserInterface.SEARCH) {
|
49
|
+
return value.value;
|
50
|
+
}
|
51
|
+
return this.dataUnit.getFormattedValue(id, value);
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { CommonsExporter } from "../interfaces/IExporterProvider";
|
2
|
+
import { getSelectedIDs } from "../utils/RecordIDUtils";
|
3
|
+
export default class ServerSideExporterProvider extends CommonsExporter {
|
4
|
+
getFilters() {
|
5
|
+
var _a;
|
6
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getAppliedFilters();
|
7
|
+
}
|
8
|
+
getOrders() {
|
9
|
+
var _a;
|
10
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSort();
|
11
|
+
}
|
12
|
+
getResourceURI() {
|
13
|
+
var _a;
|
14
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name;
|
15
|
+
}
|
16
|
+
getSelectedNumber() {
|
17
|
+
return this.dataUnit.getSelectionInfo().length;
|
18
|
+
}
|
19
|
+
getTotalRecords() {
|
20
|
+
var _a, _b, _c;
|
21
|
+
const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
|
22
|
+
return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
|
23
|
+
}
|
24
|
+
getSelectedIDs() {
|
25
|
+
return getSelectedIDs(this.dataUnit);
|
26
|
+
}
|
27
|
+
getOffset() {
|
28
|
+
return this.getExporterOffset(this.getPaginationInfo());
|
29
|
+
}
|
30
|
+
getPageSize() {
|
31
|
+
var _a;
|
32
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.pageSize;
|
33
|
+
}
|
34
|
+
getExportLimit() {
|
35
|
+
return 5000;
|
36
|
+
}
|
37
|
+
getRecordID() {
|
38
|
+
var _a, _b, _c;
|
39
|
+
return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
|
40
|
+
}
|
41
|
+
getPaginationInfo() {
|
42
|
+
var _a;
|
43
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo();
|
44
|
+
}
|
45
|
+
getExporterOffset(paginationInfo) {
|
46
|
+
if (paginationInfo == undefined) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
const offset = paginationInfo.firstRecord;
|
50
|
+
if (offset > 0) {
|
51
|
+
return (offset - 1);
|
52
|
+
}
|
53
|
+
return offset;
|
54
|
+
}
|
55
|
+
}
|
@@ -4,17 +4,15 @@ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/
|
|
4
4
|
import { ItemBuilder } from './structure/ItemBuilder';
|
5
5
|
import { DataExporterFormat, DataExporterOption, DataExporterType } from '../../lib/@types';
|
6
6
|
import { REPORT_LAUNCHER_RESOURCE_ID } from '../../lib/utils/constants';
|
7
|
-
import fetchDataExporter from '../../lib/http/data-fetcher/fetchers/fetchDataExporter';
|
8
7
|
import fileViewer from '../../lib/utils/fileViewer';
|
9
8
|
import getPersonalizedReports from '../../lib/http/data-fetcher/fetchers/fetchDataExporter/personalized-reports-fetcher';
|
10
9
|
import { SnkDataUnit } from '../snk-data-unit/snk-data-unit';
|
11
|
-
|
10
|
+
import ServerSideExporterStrategy from './exporter-strategy/ServerSideExporterStrategy';
|
11
|
+
import ClientSideExporterStrategy from './exporter-strategy/ClientSideExporterStrategy';
|
12
12
|
export class SnkDataExporter {
|
13
13
|
constructor() {
|
14
14
|
this._selectedNumber = 0;
|
15
15
|
this._customPrefix = "$custom$";
|
16
|
-
this._items = [];
|
17
|
-
this._showDropdown = false;
|
18
16
|
this._releasedToExport = [
|
19
17
|
DataExporterOption.EXPORT_TO_PDF,
|
20
18
|
DataExporterOption.EXPORT_TO_XLS,
|
@@ -24,6 +22,8 @@ export class SnkDataExporter {
|
|
24
22
|
DataExporterOption.EXPORT_PAGE_TO_PDF,
|
25
23
|
DataExporterOption.EXPORT_PAGE_TO_XLS
|
26
24
|
];
|
25
|
+
this._items = [];
|
26
|
+
this._showDropdown = false;
|
27
27
|
this.provider = null;
|
28
28
|
this.messagesBuilder = undefined;
|
29
29
|
}
|
@@ -94,31 +94,7 @@ export class SnkDataExporter {
|
|
94
94
|
if (this.provider == undefined || resolveProps == undefined || callbackResolver == undefined) {
|
95
95
|
return;
|
96
96
|
}
|
97
|
-
|
98
|
-
const columns = await this.provider.getColumnsMetadata();
|
99
|
-
const sort = this.provider.getOrders();
|
100
|
-
const resourceURI = this.provider.getResourceURI();
|
101
|
-
const selectedIDs = this.provider.getSelectedIDs();
|
102
|
-
const option = resolveProps.exportOption;
|
103
|
-
const currentPageOptions = [
|
104
|
-
DataExporterOption.EXPORT_PAGE_TO_PDF,
|
105
|
-
DataExporterOption.EXPORT_PAGE_TO_XLS
|
106
|
-
];
|
107
|
-
delete resolveProps.exportOption;
|
108
|
-
let params = Object.assign({ filters,
|
109
|
-
columns,
|
110
|
-
sort,
|
111
|
-
resourceURI, selectedIDs: selectedIDs.slice(0, LIMIT_PER_EXPORT) }, resolveProps);
|
112
|
-
if (currentPageOptions.includes(option) || resolveProps.type == "page") {
|
113
|
-
const offset = this.provider.getOffset();
|
114
|
-
const limit = this.provider.getLimit();
|
115
|
-
params = Object.assign(Object.assign({}, params), { offset,
|
116
|
-
limit, selectedIDs: [] });
|
117
|
-
}
|
118
|
-
else if (resolveProps.type == "all") {
|
119
|
-
params = Object.assign(Object.assign({}, params), { offset: 0, limit: LIMIT_PER_EXPORT, selectedIDs: [] });
|
120
|
-
}
|
121
|
-
fetchDataExporter(params)
|
97
|
+
this.getExporterStrategy().executeExport(resolveProps)
|
122
98
|
.then((result) => callbackResolver(result))
|
123
99
|
.catch((exception) => {
|
124
100
|
console.error(exception);
|
@@ -126,6 +102,9 @@ export class SnkDataExporter {
|
|
126
102
|
ApplicationUtils.error(title || this.getMessage("snkDataExporter.message.exportError"), statusMessage || message || this.getMessage("snkDataExporter.message.unknownFailure"));
|
127
103
|
});
|
128
104
|
}
|
105
|
+
getExporterStrategy() {
|
106
|
+
return this.provider.getRecords == undefined ? new ServerSideExporterStrategy(this.provider) : new ClientSideExporterStrategy(this.provider);
|
107
|
+
}
|
129
108
|
getOptionKey(option) {
|
130
109
|
return Object.keys(DataExporterOption)
|
131
110
|
.find((key) => {
|
@@ -133,7 +112,7 @@ export class SnkDataExporter {
|
|
133
112
|
});
|
134
113
|
}
|
135
114
|
dispatchExporter(option) {
|
136
|
-
var _a;
|
115
|
+
var _a, _b, _c;
|
137
116
|
const optionKey = this.getOptionKey(option);
|
138
117
|
const fileType = (_a = DataExporterType[optionKey]) !== null && _a !== void 0 ? _a : DataExporterType.EXPORT_TO_PDF;
|
139
118
|
const isDownload = DataExporterType[optionKey] === DataExporterType.EXPORT_TO_XLS;
|
@@ -142,7 +121,7 @@ export class SnkDataExporter {
|
|
142
121
|
fileName: this._appLabel,
|
143
122
|
titleGrid: this._appLabel,
|
144
123
|
exportOption: option,
|
145
|
-
limit:
|
124
|
+
limit: (_c = (_b = this.provider) === null || _b === void 0 ? void 0 : _b.getExportLimit) === null || _c === void 0 ? void 0 : _c.call(_b)
|
146
125
|
};
|
147
126
|
this.resolveExporter(params, (response) => {
|
148
127
|
fileViewer(Object.assign(Object.assign({}, response), { fileType,
|
@@ -150,7 +129,7 @@ export class SnkDataExporter {
|
|
150
129
|
});
|
151
130
|
}
|
152
131
|
async processExporter(evt) {
|
153
|
-
var _a, _b, _c, _d;
|
132
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
154
133
|
const item = evt === null || evt === void 0 ? void 0 : evt.detail;
|
155
134
|
const exportCurrentPageOptions = [DataExporterOption.EXPORT_PAGE_TO_PDF, DataExporterOption.EXPORT_PAGE_TO_XLS];
|
156
135
|
const isCustomReport = (_a = item === null || item === void 0 ? void 0 : item.id) === null || _a === void 0 ? void 0 : _a.includes(this._customPrefix);
|
@@ -158,18 +137,19 @@ export class SnkDataExporter {
|
|
158
137
|
return;
|
159
138
|
const selectedRecords = (_b = this.provider) === null || _b === void 0 ? void 0 : _b.getSelectedIDs();
|
160
139
|
const totalRecords = (_c = this.provider) === null || _c === void 0 ? void 0 : _c.getTotalRecords();
|
161
|
-
const totalPerPage = (_d = this.provider) === null || _d === void 0 ? void 0 : _d.
|
140
|
+
const totalPerPage = (_e = (_d = this.provider) === null || _d === void 0 ? void 0 : _d.getPageSize) === null || _e === void 0 ? void 0 : _e.call(_d);
|
141
|
+
const exportLimit = (_g = (_f = this.provider) === null || _f === void 0 ? void 0 : _f.getExportLimit) === null || _g === void 0 ? void 0 : _g.call(_f);
|
162
142
|
let limitExceeded = false;
|
163
|
-
if ((exportCurrentPageOptions.includes(item === null || item === void 0 ? void 0 : item.id) && totalPerPage <=
|
143
|
+
if ((exportCurrentPageOptions.includes(item === null || item === void 0 ? void 0 : item.id) && totalPerPage <= exportLimit) || isCustomReport) {
|
164
144
|
limitExceeded = false;
|
165
145
|
}
|
166
146
|
else if (selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) {
|
167
|
-
limitExceeded = selectedRecords.length >
|
147
|
+
limitExceeded = selectedRecords.length > exportLimit;
|
168
148
|
}
|
169
|
-
else if (totalRecords >
|
149
|
+
else if (totalRecords > exportLimit)
|
170
150
|
limitExceeded = true;
|
171
151
|
if (limitExceeded) {
|
172
|
-
const formattedLimit =
|
152
|
+
const formattedLimit = exportLimit.toLocaleString('pt-BR', { minimumFractionDigits: 0 });
|
173
153
|
const limitModalMessages = {
|
174
154
|
title: this.getMessage("snkDataExporter.limitExceeded.title"),
|
175
155
|
description: `
|
@@ -194,7 +174,7 @@ export class SnkDataExporter {
|
|
194
174
|
this._showDropdown = false;
|
195
175
|
return;
|
196
176
|
}
|
197
|
-
if (!this.
|
177
|
+
if (!this.getFilteredReleasedToExport().includes(item === null || item === void 0 ? void 0 : item.id)) {
|
198
178
|
return;
|
199
179
|
}
|
200
180
|
if (item.id === DataExporterOption.EXPORT_BY_EMAIL) {
|
@@ -205,9 +185,20 @@ export class SnkDataExporter {
|
|
205
185
|
}
|
206
186
|
this._showDropdown = false;
|
207
187
|
}
|
188
|
+
getFilteredReleasedToExport() {
|
189
|
+
var _a, _b;
|
190
|
+
if (this.provider == undefined) {
|
191
|
+
return this._releasedToExport;
|
192
|
+
}
|
193
|
+
const hiddenOptions = (_b = (_a = this.provider).getHiddenOptions) === null || _b === void 0 ? void 0 : _b.call(_a);
|
194
|
+
if (hiddenOptions == undefined) {
|
195
|
+
return this._releasedToExport;
|
196
|
+
}
|
197
|
+
return this._releasedToExport.filter(option => !hiddenOptions.includes(option));
|
198
|
+
}
|
208
199
|
loadItems() {
|
209
200
|
const items = [];
|
210
|
-
this.
|
201
|
+
this.getFilteredReleasedToExport()
|
211
202
|
.forEach((option) => {
|
212
203
|
var _a;
|
213
204
|
(_a = this._itemBuilder) === null || _a === void 0 ? void 0 : _a.setExportOption(option, items);
|
@@ -215,8 +206,8 @@ export class SnkDataExporter {
|
|
215
206
|
this.loadPersonalizedItems(items);
|
216
207
|
}
|
217
208
|
async loadPersonalizedItems(items) {
|
218
|
-
var _a;
|
219
|
-
const recordID = (_a = this.provider) === null || _a === void 0 ? void 0 : _a.getRecordID();
|
209
|
+
var _a, _b;
|
210
|
+
const recordID = (_b = (_a = this.provider) === null || _a === void 0 ? void 0 : _a.getRecordID) === null || _b === void 0 ? void 0 : _b.call(_a);
|
220
211
|
if (recordID == undefined) {
|
221
212
|
this._items = items;
|
222
213
|
return;
|
@@ -232,10 +223,10 @@ export class SnkDataExporter {
|
|
232
223
|
this._items = items;
|
233
224
|
}
|
234
225
|
openPersonalizedReports(option) {
|
235
|
-
var _a;
|
226
|
+
var _a, _b;
|
236
227
|
const pkObject = [];
|
237
228
|
const appId = (option === null || option === void 0 ? void 0 : option.replace(this._customPrefix, "")) || "";
|
238
|
-
(_a = this.provider) === null || _a === void 0 ? void 0 : _a.getSelectedIDs().forEach(({ name, type, value }, index) => {
|
229
|
+
(_b = (_a = this.provider) === null || _a === void 0 ? void 0 : _a.getSelectedIDs) === null || _b === void 0 ? void 0 : _b.call(_a).forEach(({ name, type, value }, index) => {
|
239
230
|
const fields = {};
|
240
231
|
fields['fields'] = [];
|
241
232
|
// Se for o primeiro elemento, adiciona essa primeira PK
|
@@ -371,8 +362,7 @@ export class SnkDataExporter {
|
|
371
362
|
static get states() {
|
372
363
|
return {
|
373
364
|
"_items": {},
|
374
|
-
"_showDropdown": {}
|
375
|
-
"_releasedToExport": {}
|
365
|
+
"_showDropdown": {}
|
376
366
|
};
|
377
367
|
}
|
378
368
|
static get elementRef() { return "_element"; }
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { DataType, StringUtils } from "@sankhyalabs/core";
|
2
|
+
export const testMetadata = {
|
3
|
+
name: 'metadataName',
|
4
|
+
label: 'metadataLabel',
|
5
|
+
fields: [{
|
6
|
+
name: 'TESTFIELD',
|
7
|
+
label: 'Test label',
|
8
|
+
dataType: DataType.TEXT,
|
9
|
+
}]
|
10
|
+
};
|
11
|
+
export const recordId1 = StringUtils.generateUUID();
|
12
|
+
export const recordId2 = StringUtils.generateUUID();
|
13
|
+
export const testRecords = [
|
14
|
+
{
|
15
|
+
__record__id__: recordId1,
|
16
|
+
TESTFIELD: 'TESTVALUE'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
__record__id__: recordId2,
|
20
|
+
TESTFIELD: 'TESTVALUE2'
|
21
|
+
},
|
22
|
+
];
|
23
|
+
export const dataFetcherPDFResponse = {
|
24
|
+
chavePDF: {
|
25
|
+
valor: 'KEYPDF'
|
26
|
+
},
|
27
|
+
permiteImprimir: {
|
28
|
+
valor: "S"
|
29
|
+
},
|
30
|
+
permiteExportar: {
|
31
|
+
valor: "S"
|
32
|
+
},
|
33
|
+
canSendEmail: {
|
34
|
+
valor: "S"
|
35
|
+
},
|
36
|
+
};
|
37
|
+
export const dataFetcherXLSResponse = {
|
38
|
+
chaveXLS: {
|
39
|
+
valor: 'KEYXLS'
|
40
|
+
},
|
41
|
+
};
|
42
|
+
export const exportPDFParams = {
|
43
|
+
methodName: 'exportToPDF',
|
44
|
+
fileName: '',
|
45
|
+
titleGrid: '',
|
46
|
+
};
|
47
|
+
export const exportXLSParams = {
|
48
|
+
methodName: 'exportToXLS',
|
49
|
+
fileName: '',
|
50
|
+
titleGrid: '',
|
51
|
+
};
|
52
|
+
export const serviceNamePDF = "GridPDFBuilderSP.buildPDFFromJson";
|
53
|
+
export const serviceNameXLS = "GridXLSBuilderSP.buildXLSFromJson";
|
54
|
+
export function buildExpectedResponse({ serviceName, titleGrid, value, align = 'left', type = 'S' }) {
|
55
|
+
return {
|
56
|
+
serviceName: serviceName,
|
57
|
+
requestBody: {
|
58
|
+
grid: {
|
59
|
+
titleGrid: titleGrid,
|
60
|
+
columns: {
|
61
|
+
column: [
|
62
|
+
{
|
63
|
+
align: align,
|
64
|
+
id: "TESTFIELD",
|
65
|
+
index: 1,
|
66
|
+
label: "Test label",
|
67
|
+
presentationType: "P",
|
68
|
+
type: type,
|
69
|
+
width: undefined,
|
70
|
+
}
|
71
|
+
]
|
72
|
+
},
|
73
|
+
customOptions: {
|
74
|
+
xlsxExtension: false
|
75
|
+
},
|
76
|
+
rows: {
|
77
|
+
row: [
|
78
|
+
{
|
79
|
+
c1: {
|
80
|
+
$: value
|
81
|
+
}
|
82
|
+
}
|
83
|
+
]
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
};
|
88
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { DataType, JSUtils } from "@sankhyalabs/core";
|
2
|
+
export const getSelectedIDs = (dataUnit) => {
|
3
|
+
const selectionInfo = dataUnit.getSelectionInfo();
|
4
|
+
if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
|
5
|
+
return [];
|
6
|
+
}
|
7
|
+
const selectedRecordsIDsInfo = [];
|
8
|
+
const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
|
9
|
+
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
|
10
|
+
selectedRecords.forEach(recordId => {
|
11
|
+
if (!dataUnit.isNewRecord(recordId)) {
|
12
|
+
/*
|
13
|
+
Esse if foi necessário para tratar corretamente o ID
|
14
|
+
do record quando está sendo utilizado no modo standAlone
|
15
|
+
isso não faz a exportação da grid funcionar no modo standAlone
|
16
|
+
mas deixa de causar erro nas oprações de CRUD.
|
17
|
+
*/
|
18
|
+
if (!JSUtils.isBase64(recordId)) {
|
19
|
+
selectedRecordsIDsInfo.push({
|
20
|
+
name: "__record__id__",
|
21
|
+
type: DataType.TEXT,
|
22
|
+
value: recordId
|
23
|
+
});
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
const revertBase64ToObject = JSON.parse(window.atob(recordId));
|
27
|
+
Object.entries(revertBase64ToObject).forEach(([name, value]) => {
|
28
|
+
const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
|
29
|
+
if (metadataField == undefined) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
|
33
|
+
});
|
34
|
+
}
|
35
|
+
});
|
36
|
+
}
|
37
|
+
return selectedRecordsIDsInfo;
|
38
|
+
};
|