@michalrakus/x-react-web-lib 1.5.1 → 1.7.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/ExportImportParam.d.ts +3 -0
- package/ExportImportParam.js +5 -0
- package/XExportRowsDialog.d.ts +3 -0
- package/XExportRowsDialog.js +5 -0
- package/XFormBaseModif.d.ts +3 -0
- package/XFormBaseModif.js +5 -0
- package/XInputFileList.d.ts +3 -0
- package/XInputFileList.js +5 -0
- package/gulpfile.js +10 -6
- package/lib/administration/XUserBrowse.js +1 -1
- package/lib/administration/XUserForm.d.ts +3 -2
- package/lib/administration/XUserForm.js +7 -2
- package/lib/components/XExportRowsDialog.d.ts +11 -3
- package/lib/components/XExportRowsDialog.js +102 -15
- package/lib/components/XFormBaseModif.d.ts +5 -0
- package/lib/components/XFormBaseModif.js +33 -0
- package/lib/components/XInputFileList.d.ts +35 -0
- package/lib/components/XInputFileList.js +234 -0
- package/lib/components/XLazyDataTable.js +10 -42
- package/lib/components/XUtils.d.ts +2 -1
- package/lib/components/XUtils.js +9 -2
- package/lib/serverApi/ExportImportParam.d.ts +9 -1
- package/lib/serverApi/ExportImportParam.js +9 -1
- package/lib/serverApi/XEntityMetadata.d.ts +3 -0
- package/package.json +1 -1
package/gulpfile.js
CHANGED
|
@@ -13,6 +13,11 @@ function generateApi(cb) {
|
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
|
|
15
15
|
const apiFileList = [
|
|
16
|
+
"./lib/administration/XUserBrowse",
|
|
17
|
+
"./lib/administration/XUserForm",
|
|
18
|
+
"./lib/administration/XBrowseMetaBrowse",
|
|
19
|
+
"./lib/administration/XBrowseMetaForm",
|
|
20
|
+
|
|
16
21
|
"./lib/components/useXToken",
|
|
17
22
|
"./lib/components/XAutoComplete",
|
|
18
23
|
"./lib/components/XAutoCompleteBase",
|
|
@@ -28,8 +33,10 @@ function generateApi(cb) {
|
|
|
28
33
|
"./lib/components/XDropdownForEntity",
|
|
29
34
|
"./lib/components/XEnvVars",
|
|
30
35
|
"./lib/components/XErrors",
|
|
36
|
+
"./lib/components/XExportRowsDialog",
|
|
31
37
|
"./lib/components/XFieldChangeEvent",
|
|
32
38
|
"./lib/components/XFormBase",
|
|
39
|
+
"./lib/components/XFormBaseModif",
|
|
33
40
|
"./lib/components/XFormBaseT",
|
|
34
41
|
"./lib/components/XFormDataTable2",
|
|
35
42
|
"./lib/components/XFormFooter",
|
|
@@ -38,6 +45,7 @@ function generateApi(cb) {
|
|
|
38
45
|
"./lib/components/XInputDate",
|
|
39
46
|
"./lib/components/XInputDecimal",
|
|
40
47
|
"./lib/components/XInputDecimalBase",
|
|
48
|
+
"./lib/components/XInputFileList",
|
|
41
49
|
"./lib/components/XInputText",
|
|
42
50
|
"./lib/components/XInputTextarea",
|
|
43
51
|
"./lib/components/XLazyDataTable",
|
|
@@ -50,13 +58,9 @@ function generateApi(cb) {
|
|
|
50
58
|
"./lib/components/XUtilsConversions",
|
|
51
59
|
"./lib/components/XUtilsMetadata",
|
|
52
60
|
|
|
61
|
+
"./lib/serverApi/ExportImportParam",
|
|
53
62
|
"./lib/serverApi/FindParam",
|
|
54
|
-
"./lib/serverApi/XUtilsCommon"
|
|
55
|
-
|
|
56
|
-
"./lib/administration/XUserBrowse",
|
|
57
|
-
"./lib/administration/XUserForm",
|
|
58
|
-
"./lib/administration/XBrowseMetaBrowse",
|
|
59
|
-
"./lib/administration/XBrowseMetaForm"
|
|
63
|
+
"./lib/serverApi/XUtilsCommon"
|
|
60
64
|
];
|
|
61
65
|
|
|
62
66
|
for (const apiFile of apiFileList) {
|
|
@@ -47,7 +47,7 @@ var XUtils_1 = require("../components/XUtils");
|
|
|
47
47
|
var XUserBrowse = function (props) {
|
|
48
48
|
var onAddRow = function () {
|
|
49
49
|
// openForm pridavame automaticky v XFormNavigator3 pri renderovani komponentu
|
|
50
|
-
props.openForm(react_1.default.createElement(XUserForm_1.XUserForm, { object: { enabled: true } }));
|
|
50
|
+
props.openForm(react_1.default.createElement(XUserForm_1.XUserForm, { object: { enabled: true, version: 0 } }));
|
|
51
51
|
};
|
|
52
52
|
var onEdit = function (selectedRow) {
|
|
53
53
|
// openForm pridavame automaticky v XFormNavigator3 pri renderovani komponentu
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FormProps
|
|
3
|
-
|
|
2
|
+
import { FormProps } from "../components/XFormBase";
|
|
3
|
+
import { XFormBaseModif } from "../components/XFormBaseModif";
|
|
4
|
+
export declare class XUserForm extends XFormBaseModif {
|
|
4
5
|
constructor(props: FormProps);
|
|
5
6
|
componentDidMount(): Promise<void>;
|
|
6
7
|
onClickSave(): Promise<void>;
|
|
@@ -73,6 +73,8 @@ var XUtils_1 = require("../components/XUtils");
|
|
|
73
73
|
var XFormFooter_1 = require("../components/XFormFooter");
|
|
74
74
|
var XCheckbox_1 = require("../components/XCheckbox");
|
|
75
75
|
var XEnvVars_1 = require("../components/XEnvVars");
|
|
76
|
+
var XFormBaseModif_1 = require("../components/XFormBaseModif");
|
|
77
|
+
var XInputDate_1 = require("../components/XInputDate");
|
|
76
78
|
var XUserForm = /** @class */ (function (_super) {
|
|
77
79
|
__extends(XUserForm, _super);
|
|
78
80
|
function XUserForm(props) {
|
|
@@ -138,6 +140,7 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
138
140
|
this.state.object.password = undefined;
|
|
139
141
|
}
|
|
140
142
|
}
|
|
143
|
+
this.preSave(this.state.object);
|
|
141
144
|
_a.label = 1;
|
|
142
145
|
case 1:
|
|
143
146
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -177,7 +180,9 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
177
180
|
react_1.default.createElement(XInputText_1.XInputText, { form: this, field: "username", label: "Username", size: 30, labelStyle: { width: '14rem' }, readOnly: this.state.usernameEnabledReadOnly }),
|
|
178
181
|
react_1.default.createElement(XInputText_1.XInputText, { form: this, field: "name", label: "Name", size: 30, labelStyle: { width: '14rem' } }),
|
|
179
182
|
react_1.default.createElement(XCheckbox_1.XCheckbox, { form: this, field: "enabled", label: "Enabled", labelStyle: { width: '14rem' }, readOnly: this.state.usernameEnabledReadOnly }),
|
|
180
|
-
passwordElems
|
|
183
|
+
passwordElems,
|
|
184
|
+
react_1.default.createElement(XInputDate_1.XInputDate, { form: this, field: "modifDate", label: "Modified at", readOnly: true, labelStyle: { width: '14rem' } }),
|
|
185
|
+
react_1.default.createElement(XInputText_1.XInputText, { form: this, field: "modifXUser.name", label: "Modified by", size: 20, labelStyle: { width: '14rem' } }))),
|
|
181
186
|
react_1.default.createElement(XFormFooter_1.XFormFooter, { form: this })));
|
|
182
187
|
};
|
|
183
188
|
XUserForm = __decorate([
|
|
@@ -185,5 +190,5 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
185
190
|
__metadata("design:paramtypes", [Object])
|
|
186
191
|
], XUserForm);
|
|
187
192
|
return XUserForm;
|
|
188
|
-
}(
|
|
193
|
+
}(XFormBaseModif_1.XFormBaseModif));
|
|
189
194
|
exports.XUserForm = XUserForm;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ExportType, LazyDataTableQueryParam } from "../serverApi/ExportImportParam";
|
|
3
|
+
export interface XExportParams {
|
|
4
|
+
path: string;
|
|
5
|
+
queryParam: LazyDataTableQueryParam | any;
|
|
6
|
+
headers?: string[];
|
|
7
|
+
fileName: string;
|
|
8
|
+
}
|
|
3
9
|
export declare const XExportRowsDialog: (props: {
|
|
4
10
|
dialogOpened: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
hideDialog: () => void;
|
|
12
|
+
rowCount?: number;
|
|
13
|
+
exportTypeOptions?: ExportType[];
|
|
14
|
+
exportParams: XExportParams | (() => XExportParams);
|
|
7
15
|
}) => JSX.Element;
|
|
@@ -22,6 +22,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
25
61
|
var __read = (this && this.__read) || function (o, n) {
|
|
26
62
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
63
|
if (!m) return o;
|
|
@@ -50,22 +86,68 @@ var XButton_1 = require("./XButton");
|
|
|
50
86
|
var XUtils_1 = require("./XUtils");
|
|
51
87
|
var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
52
88
|
var XExportRowsDialog = function (props) {
|
|
53
|
-
var _a;
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
89
|
+
var _a, _b;
|
|
90
|
+
var _c = __read((0, react_1.useState)(ExportImportParam_1.ExportType.Csv), 2), exportType = _c[0], setExportType = _c[1];
|
|
91
|
+
var _d = __read((0, react_1.useState)(true), 2), createHeaderLine = _d[0], setCreateHeaderLine = _d[1];
|
|
92
|
+
var _e = __read((0, react_1.useState)(ExportImportParam_1.CsvSeparator.Semicolon), 2), csvSeparator = _e[0], setCsvSeparator = _e[1];
|
|
93
|
+
var _f = __read((0, react_1.useState)(ExportImportParam_1.CsvDecimalFormat.Comma), 2), decimalFormat = _f[0], setDecimalFormat = _f[1];
|
|
94
|
+
var _g = __read((0, react_1.useState)(ExportImportParam_1.CsvEncoding.Win1250), 2), csvEncoding = _g[0], setCsvEncoding = _g[1];
|
|
58
95
|
// bez tejto metody by pri opetovnom otvoreni dialogu ponechal povodne hodnoty
|
|
59
96
|
var onShow = function () {
|
|
60
97
|
setExportType(ExportImportParam_1.ExportType.Csv);
|
|
61
98
|
setCreateHeaderLine(true); // excel hadze hlasky koli prvemu riadku header-ov
|
|
62
99
|
setCsvSeparator(ExportImportParam_1.CsvSeparator.Semicolon);
|
|
63
100
|
setDecimalFormat(ExportImportParam_1.CsvDecimalFormat.Comma);
|
|
101
|
+
setCsvEncoding(ExportImportParam_1.CsvEncoding.Win1250);
|
|
64
102
|
};
|
|
65
|
-
var onExport = function () {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
103
|
+
var onExport = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
+
var exportParams, csvParam, exportParam, response, e_1, fileExt, fileName, respBlob, url, a;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
// export vykoname az po zatvoreni dialogu - moze dlho trvat a pobezi asynchronne (user zatial moze pracovat s aplikaciou)
|
|
109
|
+
// zavrieme dialog
|
|
110
|
+
props.hideDialog();
|
|
111
|
+
if (typeof props.exportParams === 'function') {
|
|
112
|
+
exportParams = props.exportParams();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
exportParams = props.exportParams;
|
|
116
|
+
}
|
|
117
|
+
csvParam = undefined;
|
|
118
|
+
if (exportType === ExportImportParam_1.ExportType.Csv) {
|
|
119
|
+
csvParam = { useHeaderLine: createHeaderLine, csvSeparator: csvSeparator, csvDecimalFormat: decimalFormat, csvEncoding: csvEncoding };
|
|
120
|
+
if (csvParam.useHeaderLine) {
|
|
121
|
+
csvParam.headers = exportParams.headers;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exportParam = { exportType: exportType, csvParam: csvParam, queryParam: exportParams.queryParam };
|
|
125
|
+
_a.label = 1;
|
|
126
|
+
case 1:
|
|
127
|
+
_a.trys.push([1, 3, , 4]);
|
|
128
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchBasicJson(exportParams.path, exportParam)];
|
|
129
|
+
case 2:
|
|
130
|
+
response = _a.sent();
|
|
131
|
+
return [3 /*break*/, 4];
|
|
132
|
+
case 3:
|
|
133
|
+
e_1 = _a.sent();
|
|
134
|
+
XUtils_1.XUtils.showErrorMessage("Export failed.", e_1);
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
case 4:
|
|
137
|
+
fileExt = exportType;
|
|
138
|
+
fileName = "".concat(exportParams.fileName, ".").concat(fileExt);
|
|
139
|
+
return [4 /*yield*/, response.blob()];
|
|
140
|
+
case 5:
|
|
141
|
+
respBlob = _a.sent();
|
|
142
|
+
url = window.URL.createObjectURL(respBlob);
|
|
143
|
+
a = document.createElement('a');
|
|
144
|
+
a.href = url;
|
|
145
|
+
a.download = fileName;
|
|
146
|
+
a.click();
|
|
147
|
+
return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); };
|
|
69
151
|
var elem = null;
|
|
70
152
|
if (props.dialogOpened) {
|
|
71
153
|
if (exportType === ExportImportParam_1.ExportType.Csv) {
|
|
@@ -78,17 +160,22 @@ var XExportRowsDialog = function (props) {
|
|
|
78
160
|
react_1.default.createElement(dropdown_1.Dropdown, { value: csvSeparator, options: XUtils_1.XUtils.csvSeparatorOptions, onChange: function (e) { return setCsvSeparator(e.value); } })),
|
|
79
161
|
react_1.default.createElement("div", { className: "field grid" },
|
|
80
162
|
react_1.default.createElement("label", { className: "col-fixed", style: { width: '9.3rem' } }, "Decimal format"),
|
|
81
|
-
react_1.default.createElement(dropdown_1.Dropdown, { value: decimalFormat, options: XUtils_1.XUtils.decimalFormatOptions, onChange: function (e) { return setDecimalFormat(e.value); } }))
|
|
163
|
+
react_1.default.createElement(dropdown_1.Dropdown, { value: decimalFormat, options: XUtils_1.XUtils.decimalFormatOptions, onChange: function (e) { return setDecimalFormat(e.value); } })),
|
|
164
|
+
react_1.default.createElement("div", { className: "field grid" },
|
|
165
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '9.3rem' } }, "Encoding"),
|
|
166
|
+
react_1.default.createElement(dropdown_1.Dropdown, { value: csvEncoding, options: XUtils_1.XUtils.csvEncodingOptions, onChange: function (e) { return setCsvEncoding(e.value); } })));
|
|
82
167
|
}
|
|
83
168
|
}
|
|
84
169
|
// poznamka: renderovanie vnutornych komponentov Dialogu sa zavola az po otvoreni dialogu
|
|
85
|
-
return (react_1.default.createElement(dialog_1.Dialog, { visible: props.dialogOpened, onShow: onShow, onHide: function () { return props.
|
|
86
|
-
|
|
87
|
-
react_1.default.createElement("
|
|
88
|
-
|
|
170
|
+
return (react_1.default.createElement(dialog_1.Dialog, { visible: props.dialogOpened, onShow: onShow, onHide: function () { return props.hideDialog(); } },
|
|
171
|
+
props.rowCount ?
|
|
172
|
+
react_1.default.createElement("div", { className: "field grid" },
|
|
173
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '9.3rem' } }, "Row count"),
|
|
174
|
+
react_1.default.createElement(inputtext_1.InputText, { value: (0, XUtilsConversions_1.numberAsUI)((_a = props.rowCount) !== null && _a !== void 0 ? _a : null, 0), readOnly: true }))
|
|
175
|
+
: null,
|
|
89
176
|
react_1.default.createElement("div", { className: "field grid" },
|
|
90
177
|
react_1.default.createElement("label", { className: "col-fixed", style: { width: '9.3rem' } }, "Export type"),
|
|
91
|
-
react_1.default.createElement(dropdown_1.Dropdown, { value: exportType, options: XUtils_1.XUtils.exportTypeOptions, onChange: function (e) { return setExportType(e.value); } })),
|
|
178
|
+
react_1.default.createElement(dropdown_1.Dropdown, { value: exportType, options: (_b = props.exportTypeOptions) !== null && _b !== void 0 ? _b : XUtils_1.XUtils.exportTypeOptions, onChange: function (e) { return setExportType(e.value); } })),
|
|
92
179
|
elem,
|
|
93
180
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
94
181
|
react_1.default.createElement(XButton_1.XButton, { label: "Export", onClick: onExport }))));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.XFormBaseModif = void 0;
|
|
19
|
+
var XFormBase_1 = require("./XFormBase");
|
|
20
|
+
var XUtils_1 = require("./XUtils");
|
|
21
|
+
var XFormBaseModif = /** @class */ (function (_super) {
|
|
22
|
+
__extends(XFormBaseModif, _super);
|
|
23
|
+
function XFormBaseModif() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
+
}
|
|
26
|
+
XFormBaseModif.prototype.preSave = function (object) {
|
|
27
|
+
var _a;
|
|
28
|
+
object.modifDate = new Date();
|
|
29
|
+
object.modifXUser = (_a = XUtils_1.XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser;
|
|
30
|
+
};
|
|
31
|
+
return XFormBaseModif;
|
|
32
|
+
}(XFormBase_1.XFormBase));
|
|
33
|
+
exports.XFormBaseModif = XFormBaseModif;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component } from "react";
|
|
2
|
+
import { FileUploadHandlerEvent } from "primereact/fileupload";
|
|
3
|
+
import { XFormBase } from "./XFormBase";
|
|
4
|
+
interface XFile {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
size: number;
|
|
8
|
+
pathName?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface XInputFileListProps {
|
|
11
|
+
form: XFormBase;
|
|
12
|
+
assocField: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
chooseLabel?: string;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
saveDest: "fileSystem" | "database";
|
|
17
|
+
subdir?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class XInputFileList extends Component<XInputFileListProps> {
|
|
20
|
+
static defaultProps: {
|
|
21
|
+
chooseLabel: string;
|
|
22
|
+
saveDest: string;
|
|
23
|
+
};
|
|
24
|
+
fileUploadRef: any;
|
|
25
|
+
props: XInputFileListProps;
|
|
26
|
+
entity: string;
|
|
27
|
+
idField: string;
|
|
28
|
+
xFileField: string;
|
|
29
|
+
constructor(props: XInputFileListProps);
|
|
30
|
+
uploadHandler(event: FileUploadHandlerEvent): Promise<void>;
|
|
31
|
+
onDownloadFile(xFile: XFile): Promise<void>;
|
|
32
|
+
onRemoveFile(fileItem: any): Promise<void>;
|
|
33
|
+
render(): JSX.Element;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __values = (this && this.__values) || function(o) {
|
|
54
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
55
|
+
if (m) return m.call(o);
|
|
56
|
+
if (o && typeof o.length === "number") return {
|
|
57
|
+
next: function () {
|
|
58
|
+
if (o && i >= o.length) o = void 0;
|
|
59
|
+
return { value: o && o[i++], done: !o };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
63
|
+
};
|
|
64
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
|
+
};
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
exports.XInputFileList = void 0;
|
|
69
|
+
var react_1 = __importDefault(require("react"));
|
|
70
|
+
var react_2 = require("react");
|
|
71
|
+
var fileupload_1 = require("primereact/fileupload");
|
|
72
|
+
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
73
|
+
var XUtils_1 = require("./XUtils");
|
|
74
|
+
var XButton_1 = require("./XButton");
|
|
75
|
+
var XButtonIconNarrow_1 = require("./XButtonIconNarrow");
|
|
76
|
+
var XInputFileList = /** @class */ (function (_super) {
|
|
77
|
+
__extends(XInputFileList, _super);
|
|
78
|
+
function XInputFileList(props) {
|
|
79
|
+
var _this = _super.call(this, props) || this;
|
|
80
|
+
_this.fileUploadRef = react_1.default.createRef();
|
|
81
|
+
_this.props = props;
|
|
82
|
+
var xEntityForm = XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity());
|
|
83
|
+
var xAssocToMany = XUtilsMetadata_1.XUtilsMetadata.getXAssocToMany(xEntityForm, props.assocField);
|
|
84
|
+
_this.entity = xAssocToMany.entityName;
|
|
85
|
+
var xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(_this.entity);
|
|
86
|
+
_this.idField = xEntity.idField;
|
|
87
|
+
_this.xFileField = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOneByAssocEntity(xEntity, 'XFile').name;
|
|
88
|
+
_this.onDownloadFile = _this.onDownloadFile.bind(_this);
|
|
89
|
+
_this.onRemoveFile = _this.onRemoveFile.bind(_this);
|
|
90
|
+
_this.uploadHandler = _this.uploadHandler.bind(_this);
|
|
91
|
+
var fieldFilename = "".concat(props.assocField, ".").concat(_this.xFileField, ".filename");
|
|
92
|
+
props.form.addField(fieldFilename);
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
XInputFileList.prototype.uploadHandler = function (event) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
var endpoint, _a, _b, file, xFile, e_1, newFileItem, e_2_1;
|
|
98
|
+
var e_2, _c;
|
|
99
|
+
return __generator(this, function (_d) {
|
|
100
|
+
switch (_d.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
endpoint = this.props.saveDest === 'fileSystem' ? 'x-upload-file-into-file-system' : 'x-upload-file-into-db';
|
|
103
|
+
_d.label = 1;
|
|
104
|
+
case 1:
|
|
105
|
+
_d.trys.push([1, 9, 10, 11]);
|
|
106
|
+
_a = __values(event.files), _b = _a.next();
|
|
107
|
+
_d.label = 2;
|
|
108
|
+
case 2:
|
|
109
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
110
|
+
file = _b.value;
|
|
111
|
+
xFile = void 0;
|
|
112
|
+
_d.label = 3;
|
|
113
|
+
case 3:
|
|
114
|
+
_d.trys.push([3, 5, , 6]);
|
|
115
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchFile(endpoint, { filename: file.name, subdir: this.props.subdir }, file)];
|
|
116
|
+
case 4:
|
|
117
|
+
xFile = _d.sent();
|
|
118
|
+
return [3 /*break*/, 6];
|
|
119
|
+
case 5:
|
|
120
|
+
e_1 = _d.sent();
|
|
121
|
+
XUtils_1.XUtils.showErrorMessage("Upload of file \"".concat(file.name, "\" failed."), e_1);
|
|
122
|
+
this.fileUploadRef.current.clear(); // vyprazdnime hidden input, nech moze user znova zadat subory
|
|
123
|
+
return [2 /*return*/]; // prerusime upload tohto a dalsich suborov
|
|
124
|
+
case 6:
|
|
125
|
+
newFileItem = {};
|
|
126
|
+
newFileItem[this.xFileField] = xFile;
|
|
127
|
+
this.props.form.onTableAddRow(this.props.assocField, newFileItem, this.idField);
|
|
128
|
+
_d.label = 7;
|
|
129
|
+
case 7:
|
|
130
|
+
_b = _a.next();
|
|
131
|
+
return [3 /*break*/, 2];
|
|
132
|
+
case 8: return [3 /*break*/, 11];
|
|
133
|
+
case 9:
|
|
134
|
+
e_2_1 = _d.sent();
|
|
135
|
+
e_2 = { error: e_2_1 };
|
|
136
|
+
return [3 /*break*/, 11];
|
|
137
|
+
case 10:
|
|
138
|
+
try {
|
|
139
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
140
|
+
}
|
|
141
|
+
finally { if (e_2) throw e_2.error; }
|
|
142
|
+
return [7 /*endfinally*/];
|
|
143
|
+
case 11:
|
|
144
|
+
// vymaze zaznamy v event.files (hidden input type="file"), sposobi ze tlacitko "+Pridat" otvori dialog na vyber suborov
|
|
145
|
+
this.fileUploadRef.current.clear();
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
XInputFileList.prototype.onDownloadFile = function (xFile) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var response, e_3, fileName, respBlob, url, a;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
_a.trys.push([0, 2, , 3]);
|
|
158
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchBasicJson('x-download-file', { xFileId: xFile.id })];
|
|
159
|
+
case 1:
|
|
160
|
+
response = _a.sent();
|
|
161
|
+
return [3 /*break*/, 3];
|
|
162
|
+
case 2:
|
|
163
|
+
e_3 = _a.sent();
|
|
164
|
+
XUtils_1.XUtils.showErrorMessage("Download failed.", e_3);
|
|
165
|
+
return [2 /*return*/];
|
|
166
|
+
case 3:
|
|
167
|
+
fileName = xFile.name;
|
|
168
|
+
return [4 /*yield*/, response.blob()];
|
|
169
|
+
case 4:
|
|
170
|
+
respBlob = _a.sent();
|
|
171
|
+
url = window.URL.createObjectURL(respBlob);
|
|
172
|
+
a = document.createElement('a');
|
|
173
|
+
a.href = url;
|
|
174
|
+
a.download = fileName;
|
|
175
|
+
a.click();
|
|
176
|
+
return [2 /*return*/];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
XInputFileList.prototype.onRemoveFile = function (fileItem) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
// poznamka: nemozme zmazat zaznam na backend-e, lebo ak user ukonci editaciu formulara tlacitkom Cancel (alebo odide uplne prec),
|
|
185
|
+
// tak musime mat v databaze zachovany povodny stav dat/suborov
|
|
186
|
+
this.props.form.onTableRemoveRow(this.props.assocField, fileItem);
|
|
187
|
+
return [2 /*return*/];
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
XInputFileList.prototype.render = function () {
|
|
192
|
+
var e_4, _a;
|
|
193
|
+
var _this = this;
|
|
194
|
+
var _b, _c;
|
|
195
|
+
var label = (_b = this.props.label) !== null && _b !== void 0 ? _b : this.props.assocField;
|
|
196
|
+
var readOnly = this.props.form.formReadOnlyBase(this.props.assocField) || ((_c = this.props.readOnly) !== null && _c !== void 0 ? _c : false);
|
|
197
|
+
var object = this.props.form.state.object;
|
|
198
|
+
var fileItemList = object !== null ? object[this.props.assocField] : [];
|
|
199
|
+
var elemList = [];
|
|
200
|
+
var _loop_1 = function (fileItem) {
|
|
201
|
+
var xFile = fileItem[this_1.xFileField];
|
|
202
|
+
// p-inputgroup uklada child elementy do riadku (display:flex)
|
|
203
|
+
// TODO - pouzit XButtonIconSmall pre button na mazanie - problem je ze tam nevieme (narychlo) dat class m-1
|
|
204
|
+
elemList.push(react_1.default.createElement("div", { key: fileItem[this_1.idField].toString(), className: "p-inputgroup p-mb-1" },
|
|
205
|
+
react_1.default.createElement(XButton_1.XButton, { label: xFile.name, onClick: function () { return _this.onDownloadFile(xFile); } }),
|
|
206
|
+
react_1.default.createElement(XButtonIconNarrow_1.XButtonIconNarrow, { icon: "pi pi-times", onClick: function () { return _this.onRemoveFile(fileItem); }, disabled: readOnly })));
|
|
207
|
+
};
|
|
208
|
+
var this_1 = this;
|
|
209
|
+
try {
|
|
210
|
+
for (var fileItemList_1 = __values(fileItemList), fileItemList_1_1 = fileItemList_1.next(); !fileItemList_1_1.done; fileItemList_1_1 = fileItemList_1.next()) {
|
|
211
|
+
var fileItem = fileItemList_1_1.value;
|
|
212
|
+
_loop_1(fileItem);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
216
|
+
finally {
|
|
217
|
+
try {
|
|
218
|
+
if (fileItemList_1_1 && !fileItemList_1_1.done && (_a = fileItemList_1.return)) _a.call(fileItemList_1);
|
|
219
|
+
}
|
|
220
|
+
finally { if (e_4) throw e_4.error; }
|
|
221
|
+
}
|
|
222
|
+
// vrchny div uklada child elementy pod seba (standardny display:block), zarovnane su dolava
|
|
223
|
+
return (react_1.default.createElement("div", null,
|
|
224
|
+
react_1.default.createElement("label", null, label),
|
|
225
|
+
elemList,
|
|
226
|
+
react_1.default.createElement(fileupload_1.FileUpload, { ref: this.fileUploadRef, mode: "basic", multiple: true, auto: true, customUpload: true, uploadHandler: this.uploadHandler, chooseLabel: this.props.chooseLabel, className: "m-1", disabled: readOnly })));
|
|
227
|
+
};
|
|
228
|
+
XInputFileList.defaultProps = {
|
|
229
|
+
chooseLabel: "Add",
|
|
230
|
+
saveDest: "fileSystem"
|
|
231
|
+
};
|
|
232
|
+
return XInputFileList;
|
|
233
|
+
}(react_2.Component));
|
|
234
|
+
exports.XInputFileList = XInputFileList;
|
|
@@ -459,47 +459,15 @@ var XLazyDataTable = function (props) {
|
|
|
459
459
|
}
|
|
460
460
|
});
|
|
461
461
|
}); };
|
|
462
|
-
var
|
|
463
|
-
var
|
|
464
|
-
return
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
setExportRowsDialogOpened(false);
|
|
472
|
-
path = 'lazyDataTableExport';
|
|
473
|
-
if (csvParam && csvParam.useHeaderLine) {
|
|
474
|
-
csvParam.headers = getHeaders();
|
|
475
|
-
}
|
|
476
|
-
exportParam = { exportType: exportType, filters: filtersAfterFiltering, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), csvParam: csvParam };
|
|
477
|
-
_a.label = 1;
|
|
478
|
-
case 1:
|
|
479
|
-
_a.trys.push([1, 3, , 4]);
|
|
480
|
-
return [4 /*yield*/, XUtils_1.XUtils.fetchBasicJson(path, exportParam)];
|
|
481
|
-
case 2:
|
|
482
|
-
response = _a.sent();
|
|
483
|
-
return [3 /*break*/, 4];
|
|
484
|
-
case 3:
|
|
485
|
-
e_7 = _a.sent();
|
|
486
|
-
XUtils_1.XUtils.showErrorMessage("Export failed.", e_7);
|
|
487
|
-
return [2 /*return*/];
|
|
488
|
-
case 4:
|
|
489
|
-
fileExt = exportType;
|
|
490
|
-
fileName = "".concat(props.entity, ".").concat(fileExt);
|
|
491
|
-
return [4 /*yield*/, response.blob()];
|
|
492
|
-
case 5:
|
|
493
|
-
respBlob = _a.sent();
|
|
494
|
-
url = window.URL.createObjectURL(respBlob);
|
|
495
|
-
a = document.createElement('a');
|
|
496
|
-
a.href = url;
|
|
497
|
-
a.download = fileName;
|
|
498
|
-
a.click();
|
|
499
|
-
return [2 /*return*/];
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
}); };
|
|
462
|
+
var createExportParams = function () {
|
|
463
|
+
var queryParam = { filters: filtersAfterFiltering, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
|
|
464
|
+
return {
|
|
465
|
+
path: "x-lazy-data-table-export",
|
|
466
|
+
queryParam: queryParam,
|
|
467
|
+
headers: getHeaders(),
|
|
468
|
+
fileName: "".concat(props.entity)
|
|
469
|
+
};
|
|
470
|
+
};
|
|
503
471
|
var onClickChoose = function () {
|
|
504
472
|
//console.log("zavolany onClickChoose");
|
|
505
473
|
if (selectedRow !== null) {
|
|
@@ -895,7 +863,7 @@ var XLazyDataTable = function (props) {
|
|
|
895
863
|
exportRows ? react_1.default.createElement(XButton_1.XButton, { label: "Export rows", onClick: onClickExport }) : null,
|
|
896
864
|
props.appButtons,
|
|
897
865
|
props.searchTableParams !== undefined ? react_1.default.createElement(XButton_1.XButton, { label: "Choose", onClick: onClickChoose }) : null,
|
|
898
|
-
exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { dialogOpened: exportRowsDialogOpened, rowCount: exportRowsDialogRowCount,
|
|
866
|
+
exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { dialogOpened: exportRowsDialogOpened, hideDialog: function () { return setExportRowsDialogOpened(false); }, rowCount: exportRowsDialogRowCount, exportParams: createExportParams }) : null)));
|
|
899
867
|
};
|
|
900
868
|
exports.XLazyDataTable = XLazyDataTable;
|
|
901
869
|
exports.XLazyDataTable.defaultProps = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XToken } from "./XToken";
|
|
2
|
-
import { CsvDecimalFormat, CsvSeparator, ExportType } from "../serverApi/ExportImportParam";
|
|
2
|
+
import { CsvDecimalFormat, CsvEncoding, CsvSeparator, ExportType } from "../serverApi/ExportImportParam";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { XEnvVar } from "./XEnvVars";
|
|
5
5
|
import { XError, XErrorMap } from "./XErrors";
|
|
@@ -19,6 +19,7 @@ export declare class XUtils {
|
|
|
19
19
|
static exportTypeOptions: ExportType[];
|
|
20
20
|
static csvSeparatorOptions: CsvSeparator[];
|
|
21
21
|
static decimalFormatOptions: CsvDecimalFormat[];
|
|
22
|
+
static csvEncodingOptions: CsvEncoding[];
|
|
22
23
|
static remSize: number | null;
|
|
23
24
|
static FIELD_LABEL_WIDTH: string;
|
|
24
25
|
static demo(): boolean;
|
package/lib/components/XUtils.js
CHANGED
|
@@ -501,8 +501,14 @@ var XUtils = /** @class */ (function () {
|
|
|
501
501
|
XUtils.showErrorMessage = function (message, e) {
|
|
502
502
|
var msg = message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
503
503
|
if (e instanceof XResponseError_1.XResponseError) {
|
|
504
|
-
|
|
505
|
-
|
|
504
|
+
// better error message for optimistic locking
|
|
505
|
+
if (e.xResponseErrorBody.exceptionName === 'OptimisticLockVersionMismatchError') {
|
|
506
|
+
msg += "The optimistic lock failed, someone else has changed the row during the editation. Sorry, you have to cancel the editation and start the editation again.";
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
msg += e.message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
510
|
+
msg += JSON.stringify(e.xResponseErrorBody, null, 4);
|
|
511
|
+
}
|
|
506
512
|
}
|
|
507
513
|
else if (e instanceof Error) {
|
|
508
514
|
msg += e.message;
|
|
@@ -612,6 +618,7 @@ var XUtils = /** @class */ (function () {
|
|
|
612
618
|
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
613
619
|
XUtils.csvSeparatorOptions = [ExportImportParam_1.CsvSeparator.Semicolon, ExportImportParam_1.CsvSeparator.Comma];
|
|
614
620
|
XUtils.decimalFormatOptions = [ExportImportParam_1.CsvDecimalFormat.Comma, ExportImportParam_1.CsvDecimalFormat.Dot];
|
|
621
|
+
XUtils.csvEncodingOptions = [ExportImportParam_1.CsvEncoding.Utf8, ExportImportParam_1.CsvEncoding.Win1250];
|
|
615
622
|
XUtils.remSize = null;
|
|
616
623
|
// konstanty (zatial takto jednoducho)
|
|
617
624
|
XUtils.FIELD_LABEL_WIDTH = '10.5rem';
|
|
@@ -6,12 +6,15 @@ export declare enum ExportType {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ExportParam {
|
|
8
8
|
exportType: ExportType;
|
|
9
|
+
csvParam?: CsvParam;
|
|
10
|
+
queryParam: LazyDataTableQueryParam | any;
|
|
11
|
+
}
|
|
12
|
+
export interface LazyDataTableQueryParam {
|
|
9
13
|
filters: DataTableFilterMeta;
|
|
10
14
|
customFilter?: XCustomFilter;
|
|
11
15
|
multiSortMeta?: DataTableSortMeta[];
|
|
12
16
|
entity: string;
|
|
13
17
|
fields: string[];
|
|
14
|
-
csvParam?: CsvParam;
|
|
15
18
|
}
|
|
16
19
|
export declare enum CsvSeparator {
|
|
17
20
|
Semicolon = ";",
|
|
@@ -21,11 +24,16 @@ export declare enum CsvDecimalFormat {
|
|
|
21
24
|
Comma = "123456,78",
|
|
22
25
|
Dot = "123456.78"
|
|
23
26
|
}
|
|
27
|
+
export declare enum CsvEncoding {
|
|
28
|
+
Utf8 = "utf-8",
|
|
29
|
+
Win1250 = "win1250"
|
|
30
|
+
}
|
|
24
31
|
export interface CsvParam {
|
|
25
32
|
useHeaderLine: boolean;
|
|
26
33
|
headers?: string[];
|
|
27
34
|
csvSeparator: CsvSeparator;
|
|
28
35
|
csvDecimalFormat: CsvDecimalFormat;
|
|
36
|
+
csvEncoding: CsvEncoding;
|
|
29
37
|
}
|
|
30
38
|
export declare enum ImportType {
|
|
31
39
|
Csv = "csv",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImportType = exports.CsvDecimalFormat = exports.CsvSeparator = exports.ExportType = void 0;
|
|
3
|
+
exports.ImportType = exports.CsvEncoding = exports.CsvDecimalFormat = exports.CsvSeparator = exports.ExportType = void 0;
|
|
4
4
|
var ExportType;
|
|
5
5
|
(function (ExportType) {
|
|
6
6
|
ExportType["Csv"] = "csv";
|
|
@@ -19,6 +19,14 @@ var CsvDecimalFormat;
|
|
|
19
19
|
CsvDecimalFormat["Comma"] = "123456,78";
|
|
20
20
|
CsvDecimalFormat["Dot"] = "123456.78";
|
|
21
21
|
})(CsvDecimalFormat = exports.CsvDecimalFormat || (exports.CsvDecimalFormat = {}));
|
|
22
|
+
// zatial len tieto 2, ak bude treba, tak pridat napr. win1252 (Western Europe)
|
|
23
|
+
// win1250 pouzivame ako default, lebo Excel automaticky predpoklada kodovanie win1250
|
|
24
|
+
// konstanty sa pouzivaju priamo v kniznici iconv-lite
|
|
25
|
+
var CsvEncoding;
|
|
26
|
+
(function (CsvEncoding) {
|
|
27
|
+
CsvEncoding["Utf8"] = "utf-8";
|
|
28
|
+
CsvEncoding["Win1250"] = "win1250";
|
|
29
|
+
})(CsvEncoding = exports.CsvEncoding || (exports.CsvEncoding = {}));
|
|
22
30
|
var ImportType;
|
|
23
31
|
(function (ImportType) {
|
|
24
32
|
ImportType["Csv"] = "csv";
|