@michalrakus/x-react-web-lib 1.7.3 → 1.8.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.
|
@@ -95,36 +95,43 @@ var XInputFileList = /** @class */ (function (_super) {
|
|
|
95
95
|
return _this;
|
|
96
96
|
}
|
|
97
97
|
XInputFileList.prototype.uploadHandler = function (event) {
|
|
98
|
+
var _a, _b;
|
|
98
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
var endpoint,
|
|
100
|
-
var e_2,
|
|
101
|
-
return __generator(this, function (
|
|
102
|
-
switch (
|
|
100
|
+
var endpoint, _c, _d, file, jsonFieldValue, xFile, e_1, newFileItem, e_2_1;
|
|
101
|
+
var e_2, _e;
|
|
102
|
+
return __generator(this, function (_f) {
|
|
103
|
+
switch (_f.label) {
|
|
103
104
|
case 0:
|
|
104
105
|
endpoint = this.props.saveDest === 'fileSystem' ? 'x-upload-file-into-file-system' : 'x-upload-file-into-db';
|
|
105
|
-
|
|
106
|
+
_f.label = 1;
|
|
106
107
|
case 1:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
_f.trys.push([1, 9, 10, 11]);
|
|
109
|
+
_c = __values(event.files), _d = _c.next();
|
|
110
|
+
_f.label = 2;
|
|
110
111
|
case 2:
|
|
111
|
-
if (!!
|
|
112
|
-
file =
|
|
112
|
+
if (!!_d.done) return [3 /*break*/, 8];
|
|
113
|
+
file = _d.value;
|
|
113
114
|
// skontrolujeme velkost - robime to tuto, lebo ked nastavime maxFileSize na komponente FileUpload, tak prilis velky subor sem do handlera ani neposle
|
|
114
115
|
if (this.props.maxFileSize !== undefined && file.size > this.props.maxFileSize) {
|
|
115
116
|
alert((0, XLocale_1.xLocaleOption)('fileUploadSizeToBig', { fileName: file.name, fileSize: XInputFileList.sizeInMB(file.size), maxFileSize: XInputFileList.sizeInMB(this.props.maxFileSize) }));
|
|
116
117
|
return [3 /*break*/, 7]; // ideme na dalsi subor
|
|
117
118
|
}
|
|
119
|
+
jsonFieldValue = {
|
|
120
|
+
filename: file.name,
|
|
121
|
+
subdir: this.props.subdir,
|
|
122
|
+
modifDate: new Date(),
|
|
123
|
+
modifXUser: (_b = (_a = XUtils_1.XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.idXUser
|
|
124
|
+
};
|
|
118
125
|
xFile = void 0;
|
|
119
|
-
|
|
126
|
+
_f.label = 3;
|
|
120
127
|
case 3:
|
|
121
|
-
|
|
122
|
-
return [4 /*yield*/, XUtils_1.XUtils.fetchFile(endpoint,
|
|
128
|
+
_f.trys.push([3, 5, , 6]);
|
|
129
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchFile(endpoint, jsonFieldValue, file)];
|
|
123
130
|
case 4:
|
|
124
|
-
xFile =
|
|
131
|
+
xFile = _f.sent();
|
|
125
132
|
return [3 /*break*/, 6];
|
|
126
133
|
case 5:
|
|
127
|
-
e_1 =
|
|
134
|
+
e_1 = _f.sent();
|
|
128
135
|
XUtils_1.XUtils.showErrorMessage((0, XLocale_1.xLocaleOption)('fileUploadFailed', { fileName: file.name }), e_1);
|
|
129
136
|
this.fileUploadRef.current.clear(); // vyprazdnime hidden input, nech moze user znova zadat subory
|
|
130
137
|
return [2 /*return*/]; // prerusime upload tohto a dalsich suborov
|
|
@@ -132,18 +139,18 @@ var XInputFileList = /** @class */ (function (_super) {
|
|
|
132
139
|
newFileItem = {};
|
|
133
140
|
newFileItem[this.xFileField] = xFile;
|
|
134
141
|
this.props.form.onTableAddRow(this.props.assocField, newFileItem, this.idField);
|
|
135
|
-
|
|
142
|
+
_f.label = 7;
|
|
136
143
|
case 7:
|
|
137
|
-
|
|
144
|
+
_d = _c.next();
|
|
138
145
|
return [3 /*break*/, 2];
|
|
139
146
|
case 8: return [3 /*break*/, 11];
|
|
140
147
|
case 9:
|
|
141
|
-
e_2_1 =
|
|
148
|
+
e_2_1 = _f.sent();
|
|
142
149
|
e_2 = { error: e_2_1 };
|
|
143
150
|
return [3 /*break*/, 11];
|
|
144
151
|
case 10:
|
|
145
152
|
try {
|
|
146
|
-
if (
|
|
153
|
+
if (_d && !_d.done && (_e = _c.return)) _e.call(_c);
|
|
147
154
|
}
|
|
148
155
|
finally { if (e_2) throw e_2.error; }
|
|
149
156
|
return [7 /*endfinally*/];
|
package/lib/components/XUtils.js
CHANGED
|
@@ -511,7 +511,7 @@ var XUtils = /** @class */ (function () {
|
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
else if (e instanceof Error) {
|
|
514
|
-
msg += e.message;
|
|
514
|
+
msg += "".concat(e.name, ": ").concat(e.message);
|
|
515
515
|
}
|
|
516
516
|
else if (typeof e === 'string' || typeof e === 'number') {
|
|
517
517
|
// chyba typu: throw 'nieco'
|