@michalrakus/x-react-web-lib 1.0.0 → 1.2.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/FindParam.d.ts +3 -0
- package/FindParam.js +5 -0
- package/LICENSE.md +21 -0
- package/XButtonIconNarrow.d.ts +3 -0
- package/XButtonIconNarrow.js +5 -0
- package/XButtonIconSmall.d.ts +3 -0
- package/XButtonIconSmall.js +5 -0
- package/XFieldChangeEvent.d.ts +3 -0
- package/XFieldChangeEvent.js +5 -0
- package/XInputTextarea.d.ts +3 -0
- package/XInputTextarea.js +5 -0
- package/gulpfile.js +5 -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/SearchTableParams.d.ts +8 -2
- package/lib/components/SourceCodeLinkEntity.js +3 -2
- package/lib/components/XAutoComplete.d.ts +10 -7
- package/lib/components/XAutoComplete.js +37 -41
- package/lib/components/XAutoCompleteBase.d.ts +8 -5
- package/lib/components/XAutoCompleteBase.js +86 -43
- package/lib/components/XAutoCompleteDT.d.ts +33 -0
- package/lib/components/XAutoCompleteDT.js +141 -0
- package/lib/components/XBrowse.js +11 -5
- package/lib/components/XButton.d.ts +3 -1
- package/lib/components/XButton.js +3 -2
- package/lib/components/XButtonIconNarrow.d.ts +10 -0
- package/lib/components/XButtonIconNarrow.js +25 -0
- package/lib/components/XButtonIconSmall.d.ts +3 -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 +7 -5
- 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/XFieldChangeEvent.d.ts +11 -0
- package/lib/components/XFieldChangeEvent.js +2 -0
- package/lib/components/XFieldSelector.js +11 -6
- package/lib/components/XFormBase.d.ts +17 -8
- package/lib/components/XFormBase.js +127 -48
- package/lib/components/XFormBaseT.js +3 -1
- package/lib/components/XFormComponent.d.ts +19 -7
- package/lib/components/XFormComponent.js +89 -49
- package/lib/components/XFormComponentDT.d.ts +30 -0
- package/lib/components/XFormComponentDT.js +119 -0
- package/lib/components/XFormDataTable2.d.ts +53 -8
- package/lib/components/XFormDataTable2.js +270 -57
- 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/XInputDT.d.ts +11 -0
- package/lib/components/XInputDT.js +37 -0
- package/lib/components/XInputDate.d.ts +2 -1
- package/lib/components/XInputDate.js +7 -4
- package/lib/components/XInputDateDT.js +3 -2
- package/lib/components/XInputDecimal.d.ts +9 -2
- package/lib/components/XInputDecimal.js +63 -45
- package/lib/components/XInputDecimalDT.d.ts +10 -8
- package/lib/components/XInputDecimalDT.js +59 -36
- package/lib/components/XInputText.d.ts +7 -11
- package/lib/components/XInputText.js +22 -49
- 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 +8 -0
- package/lib/components/XLazyDataTable.js +187 -85
- 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 +8 -7
- package/lib/components/XSearchButton.js +32 -51
- package/lib/components/XSearchButtonDT.js +15 -10
- package/lib/components/XSearchButtonOld.js +13 -8
- package/lib/components/XToOneAssocButton.js +2 -1
- package/lib/components/XUtils.d.ts +13 -1
- package/lib/components/XUtils.js +125 -5
- package/lib/components/XUtilsConversions.d.ts +1 -0
- package/lib/components/XUtilsConversions.js +24 -3
- package/lib/components/XUtilsMetadata.d.ts +4 -1
- package/lib/components/XUtilsMetadata.js +62 -14
- package/lib/components/useXToken.js +1 -1
- package/lib/serverApi/ExportImportParam.d.ts +3 -3
- package/lib/serverApi/FindParam.d.ts +12 -14
- package/lib/serverApi/FindParam.js +14 -0
- package/lib/serverApi/XUtilsCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +6 -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 __());
|
|
@@ -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, onChange, assocObjectChange) {
|
|
46
|
+
var error = this.validateOnChange(value);
|
|
47
|
+
this.props.form.onFieldChange(this.getField(), value, error, onChange, assocObjectChange);
|
|
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);
|
|
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;
|
|
29
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,37 @@ 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.getErrorMessage(error) : undefined;
|
|
120
|
+
};
|
|
121
|
+
XFormComponent.prototype.callOnChangeFromOnBlur = function () {
|
|
122
|
+
if (this.props.onChange) {
|
|
123
|
+
var object = this.props.form.getXObject();
|
|
124
|
+
// developer v onChange nastavi atributy na object-e
|
|
125
|
+
this.props.onChange({ object: object });
|
|
126
|
+
// rovno zavolame form.setState({...}), nech to nemusi robit developer
|
|
127
|
+
this.props.form.setStateXForm();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
// len pre assoc fieldy sa pouziva
|
|
131
|
+
XFormComponent.prototype.getFilterBase = function (filter) {
|
|
132
|
+
var customFilter = undefined;
|
|
133
|
+
if (typeof filter === 'object') {
|
|
134
|
+
customFilter = filter;
|
|
135
|
+
}
|
|
136
|
+
if (typeof filter === 'function') {
|
|
137
|
+
//const object: XObject = this.props.form.getXObject();
|
|
138
|
+
var object = this.props.form.state.object;
|
|
139
|
+
// zatial zakomentujeme, aby sa zavolal aj pre XAutoComplete (tam zatial nemame k dispozicii object
|
|
140
|
+
// (componentDidMount pre XAutoComplete sa vola skor ako componentDidMount pre XFormBase))
|
|
141
|
+
//if (object) {
|
|
142
|
+
customFilter = filter(object);
|
|
143
|
+
//}
|
|
144
|
+
}
|
|
145
|
+
return customFilter;
|
|
146
|
+
};
|
|
107
147
|
return XFormComponent;
|
|
108
148
|
}(react_1.Component));
|
|
109
149
|
exports.XFormComponent = XFormComponent;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { XFormBase } from "./XFormBase";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
import { OperationType } from "./XUtils";
|
|
4
|
+
import { XError } from "./XErrors";
|
|
5
|
+
import { XCustomFilter } from "../serverApi/FindParam";
|
|
6
|
+
import { XTableFieldFilterProp, TableFieldOnChange } from "./XFormDataTable2";
|
|
7
|
+
export interface XFormComponentDTProps {
|
|
8
|
+
form: XFormBase;
|
|
9
|
+
entity: string;
|
|
10
|
+
rowData: any;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
onChange?: TableFieldOnChange;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class XFormComponentDT<P extends XFormComponentDTProps> extends Component<P> {
|
|
15
|
+
protected constructor(props: P);
|
|
16
|
+
abstract getField(): string;
|
|
17
|
+
getValueFromRowData(): any;
|
|
18
|
+
onValueChangeBase(value: any, onChange?: TableFieldOnChange, assocObjectChange?: OperationType): void;
|
|
19
|
+
abstract isNotNull(): boolean;
|
|
20
|
+
isReadOnly(): boolean;
|
|
21
|
+
validate(): {
|
|
22
|
+
field: string;
|
|
23
|
+
xError: XError;
|
|
24
|
+
} | undefined;
|
|
25
|
+
validateOnChange(value: any): string | undefined;
|
|
26
|
+
validateNotNull(value: any): string | undefined;
|
|
27
|
+
getError(): string | undefined;
|
|
28
|
+
callOnChangeFromOnBlur(): void;
|
|
29
|
+
getFilterBase(filter: XTableFieldFilterProp | undefined): XCustomFilter | undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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.XFormComponentDT = void 0;
|
|
19
|
+
var XFormBase_1 = require("./XFormBase");
|
|
20
|
+
var react_1 = require("react");
|
|
21
|
+
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
22
|
+
var XUtils_1 = require("./XUtils");
|
|
23
|
+
var XFormComponentDT = /** @class */ (function (_super) {
|
|
24
|
+
__extends(XFormComponentDT, _super);
|
|
25
|
+
function XFormComponentDT(props) {
|
|
26
|
+
var _this = _super.call(this, props) || this;
|
|
27
|
+
XFormBase_1.XFormBase.getXRowTechData(props.rowData).xFormComponentDTList.push(_this);
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
// ******** read and write from/into this.props.rowData ***********
|
|
31
|
+
// reads value from this.props.rowData
|
|
32
|
+
// can be overridden, but this should work for every component
|
|
33
|
+
XFormComponentDT.prototype.getValueFromRowData = function () {
|
|
34
|
+
var rowDataValue = null;
|
|
35
|
+
// test na undefined je tu koli insertu noveho riadku
|
|
36
|
+
if (this.props.rowData !== undefined && this.props.rowData !== null) {
|
|
37
|
+
rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(this.props.rowData, this.getField());
|
|
38
|
+
// pre istotu dame na null, null je standard
|
|
39
|
+
if (rowDataValue === undefined) {
|
|
40
|
+
rowDataValue = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return rowDataValue;
|
|
44
|
+
};
|
|
45
|
+
// writes value into form.state.object
|
|
46
|
+
XFormComponentDT.prototype.onValueChangeBase = function (value, onChange, assocObjectChange) {
|
|
47
|
+
var error = this.validateOnChange(value);
|
|
48
|
+
this.props.form.onTableFieldChange(this.props.rowData, this.getField(), value, error, onChange, assocObjectChange);
|
|
49
|
+
};
|
|
50
|
+
XFormComponentDT.prototype.isReadOnly = function () {
|
|
51
|
+
// tuto do buducna planujeme pridat aj dynamicky readOnly, bude ho treba ukladat do form.state podobne ako sa ukladaju errory do form.state.errorMap
|
|
52
|
+
return XUtils_1.XUtils.isReadOnly(this.getField(), this.props.readOnly);
|
|
53
|
+
};
|
|
54
|
+
// *********** validation support ************
|
|
55
|
+
// volane po kliknuti na Save
|
|
56
|
+
// vrati (field, XError) ak nezbehne "field validacia", ak zbehne, vrati undefined
|
|
57
|
+
XFormComponentDT.prototype.validate = function () {
|
|
58
|
+
// TODO - FILOZOFICKA OTAZKA - volat validaciu aj ked je field readOnly (this.isReadOnly() === true)? zatial dame ze hej...
|
|
59
|
+
var value = this.getValueFromRowData();
|
|
60
|
+
// not null validacia + custom field validacia volana na onChange
|
|
61
|
+
var errorOnChange = this.validateOnChange(value);
|
|
62
|
+
// custom field validacia volana na onBlur (focus lost)
|
|
63
|
+
// TODO - fieldLabel
|
|
64
|
+
if (errorOnChange) {
|
|
65
|
+
return { field: this.getField(), xError: { onChange: errorOnChange, fieldLabel: undefined } };
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
};
|
|
69
|
+
XFormComponentDT.prototype.validateOnChange = function (value) {
|
|
70
|
+
var error = this.validateNotNull(value);
|
|
71
|
+
if (error) {
|
|
72
|
+
return error;
|
|
73
|
+
}
|
|
74
|
+
// custom field validacia volana na onChange
|
|
75
|
+
// TODO
|
|
76
|
+
return undefined;
|
|
77
|
+
};
|
|
78
|
+
XFormComponentDT.prototype.validateNotNull = function (value) {
|
|
79
|
+
// validacia by mala sediet s metodou getLabel(), kde sa pridava * , preto tu mame aj test !this.isReadOnly() - id fieldy pri inserte nechceme testovat
|
|
80
|
+
// otazka je ci nevypinat validaciu pre readOnly fieldy vzdy (aj ked napr. readOnly vznikne dynamicky)
|
|
81
|
+
if (this.isNotNull() && !this.isReadOnly() && value === null) {
|
|
82
|
+
return "Field is required.";
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
};
|
|
86
|
+
// vrati error message z rowData.errorMap
|
|
87
|
+
XFormComponentDT.prototype.getError = function () {
|
|
88
|
+
var error = XFormBase_1.XFormBase.getXRowTechData(this.props.rowData).errorMap[this.getField()];
|
|
89
|
+
return error ? XUtils_1.XUtils.getErrorMessage(error) : undefined;
|
|
90
|
+
};
|
|
91
|
+
XFormComponentDT.prototype.callOnChangeFromOnBlur = function () {
|
|
92
|
+
if (this.props.onChange) {
|
|
93
|
+
var object = this.props.form.getXObject();
|
|
94
|
+
// developer v onChange nastavi atributy na object-e
|
|
95
|
+
this.props.onChange({ object: object, tableRow: this.props.rowData, assocObjectChange: undefined });
|
|
96
|
+
// rovno zavolame form.setState({...}), nech to nemusi robit developer
|
|
97
|
+
this.props.form.setStateXForm();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
// len pre assoc fieldy sa pouziva, aj to nie pre vsetky
|
|
101
|
+
XFormComponentDT.prototype.getFilterBase = function (filter) {
|
|
102
|
+
var customFilter = undefined;
|
|
103
|
+
if (typeof filter === 'object') {
|
|
104
|
+
customFilter = filter;
|
|
105
|
+
}
|
|
106
|
+
if (typeof filter === 'function') {
|
|
107
|
+
//const object: XObject = this.props.form.getXObject();
|
|
108
|
+
var object = this.props.form.state.object;
|
|
109
|
+
// zatial zakomentujeme, aby sa zavolal aj pre XAutoComplete (tam zatial nemame k dispozicii object
|
|
110
|
+
// (componentDidMount pre XAutoComplete sa vola skor ako componentDidMount pre XFormBase))
|
|
111
|
+
//if (object) {
|
|
112
|
+
customFilter = filter(object, this.props.rowData);
|
|
113
|
+
//}
|
|
114
|
+
}
|
|
115
|
+
return customFilter;
|
|
116
|
+
};
|
|
117
|
+
return XFormComponentDT;
|
|
118
|
+
}(react_1.Component));
|
|
119
|
+
exports.XFormComponentDT = XFormComponentDT;
|
|
@@ -1,7 +1,18 @@
|
|
|
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";
|
|
6
|
+
import { XTableFieldChangeEvent } from "./XFieldChangeEvent";
|
|
7
|
+
import { XCustomFilter } from "../serverApi/FindParam";
|
|
8
|
+
import { XFormComponentDT } from "./XFormComponentDT";
|
|
9
|
+
import { XErrorMap } from "./XErrors";
|
|
10
|
+
import { IconType } from "primereact/utils";
|
|
11
|
+
import { ButtonProps } from "primereact/button";
|
|
12
|
+
export interface XRowTechData {
|
|
13
|
+
xFormComponentDTList: Array<XFormComponentDT<any>>;
|
|
14
|
+
errorMap: XErrorMap;
|
|
15
|
+
}
|
|
5
16
|
export interface XDropdownOptionsMap {
|
|
6
17
|
[assocField: string]: any[];
|
|
7
18
|
}
|
|
@@ -11,6 +22,8 @@ export interface XFormDataTableProps {
|
|
|
11
22
|
dataKey?: string;
|
|
12
23
|
paginator?: boolean;
|
|
13
24
|
rows?: number;
|
|
25
|
+
filterDisplay: "menu" | "row" | "none";
|
|
26
|
+
sortable: boolean;
|
|
14
27
|
scrollable: boolean;
|
|
15
28
|
scrollWidth?: string;
|
|
16
29
|
scrollHeight?: string;
|
|
@@ -18,16 +31,26 @@ export interface XFormDataTableProps {
|
|
|
18
31
|
label?: string;
|
|
19
32
|
readOnly?: boolean;
|
|
20
33
|
onClickAddRow?: () => void;
|
|
21
|
-
onClickRemoveRow?: () => void;
|
|
34
|
+
onClickRemoveRow?: (row: any) => void;
|
|
35
|
+
removeButtonInRow: boolean;
|
|
36
|
+
addRowLabel: string;
|
|
37
|
+
addRowIcon?: IconType<ButtonProps>;
|
|
38
|
+
removeRowLabel: string;
|
|
39
|
+
removeRowIcon?: IconType<ButtonProps>;
|
|
22
40
|
width?: string;
|
|
23
41
|
children: ReactChild[];
|
|
24
42
|
}
|
|
25
43
|
export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
26
44
|
static defaultProps: {
|
|
45
|
+
filterDisplay: string;
|
|
46
|
+
sortable: boolean;
|
|
27
47
|
scrollable: boolean;
|
|
28
48
|
scrollWidth: string;
|
|
29
49
|
scrollHeight: string;
|
|
30
50
|
shrinkWidth: boolean;
|
|
51
|
+
removeButtonInRow: boolean;
|
|
52
|
+
addRowLabel: string;
|
|
53
|
+
removeRowLabel: string;
|
|
31
54
|
};
|
|
32
55
|
props: XFormDataTableProps;
|
|
33
56
|
entity?: string;
|
|
@@ -36,12 +59,15 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
36
59
|
state: {
|
|
37
60
|
selectedRow: {} | undefined;
|
|
38
61
|
dropdownOptionsMap: XDropdownOptionsMap;
|
|
39
|
-
filters:
|
|
62
|
+
filters: DataTableFilterMeta;
|
|
40
63
|
};
|
|
41
64
|
constructor(props: XFormDataTableProps);
|
|
42
|
-
|
|
65
|
+
getPathForColumn(columnProps: XFormColumnProps): string;
|
|
66
|
+
getDisplayFieldOrId(columnPropsAutoComplete: XFormAutoCompleteColumnProps): string;
|
|
43
67
|
static getHeader(columnProps: XFormColumnProps, xEntity: XEntity, field: string, xField: XField): string;
|
|
44
68
|
getEntity(): string;
|
|
69
|
+
createInitFilters(): DataTableFilterMeta;
|
|
70
|
+
getFilterMatchMode(xField: XField): FilterMatchMode;
|
|
45
71
|
onSelectionChange(event: any): void;
|
|
46
72
|
onDropdownOptionsMapChange(dropdownOptionsMap: XDropdownOptionsMap): void;
|
|
47
73
|
onFilter(event: any): void;
|
|
@@ -49,18 +75,24 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
49
75
|
getCheckboxFilterValue(field: string): boolean | null;
|
|
50
76
|
onDropdownFilterChange(field: string, displayValue: any): void;
|
|
51
77
|
getDropdownFilterValue(field: string): any;
|
|
52
|
-
onBodyValueChange(field: string, rowData: any, newValue: any): void;
|
|
53
78
|
bodyTemplate(columnProps: XFormColumnProps, rowData: any, xEntity: XEntity): any;
|
|
54
|
-
|
|
55
|
-
|
|
79
|
+
onClickAddRow(): void;
|
|
80
|
+
onClickRemoveRowBySelection(): void;
|
|
81
|
+
removeRow(row: any): void;
|
|
82
|
+
validate(): void;
|
|
83
|
+
getErrorMessages(): string;
|
|
56
84
|
render(): JSX.Element;
|
|
57
85
|
}
|
|
86
|
+
export type TableFieldOnChange = (e: XTableFieldChangeEvent<any, any>) => void;
|
|
87
|
+
export type XTableFieldFilterProp = XCustomFilter | ((object: any, rowData: any) => XCustomFilter | undefined);
|
|
58
88
|
export interface XFormColumnProps {
|
|
59
|
-
type:
|
|
89
|
+
type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton";
|
|
60
90
|
header?: any;
|
|
61
91
|
readOnly?: boolean;
|
|
62
92
|
dropdownInFilter?: boolean;
|
|
93
|
+
showFilterMenu?: boolean;
|
|
63
94
|
width?: string;
|
|
95
|
+
onChange?: TableFieldOnChange;
|
|
64
96
|
}
|
|
65
97
|
export interface XFormInputSimpleColumnProps extends XFormColumnProps {
|
|
66
98
|
field: string;
|
|
@@ -69,6 +101,13 @@ export interface XFormDropdownColumnProps extends XFormColumnProps {
|
|
|
69
101
|
assocField: string;
|
|
70
102
|
displayField: string;
|
|
71
103
|
}
|
|
104
|
+
export interface XFormAutoCompleteColumnProps extends XFormColumnProps {
|
|
105
|
+
assocField: string;
|
|
106
|
+
displayField: string | ((suggestion: any) => string);
|
|
107
|
+
searchTable?: any;
|
|
108
|
+
assocForm?: any;
|
|
109
|
+
filter?: XTableFieldFilterProp;
|
|
110
|
+
}
|
|
72
111
|
export interface XFormSearchButtonColumnProps extends XFormColumnProps {
|
|
73
112
|
assocField: string;
|
|
74
113
|
displayField: string;
|
|
@@ -86,6 +125,12 @@ export declare const XFormDropdownColumn: {
|
|
|
86
125
|
type: string;
|
|
87
126
|
};
|
|
88
127
|
};
|
|
128
|
+
export declare const XFormAutoCompleteColumn: {
|
|
129
|
+
(props: XFormAutoCompleteColumnProps): null;
|
|
130
|
+
defaultProps: {
|
|
131
|
+
type: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
89
134
|
export declare const XFormSearchButtonColumn: {
|
|
90
135
|
(props: XFormSearchButtonColumnProps): null;
|
|
91
136
|
defaultProps: {
|