@michalrakus/x-react-web-lib 1.5.1 → 1.6.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/XFormBaseModif.d.ts +3 -0
- package/XFormBaseModif.js +5 -0
- package/XInputFileList.d.ts +3 -0
- package/XInputFileList.js +5 -0
- package/gulpfile.js +2 -0
- 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/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/XUtils.js +8 -2
- package/lib/serverApi/XEntityMetadata.d.ts +3 -0
- package/package.json +1 -1
package/gulpfile.js
CHANGED
|
@@ -30,6 +30,7 @@ function generateApi(cb) {
|
|
|
30
30
|
"./lib/components/XErrors",
|
|
31
31
|
"./lib/components/XFieldChangeEvent",
|
|
32
32
|
"./lib/components/XFormBase",
|
|
33
|
+
"./lib/components/XFormBaseModif",
|
|
33
34
|
"./lib/components/XFormBaseT",
|
|
34
35
|
"./lib/components/XFormDataTable2",
|
|
35
36
|
"./lib/components/XFormFooter",
|
|
@@ -38,6 +39,7 @@ function generateApi(cb) {
|
|
|
38
39
|
"./lib/components/XInputDate",
|
|
39
40
|
"./lib/components/XInputDecimal",
|
|
40
41
|
"./lib/components/XInputDecimalBase",
|
|
42
|
+
"./lib/components/XInputFileList",
|
|
41
43
|
"./lib/components/XInputText",
|
|
42
44
|
"./lib/components/XInputTextarea",
|
|
43
45
|
"./lib/components/XLazyDataTable",
|
|
@@ -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;
|
|
@@ -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;
|
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;
|