@michalrakus/x-react-web-lib 0.25.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/XEnvVars.d.ts +3 -0
- package/XEnvVars.js +5 -0
- package/XInputTextarea.d.ts +3 -0
- package/XInputTextarea.js +5 -0
- package/gulpfile.js +2 -0
- package/lib/administration/XBrowseMetaForm.js +1 -1
- package/lib/administration/XUserBrowse.js +5 -4
- package/lib/administration/XUserForm.js +40 -28
- package/lib/components/SourceCodeLinkEntity.js +1 -1
- package/lib/components/XAutoComplete.d.ts +3 -3
- package/lib/components/XAutoComplete.js +16 -37
- package/lib/components/XAutoCompleteBase.d.ts +1 -1
- package/lib/components/XAutoCompleteBase.js +23 -22
- package/lib/components/XBrowse.js +7 -3
- package/lib/components/XChangePasswordForm.js +9 -5
- package/lib/components/XCheckbox.d.ts +8 -9
- package/lib/components/XCheckbox.js +38 -30
- package/lib/components/XDataTable.js +11 -7
- package/lib/components/XDropdown.d.ts +4 -3
- package/lib/components/XDropdown.js +21 -44
- package/lib/components/XDropdownDT.js +7 -3
- package/lib/components/XDropdownDTFilter.js +9 -5
- package/lib/components/XDropdownFormDTFilter.js +9 -5
- package/lib/components/XEditColumnDialog.js +9 -5
- package/lib/components/XEnvVars.d.ts +12 -0
- package/lib/components/XEnvVars.js +20 -0
- package/lib/components/XErrors.d.ts +1 -0
- package/lib/components/XExportRowsDialog.js +12 -6
- package/lib/components/XFieldSelector.js +8 -4
- package/lib/components/XFormBase.d.ts +1 -0
- package/lib/components/XFormBase.js +47 -21
- package/lib/components/XFormComponent.d.ts +10 -6
- package/lib/components/XFormComponent.js +60 -48
- package/lib/components/XFormDataTable2.d.ts +8 -3
- package/lib/components/XFormDataTable2.js +106 -28
- package/lib/components/XFormNavigator3.js +14 -6
- package/lib/components/XInput.d.ts +13 -0
- package/lib/components/XInput.js +38 -0
- package/lib/components/XInputDate.js +1 -1
- package/lib/components/XInputDateDT.js +1 -1
- package/lib/components/XInputText.d.ts +6 -11
- package/lib/components/XInputText.js +14 -49
- package/lib/components/XInputTextDT.js +2 -3
- 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 +162 -77
- package/lib/components/XLoginForm.js +9 -5
- package/lib/components/XResponseError.js +1 -1
- package/lib/components/XSearchButton.d.ts +2 -3
- package/lib/components/XSearchButton.js +12 -35
- package/lib/components/XSearchButtonDT.js +10 -6
- package/lib/components/XSearchButtonOld.js +10 -6
- package/lib/components/XToken.d.ts +4 -3
- package/lib/components/XUtils.d.ts +13 -4
- package/lib/components/XUtils.js +90 -15
- 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/XUser.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +2 -2
- package/package.json +34 -32
|
@@ -40,7 +40,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
40
40
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
41
|
function step(op) {
|
|
42
42
|
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (_) try {
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
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;
|
|
45
45
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
46
|
switch (op[0]) {
|
|
@@ -89,32 +89,15 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
89
89
|
props.form.addField(props.assocField + '.' + props.displayField);
|
|
90
90
|
return _this;
|
|
91
91
|
}
|
|
92
|
-
XSearchButton.prototype.
|
|
93
|
-
|
|
94
|
-
// TODO - zohladnit aj aktualny readOnly stav
|
|
95
|
-
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
96
|
-
if (!readOnly) {
|
|
97
|
-
return this.props.assocField;
|
|
98
|
-
}
|
|
99
|
-
return undefined;
|
|
92
|
+
XSearchButton.prototype.getField = function () {
|
|
93
|
+
return this.props.assocField;
|
|
100
94
|
};
|
|
101
|
-
XSearchButton.prototype.
|
|
102
|
-
|
|
103
|
-
// TODO - zohladnit aj aktualny readOnly stav
|
|
104
|
-
return !this.xAssoc.isNullable && !((_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false);
|
|
105
|
-
};
|
|
106
|
-
XSearchButton.prototype.getValueFromObject = function () {
|
|
107
|
-
var object = this.props.form.state.object;
|
|
108
|
-
var assocObject = object !== null ? object[this.props.assocField] : null;
|
|
109
|
-
// ak je undefined, pre istotu dame na null, null je standard
|
|
110
|
-
if (assocObject === undefined) {
|
|
111
|
-
assocObject = null;
|
|
112
|
-
}
|
|
113
|
-
return assocObject;
|
|
95
|
+
XSearchButton.prototype.isNotNull = function () {
|
|
96
|
+
return !this.xAssoc.isNullable;
|
|
114
97
|
};
|
|
115
98
|
XSearchButton.prototype.render = function () {
|
|
116
99
|
var _this = this;
|
|
117
|
-
var _a
|
|
100
|
+
var _a;
|
|
118
101
|
var props = this.props;
|
|
119
102
|
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
120
103
|
var xDisplayField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntityAssoc, props.displayField);
|
|
@@ -126,7 +109,7 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
126
109
|
var dialogOpened = this.state.dialogOpened;
|
|
127
110
|
var setDialogOpened = function (dialogOpened) { _this.setState({ dialogOpened: dialogOpened }); };
|
|
128
111
|
var computeInputValue = function () {
|
|
129
|
-
var inputValue
|
|
112
|
+
var inputValue;
|
|
130
113
|
if (!inputChanged) {
|
|
131
114
|
// TODO - pridat cez generikum typ fieldu (ak sa da)
|
|
132
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
|
|
@@ -138,12 +121,7 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
138
121
|
}
|
|
139
122
|
return inputValue;
|
|
140
123
|
};
|
|
141
|
-
var
|
|
142
|
-
if (this.checkNotNull()) {
|
|
143
|
-
label = XUtils_1.XUtils.markNotNull(label);
|
|
144
|
-
}
|
|
145
|
-
var readOnly = (_b = props.readOnly) !== null && _b !== void 0 ? _b : false;
|
|
146
|
-
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;
|
|
147
125
|
var onInputValueChange = function (e) {
|
|
148
126
|
setInputChanged(true);
|
|
149
127
|
setInputValueState(e.target.value);
|
|
@@ -186,13 +164,12 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
186
164
|
});
|
|
187
165
|
}); };
|
|
188
166
|
var setValueToModel = function (row) {
|
|
189
|
-
|
|
190
|
-
props.form.onFieldChange(props.assocField, row, error);
|
|
167
|
+
_this.onValueChangeBase(row);
|
|
191
168
|
setInputChanged(false);
|
|
192
169
|
};
|
|
193
170
|
var onClickSearch = function (e) {
|
|
194
171
|
console.log("zavolany onClickSearch");
|
|
195
|
-
if (!
|
|
172
|
+
if (!_this.isReadOnly()) {
|
|
196
173
|
setDialogOpened(true);
|
|
197
174
|
// POVODNY KOD
|
|
198
175
|
//overlayPanelEl.current.toggle(e);
|
|
@@ -229,9 +206,9 @@ var XSearchButton = /** @class */ (function (_super) {
|
|
|
229
206
|
// vypocitame inputValue
|
|
230
207
|
var inputValue = computeInputValue();
|
|
231
208
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
232
|
-
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()),
|
|
233
210
|
react_1.default.createElement("div", { className: "x-search-button-base" },
|
|
234
|
-
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())),
|
|
235
212
|
react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
|
|
236
213
|
react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, {
|
|
237
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];
|
|
@@ -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]) {
|
|
@@ -79,10 +83,10 @@ var button_1 = require("primereact/button");
|
|
|
79
83
|
var dialog_1 = require("primereact/dialog");
|
|
80
84
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
81
85
|
var XSearchButtonDT = function (props) {
|
|
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];
|
|
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) {
|
|
@@ -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];
|
|
@@ -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]) {
|
|
@@ -87,10 +91,10 @@ var 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) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { XToken } from "./XToken";
|
|
2
2
|
import { CsvDecimalFormat, CsvSeparator, ExportType } from "../serverApi/ExportImportParam";
|
|
3
3
|
import React from "react";
|
|
4
|
+
import { XEnvVar } from "./XEnvVars";
|
|
5
|
+
import { XError } from "./XErrors";
|
|
4
6
|
export declare enum OperationType {
|
|
5
7
|
None = 0,
|
|
6
8
|
Insert = 1,
|
|
@@ -9,7 +11,7 @@ export declare enum OperationType {
|
|
|
9
11
|
}
|
|
10
12
|
export declare class XUtils {
|
|
11
13
|
static dropdownEmptyOptionValue: string;
|
|
12
|
-
static
|
|
14
|
+
static xBackendUrl: string | undefined;
|
|
13
15
|
static xToken: XToken | null;
|
|
14
16
|
static xTokenPublic: XToken;
|
|
15
17
|
private static appFormMap;
|
|
@@ -37,18 +39,25 @@ export declare class XUtils {
|
|
|
37
39
|
static post(path: string, value: any): Promise<Response>;
|
|
38
40
|
static fetchBasicJson(path: string, value: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
|
39
41
|
static fetchFile(path: string, jsonFieldValue: any, fileToPost: any): Promise<any>;
|
|
42
|
+
static fetchBasicAuthBasic(path: string, headers: any, body: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
|
40
43
|
static fetchBasic(path: string, headers: any, body: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
|
41
44
|
static fetchById(entity: string, fields: string[], id: number): Promise<any>;
|
|
42
45
|
static setXToken(xToken: XToken | null): void;
|
|
43
46
|
static getXToken(): XToken | null;
|
|
44
47
|
static getUsername(): string | undefined;
|
|
45
|
-
static
|
|
46
|
-
static
|
|
48
|
+
static getXBackendUrl(): string;
|
|
49
|
+
static setXBackendUrl(xBackendUrl: string | undefined): void;
|
|
50
|
+
/**
|
|
51
|
+
* returns value of environment variable from configuration file .env
|
|
52
|
+
* @param envVar
|
|
53
|
+
*/
|
|
54
|
+
static getEnvVarValue(envVarEnum: XEnvVar): string;
|
|
47
55
|
static removeRow(entity: string, row: any): Promise<void>;
|
|
48
56
|
static arrayMoveElement(array: any[], position: number, offset: number): void;
|
|
49
57
|
static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
|
|
50
58
|
static markNotNull(label: string): string;
|
|
51
|
-
static showErrorMessage(message: string, e:
|
|
59
|
+
static showErrorMessage(message: string, e: unknown): void;
|
|
52
60
|
static createErrorProps(error: string | undefined): {};
|
|
61
|
+
static getXErrorMessage(xError: XError): string | undefined;
|
|
53
62
|
static normalizeString(value: string): string;
|
|
54
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]) {
|
|
@@ -90,7 +90,7 @@ var XUtils = /** @class */ (function () {
|
|
|
90
90
|
function XUtils() {
|
|
91
91
|
}
|
|
92
92
|
XUtils.demo = function () {
|
|
93
|
-
return XUtils.
|
|
93
|
+
return XUtils.getXBackendUrl().indexOf('x-demo-server') !== -1;
|
|
94
94
|
};
|
|
95
95
|
XUtils.isMobile = function () {
|
|
96
96
|
// extra small displays (podla https://www.w3schools.com/howto/howto_css_media_query_breakpoints.asp)
|
|
@@ -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) {
|
|
@@ -306,6 +306,43 @@ var XUtils = /** @class */ (function () {
|
|
|
306
306
|
});
|
|
307
307
|
});
|
|
308
308
|
};
|
|
309
|
+
// nepouzivana stara Basic autentifikacia
|
|
310
|
+
XUtils.fetchBasicAuthBasic = function (path, headers, body, usePublicToken) {
|
|
311
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
312
|
+
var xToken, response, responseBody;
|
|
313
|
+
return __generator(this, function (_a) {
|
|
314
|
+
switch (_a.label) {
|
|
315
|
+
case 0:
|
|
316
|
+
if (typeof usePublicToken === 'object') {
|
|
317
|
+
xToken = usePublicToken;
|
|
318
|
+
}
|
|
319
|
+
else if (usePublicToken) {
|
|
320
|
+
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
xToken = XUtils.getXToken();
|
|
324
|
+
if (xToken === null) {
|
|
325
|
+
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Basic ".concat(Buffer.from(xToken.username + ':' + xToken.password).toString('base64')) });
|
|
329
|
+
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
330
|
+
method: 'POST',
|
|
331
|
+
headers: headers,
|
|
332
|
+
body: body
|
|
333
|
+
})];
|
|
334
|
+
case 1:
|
|
335
|
+
response = _a.sent();
|
|
336
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
337
|
+
return [4 /*yield*/, response.json()];
|
|
338
|
+
case 2:
|
|
339
|
+
responseBody = _a.sent();
|
|
340
|
+
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
341
|
+
case 3: return [2 /*return*/, response];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
309
346
|
XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
|
|
310
347
|
return __awaiter(this, void 0, void 0, function () {
|
|
311
348
|
var xToken, response, responseBody;
|
|
@@ -324,8 +361,8 @@ var XUtils = /** @class */ (function () {
|
|
|
324
361
|
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
325
362
|
}
|
|
326
363
|
}
|
|
327
|
-
headers = __assign(__assign({}, headers), { 'Authorization': "
|
|
328
|
-
return [4 /*yield*/, fetch(XUtils.
|
|
364
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(xToken.accessToken) });
|
|
365
|
+
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
329
366
|
method: 'POST',
|
|
330
367
|
headers: headers,
|
|
331
368
|
body: body
|
|
@@ -352,17 +389,28 @@ var XUtils = /** @class */ (function () {
|
|
|
352
389
|
return XUtils.xToken;
|
|
353
390
|
};
|
|
354
391
|
XUtils.getUsername = function () {
|
|
355
|
-
var _a;
|
|
356
|
-
return (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.username;
|
|
392
|
+
var _a, _b;
|
|
393
|
+
return (_b = (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.username;
|
|
357
394
|
};
|
|
358
|
-
XUtils.
|
|
359
|
-
if (XUtils.
|
|
360
|
-
throw "XUtils.
|
|
395
|
+
XUtils.getXBackendUrl = function () {
|
|
396
|
+
if (XUtils.xBackendUrl === undefined) {
|
|
397
|
+
throw "XUtils.xBackendUrl is undefined";
|
|
361
398
|
}
|
|
362
|
-
return XUtils.
|
|
363
|
-
};
|
|
364
|
-
XUtils.
|
|
365
|
-
XUtils.
|
|
399
|
+
return XUtils.xBackendUrl;
|
|
400
|
+
};
|
|
401
|
+
XUtils.setXBackendUrl = function (xBackendUrl) {
|
|
402
|
+
XUtils.xBackendUrl = xBackendUrl;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* returns value of environment variable from configuration file .env
|
|
406
|
+
* @param envVar
|
|
407
|
+
*/
|
|
408
|
+
XUtils.getEnvVarValue = function (envVarEnum) {
|
|
409
|
+
var value = process.env[envVarEnum];
|
|
410
|
+
if (value === undefined) {
|
|
411
|
+
throw "Environment variable ".concat(envVarEnum, " - value not found. Check configuration file .env*");
|
|
412
|
+
}
|
|
413
|
+
return value;
|
|
366
414
|
};
|
|
367
415
|
// funkcionalita ktoru by bolo dobre dat do servisov
|
|
368
416
|
XUtils.removeRow = function (entity, row) {
|
|
@@ -419,12 +467,39 @@ var XUtils = /** @class */ (function () {
|
|
|
419
467
|
else if (e instanceof Error) {
|
|
420
468
|
msg += e.message;
|
|
421
469
|
}
|
|
470
|
+
else if (typeof e === 'string' || typeof e === 'number') {
|
|
471
|
+
// chyba typu: throw 'nieco'
|
|
472
|
+
msg += e;
|
|
473
|
+
}
|
|
422
474
|
alert(msg);
|
|
423
475
|
};
|
|
424
476
|
// pouziva sa hlavne na inputy
|
|
425
477
|
XUtils.createErrorProps = function (error) {
|
|
426
478
|
return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } } : {};
|
|
427
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
|
+
};
|
|
428
503
|
// pomocna metodka pouzivana (zatial len) pre autocomplete na ignorovanie velkych-malych znakov a diakritiky
|
|
429
504
|
XUtils.normalizeString = function (value) {
|
|
430
505
|
if (value) {
|
|
@@ -434,7 +509,7 @@ var XUtils = /** @class */ (function () {
|
|
|
434
509
|
return value;
|
|
435
510
|
};
|
|
436
511
|
XUtils.dropdownEmptyOptionValue = " ";
|
|
437
|
-
XUtils.
|
|
512
|
+
XUtils.xBackendUrl = undefined;
|
|
438
513
|
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
439
514
|
XUtils.xToken = null;
|
|
440
515
|
// token pouzivany pre public stranky (napr. XLoginForm), meno/heslo natvrdo (lepsie ako nic)
|
|
@@ -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";
|
package/lib/serverApi/XUser.d.ts
CHANGED
|
@@ -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
|
};
|