@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]) {
|
|
@@ -87,32 +89,15 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
87
89
|
props.form.addField(props.assocField + '.' + props.displayField);
|
|
88
90
|
return _this;
|
|
89
91
|
}
|
|
90
|
-
XSearchButton.prototype.
|
|
91
|
-
|
|
92
|
-
// TODO - zohladnit aj aktualny readOnly stav
|
|
93
|
-
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
94
|
-
if (!readOnly) {
|
|
95
|
-
return this.props.assocField;
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
92
|
+
XSearchButton.prototype.getField = function () {
|
|
93
|
+
return this.props.assocField;
|
|
98
94
|
};
|
|
99
|
-
XSearchButton.prototype.
|
|
100
|
-
|
|
101
|
-
// TODO - zohladnit aj aktualny readOnly stav
|
|
102
|
-
return !this.xAssoc.isNullable && !((_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false);
|
|
103
|
-
};
|
|
104
|
-
XSearchButton.prototype.getValueFromObject = function () {
|
|
105
|
-
var object = this.props.form.state.object;
|
|
106
|
-
var assocObject = object !== null ? object[this.props.assocField] : null;
|
|
107
|
-
// ak je undefined, pre istotu dame na null, null je standard
|
|
108
|
-
if (assocObject === undefined) {
|
|
109
|
-
assocObject = null;
|
|
110
|
-
}
|
|
111
|
-
return assocObject;
|
|
95
|
+
XSearchButton.prototype.isNotNull = function () {
|
|
96
|
+
return !this.xAssoc.isNullable;
|
|
112
97
|
};
|
|
113
98
|
XSearchButton.prototype.render = function () {
|
|
114
99
|
var _this = this;
|
|
115
|
-
var _a
|
|
100
|
+
var _a;
|
|
116
101
|
var props = this.props;
|
|
117
102
|
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
118
103
|
var xDisplayField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntityAssoc, props.displayField);
|
|
@@ -124,7 +109,7 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
124
109
|
var dialogOpened = this.state.dialogOpened;
|
|
125
110
|
var setDialogOpened = function (dialogOpened) { _this.setState({ dialogOpened: dialogOpened }); };
|
|
126
111
|
var computeInputValue = function () {
|
|
127
|
-
var inputValue
|
|
112
|
+
var inputValue;
|
|
128
113
|
if (!inputChanged) {
|
|
129
114
|
// TODO - pridat cez generikum typ fieldu (ak sa da)
|
|
130
115
|
// poznamka: ak assocObject === null tak treba do inputu zapisovat prazdny retazec, ak by sme pouzili null, neprejavila by sa zmena v modeli na null
|
|
@@ -136,12 +121,7 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
136
121
|
}
|
|
137
122
|
return inputValue;
|
|
138
123
|
};
|
|
139
|
-
var
|
|
140
|
-
if (this.checkNotNull()) {
|
|
141
|
-
label = XUtils_1.XUtils.markNotNull(label);
|
|
142
|
-
}
|
|
143
|
-
var readOnly = (_b = props.readOnly) !== null && _b !== void 0 ? _b : false;
|
|
144
|
-
var size = (_c = props.size) !== null && _c !== void 0 ? _c : xDisplayField.length;
|
|
124
|
+
var size = (_a = props.size) !== null && _a !== void 0 ? _a : xDisplayField.length;
|
|
145
125
|
var onInputValueChange = function (e) {
|
|
146
126
|
setInputChanged(true);
|
|
147
127
|
setInputValueState(e.target.value);
|
|
@@ -184,13 +164,12 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
184
164
|
});
|
|
185
165
|
}); };
|
|
186
166
|
var setValueToModel = function (row) {
|
|
187
|
-
|
|
188
|
-
props.form.onFieldChange(props.assocField, row, error);
|
|
167
|
+
_this.onValueChangeBase(row);
|
|
189
168
|
setInputChanged(false);
|
|
190
169
|
};
|
|
191
170
|
var onClickSearch = function (e) {
|
|
192
171
|
console.log("zavolany onClickSearch");
|
|
193
|
-
if (!
|
|
172
|
+
if (!_this.isReadOnly()) {
|
|
194
173
|
setDialogOpened(true);
|
|
195
174
|
// POVODNY KOD
|
|
196
175
|
//overlayPanelEl.current.toggle(e);
|
|
@@ -227,9 +206,9 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
227
206
|
// vypocitame inputValue
|
|
228
207
|
var inputValue = computeInputValue();
|
|
229
208
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
230
|
-
react_1.default.createElement("label", { htmlFor: props.assocField, className: "col-fixed", style:
|
|
209
|
+
react_1.default.createElement("label", { htmlFor: props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
231
210
|
react_1.default.createElement("div", { className: "x-search-button-base" },
|
|
232
|
-
react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly:
|
|
211
|
+
react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: this.isReadOnly(), ref: this.inputTextEl, maxLength: xDisplayField.length, size: size, style: props.inputStyle }, this.getClassNameTooltip())),
|
|
233
212
|
react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
|
|
234
213
|
react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, {
|
|
235
214
|
searchTableParams: {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -33,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
33
37
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
38
|
function step(op) {
|
|
35
39
|
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
37
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;
|
|
38
42
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
43
|
switch (op[0]) {
|
|
@@ -78,11 +82,11 @@ var inputtext_1 = require("primereact/inputtext");
|
|
|
78
82
|
var button_1 = require("primereact/button");
|
|
79
83
|
var dialog_1 = require("primereact/dialog");
|
|
80
84
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
81
|
-
|
|
82
|
-
var inputTextEl = react_1.useRef(null);
|
|
83
|
-
var _a = __read(react_1.useState(false), 2), inputChanged = _a[0], setInputChanged = _a[1]; // priznak, ci uzivatel typovanim zmenil hodnotu v inpute
|
|
84
|
-
var _b = __read(react_1.useState(null), 2), inputValueState = _b[0], setInputValueState = _b[1]; // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
|
|
85
|
-
var _c = __read(react_1.useState(false), 2), dialogOpened = _c[0], setDialogOpened = _c[1];
|
|
85
|
+
var XSearchButtonDT = function (props) {
|
|
86
|
+
var inputTextEl = (0, react_1.useRef)(null);
|
|
87
|
+
var _a = __read((0, react_1.useState)(false), 2), inputChanged = _a[0], setInputChanged = _a[1]; // priznak, ci uzivatel typovanim zmenil hodnotu v inpute
|
|
88
|
+
var _b = __read((0, react_1.useState)(null), 2), inputValueState = _b[0], setInputValueState = _b[1]; // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
|
|
89
|
+
var _c = __read((0, react_1.useState)(false), 2), dialogOpened = _c[0], setDialogOpened = _c[1];
|
|
86
90
|
var computeInputValue = function () {
|
|
87
91
|
var inputValue = null;
|
|
88
92
|
if (!inputChanged) {
|
|
@@ -181,3 +185,4 @@ exports.XSearchButtonDT = function (props) {
|
|
|
181
185
|
react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
|
|
182
186
|
react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, { searchTableParams: { onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined) } }, props.searchTable.children))));
|
|
183
187
|
};
|
|
188
|
+
exports.XSearchButtonDT = XSearchButtonDT;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -33,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
33
37
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
38
|
function step(op) {
|
|
35
39
|
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
37
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;
|
|
38
42
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
43
|
switch (op[0]) {
|
|
@@ -78,7 +82,7 @@ var button_1 = require("primereact/button");
|
|
|
78
82
|
var XUtils_1 = require("./XUtils");
|
|
79
83
|
var dialog_1 = require("primereact/dialog");
|
|
80
84
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
81
|
-
|
|
85
|
+
var XSearchButtonOld = function (props) {
|
|
82
86
|
var _a, _b, _c;
|
|
83
87
|
props.form.addField(props.assocField + '.' + props.displayField);
|
|
84
88
|
var xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity());
|
|
@@ -87,10 +91,10 @@ exports.XSearchButtonOld = function (props) {
|
|
|
87
91
|
var xDisplayField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntityAssoc, props.displayField);
|
|
88
92
|
// POVODNY KOD
|
|
89
93
|
//const overlayPanelEl = useRef<any>(null);
|
|
90
|
-
var inputTextEl = react_1.useRef(null);
|
|
91
|
-
var _d = __read(react_1.useState(false), 2), inputChanged = _d[0], setInputChanged = _d[1]; // priznak, ci uzivatel typovanim zmenil hodnotu v inpute
|
|
92
|
-
var _e = __read(react_1.useState(null), 2), inputValueState = _e[0], setInputValueState = _e[1]; // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
|
|
93
|
-
var _f = __read(react_1.useState(false), 2), dialogOpened = _f[0], setDialogOpened = _f[1];
|
|
94
|
+
var inputTextEl = (0, react_1.useRef)(null);
|
|
95
|
+
var _d = __read((0, react_1.useState)(false), 2), inputChanged = _d[0], setInputChanged = _d[1]; // priznak, ci uzivatel typovanim zmenil hodnotu v inpute
|
|
96
|
+
var _e = __read((0, react_1.useState)(null), 2), inputValueState = _e[0], setInputValueState = _e[1]; // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
|
|
97
|
+
var _f = __read((0, react_1.useState)(false), 2), dialogOpened = _f[0], setDialogOpened = _f[1];
|
|
94
98
|
var computeInputValue = function () {
|
|
95
99
|
var inputValue = null;
|
|
96
100
|
if (!inputChanged) {
|
|
@@ -205,3 +209,4 @@ exports.XSearchButtonOld = function (props) {
|
|
|
205
209
|
react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch }),
|
|
206
210
|
react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, { searchTableParams: { onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined) } }, props.searchTable.children))));
|
|
207
211
|
};
|
|
212
|
+
exports.XSearchButtonOld = XSearchButtonOld;
|
|
@@ -8,7 +8,7 @@ var react_1 = __importDefault(require("react"));
|
|
|
8
8
|
var button_1 = require("primereact/button");
|
|
9
9
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
10
10
|
var XUtils_1 = require("./XUtils");
|
|
11
|
-
|
|
11
|
+
var XToOneAssocButton = function (props) {
|
|
12
12
|
// mozno lepsie by bolo sem dat xEntityAssoc.idField ale postaci aj *FAKE*
|
|
13
13
|
props.form.addField(props.assocField + '.*FAKE*');
|
|
14
14
|
var label = props.label !== undefined ? props.label : props.assocField;
|
|
@@ -27,3 +27,4 @@ exports.XToOneAssocButton = function (props) {
|
|
|
27
27
|
react_1.default.createElement("label", { htmlFor: props.assocField, className: "col-fixed", style: { width: XUtils_1.XUtils.FIELD_LABEL_WIDTH } }, label),
|
|
28
28
|
react_1.default.createElement(button_1.Button, { label: label, onClick: onClickButton, disabled: assocObject === null })));
|
|
29
29
|
};
|
|
30
|
+
exports.XToOneAssocButton = XToOneAssocButton;
|
|
@@ -2,6 +2,7 @@ import { XToken } from "./XToken";
|
|
|
2
2
|
import { CsvDecimalFormat, CsvSeparator, ExportType } from "../serverApi/ExportImportParam";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { XEnvVar } from "./XEnvVars";
|
|
5
|
+
import { XError } from "./XErrors";
|
|
5
6
|
export declare enum OperationType {
|
|
6
7
|
None = 0,
|
|
7
8
|
Insert = 1,
|
|
@@ -55,7 +56,8 @@ export declare class XUtils {
|
|
|
55
56
|
static arrayMoveElement(array: any[], position: number, offset: number): void;
|
|
56
57
|
static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
|
|
57
58
|
static markNotNull(label: string): string;
|
|
58
|
-
static showErrorMessage(message: string, e:
|
|
59
|
+
static showErrorMessage(message: string, e: unknown): void;
|
|
59
60
|
static createErrorProps(error: string | undefined): {};
|
|
61
|
+
static getXErrorMessage(xError: XError): string | undefined;
|
|
60
62
|
static normalizeString(value: string): string;
|
|
61
63
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
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;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -202,7 +202,7 @@ var XUtils = /** @class */ (function () {
|
|
|
202
202
|
finally { if (e_2) throw e_2.error; }
|
|
203
203
|
}
|
|
204
204
|
// should not happen
|
|
205
|
-
console.log("XUtils.processGridBreakpoints: unexpected error: no breakpoint value found, breakpointExp = "
|
|
205
|
+
console.log("XUtils.processGridBreakpoints: unexpected error: no breakpoint value found, breakpointExp = ".concat(breakpointExp, ", availWidth = ").concat(availWidth));
|
|
206
206
|
return undefined;
|
|
207
207
|
};
|
|
208
208
|
XUtils.processPropWidth = function (widthProp) {
|
|
@@ -325,7 +325,7 @@ var XUtils = /** @class */ (function () {
|
|
|
325
325
|
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
headers = __assign(__assign({}, headers), { 'Authorization': "Basic "
|
|
328
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Basic ".concat(Buffer.from(xToken.username + ':' + xToken.password).toString('base64')) });
|
|
329
329
|
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
330
330
|
method: 'POST',
|
|
331
331
|
headers: headers,
|
|
@@ -361,7 +361,7 @@ var XUtils = /** @class */ (function () {
|
|
|
361
361
|
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer "
|
|
364
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(xToken.accessToken) });
|
|
365
365
|
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
366
366
|
method: 'POST',
|
|
367
367
|
headers: headers,
|
|
@@ -408,7 +408,7 @@ var XUtils = /** @class */ (function () {
|
|
|
408
408
|
XUtils.getEnvVarValue = function (envVarEnum) {
|
|
409
409
|
var value = process.env[envVarEnum];
|
|
410
410
|
if (value === undefined) {
|
|
411
|
-
throw "Environment variable "
|
|
411
|
+
throw "Environment variable ".concat(envVarEnum, " - value not found. Check configuration file .env*");
|
|
412
412
|
}
|
|
413
413
|
return value;
|
|
414
414
|
};
|
|
@@ -467,12 +467,39 @@ var XUtils = /** @class */ (function () {
|
|
|
467
467
|
else if (e instanceof Error) {
|
|
468
468
|
msg += e.message;
|
|
469
469
|
}
|
|
470
|
+
else if (typeof e === 'string' || typeof e === 'number') {
|
|
471
|
+
// chyba typu: throw 'nieco'
|
|
472
|
+
msg += e;
|
|
473
|
+
}
|
|
470
474
|
alert(msg);
|
|
471
475
|
};
|
|
472
476
|
// pouziva sa hlavne na inputy
|
|
473
477
|
XUtils.createErrorProps = function (error) {
|
|
474
478
|
return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } } : {};
|
|
475
479
|
};
|
|
480
|
+
// pomocna metodka
|
|
481
|
+
XUtils.getXErrorMessage = function (xError) {
|
|
482
|
+
if (xError.onChange || xError.onBlur || xError.form) {
|
|
483
|
+
var message = '';
|
|
484
|
+
if (xError.onChange) {
|
|
485
|
+
message += xError.onChange;
|
|
486
|
+
}
|
|
487
|
+
if (xError.onBlur) {
|
|
488
|
+
if (message !== '') {
|
|
489
|
+
message += ' ';
|
|
490
|
+
}
|
|
491
|
+
message += xError.onBlur;
|
|
492
|
+
}
|
|
493
|
+
if (xError.form) {
|
|
494
|
+
if (message !== '') {
|
|
495
|
+
message += ' ';
|
|
496
|
+
}
|
|
497
|
+
message += xError.form;
|
|
498
|
+
}
|
|
499
|
+
return message;
|
|
500
|
+
}
|
|
501
|
+
return undefined;
|
|
502
|
+
};
|
|
476
503
|
// pomocna metodka pouzivana (zatial len) pre autocomplete na ignorovanie velkych-malych znakov a diakritiky
|
|
477
504
|
XUtils.normalizeString = function (value) {
|
|
478
505
|
if (value) {
|
|
@@ -55,7 +55,7 @@ function dateFromModel(value) {
|
|
|
55
55
|
exports.dateFromModel = dateFromModel;
|
|
56
56
|
function dateAsUI(value) {
|
|
57
57
|
if (value !== null) {
|
|
58
|
-
return XUtilsCommon_1.dateFormat(value, dateFormatUI());
|
|
58
|
+
return (0, XUtilsCommon_1.dateFormat)(value, dateFormatUI());
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
return "";
|
|
@@ -64,7 +64,7 @@ function dateAsUI(value) {
|
|
|
64
64
|
exports.dateAsUI = dateAsUI;
|
|
65
65
|
function datetimeAsUI(value) {
|
|
66
66
|
if (value !== null) {
|
|
67
|
-
return XUtilsCommon_1.dateFormat(value, datetimeFormatUI());
|
|
67
|
+
return (0, XUtilsCommon_1.dateFormat)(value, datetimeFormatUI());
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
return "";
|
|
@@ -82,6 +82,14 @@ function timeFromModel(value) {
|
|
|
82
82
|
// mame '19:30:00' -> pridame hociaky rok aby sme skonvertovali na validny Date
|
|
83
83
|
rowDataCasStr = '1970-01-01 ' + rowDataCasStr;
|
|
84
84
|
}
|
|
85
|
+
// na safari nefunguje konverzia new Date('2021-06-07 19:30:00') - vrati NaN
|
|
86
|
+
// preto string prehodime na '2021-06-07T19:30:00+01:00'
|
|
87
|
+
// 19:30:00 je cas z timezony Central Europe (taka je nastavena na nodejs)), preto oznacime tento cas touto timezonou
|
|
88
|
+
// (spravne riesenie je posielat time cez json vzdy vo formate '2021-06-07T18:30:00Z', v tomto formate chodia aj datetime atributy)
|
|
89
|
+
rowDataCasStr = rowDataCasStr.replace(' ', 'T');
|
|
90
|
+
if (!rowDataCasStr.endsWith('Z') && rowDataCasStr.indexOf('+') === -1) {
|
|
91
|
+
rowDataCasStr += '+01:00'; // Central Europe timezone
|
|
92
|
+
}
|
|
85
93
|
timeValue = new Date(rowDataCasStr);
|
|
86
94
|
}
|
|
87
95
|
else if (typeof value === 'object' && value instanceof Date) {
|
|
@@ -22,7 +22,7 @@ export declare class XUtilsMetadata {
|
|
|
22
22
|
size?: number;
|
|
23
23
|
};
|
|
24
24
|
static CHAR_SIZE: number;
|
|
25
|
-
static computeColumnWidth(xField: XField, formColumnType: string | undefined, header: string | undefined): string | undefined;
|
|
25
|
+
static computeColumnWidth(xField: XField, filterMenuInFilterRow: boolean, formColumnType: string | undefined, header: string | undefined, filterButtonInHeader: boolean): string | undefined;
|
|
26
26
|
static computeColumnWidthBase(charSize?: number, paddingAndOther?: number): number | undefined;
|
|
27
27
|
static getXBrowseMeta(entity: string, browseId?: string): XBrowseMeta;
|
|
28
28
|
static setXBrowseMeta(entity: string, browseId: string | undefined, xBrowseMeta: XBrowseMeta): void;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
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;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -109,7 +109,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
109
109
|
XUtilsMetadata.getXEntity = function (entity) {
|
|
110
110
|
var xEntity = XUtilsMetadata.xEntityMap[entity];
|
|
111
111
|
if (xEntity === undefined) {
|
|
112
|
-
throw "Entity "
|
|
112
|
+
throw "Entity ".concat(entity, " was not found in entity metadata");
|
|
113
113
|
}
|
|
114
114
|
return xEntity;
|
|
115
115
|
};
|
|
@@ -117,7 +117,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
117
117
|
// TODO - pozor, vo fieldMap su aj asociacie, trebalo by zmenit vytvaranie metadat tak aby tam tie asociacie neboli
|
|
118
118
|
var xField = xEntity.fieldMap[field];
|
|
119
119
|
if (xField === undefined) {
|
|
120
|
-
throw "Field "
|
|
120
|
+
throw "Field ".concat(field, " was not found in entity ").concat(xEntity.name);
|
|
121
121
|
}
|
|
122
122
|
return xField;
|
|
123
123
|
};
|
|
@@ -192,7 +192,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
192
192
|
size = precision;
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
|
-
throw "XInputDecimal: field "
|
|
195
|
+
throw "XInputDecimal: field ".concat(xField.name, " has unsupported type ").concat(xField.type, ". Supported types are decimal and number.");
|
|
196
196
|
}
|
|
197
197
|
var min = undefined;
|
|
198
198
|
var max = undefined;
|
|
@@ -203,7 +203,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
203
203
|
}
|
|
204
204
|
return { useGrouping: useGrouping, fractionDigits: fractionDigits, min: min, max: max, size: size };
|
|
205
205
|
};
|
|
206
|
-
XUtilsMetadata.computeColumnWidth = function (xField, formColumnType, header) {
|
|
206
|
+
XUtilsMetadata.computeColumnWidth = function (xField, filterMenuInFilterRow, formColumnType, header, filterButtonInHeader) {
|
|
207
207
|
var width;
|
|
208
208
|
if (formColumnType === undefined) {
|
|
209
209
|
// lazy datatable (no inputs, no buttons, only text and padding)
|
|
@@ -224,7 +224,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
224
224
|
width = 1.43 + 0.5 + 0.5; // checkbox ma sirku 20px
|
|
225
225
|
}
|
|
226
226
|
else {
|
|
227
|
-
throw "XField "
|
|
227
|
+
throw "XField ".concat(xField.name, ": unknown xField.type = ").concat(xField.type);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
else {
|
|
@@ -248,7 +248,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
248
248
|
width = 1.43 + 0.5 + 0.5; // checkbox ma sirku 20px
|
|
249
249
|
}
|
|
250
250
|
else {
|
|
251
|
-
throw "XField "
|
|
251
|
+
throw "XField ".concat(xField.name, ": unknown xField.type = ").concat(xField.type);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
else if (formColumnType === "dropdown" || formColumnType === "searchButton" || formColumnType === "autoComplete") {
|
|
@@ -268,7 +268,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
268
268
|
width = XUtilsMetadata.computeColumnWidthBase(10 + 9, padding + padding); // napr. 31.12.2021 03:03:00
|
|
269
269
|
}
|
|
270
270
|
else {
|
|
271
|
-
throw "XField "
|
|
271
|
+
throw "XField ".concat(xField.name, ": xField.type = ").concat(xField.type, " not implemented for dropdown/searchButton/autoComplete");
|
|
272
272
|
}
|
|
273
273
|
// pridame sirku buttonu
|
|
274
274
|
if (formColumnType === "dropdown") {
|
|
@@ -282,16 +282,25 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
else if (formColumnType === "autoComplete") {
|
|
285
|
-
throw "XField "
|
|
285
|
+
throw "XField ".concat(xField.name, ": computing button width not implemented for autoComplete");
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
else {
|
|
289
289
|
throw "Unknown prop type = " + formColumnType;
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
+
if (filterMenuInFilterRow) {
|
|
293
|
+
// if the column has width of 25 characters or more, then the input field can be shorter
|
|
294
|
+
if (width !== undefined && width < 25 * XUtilsMetadata.CHAR_SIZE) {
|
|
295
|
+
width += 1.25; // filter menu icon
|
|
296
|
+
}
|
|
297
|
+
}
|
|
292
298
|
// ak je label dlhsi ako sirka stlpca, tak sirka stlpca bude podla label-u
|
|
293
299
|
if (header !== undefined) {
|
|
294
|
-
var widthHeader = XUtilsMetadata.computeColumnWidthBase(header.length, 0.5 + 0.5 + 1.28
|
|
300
|
+
var widthHeader = XUtilsMetadata.computeColumnWidthBase(header.length, 0.5 + 0.5 + 1.28); // padding (7px) + space (7px) + sort icon (18px)
|
|
301
|
+
if (filterButtonInHeader && widthHeader !== undefined) {
|
|
302
|
+
widthHeader += 1.5; // filter icon (21px = 14px (icon body) + 7px (right padding))
|
|
303
|
+
}
|
|
295
304
|
if (widthHeader !== undefined) {
|
|
296
305
|
if (width === undefined || widthHeader > width) {
|
|
297
306
|
width = widthHeader;
|
|
@@ -329,7 +338,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
329
338
|
XUtilsMetadata.getXAssoc = function (xEntity, assocMap, assocField) {
|
|
330
339
|
var xAssoc = assocMap[assocField];
|
|
331
340
|
if (xAssoc === undefined) {
|
|
332
|
-
throw "Assoc "
|
|
341
|
+
throw "Assoc ".concat(assocField, " was not found in entity = ").concat(xEntity.name);
|
|
333
342
|
}
|
|
334
343
|
return xAssoc;
|
|
335
344
|
};
|
|
@@ -27,7 +27,7 @@ function useXToken() {
|
|
|
27
27
|
}
|
|
28
28
|
return xToken;
|
|
29
29
|
};
|
|
30
|
-
var _a = __read(react_1.useState(getXToken()), 2), xToken = _a[0], setXToken = _a[1];
|
|
30
|
+
var _a = __read((0, react_1.useState)(getXToken()), 2), xToken = _a[0], setXToken = _a[1];
|
|
31
31
|
XUtils_1.XUtils.setXToken(xToken);
|
|
32
32
|
var saveXToken = function (xToken) {
|
|
33
33
|
if (xToken !== null) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataTableFilterMeta, DataTableSortMeta } from "primereact/datatable";
|
|
2
2
|
export declare enum ExportType {
|
|
3
3
|
Csv = "csv",
|
|
4
4
|
Json = "json"
|
|
5
5
|
}
|
|
6
6
|
export interface ExportParam {
|
|
7
7
|
exportType: ExportType;
|
|
8
|
-
filters:
|
|
9
|
-
multiSortMeta?:
|
|
8
|
+
filters: DataTableFilterMeta;
|
|
9
|
+
multiSortMeta?: DataTableSortMeta[];
|
|
10
10
|
entity: string;
|
|
11
11
|
fields: string[];
|
|
12
12
|
csvParam?: CsvParam;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
value: string;
|
|
3
|
-
matchMode: 'startsWith' | 'equals';
|
|
4
|
-
}
|
|
5
|
-
export interface Filters {
|
|
6
|
-
[field: string]: FilterValue;
|
|
7
|
-
}
|
|
8
|
-
export interface SortMeta {
|
|
9
|
-
field: string;
|
|
10
|
-
order: 1 | -1;
|
|
11
|
-
}
|
|
1
|
+
import { DataTableFilterMeta, DataTableSortMeta } from "primereact/datatable";
|
|
12
2
|
export declare enum ResultType {
|
|
13
3
|
OnlyRowCount = 0,
|
|
14
4
|
RowCountAndPagedRows = 1,
|
|
@@ -18,8 +8,8 @@ export interface FindParam {
|
|
|
18
8
|
resultType: ResultType;
|
|
19
9
|
first?: number;
|
|
20
10
|
rows?: number;
|
|
21
|
-
filters:
|
|
22
|
-
multiSortMeta?:
|
|
11
|
+
filters: DataTableFilterMeta;
|
|
12
|
+
multiSortMeta?: DataTableSortMeta[];
|
|
23
13
|
entity: string;
|
|
24
14
|
fields: string[];
|
|
25
15
|
}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ResultType = void 0;
|
|
4
|
+
// TODO - replaced with DataTableFilterMetaData
|
|
5
|
+
// export interface FilterValue {
|
|
6
|
+
// value : string;
|
|
7
|
+
// matchMode : 'startsWith' | 'equals'; // matchMode ma konstanty napr. startsWith
|
|
8
|
+
// }
|
|
9
|
+
// TODO - replaced with DataTableFilterMeta
|
|
10
|
+
// export interface Filters {
|
|
11
|
+
// [field: string]: FilterValue; // specialny typ pre object (dictionary) ktory ma dynamicky pocet propertiesov
|
|
12
|
+
// }
|
|
13
|
+
// TODO - replace with DataTableSortMeta
|
|
14
|
+
// export interface SortMeta {
|
|
15
|
+
// field : string;
|
|
16
|
+
// order : 1 | -1; // hodnoty 1 alebo -1
|
|
17
|
+
// }
|
|
4
18
|
var ResultType;
|
|
5
19
|
(function (ResultType) {
|
|
6
20
|
ResultType[ResultType["OnlyRowCount"] = 0] = "OnlyRowCount";
|
|
@@ -64,11 +64,11 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
64
64
|
// TODO - ak pre datetime nastavime vsetky zlozky casu na 00:00:00, tak sformatuje hodnotu ako datum a spravi chybu pri zapise do DB - zapise 1:00:00
|
|
65
65
|
var dateStr;
|
|
66
66
|
if (this.getHours() === 0 && this.getMinutes() === 0 && this.getSeconds() === 0) {
|
|
67
|
-
dateStr = exports.dateFormat(this, 'yyyy-mm-dd');
|
|
67
|
+
dateStr = (0, exports.dateFormat)(this, 'yyyy-mm-dd');
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
// jedna sa o datetime
|
|
71
|
-
dateStr = exports.dateFormat(this, 'yyyy-mm-dd HH:MM:ss');
|
|
71
|
+
dateStr = (0, exports.dateFormat)(this, 'yyyy-mm-dd HH:MM:ss');
|
|
72
72
|
}
|
|
73
73
|
return dateStr;
|
|
74
74
|
};
|