@michalrakus/x-react-web-lib 1.0.0 → 1.1.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/LICENSE.md +21 -0
- package/XInputTextarea.d.ts +3 -0
- package/XInputTextarea.js +5 -0
- package/gulpfile.js +1 -0
- package/lib/administration/XBrowseMetaBrowse.js +2 -1
- package/lib/administration/XBrowseMetaForm.js +4 -2
- package/lib/administration/XUserBrowse.js +3 -2
- package/lib/administration/XUserForm.js +5 -3
- package/lib/components/SourceCodeLinkEntity.js +3 -2
- package/lib/components/XAutoComplete.d.ts +3 -3
- package/lib/components/XAutoComplete.js +19 -38
- package/lib/components/XAutoCompleteBase.d.ts +1 -1
- package/lib/components/XAutoCompleteBase.js +27 -23
- package/lib/components/XBrowse.js +11 -5
- package/lib/components/XButton.js +2 -1
- package/lib/components/XButtonIconSmall.js +2 -1
- package/lib/components/XChangePasswordForm.js +12 -7
- package/lib/components/XCheckbox.d.ts +8 -10
- package/lib/components/XCheckbox.js +39 -31
- package/lib/components/XCheckboxDT.js +2 -1
- package/lib/components/XDataTable.js +16 -10
- package/lib/components/XDropdown.d.ts +4 -3
- package/lib/components/XDropdown.js +24 -45
- package/lib/components/XDropdownDT.js +10 -5
- package/lib/components/XDropdownDTFilter.js +12 -7
- package/lib/components/XDropdownFormDTFilter.js +12 -7
- package/lib/components/XEditColumnDialog.js +12 -7
- package/lib/components/XErrors.d.ts +1 -0
- package/lib/components/XExportRowsDialog.js +13 -8
- package/lib/components/XFieldSelector.js +11 -6
- package/lib/components/XFormBase.d.ts +1 -0
- package/lib/components/XFormBase.js +50 -22
- package/lib/components/XFormBaseT.js +3 -1
- package/lib/components/XFormComponent.d.ts +10 -6
- package/lib/components/XFormComponent.js +63 -49
- package/lib/components/XFormDataTable2.d.ts +8 -3
- package/lib/components/XFormDataTable2.js +115 -32
- package/lib/components/XFormFooter.js +2 -1
- package/lib/components/XFormNavigator3.js +18 -7
- package/lib/components/XHolders.js +4 -2
- package/lib/components/XInput.d.ts +13 -0
- package/lib/components/XInput.js +38 -0
- package/lib/components/XInputDate.js +3 -2
- package/lib/components/XInputDateDT.js +3 -2
- package/lib/components/XInputDecimal.js +2 -1
- package/lib/components/XInputDecimalDT.js +2 -1
- package/lib/components/XInputText.d.ts +6 -11
- package/lib/components/XInputText.js +17 -50
- package/lib/components/XInputTextDT.js +4 -4
- package/lib/components/XInputTextarea.d.ts +18 -0
- package/lib/components/XInputTextarea.js +85 -0
- package/lib/components/XLazyDataTable.d.ts +3 -0
- package/lib/components/XLazyDataTable.js +166 -79
- package/lib/components/XLoginDialog.js +2 -1
- package/lib/components/XLoginForm.js +11 -6
- package/lib/components/XResponseError.js +4 -2
- package/lib/components/XSearchButton.d.ts +2 -3
- package/lib/components/XSearchButton.js +15 -36
- package/lib/components/XSearchButtonDT.js +13 -8
- package/lib/components/XSearchButtonOld.js +13 -8
- package/lib/components/XToOneAssocButton.js +2 -1
- package/lib/components/XUtils.d.ts +3 -1
- package/lib/components/XUtils.js +32 -5
- package/lib/components/XUtilsConversions.js +10 -2
- package/lib/components/XUtilsMetadata.d.ts +1 -1
- package/lib/components/XUtilsMetadata.js +20 -11
- package/lib/components/useXToken.js +1 -1
- package/lib/serverApi/ExportImportParam.d.ts +3 -3
- package/lib/serverApi/FindParam.d.ts +3 -13
- package/lib/serverApi/FindParam.js +14 -0
- package/lib/serverApi/XUtilsCommon.js +2 -2
- package/package.json +24 -25
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -38,7 +40,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
40
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
39
41
|
function step(op) {
|
|
40
42
|
if (f) throw new TypeError("Generator is already executing.");
|
|
41
|
-
while (_) try {
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
42
44
|
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;
|
|
43
45
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
44
46
|
switch (op[0]) {
|
|
@@ -275,12 +277,33 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
275
277
|
XFormBase.prototype.addXFormComponent = function (xFormComponent) {
|
|
276
278
|
this.xFormComponentList.push(xFormComponent);
|
|
277
279
|
};
|
|
280
|
+
XFormBase.prototype.findXFormComponent = function (field) {
|
|
281
|
+
var e_2, _a;
|
|
282
|
+
try {
|
|
283
|
+
// TODO - vytvorit mapu (field, ref(xFormComponent)), bude to rychlejsie
|
|
284
|
+
// vytvorit len mapu (a list zrusit) je problem - mozme mat pre jeden field viacero (napr. asociacnych) componentov
|
|
285
|
+
for (var _b = __values(this.xFormComponentList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
286
|
+
var xFormComponent = _c.value;
|
|
287
|
+
if (xFormComponent.getField() === field) {
|
|
288
|
+
return xFormComponent;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
293
|
+
finally {
|
|
294
|
+
try {
|
|
295
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
296
|
+
}
|
|
297
|
+
finally { if (e_2) throw e_2.error; }
|
|
298
|
+
}
|
|
299
|
+
return undefined;
|
|
300
|
+
};
|
|
278
301
|
XFormBase.prototype.addXFormDataTable = function (xFormDataTable) {
|
|
279
302
|
this.xFormDataTableList.push(xFormDataTable);
|
|
280
303
|
};
|
|
281
304
|
XFormBase.prototype.onClickSave = function () {
|
|
282
305
|
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var isAddRow, object,
|
|
306
|
+
var isAddRow, object, e_3;
|
|
284
307
|
return __generator(this, function (_a) {
|
|
285
308
|
switch (_a.label) {
|
|
286
309
|
case 0:
|
|
@@ -310,8 +333,8 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
310
333
|
object = _a.sent();
|
|
311
334
|
return [3 /*break*/, 4];
|
|
312
335
|
case 3:
|
|
313
|
-
|
|
314
|
-
XUtils_1.XUtils.showErrorMessage("Save row failed.",
|
|
336
|
+
e_3 = _a.sent();
|
|
337
|
+
XUtils_1.XUtils.showErrorMessage("Save row failed.", e_3);
|
|
315
338
|
return [2 /*return*/]; // zostavame vo formulari
|
|
316
339
|
case 4:
|
|
317
340
|
if (this.props.onSaveOrCancel !== undefined) {
|
|
@@ -338,26 +361,28 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
338
361
|
}
|
|
339
362
|
};
|
|
340
363
|
XFormBase.prototype.validateSave = function () {
|
|
341
|
-
var
|
|
364
|
+
var e_4, _a;
|
|
365
|
+
var _b;
|
|
342
366
|
var xErrorMap = this.validateForm();
|
|
343
367
|
// zatial takto
|
|
344
368
|
var msg = "";
|
|
345
369
|
try {
|
|
346
|
-
for (var
|
|
347
|
-
var
|
|
370
|
+
for (var _c = __values(Object.entries(xErrorMap)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
371
|
+
var _e = __read(_d.value, 2), field = _e[0], xError = _e[1];
|
|
348
372
|
if (xError) {
|
|
349
|
-
|
|
350
|
-
|
|
373
|
+
var errorMessage = XUtils_1.XUtils.getXErrorMessage(xError);
|
|
374
|
+
if (errorMessage) {
|
|
375
|
+
msg += "".concat((_b = xError.fieldLabel) !== null && _b !== void 0 ? _b : field, ": ").concat(errorMessage).concat(XUtilsCommon_1.XUtilsCommon.newLine);
|
|
351
376
|
}
|
|
352
377
|
}
|
|
353
378
|
}
|
|
354
379
|
}
|
|
355
|
-
catch (
|
|
380
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
356
381
|
finally {
|
|
357
382
|
try {
|
|
358
|
-
if (
|
|
383
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
359
384
|
}
|
|
360
|
-
finally { if (
|
|
385
|
+
finally { if (e_4) throw e_4.error; }
|
|
361
386
|
}
|
|
362
387
|
var ok = true;
|
|
363
388
|
if (msg !== "") {
|
|
@@ -367,7 +392,7 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
367
392
|
return ok;
|
|
368
393
|
};
|
|
369
394
|
XFormBase.prototype.validateForm = function () {
|
|
370
|
-
var
|
|
395
|
+
var e_5, _a;
|
|
371
396
|
var xErrorMap = this.fieldValidation();
|
|
372
397
|
// form validation
|
|
373
398
|
var xErrors = this.validate(this.getXObject());
|
|
@@ -375,23 +400,26 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
375
400
|
for (var _b = __values(Object.entries(xErrors)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
376
401
|
var _d = __read(_c.value, 2), field = _d[0], error = _d[1];
|
|
377
402
|
if (error) {
|
|
378
|
-
|
|
403
|
+
// skusime zistit label
|
|
404
|
+
var xFormComponent = this.findXFormComponent(field);
|
|
405
|
+
var fieldLabel = xFormComponent ? xFormComponent.getLabel() : undefined;
|
|
406
|
+
xErrorMap[field] = __assign(__assign({}, xErrorMap[field]), { form: error, fieldLabel: fieldLabel });
|
|
379
407
|
}
|
|
380
408
|
}
|
|
381
409
|
}
|
|
382
|
-
catch (
|
|
410
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
383
411
|
finally {
|
|
384
412
|
try {
|
|
385
413
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
386
414
|
}
|
|
387
|
-
finally { if (
|
|
415
|
+
finally { if (e_5) throw e_5.error; }
|
|
388
416
|
}
|
|
389
417
|
// TODO - optimalizacia - netreba setovat stav ak by sme sli prec z formulara (ak by zbehla validacia aj save a isli by sme naspet do browsu)
|
|
390
418
|
this.setState({ errorMap: xErrorMap });
|
|
391
419
|
return xErrorMap;
|
|
392
420
|
};
|
|
393
421
|
XFormBase.prototype.fieldValidation = function () {
|
|
394
|
-
var
|
|
422
|
+
var e_6, _a, e_7, _b;
|
|
395
423
|
var xErrorMap = {};
|
|
396
424
|
try {
|
|
397
425
|
for (var _c = __values(this.xFormComponentList), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
@@ -403,12 +431,12 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
403
431
|
}
|
|
404
432
|
}
|
|
405
433
|
}
|
|
406
|
-
catch (
|
|
434
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
407
435
|
finally {
|
|
408
436
|
try {
|
|
409
437
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
410
438
|
}
|
|
411
|
-
finally { if (
|
|
439
|
+
finally { if (e_6) throw e_6.error; }
|
|
412
440
|
}
|
|
413
441
|
try {
|
|
414
442
|
for (var _e = __values(this.xFormDataTableList), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -416,12 +444,12 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
416
444
|
// TODO - validate table
|
|
417
445
|
}
|
|
418
446
|
}
|
|
419
|
-
catch (
|
|
447
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
420
448
|
finally {
|
|
421
449
|
try {
|
|
422
450
|
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
423
451
|
}
|
|
424
|
-
finally { if (
|
|
452
|
+
finally { if (e_7) throw e_7.error; }
|
|
425
453
|
}
|
|
426
454
|
return xErrorMap;
|
|
427
455
|
};
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -8,17 +8,21 @@ export interface XFormComponentProps {
|
|
|
8
8
|
labelStyle?: React.CSSProperties;
|
|
9
9
|
inline?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export declare class XFormComponent<P extends XFormComponentProps> extends Component<P> {
|
|
12
|
-
constructor(props: P);
|
|
13
|
-
|
|
11
|
+
export declare abstract class XFormComponent<P extends XFormComponentProps> extends Component<P> {
|
|
12
|
+
protected constructor(props: P);
|
|
13
|
+
abstract getField(): string;
|
|
14
|
+
getValueFromObject(): any;
|
|
15
|
+
onValueChangeBase(value: any): void;
|
|
16
|
+
abstract isNotNull(): boolean;
|
|
17
|
+
isReadOnly(): boolean;
|
|
18
|
+
getLabel(): string;
|
|
19
|
+
getLabelStyle(): React.CSSProperties;
|
|
14
20
|
validate(): {
|
|
15
21
|
field: string;
|
|
16
22
|
xError: XError;
|
|
17
23
|
} | undefined;
|
|
18
24
|
validateOnChange(value: any): string | undefined;
|
|
19
25
|
validateNotNull(value: any): string | undefined;
|
|
20
|
-
checkNotNull(): boolean;
|
|
21
|
-
getValueFromObject(): any;
|
|
22
|
-
getError(): string | undefined;
|
|
23
26
|
getClassNameTooltip(): {};
|
|
27
|
+
getError(): string | undefined;
|
|
24
28
|
}
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -15,6 +17,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
18
|
exports.XFormComponent = void 0;
|
|
17
19
|
var react_1 = require("react");
|
|
20
|
+
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
21
|
+
var XUtils_1 = require("./XUtils");
|
|
18
22
|
var XFormComponent = /** @class */ (function (_super) {
|
|
19
23
|
__extends(XFormComponent, _super);
|
|
20
24
|
function XFormComponent(props) {
|
|
@@ -22,24 +26,64 @@ var XFormComponent = /** @class */ (function (_super) {
|
|
|
22
26
|
props.form.addXFormComponent(_this);
|
|
23
27
|
return _this;
|
|
24
28
|
}
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
// ******** read and write from/into form.state.object ***********
|
|
30
|
+
// reads value from form.state.object
|
|
31
|
+
// can be overridden, but this should work for every component
|
|
32
|
+
XFormComponent.prototype.getValueFromObject = function () {
|
|
33
|
+
var objectValue = null;
|
|
34
|
+
var object = this.props.form.state.object;
|
|
35
|
+
if (object !== null) {
|
|
36
|
+
objectValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(object, this.getField());
|
|
37
|
+
// pre istotu dame na null, null je standard
|
|
38
|
+
if (objectValue === undefined) {
|
|
39
|
+
objectValue = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return objectValue;
|
|
43
|
+
};
|
|
44
|
+
// writes value into form.state.object
|
|
45
|
+
XFormComponent.prototype.onValueChangeBase = function (value) {
|
|
46
|
+
var error = this.validateOnChange(value);
|
|
47
|
+
this.props.form.onFieldChange(this.getField(), value, error);
|
|
48
|
+
};
|
|
49
|
+
XFormComponent.prototype.isReadOnly = function () {
|
|
50
|
+
// tuto do buducna planujeme pridat aj dynamicky readOnly, bude ho treba ukladat do form.state podobne ako sa ukladaju errory do form.state.errorMap
|
|
51
|
+
return XUtils_1.XUtils.isReadOnly(this.getField(), this.props.readOnly);
|
|
29
52
|
};
|
|
53
|
+
XFormComponent.prototype.getLabel = function () {
|
|
54
|
+
var _a;
|
|
55
|
+
var label = (_a = this.props.label) !== null && _a !== void 0 ? _a : this.getField();
|
|
56
|
+
// test na readOnly je tu hlavne koli tomu aby sme nemali * pri ID atribute, ktory sa pri inserte generuje az pri zapise do DB
|
|
57
|
+
if (this.isNotNull() && !this.isReadOnly()) {
|
|
58
|
+
label = XUtils_1.XUtils.markNotNull(label);
|
|
59
|
+
}
|
|
60
|
+
return label;
|
|
61
|
+
};
|
|
62
|
+
XFormComponent.prototype.getLabelStyle = function () {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
var labelStyle = (_a = this.props.labelStyle) !== null && _a !== void 0 ? _a : {};
|
|
65
|
+
var inline = (_b = this.props.inline) !== null && _b !== void 0 ? _b : false;
|
|
66
|
+
if (!inline) {
|
|
67
|
+
XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { width: XUtils_1.XUtils.FIELD_LABEL_WIDTH });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { width: 'auto' }); // podla dlzky labelu
|
|
71
|
+
XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { marginLeft: '1rem' });
|
|
72
|
+
}
|
|
73
|
+
return labelStyle;
|
|
74
|
+
};
|
|
75
|
+
// *********** validation support ************
|
|
30
76
|
// volane po kliknuti na Save
|
|
31
|
-
// vrati
|
|
77
|
+
// vrati (field, XError) ak nezbehne "field validacia", ak zbehne, vrati undefined
|
|
32
78
|
XFormComponent.prototype.validate = function () {
|
|
79
|
+
// TODO - FILOZOFICKA OTAZKA - volat validaciu aj ked je field readOnly (this.isReadOnly() === true)? zatial dame ze hej...
|
|
33
80
|
var value = this.getValueFromObject();
|
|
34
81
|
// not null validacia + custom field validacia volana na onChange
|
|
35
82
|
var errorOnChange = this.validateOnChange(value);
|
|
36
83
|
// custom field validacia volana na onBlur (focus lost)
|
|
37
84
|
// TODO
|
|
38
85
|
if (errorOnChange) {
|
|
39
|
-
|
|
40
|
-
if (field) {
|
|
41
|
-
return { field: field, xError: { onChange: errorOnChange } };
|
|
42
|
-
}
|
|
86
|
+
return { field: this.getField(), xError: { onChange: errorOnChange, fieldLabel: this.getLabel() } };
|
|
43
87
|
}
|
|
44
88
|
return undefined;
|
|
45
89
|
};
|
|
@@ -53,49 +97,14 @@ var XFormComponent = /** @class */ (function (_super) {
|
|
|
53
97
|
return undefined;
|
|
54
98
|
};
|
|
55
99
|
XFormComponent.prototype.validateNotNull = function (value) {
|
|
56
|
-
|
|
100
|
+
// validacia by mala sediet s metodou getLabel(), kde sa pridava * , preto tu mame aj test !this.isReadOnly() - id fieldy pri inserte nechceme testovat
|
|
101
|
+
// otazka je ci nevypinat validaciu pre readOnly fieldy vzdy (aj ked napr. readOnly vznikne dynamicky)
|
|
102
|
+
if (this.isNotNull() && !this.isReadOnly() && value === null) {
|
|
57
103
|
return "Field is required.";
|
|
58
104
|
}
|
|
59
105
|
return undefined;
|
|
60
106
|
};
|
|
61
|
-
//
|
|
62
|
-
XFormComponent.prototype.checkNotNull = function () {
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
// should be overriden
|
|
66
|
-
XFormComponent.prototype.getValueFromObject = function () {
|
|
67
|
-
return null;
|
|
68
|
-
};
|
|
69
|
-
// vrati error message z form.state.errorMap
|
|
70
|
-
XFormComponent.prototype.getError = function () {
|
|
71
|
-
var field = this.getFieldForEdit();
|
|
72
|
-
if (field) {
|
|
73
|
-
var error = this.props.form.state.errorMap[field];
|
|
74
|
-
if (error) {
|
|
75
|
-
if (error.onChange || error.onBlur || error.form) {
|
|
76
|
-
var message = '';
|
|
77
|
-
if (error.onChange) {
|
|
78
|
-
message += error.onChange;
|
|
79
|
-
}
|
|
80
|
-
if (error.onBlur) {
|
|
81
|
-
if (message !== '') {
|
|
82
|
-
message += ' ';
|
|
83
|
-
}
|
|
84
|
-
message += error.onBlur;
|
|
85
|
-
}
|
|
86
|
-
if (error.form) {
|
|
87
|
-
if (message !== '') {
|
|
88
|
-
message += ' ';
|
|
89
|
-
}
|
|
90
|
-
message += error.form;
|
|
91
|
-
}
|
|
92
|
-
return message;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return undefined;
|
|
97
|
-
};
|
|
98
|
-
// deprecated - nie je to pekne riesenie - do komponentu treba posielat error message (string) a nie props
|
|
107
|
+
// deprecated - nie je to pekne riesenie - do komponentu treba posielat error message (string) a nie props (asi ako v XAutoComplete)
|
|
99
108
|
XFormComponent.prototype.getClassNameTooltip = function () {
|
|
100
109
|
var error = this.getError();
|
|
101
110
|
return error ? {
|
|
@@ -104,6 +113,11 @@ var XFormComponent = /** @class */ (function (_super) {
|
|
|
104
113
|
tooltipOptions: { className: 'pink-tooltip', position: 'bottom' }
|
|
105
114
|
} : {};
|
|
106
115
|
};
|
|
116
|
+
// vrati error message z form.state.errorMap
|
|
117
|
+
XFormComponent.prototype.getError = function () {
|
|
118
|
+
var error = this.props.form.state.errorMap[this.getField()];
|
|
119
|
+
return error ? XUtils_1.XUtils.getXErrorMessage(error) : undefined;
|
|
120
|
+
};
|
|
107
121
|
return XFormComponent;
|
|
108
122
|
}(react_1.Component));
|
|
109
123
|
exports.XFormComponent = XFormComponent;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { XFormBase } from "./XFormBase";
|
|
2
2
|
import { Component, ReactChild } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { DataTableFilterMeta } from "primereact/datatable";
|
|
4
4
|
import { XEntity, XField } from "../serverApi/XEntityMetadata";
|
|
5
|
+
import { FilterMatchMode } from "primereact/api";
|
|
5
6
|
export interface XDropdownOptionsMap {
|
|
6
7
|
[assocField: string]: any[];
|
|
7
8
|
}
|
|
@@ -11,6 +12,7 @@ export interface XFormDataTableProps {
|
|
|
11
12
|
dataKey?: string;
|
|
12
13
|
paginator?: boolean;
|
|
13
14
|
rows?: number;
|
|
15
|
+
filterDisplay: "menu" | "row";
|
|
14
16
|
scrollable: boolean;
|
|
15
17
|
scrollWidth?: string;
|
|
16
18
|
scrollHeight?: string;
|
|
@@ -24,6 +26,7 @@ export interface XFormDataTableProps {
|
|
|
24
26
|
}
|
|
25
27
|
export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
26
28
|
static defaultProps: {
|
|
29
|
+
filterDisplay: string;
|
|
27
30
|
scrollable: boolean;
|
|
28
31
|
scrollWidth: string;
|
|
29
32
|
scrollHeight: string;
|
|
@@ -36,12 +39,14 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
36
39
|
state: {
|
|
37
40
|
selectedRow: {} | undefined;
|
|
38
41
|
dropdownOptionsMap: XDropdownOptionsMap;
|
|
39
|
-
filters:
|
|
42
|
+
filters: DataTableFilterMeta;
|
|
40
43
|
};
|
|
41
44
|
constructor(props: XFormDataTableProps);
|
|
42
45
|
static getPathForColumn(columnProps: XFormColumnProps): string;
|
|
43
46
|
static getHeader(columnProps: XFormColumnProps, xEntity: XEntity, field: string, xField: XField): string;
|
|
44
47
|
getEntity(): string;
|
|
48
|
+
createInitFilters(): DataTableFilterMeta;
|
|
49
|
+
getFilterMatchMode(xField: XField): FilterMatchMode;
|
|
45
50
|
onSelectionChange(event: any): void;
|
|
46
51
|
onDropdownOptionsMapChange(dropdownOptionsMap: XDropdownOptionsMap): void;
|
|
47
52
|
onFilter(event: any): void;
|
|
@@ -49,7 +54,6 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
49
54
|
getCheckboxFilterValue(field: string): boolean | null;
|
|
50
55
|
onDropdownFilterChange(field: string, displayValue: any): void;
|
|
51
56
|
getDropdownFilterValue(field: string): any;
|
|
52
|
-
onBodyValueChange(field: string, rowData: any, newValue: any): void;
|
|
53
57
|
bodyTemplate(columnProps: XFormColumnProps, rowData: any, xEntity: XEntity): any;
|
|
54
58
|
onClickAddRowDefault(): void;
|
|
55
59
|
onClickRemoveRowDefault(): void;
|
|
@@ -60,6 +64,7 @@ export interface XFormColumnProps {
|
|
|
60
64
|
header?: any;
|
|
61
65
|
readOnly?: boolean;
|
|
62
66
|
dropdownInFilter?: boolean;
|
|
67
|
+
showFilterMenu?: boolean;
|
|
63
68
|
width?: string;
|
|
64
69
|
}
|
|
65
70
|
export interface XFormInputSimpleColumnProps extends XFormColumnProps {
|