@michalrakus/x-react-web-lib 1.8.0 → 1.9.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/README.md +3 -3
- package/gulpfile.js +82 -82
- package/lib/administration/XBrowseMetaBrowse.d.ts +2 -2
- package/lib/administration/XBrowseMetaBrowse.js +21 -21
- package/lib/administration/XBrowseMetaForm.d.ts +5 -5
- package/lib/administration/XBrowseMetaForm.js +63 -63
- package/lib/administration/XUserBrowse.d.ts +2 -2
- package/lib/administration/XUserBrowse.js +88 -87
- package/lib/administration/XUserForm.d.ts +9 -9
- package/lib/administration/XUserForm.js +195 -194
- package/lib/components/SearchTableParams.d.ts +11 -11
- package/lib/components/SearchTableParams.js +2 -2
- package/lib/components/SourceCodeLinkEntity.d.ts +4 -4
- package/lib/components/SourceCodeLinkEntity.js +14 -14
- package/lib/components/XAutoComplete.d.ts +36 -36
- package/lib/components/XAutoComplete.js +155 -155
- package/lib/components/XAutoCompleteBase.d.ts +45 -45
- package/lib/components/XAutoCompleteBase.js +371 -371
- package/lib/components/XAutoCompleteDT.d.ts +33 -33
- package/lib/components/XAutoCompleteDT.js +140 -140
- package/lib/components/XBrowse.d.ts +33 -33
- package/lib/components/XBrowse.js +360 -360
- package/lib/components/XButton.d.ts +9 -9
- package/lib/components/XButton.js +13 -13
- package/lib/components/XButtonIconMedium.d.ts +9 -9
- package/lib/components/XButtonIconMedium.js +13 -13
- package/lib/components/XButtonIconNarrow.d.ts +10 -10
- package/lib/components/XButtonIconNarrow.js +25 -25
- package/lib/components/XButtonIconSmall.d.ts +9 -9
- package/lib/components/XButtonIconSmall.js +13 -13
- package/lib/components/XCalendar.d.ts +8 -8
- package/lib/components/XCalendar.js +27 -27
- package/lib/components/XChangePasswordForm.d.ts +5 -5
- package/lib/components/XChangePasswordForm.js +160 -160
- package/lib/components/XCheckbox.d.ts +8 -8
- package/lib/components/XCheckbox.js +57 -57
- package/lib/components/XCheckboxDT.d.ts +10 -10
- package/lib/components/XCheckboxDT.js +46 -46
- package/lib/components/XDataTable.d.ts +11 -11
- package/lib/components/XDataTable.js +197 -197
- package/lib/components/XDropdown.d.ts +18 -18
- package/lib/components/XDropdown.js +57 -57
- package/lib/components/XDropdownDT.d.ts +13 -13
- package/lib/components/XDropdownDT.js +128 -128
- package/lib/components/XDropdownDTFilter.d.ts +7 -7
- package/lib/components/XDropdownDTFilter.js +121 -121
- package/lib/components/XDropdownForEntity.d.ts +25 -25
- package/lib/components/XDropdownForEntity.js +149 -149
- package/lib/components/XDropdownFormDTFilter.d.ts +7 -7
- package/lib/components/XDropdownFormDTFilter.js +121 -121
- package/lib/components/XEditColumnDialog.d.ts +13 -13
- package/lib/components/XEditColumnDialog.js +112 -112
- package/lib/components/XEnvVars.d.ts +15 -12
- package/lib/components/XEnvVars.js +23 -20
- package/lib/components/XErrors.d.ts +12 -12
- package/lib/components/XErrors.js +2 -2
- package/lib/components/XExportRowsDialog.d.ts +15 -15
- package/lib/components/XExportRowsDialog.js +184 -184
- package/lib/components/XFieldChangeEvent.d.ts +11 -11
- package/lib/components/XFieldChangeEvent.js +2 -2
- package/lib/components/XFieldSelector.d.ts +7 -7
- package/lib/components/XFieldSelector.js +113 -113
- package/lib/components/XFormBase.d.ts +59 -59
- package/lib/components/XFormBase.js +526 -526
- package/lib/components/XFormBaseModif.d.ts +5 -5
- package/lib/components/XFormBaseModif.js +33 -33
- package/lib/components/XFormBaseT.d.ts +4 -4
- package/lib/components/XFormBaseT.js +31 -31
- package/lib/components/XFormComponent.d.ts +40 -40
- package/lib/components/XFormComponent.js +177 -177
- package/lib/components/XFormComponentDT.d.ts +30 -30
- package/lib/components/XFormComponentDT.js +145 -145
- package/lib/components/XFormDataTable2.d.ts +143 -143
- package/lib/components/XFormDataTable2.js +686 -686
- package/lib/components/XFormFooter.d.ts +6 -6
- package/lib/components/XFormFooter.js +19 -19
- package/lib/components/XFormNavigator3.d.ts +12 -12
- package/lib/components/XFormNavigator3.js +130 -130
- package/lib/components/XHolders.d.ts +7 -7
- package/lib/components/XHolders.js +15 -15
- package/lib/components/XInput.d.ts +13 -13
- package/lib/components/XInput.js +38 -38
- package/lib/components/XInputDT.d.ts +11 -11
- package/lib/components/XInputDT.js +37 -37
- package/lib/components/XInputDate.d.ts +13 -13
- package/lib/components/XInputDate.js +63 -63
- package/lib/components/XInputDateDT.d.ts +10 -10
- package/lib/components/XInputDateDT.js +55 -55
- package/lib/components/XInputDecimal.d.ts +15 -15
- package/lib/components/XInputDecimal.js +78 -78
- package/lib/components/XInputDecimalBase.d.ts +12 -12
- package/lib/components/XInputDecimalBase.js +18 -18
- package/lib/components/XInputDecimalDT.d.ts +11 -11
- package/lib/components/XInputDecimalDT.js +74 -74
- package/lib/components/XInputFileList.d.ts +36 -36
- package/lib/components/XInputFileList.js +251 -251
- package/lib/components/XInputText.d.ts +12 -12
- package/lib/components/XInputText.js +69 -69
- package/lib/components/XInputTextDT.d.ts +9 -9
- package/lib/components/XInputTextDT.js +42 -42
- package/lib/components/XInputTextarea.d.ts +18 -18
- package/lib/components/XInputTextarea.js +85 -85
- package/lib/components/XLazyDataTable.d.ts +78 -78
- package/lib/components/XLazyDataTable.js +885 -885
- package/lib/components/XLocale.d.ts +26 -26
- package/lib/components/XLocale.js +59 -59
- package/lib/components/XLoginDialog.d.ts +8 -8
- package/lib/components/XLoginDialog.js +21 -21
- package/lib/components/XLoginForm.d.ts +7 -7
- package/lib/components/XLoginForm.js +128 -128
- package/lib/components/XObject.d.ts +3 -3
- package/lib/components/XObject.js +2 -2
- package/lib/components/XResponseError.d.ts +11 -11
- package/lib/components/XResponseError.js +32 -32
- package/lib/components/XSearchButton.d.ts +26 -26
- package/lib/components/XSearchButton.js +225 -225
- package/lib/components/XSearchButtonDT.d.ts +12 -12
- package/lib/components/XSearchButtonDT.js +188 -188
- package/lib/components/XSearchButtonOld.d.ts +13 -13
- package/lib/components/XSearchButtonOld.js +212 -212
- package/lib/components/XToOneAssocButton.d.ts +8 -8
- package/lib/components/XToOneAssocButton.js +30 -30
- package/lib/components/XToken.d.ts +6 -6
- package/lib/components/XToken.js +2 -2
- package/lib/components/XUtils.d.ts +74 -74
- package/lib/components/XUtils.js +627 -627
- package/lib/components/XUtilsConversions.d.ts +12 -12
- package/lib/components/XUtilsConversions.js +125 -125
- package/lib/components/XUtilsMetadata.d.ts +39 -39
- package/lib/components/XUtilsMetadata.js +452 -452
- package/lib/components/locale/x-en.json +26 -26
- package/lib/components/useXToken.d.ts +2 -2
- package/lib/components/useXToken.js +44 -44
- package/lib/serverApi/ExportImportParam.d.ts +51 -51
- package/lib/serverApi/ExportImportParam.js +34 -34
- package/lib/serverApi/FindParam.d.ts +34 -34
- package/lib/serverApi/FindParam.js +30 -30
- package/lib/serverApi/FindResult.d.ts +8 -8
- package/lib/serverApi/FindResult.js +2 -2
- package/lib/serverApi/XBrowseMetadata.d.ts +19 -19
- package/lib/serverApi/XBrowseMetadata.js +2 -2
- package/lib/serverApi/XEntityMetadata.d.ts +35 -35
- package/lib/serverApi/XEntityMetadata.js +2 -2
- package/lib/serverApi/XFileJsonField.d.ts +6 -6
- package/lib/serverApi/XFileJsonField.js +2 -2
- package/lib/serverApi/XUser.d.ts +8 -7
- package/lib/serverApi/XUser.js +2 -2
- package/lib/serverApi/XUserAuthenticationIfc.d.ts +9 -9
- package/lib/serverApi/XUserAuthenticationIfc.js +2 -2
- package/lib/serverApi/XUtilsCommon.d.ts +13 -13
- package/lib/serverApi/XUtilsCommon.js +110 -110
- package/package.json +1 -1
package/lib/components/XUtils.js
CHANGED
|
@@ -1,627 +1,627 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __values = (this && this.__values) || function(o) {
|
|
50
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
51
|
-
if (m) return m.call(o);
|
|
52
|
-
if (o && typeof o.length === "number") return {
|
|
53
|
-
next: function () {
|
|
54
|
-
if (o && i >= o.length) o = void 0;
|
|
55
|
-
return { value: o && o[i++], done: !o };
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
|
-
};
|
|
60
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
61
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
62
|
-
if (!m) return o;
|
|
63
|
-
var i = m.call(o), r, ar = [], e;
|
|
64
|
-
try {
|
|
65
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
66
|
-
}
|
|
67
|
-
catch (error) { e = { error: error }; }
|
|
68
|
-
finally {
|
|
69
|
-
try {
|
|
70
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
71
|
-
}
|
|
72
|
-
finally { if (e) throw e.error; }
|
|
73
|
-
}
|
|
74
|
-
return ar;
|
|
75
|
-
};
|
|
76
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
-
exports.XUtils = exports.OperationType = void 0;
|
|
78
|
-
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
79
|
-
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
80
|
-
var ExportImportParam_1 = require("../serverApi/ExportImportParam");
|
|
81
|
-
var XResponseError_1 = require("./XResponseError");
|
|
82
|
-
var FindParam_1 = require("../serverApi/FindParam");
|
|
83
|
-
var OperationType;
|
|
84
|
-
(function (OperationType) {
|
|
85
|
-
OperationType[OperationType["None"] = 0] = "None";
|
|
86
|
-
OperationType[OperationType["Insert"] = 1] = "Insert";
|
|
87
|
-
OperationType[OperationType["Update"] = 2] = "Update";
|
|
88
|
-
OperationType[OperationType["Remove"] = 3] = "Remove";
|
|
89
|
-
})(OperationType = exports.OperationType || (exports.OperationType = {}));
|
|
90
|
-
var XUtils = /** @class */ (function () {
|
|
91
|
-
function XUtils() {
|
|
92
|
-
}
|
|
93
|
-
XUtils.demo = function () {
|
|
94
|
-
return XUtils.getXBackendUrl().indexOf('x-demo-server') !== -1;
|
|
95
|
-
};
|
|
96
|
-
XUtils.isMobile = function () {
|
|
97
|
-
// extra small displays (podla https://www.w3schools.com/howto/howto_css_media_query_breakpoints.asp)
|
|
98
|
-
// mozno tu treba dat (window.screen.width * window.devicePixelRatio)
|
|
99
|
-
// bolo 600 ($sm = 576 (primeflex)) - len ak bol mobil na vysku, 768 ma byt aj pre mobil na sirku
|
|
100
|
-
return typeof window !== 'undefined' && window.screen.availWidth < 768; // $sm = 576 (primeflex)
|
|
101
|
-
};
|
|
102
|
-
XUtils.mobileCssSuffix = function () {
|
|
103
|
-
return XUtils.isMobile() ? '-mobile' : '';
|
|
104
|
-
};
|
|
105
|
-
XUtils.toPX = function (size) {
|
|
106
|
-
var sizeInPx;
|
|
107
|
-
if (size !== undefined) {
|
|
108
|
-
if (size.endsWith('px')) {
|
|
109
|
-
sizeInPx = parseFloat(size);
|
|
110
|
-
}
|
|
111
|
-
else if (size.endsWith('rem')) {
|
|
112
|
-
sizeInPx = parseFloat(size) * XUtils.getRemSize();
|
|
113
|
-
}
|
|
114
|
-
if (Number.isNaN(sizeInPx)) {
|
|
115
|
-
sizeInPx = undefined;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return sizeInPx;
|
|
119
|
-
};
|
|
120
|
-
XUtils.toPX0 = function (size) {
|
|
121
|
-
var _a;
|
|
122
|
-
return (_a = XUtils.toPX(size)) !== null && _a !== void 0 ? _a : 0;
|
|
123
|
-
};
|
|
124
|
-
XUtils.getRemSize = function () {
|
|
125
|
-
if (XUtils.remSize === null) {
|
|
126
|
-
// font-size of root element (HTML element), e.g. "14px"
|
|
127
|
-
XUtils.remSize = parseFloat(window.getComputedStyle(document.documentElement).fontSize);
|
|
128
|
-
}
|
|
129
|
-
return XUtils.remSize;
|
|
130
|
-
};
|
|
131
|
-
// param example: "3rem md:4rem xl:6rem"
|
|
132
|
-
// (in general: "<exp1> sm:<exp2> md:<exp3> lg:<exp4> xl:<exp5>")
|
|
133
|
-
// according to device width returns "exp(n)"
|
|
134
|
-
XUtils.processGridBreakpoints = function (breakpointExp) {
|
|
135
|
-
var e_1, _a, e_2, _b, e_3, _c;
|
|
136
|
-
var breakpointList = breakpointExp.split(' ');
|
|
137
|
-
try {
|
|
138
|
-
// pridame si prefix xs: ak neni ziaden prefix, aby sa s tym lahsie pracovalo
|
|
139
|
-
for (var _d = __values(breakpointList.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
140
|
-
var _f = __read(_e.value, 2), index = _f[0], breakpoint = _f[1];
|
|
141
|
-
if (breakpoint !== '' && breakpoint.indexOf(':') === -1) {
|
|
142
|
-
breakpointList[index] = 'xs:' + breakpoint;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
147
|
-
finally {
|
|
148
|
-
try {
|
|
149
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
150
|
-
}
|
|
151
|
-
finally { if (e_1) throw e_1.error; }
|
|
152
|
-
}
|
|
153
|
-
// TODO - use variables $sm, $md, ...
|
|
154
|
-
var breakpointsToFind;
|
|
155
|
-
var availWidth;
|
|
156
|
-
if (typeof window !== 'undefined') {
|
|
157
|
-
availWidth = window.screen.availWidth; // pouzivame availWidth, nie width, availWidth odratava napr. taskbar
|
|
158
|
-
if (availWidth < 576) {
|
|
159
|
-
breakpointsToFind = ['xs:'];
|
|
160
|
-
}
|
|
161
|
-
else if (availWidth < 768) {
|
|
162
|
-
breakpointsToFind = ['sm:', 'xs:'];
|
|
163
|
-
}
|
|
164
|
-
else if (availWidth < 992) {
|
|
165
|
-
breakpointsToFind = ['md:', 'sm:', 'xs:'];
|
|
166
|
-
}
|
|
167
|
-
else if (availWidth < 1200) {
|
|
168
|
-
breakpointsToFind = ['lg:', 'md:', 'sm:', 'xs:'];
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
breakpointsToFind = ['xl:', 'lg:', 'md:', 'sm:', 'xs:'];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
// desktop screen?
|
|
176
|
-
breakpointsToFind = ['xl:', 'lg:', 'md:', 'sm:', 'xs:'];
|
|
177
|
-
}
|
|
178
|
-
try {
|
|
179
|
-
for (var breakpointsToFind_1 = __values(breakpointsToFind), breakpointsToFind_1_1 = breakpointsToFind_1.next(); !breakpointsToFind_1_1.done; breakpointsToFind_1_1 = breakpointsToFind_1.next()) {
|
|
180
|
-
var breakpointToFind = breakpointsToFind_1_1.value;
|
|
181
|
-
try {
|
|
182
|
-
for (var breakpointList_1 = (e_3 = void 0, __values(breakpointList)), breakpointList_1_1 = breakpointList_1.next(); !breakpointList_1_1.done; breakpointList_1_1 = breakpointList_1.next()) {
|
|
183
|
-
var breakpoint = breakpointList_1_1.value;
|
|
184
|
-
if (breakpoint.startsWith(breakpointToFind)) {
|
|
185
|
-
return breakpoint.substring(breakpointToFind.length);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
190
|
-
finally {
|
|
191
|
-
try {
|
|
192
|
-
if (breakpointList_1_1 && !breakpointList_1_1.done && (_c = breakpointList_1.return)) _c.call(breakpointList_1);
|
|
193
|
-
}
|
|
194
|
-
finally { if (e_3) throw e_3.error; }
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
199
|
-
finally {
|
|
200
|
-
try {
|
|
201
|
-
if (breakpointsToFind_1_1 && !breakpointsToFind_1_1.done && (_b = breakpointsToFind_1.return)) _b.call(breakpointsToFind_1);
|
|
202
|
-
}
|
|
203
|
-
finally { if (e_2) throw e_2.error; }
|
|
204
|
-
}
|
|
205
|
-
// should not happen
|
|
206
|
-
console.log("XUtils.processGridBreakpoints: unexpected error: no breakpoint value found, breakpointExp = ".concat(breakpointExp, ", availWidth = ").concat(availWidth));
|
|
207
|
-
return undefined;
|
|
208
|
-
};
|
|
209
|
-
XUtils.processPropWidth = function (widthProp) {
|
|
210
|
-
var width;
|
|
211
|
-
if (widthProp !== undefined && widthProp !== null) {
|
|
212
|
-
width = XUtils.processGridBreakpoints(widthProp);
|
|
213
|
-
if (width !== undefined) {
|
|
214
|
-
if (!isNaN(Number(width))) { // if width is number
|
|
215
|
-
width = width + 'rem';
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return width;
|
|
220
|
-
};
|
|
221
|
-
XUtils.addCssPropIfNotExists = function (cssProps, newCssProps) {
|
|
222
|
-
var e_4, _a;
|
|
223
|
-
try {
|
|
224
|
-
for (var _b = __values(Object.entries(newCssProps)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
225
|
-
var _d = __read(_c.value, 2), cssProp = _d[0], cssPropValue = _d[1];
|
|
226
|
-
if (!(cssProp in cssProps)) {
|
|
227
|
-
cssProps[cssProp] = cssPropValue;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
232
|
-
finally {
|
|
233
|
-
try {
|
|
234
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
235
|
-
}
|
|
236
|
-
finally { if (e_4) throw e_4.error; }
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
// zatial nepouzivane - v buducnosti sa takto mozu vytvorit registre browsov a formularov, ktore potom budeme vediet otvorit len na zaklade entity
|
|
240
|
-
XUtils.registerAppBrowse = function (elem, entity, formId) {
|
|
241
|
-
// console.log("***************** sme v register");
|
|
242
|
-
// console.log(elem);
|
|
243
|
-
// console.log(entity);
|
|
244
|
-
};
|
|
245
|
-
XUtils.registerAppForm = function (elem, entity, formId) {
|
|
246
|
-
var formKey = XUtilsMetadata_1.XUtilsMetadata.getXBrowseFormMetaKey(entity, formId);
|
|
247
|
-
XUtils.appFormMap[formKey] = elem;
|
|
248
|
-
};
|
|
249
|
-
XUtils.getAppForm = function (entity, formId) {
|
|
250
|
-
var formKey = XUtilsMetadata_1.XUtilsMetadata.getXBrowseFormMetaKey(entity, formId);
|
|
251
|
-
return XUtils.appFormMap[formKey];
|
|
252
|
-
};
|
|
253
|
-
XUtils.fetchMany = function (path, value, usePublicToken) {
|
|
254
|
-
return XUtils.fetch(path, value, usePublicToken);
|
|
255
|
-
};
|
|
256
|
-
// pomocna metodka pouzivajuca lazyDataTable service
|
|
257
|
-
XUtils.fetchRows = function (entity, customFilter, sortField, fields) {
|
|
258
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
-
var findParam, rowList;
|
|
260
|
-
return __generator(this, function (_a) {
|
|
261
|
-
switch (_a.label) {
|
|
262
|
-
case 0:
|
|
263
|
-
findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilter: customFilter, multiSortMeta: sortField ? [{ field: sortField, order: 1 }] : undefined, fields: fields };
|
|
264
|
-
return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
|
|
265
|
-
case 1:
|
|
266
|
-
rowList = (_a.sent()).rowList;
|
|
267
|
-
return [2 /*return*/, rowList];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
XUtils.fetchOne = function (path, value, usePublicToken) {
|
|
273
|
-
return XUtils.fetch(path, value, usePublicToken);
|
|
274
|
-
};
|
|
275
|
-
XUtils.fetchString = function (path, value) {
|
|
276
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
-
var valueObj;
|
|
278
|
-
return __generator(this, function (_a) {
|
|
279
|
-
switch (_a.label) {
|
|
280
|
-
case 0: return [4 /*yield*/, XUtils.fetch(path, value)];
|
|
281
|
-
case 1:
|
|
282
|
-
valueObj = _a.sent();
|
|
283
|
-
return [2 /*return*/, valueObj.value];
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
XUtils.fetch = function (path, value, usePublicToken) {
|
|
289
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
-
var response;
|
|
291
|
-
return __generator(this, function (_a) {
|
|
292
|
-
switch (_a.label) {
|
|
293
|
-
case 0: return [4 /*yield*/, XUtils.fetchBasicJson(path, value, usePublicToken)];
|
|
294
|
-
case 1:
|
|
295
|
-
response = _a.sent();
|
|
296
|
-
return [4 /*yield*/, response.json()];
|
|
297
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
};
|
|
302
|
-
XUtils.post = function (path, value) {
|
|
303
|
-
return XUtils.fetchBasicJson(path, value);
|
|
304
|
-
};
|
|
305
|
-
XUtils.fetchBasicJson = function (path, value, usePublicToken) {
|
|
306
|
-
return XUtils.fetchBasic(path, { 'Content-Type': 'application/json' }, XUtilsCommon_1.XUtilsCommon.objectAsJSON(value), usePublicToken);
|
|
307
|
-
};
|
|
308
|
-
XUtils.fetchFile = function (path, jsonFieldValue, fileToPost) {
|
|
309
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
310
|
-
var formData, response;
|
|
311
|
-
return __generator(this, function (_a) {
|
|
312
|
-
switch (_a.label) {
|
|
313
|
-
case 0:
|
|
314
|
-
formData = new FormData();
|
|
315
|
-
formData.append("jsonField", XUtilsCommon_1.XUtilsCommon.objectAsJSON(jsonFieldValue));
|
|
316
|
-
formData.append("fileField", fileToPost, fileToPost.name);
|
|
317
|
-
return [4 /*yield*/, XUtils.fetchBasic(path, {}, formData)];
|
|
318
|
-
case 1:
|
|
319
|
-
response = _a.sent();
|
|
320
|
-
return [4 /*yield*/, response.json()];
|
|
321
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
// nepouzivana stara Basic autentifikacia
|
|
327
|
-
XUtils.fetchBasicAuthBasic = function (path, headers, body, usePublicToken) {
|
|
328
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
329
|
-
var xToken, response, responseBody;
|
|
330
|
-
return __generator(this, function (_a) {
|
|
331
|
-
switch (_a.label) {
|
|
332
|
-
case 0:
|
|
333
|
-
if (typeof usePublicToken === 'object') {
|
|
334
|
-
xToken = usePublicToken;
|
|
335
|
-
}
|
|
336
|
-
else if (usePublicToken) {
|
|
337
|
-
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
xToken = XUtils.getXToken();
|
|
341
|
-
if (xToken === null) {
|
|
342
|
-
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
headers = __assign(__assign({}, headers), { 'Authorization': "Basic ".concat(Buffer.from(xToken.username + ':' + xToken.password).toString('base64')) });
|
|
346
|
-
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
347
|
-
method: 'POST',
|
|
348
|
-
headers: headers,
|
|
349
|
-
body: body
|
|
350
|
-
})];
|
|
351
|
-
case 1:
|
|
352
|
-
response = _a.sent();
|
|
353
|
-
if (!!response.ok) return [3 /*break*/, 3];
|
|
354
|
-
return [4 /*yield*/, response.json()];
|
|
355
|
-
case 2:
|
|
356
|
-
responseBody = _a.sent();
|
|
357
|
-
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
358
|
-
case 3: return [2 /*return*/, response];
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
};
|
|
363
|
-
XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
|
|
364
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
-
var xToken, response, responseBody;
|
|
366
|
-
return __generator(this, function (_a) {
|
|
367
|
-
switch (_a.label) {
|
|
368
|
-
case 0:
|
|
369
|
-
if (typeof usePublicToken === 'object') {
|
|
370
|
-
xToken = usePublicToken;
|
|
371
|
-
}
|
|
372
|
-
else if (usePublicToken) {
|
|
373
|
-
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
xToken = XUtils.getXToken();
|
|
377
|
-
if (xToken === null) {
|
|
378
|
-
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(xToken.accessToken) });
|
|
382
|
-
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
383
|
-
method: 'POST',
|
|
384
|
-
headers: headers,
|
|
385
|
-
body: body
|
|
386
|
-
})];
|
|
387
|
-
case 1:
|
|
388
|
-
response = _a.sent();
|
|
389
|
-
if (!!response.ok) return [3 /*break*/, 3];
|
|
390
|
-
return [4 /*yield*/, response.json()];
|
|
391
|
-
case 2:
|
|
392
|
-
responseBody = _a.sent();
|
|
393
|
-
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
394
|
-
case 3: return [2 /*return*/, response];
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
XUtils.fetchById = function (entity, fields, id) {
|
|
400
|
-
return XUtils.fetchOne('findRowById', { entity: entity, fields: fields, id: id });
|
|
401
|
-
};
|
|
402
|
-
XUtils.setXToken = function (xToken) {
|
|
403
|
-
XUtils.xToken = xToken;
|
|
404
|
-
};
|
|
405
|
-
XUtils.getXToken = function () {
|
|
406
|
-
return XUtils.xToken;
|
|
407
|
-
};
|
|
408
|
-
XUtils.getUsername = function () {
|
|
409
|
-
var _a, _b;
|
|
410
|
-
return (_b = (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.username;
|
|
411
|
-
};
|
|
412
|
-
XUtils.getXBackendUrl = function () {
|
|
413
|
-
if (XUtils.xBackendUrl === undefined) {
|
|
414
|
-
throw "XUtils.xBackendUrl is undefined";
|
|
415
|
-
}
|
|
416
|
-
return XUtils.xBackendUrl;
|
|
417
|
-
};
|
|
418
|
-
XUtils.setXBackendUrl = function (xBackendUrl) {
|
|
419
|
-
XUtils.xBackendUrl = xBackendUrl;
|
|
420
|
-
};
|
|
421
|
-
/**
|
|
422
|
-
* returns value of environment variable from configuration file .env
|
|
423
|
-
* @param envVar
|
|
424
|
-
*/
|
|
425
|
-
XUtils.getEnvVarValue = function (envVarEnum) {
|
|
426
|
-
var value = process.env[envVarEnum];
|
|
427
|
-
if (value === undefined) {
|
|
428
|
-
throw "Environment variable ".concat(envVarEnum, " - value not found. Check configuration file .env*");
|
|
429
|
-
}
|
|
430
|
-
return value;
|
|
431
|
-
};
|
|
432
|
-
// funkcionalita ktoru by bolo dobre dat do servisov
|
|
433
|
-
XUtils.removeRow = function (entity, row) {
|
|
434
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
435
|
-
var xEntity, id;
|
|
436
|
-
return __generator(this, function (_a) {
|
|
437
|
-
switch (_a.label) {
|
|
438
|
-
case 0:
|
|
439
|
-
xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(entity);
|
|
440
|
-
id = row[xEntity.idField];
|
|
441
|
-
return [4 /*yield*/, XUtils.post('removeRow', { entity: entity, id: id })];
|
|
442
|
-
case 1:
|
|
443
|
-
_a.sent();
|
|
444
|
-
return [2 /*return*/];
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
};
|
|
449
|
-
XUtils.arrayMoveElement = function (array, position, offset) {
|
|
450
|
-
var element = array[position];
|
|
451
|
-
array.splice(position, 1);
|
|
452
|
-
var positionNew = position + offset;
|
|
453
|
-
if (positionNew > array.length) {
|
|
454
|
-
positionNew = positionNew - array.length - 1; // element goes to the begin
|
|
455
|
-
}
|
|
456
|
-
else if (positionNew < 0) {
|
|
457
|
-
positionNew = array.length + positionNew + 1; // element goes to the end
|
|
458
|
-
}
|
|
459
|
-
if (positionNew >= 0 && positionNew <= array.length) {
|
|
460
|
-
array.splice(positionNew, 0, element);
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
// helper function
|
|
464
|
-
XUtils.arraySort = function (array, fieldOrStringFunction) {
|
|
465
|
-
var stringFunction;
|
|
466
|
-
if (typeof fieldOrStringFunction === 'string') {
|
|
467
|
-
stringFunction = function (item) { return item[fieldOrStringFunction]; };
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
stringFunction = fieldOrStringFunction;
|
|
471
|
-
}
|
|
472
|
-
return array.sort(function (suggestion1, suggestion2) {
|
|
473
|
-
var value1 = stringFunction(suggestion1);
|
|
474
|
-
var value2 = stringFunction(suggestion2);
|
|
475
|
-
if (value1 > value2) {
|
|
476
|
-
return 1;
|
|
477
|
-
}
|
|
478
|
-
else if (value1 < value2) {
|
|
479
|
-
return -1;
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
return 0;
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
};
|
|
486
|
-
// helper
|
|
487
|
-
XUtils.isReadOnly = function (path, readOnlyInit) {
|
|
488
|
-
// ak mame path dlzky 2 a viac, field je vzdy readOnly
|
|
489
|
-
var readOnly;
|
|
490
|
-
if (!XUtilsCommon_1.XUtilsCommon.isSingleField(path)) {
|
|
491
|
-
readOnly = true;
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
readOnly = readOnlyInit !== null && readOnlyInit !== void 0 ? readOnlyInit : false;
|
|
495
|
-
}
|
|
496
|
-
return readOnly;
|
|
497
|
-
};
|
|
498
|
-
XUtils.markNotNull = function (label) {
|
|
499
|
-
return label + ' *';
|
|
500
|
-
};
|
|
501
|
-
XUtils.showErrorMessage = function (message, e) {
|
|
502
|
-
var msg = message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
503
|
-
if (e instanceof XResponseError_1.XResponseError) {
|
|
504
|
-
// better error message for optimistic locking
|
|
505
|
-
if (e.xResponseErrorBody.exceptionName === 'OptimisticLockVersionMismatchError') {
|
|
506
|
-
msg += "The optimistic lock failed, someone else has changed the row during the editation. Sorry, you have to cancel the editation and start the editation again.";
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
msg += e.message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
510
|
-
msg += JSON.stringify(e.xResponseErrorBody, null, 4);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
else if (e instanceof Error) {
|
|
514
|
-
msg += "".concat(e.name, ": ").concat(e.message);
|
|
515
|
-
}
|
|
516
|
-
else if (typeof e === 'string' || typeof e === 'number') {
|
|
517
|
-
// chyba typu: throw 'nieco'
|
|
518
|
-
msg += e;
|
|
519
|
-
}
|
|
520
|
-
alert(msg);
|
|
521
|
-
};
|
|
522
|
-
// pouziva sa hlavne na inputy
|
|
523
|
-
XUtils.createErrorProps = function (error) {
|
|
524
|
-
return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } } : {};
|
|
525
|
-
};
|
|
526
|
-
// pomocna metodka - prida className do props, ak uz className v props existuje tak len pripoji dalsiu hodnotu
|
|
527
|
-
// pouzivame ju, lebo XUtils.createErrorProps nam prebijal className
|
|
528
|
-
XUtils.addClassName = function (props, className) {
|
|
529
|
-
var propsClassName = props.className;
|
|
530
|
-
if (propsClassName !== undefined) {
|
|
531
|
-
propsClassName += " " + className;
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
propsClassName = className;
|
|
535
|
-
}
|
|
536
|
-
props.className = propsClassName;
|
|
537
|
-
return props;
|
|
538
|
-
};
|
|
539
|
-
// pomocna metodka
|
|
540
|
-
// ak nie su v xErrorMap ziadne chyby, vrati ""
|
|
541
|
-
XUtils.getErrorMessages = function (xErrorMap) {
|
|
542
|
-
var e_5, _a;
|
|
543
|
-
var _b;
|
|
544
|
-
var msg = "";
|
|
545
|
-
try {
|
|
546
|
-
for (var _c = __values(Object.entries(xErrorMap)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
547
|
-
var _e = __read(_d.value, 2), field = _e[0], xError = _e[1];
|
|
548
|
-
if (xError) {
|
|
549
|
-
var errorMessage = XUtils.getErrorMessage(xError);
|
|
550
|
-
if (errorMessage) {
|
|
551
|
-
msg += "".concat((_b = xError.fieldLabel) !== null && _b !== void 0 ? _b : field, ": ").concat(errorMessage).concat(XUtilsCommon_1.XUtilsCommon.newLine);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
557
|
-
finally {
|
|
558
|
-
try {
|
|
559
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
560
|
-
}
|
|
561
|
-
finally { if (e_5) throw e_5.error; }
|
|
562
|
-
}
|
|
563
|
-
return msg;
|
|
564
|
-
};
|
|
565
|
-
XUtils.getErrorMessage = function (xError) {
|
|
566
|
-
if (xError.onChange || xError.onBlur || xError.form) {
|
|
567
|
-
var message = '';
|
|
568
|
-
if (xError.onChange) {
|
|
569
|
-
message += xError.onChange;
|
|
570
|
-
}
|
|
571
|
-
if (xError.onBlur) {
|
|
572
|
-
if (message !== '') {
|
|
573
|
-
message += ' ';
|
|
574
|
-
}
|
|
575
|
-
message += xError.onBlur;
|
|
576
|
-
}
|
|
577
|
-
if (xError.form) {
|
|
578
|
-
if (message !== '') {
|
|
579
|
-
message += ' ';
|
|
580
|
-
}
|
|
581
|
-
message += xError.form;
|
|
582
|
-
}
|
|
583
|
-
return message;
|
|
584
|
-
}
|
|
585
|
-
return undefined;
|
|
586
|
-
};
|
|
587
|
-
// pomocna metodka pouzivana (zatial len) pre autocomplete na ignorovanie velkych-malych znakov a diakritiky
|
|
588
|
-
XUtils.normalizeString = function (value) {
|
|
589
|
-
if (value) {
|
|
590
|
-
// odstranuje vselijaku moznu diakritiku, pre nas je dolezite, ze zmeni "ľščťžýáíéúäňô" na "lsctzyaieuano"
|
|
591
|
-
value = value.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
592
|
-
}
|
|
593
|
-
return value;
|
|
594
|
-
};
|
|
595
|
-
// pomocna metodka
|
|
596
|
-
XUtils.filterAnd = function (filter1, filter2) {
|
|
597
|
-
if (filter1 && filter2) {
|
|
598
|
-
return { filter: "(".concat(filter1.filter, ") AND (").concat(filter2.filter, ")"), values: __assign(__assign({}, filter1.values), filter2.values) };
|
|
599
|
-
}
|
|
600
|
-
else if (filter1 && filter2 === undefined) {
|
|
601
|
-
return filter1;
|
|
602
|
-
}
|
|
603
|
-
else if (filter1 === undefined && filter2) {
|
|
604
|
-
return filter2;
|
|
605
|
-
}
|
|
606
|
-
else {
|
|
607
|
-
return undefined;
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
XUtils.dropdownEmptyOptionValue = " ";
|
|
611
|
-
XUtils.xBackendUrl = undefined;
|
|
612
|
-
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
613
|
-
XUtils.xToken = null;
|
|
614
|
-
// token pouzivany pre public stranky (napr. XLoginForm), meno/heslo natvrdo (lepsie ako nic)
|
|
615
|
-
XUtils.xTokenPublic = { username: "xPublicUser", password: "xPublicUserPassword123" };
|
|
616
|
-
// nacachovane metadata (setuju sa v App.fetchAndSetXMetadata)
|
|
617
|
-
XUtils.appFormMap = {};
|
|
618
|
-
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
619
|
-
XUtils.csvSeparatorOptions = [ExportImportParam_1.CsvSeparator.Semicolon, ExportImportParam_1.CsvSeparator.Comma];
|
|
620
|
-
XUtils.decimalFormatOptions = [ExportImportParam_1.CsvDecimalFormat.Comma, ExportImportParam_1.CsvDecimalFormat.Dot];
|
|
621
|
-
XUtils.csvEncodingOptions = [ExportImportParam_1.CsvEncoding.Utf8, ExportImportParam_1.CsvEncoding.Win1250];
|
|
622
|
-
XUtils.remSize = null;
|
|
623
|
-
// konstanty (zatial takto jednoducho)
|
|
624
|
-
XUtils.FIELD_LABEL_WIDTH = '10.5rem';
|
|
625
|
-
return XUtils;
|
|
626
|
-
}());
|
|
627
|
-
exports.XUtils = XUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __values = (this && this.__values) || function(o) {
|
|
50
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
51
|
+
if (m) return m.call(o);
|
|
52
|
+
if (o && typeof o.length === "number") return {
|
|
53
|
+
next: function () {
|
|
54
|
+
if (o && i >= o.length) o = void 0;
|
|
55
|
+
return { value: o && o[i++], done: !o };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
|
+
};
|
|
60
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
61
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
62
|
+
if (!m) return o;
|
|
63
|
+
var i = m.call(o), r, ar = [], e;
|
|
64
|
+
try {
|
|
65
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
66
|
+
}
|
|
67
|
+
catch (error) { e = { error: error }; }
|
|
68
|
+
finally {
|
|
69
|
+
try {
|
|
70
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
71
|
+
}
|
|
72
|
+
finally { if (e) throw e.error; }
|
|
73
|
+
}
|
|
74
|
+
return ar;
|
|
75
|
+
};
|
|
76
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
+
exports.XUtils = exports.OperationType = void 0;
|
|
78
|
+
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
79
|
+
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
80
|
+
var ExportImportParam_1 = require("../serverApi/ExportImportParam");
|
|
81
|
+
var XResponseError_1 = require("./XResponseError");
|
|
82
|
+
var FindParam_1 = require("../serverApi/FindParam");
|
|
83
|
+
var OperationType;
|
|
84
|
+
(function (OperationType) {
|
|
85
|
+
OperationType[OperationType["None"] = 0] = "None";
|
|
86
|
+
OperationType[OperationType["Insert"] = 1] = "Insert";
|
|
87
|
+
OperationType[OperationType["Update"] = 2] = "Update";
|
|
88
|
+
OperationType[OperationType["Remove"] = 3] = "Remove";
|
|
89
|
+
})(OperationType = exports.OperationType || (exports.OperationType = {}));
|
|
90
|
+
var XUtils = /** @class */ (function () {
|
|
91
|
+
function XUtils() {
|
|
92
|
+
}
|
|
93
|
+
XUtils.demo = function () {
|
|
94
|
+
return XUtils.getXBackendUrl().indexOf('x-demo-server') !== -1;
|
|
95
|
+
};
|
|
96
|
+
XUtils.isMobile = function () {
|
|
97
|
+
// extra small displays (podla https://www.w3schools.com/howto/howto_css_media_query_breakpoints.asp)
|
|
98
|
+
// mozno tu treba dat (window.screen.width * window.devicePixelRatio)
|
|
99
|
+
// bolo 600 ($sm = 576 (primeflex)) - len ak bol mobil na vysku, 768 ma byt aj pre mobil na sirku
|
|
100
|
+
return typeof window !== 'undefined' && window.screen.availWidth < 768; // $sm = 576 (primeflex)
|
|
101
|
+
};
|
|
102
|
+
XUtils.mobileCssSuffix = function () {
|
|
103
|
+
return XUtils.isMobile() ? '-mobile' : '';
|
|
104
|
+
};
|
|
105
|
+
XUtils.toPX = function (size) {
|
|
106
|
+
var sizeInPx;
|
|
107
|
+
if (size !== undefined) {
|
|
108
|
+
if (size.endsWith('px')) {
|
|
109
|
+
sizeInPx = parseFloat(size);
|
|
110
|
+
}
|
|
111
|
+
else if (size.endsWith('rem')) {
|
|
112
|
+
sizeInPx = parseFloat(size) * XUtils.getRemSize();
|
|
113
|
+
}
|
|
114
|
+
if (Number.isNaN(sizeInPx)) {
|
|
115
|
+
sizeInPx = undefined;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return sizeInPx;
|
|
119
|
+
};
|
|
120
|
+
XUtils.toPX0 = function (size) {
|
|
121
|
+
var _a;
|
|
122
|
+
return (_a = XUtils.toPX(size)) !== null && _a !== void 0 ? _a : 0;
|
|
123
|
+
};
|
|
124
|
+
XUtils.getRemSize = function () {
|
|
125
|
+
if (XUtils.remSize === null) {
|
|
126
|
+
// font-size of root element (HTML element), e.g. "14px"
|
|
127
|
+
XUtils.remSize = parseFloat(window.getComputedStyle(document.documentElement).fontSize);
|
|
128
|
+
}
|
|
129
|
+
return XUtils.remSize;
|
|
130
|
+
};
|
|
131
|
+
// param example: "3rem md:4rem xl:6rem"
|
|
132
|
+
// (in general: "<exp1> sm:<exp2> md:<exp3> lg:<exp4> xl:<exp5>")
|
|
133
|
+
// according to device width returns "exp(n)"
|
|
134
|
+
XUtils.processGridBreakpoints = function (breakpointExp) {
|
|
135
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
136
|
+
var breakpointList = breakpointExp.split(' ');
|
|
137
|
+
try {
|
|
138
|
+
// pridame si prefix xs: ak neni ziaden prefix, aby sa s tym lahsie pracovalo
|
|
139
|
+
for (var _d = __values(breakpointList.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
140
|
+
var _f = __read(_e.value, 2), index = _f[0], breakpoint = _f[1];
|
|
141
|
+
if (breakpoint !== '' && breakpoint.indexOf(':') === -1) {
|
|
142
|
+
breakpointList[index] = 'xs:' + breakpoint;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
147
|
+
finally {
|
|
148
|
+
try {
|
|
149
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
150
|
+
}
|
|
151
|
+
finally { if (e_1) throw e_1.error; }
|
|
152
|
+
}
|
|
153
|
+
// TODO - use variables $sm, $md, ...
|
|
154
|
+
var breakpointsToFind;
|
|
155
|
+
var availWidth;
|
|
156
|
+
if (typeof window !== 'undefined') {
|
|
157
|
+
availWidth = window.screen.availWidth; // pouzivame availWidth, nie width, availWidth odratava napr. taskbar
|
|
158
|
+
if (availWidth < 576) {
|
|
159
|
+
breakpointsToFind = ['xs:'];
|
|
160
|
+
}
|
|
161
|
+
else if (availWidth < 768) {
|
|
162
|
+
breakpointsToFind = ['sm:', 'xs:'];
|
|
163
|
+
}
|
|
164
|
+
else if (availWidth < 992) {
|
|
165
|
+
breakpointsToFind = ['md:', 'sm:', 'xs:'];
|
|
166
|
+
}
|
|
167
|
+
else if (availWidth < 1200) {
|
|
168
|
+
breakpointsToFind = ['lg:', 'md:', 'sm:', 'xs:'];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
breakpointsToFind = ['xl:', 'lg:', 'md:', 'sm:', 'xs:'];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// desktop screen?
|
|
176
|
+
breakpointsToFind = ['xl:', 'lg:', 'md:', 'sm:', 'xs:'];
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
for (var breakpointsToFind_1 = __values(breakpointsToFind), breakpointsToFind_1_1 = breakpointsToFind_1.next(); !breakpointsToFind_1_1.done; breakpointsToFind_1_1 = breakpointsToFind_1.next()) {
|
|
180
|
+
var breakpointToFind = breakpointsToFind_1_1.value;
|
|
181
|
+
try {
|
|
182
|
+
for (var breakpointList_1 = (e_3 = void 0, __values(breakpointList)), breakpointList_1_1 = breakpointList_1.next(); !breakpointList_1_1.done; breakpointList_1_1 = breakpointList_1.next()) {
|
|
183
|
+
var breakpoint = breakpointList_1_1.value;
|
|
184
|
+
if (breakpoint.startsWith(breakpointToFind)) {
|
|
185
|
+
return breakpoint.substring(breakpointToFind.length);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
190
|
+
finally {
|
|
191
|
+
try {
|
|
192
|
+
if (breakpointList_1_1 && !breakpointList_1_1.done && (_c = breakpointList_1.return)) _c.call(breakpointList_1);
|
|
193
|
+
}
|
|
194
|
+
finally { if (e_3) throw e_3.error; }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
199
|
+
finally {
|
|
200
|
+
try {
|
|
201
|
+
if (breakpointsToFind_1_1 && !breakpointsToFind_1_1.done && (_b = breakpointsToFind_1.return)) _b.call(breakpointsToFind_1);
|
|
202
|
+
}
|
|
203
|
+
finally { if (e_2) throw e_2.error; }
|
|
204
|
+
}
|
|
205
|
+
// should not happen
|
|
206
|
+
console.log("XUtils.processGridBreakpoints: unexpected error: no breakpoint value found, breakpointExp = ".concat(breakpointExp, ", availWidth = ").concat(availWidth));
|
|
207
|
+
return undefined;
|
|
208
|
+
};
|
|
209
|
+
XUtils.processPropWidth = function (widthProp) {
|
|
210
|
+
var width;
|
|
211
|
+
if (widthProp !== undefined && widthProp !== null) {
|
|
212
|
+
width = XUtils.processGridBreakpoints(widthProp);
|
|
213
|
+
if (width !== undefined) {
|
|
214
|
+
if (!isNaN(Number(width))) { // if width is number
|
|
215
|
+
width = width + 'rem';
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return width;
|
|
220
|
+
};
|
|
221
|
+
XUtils.addCssPropIfNotExists = function (cssProps, newCssProps) {
|
|
222
|
+
var e_4, _a;
|
|
223
|
+
try {
|
|
224
|
+
for (var _b = __values(Object.entries(newCssProps)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
225
|
+
var _d = __read(_c.value, 2), cssProp = _d[0], cssPropValue = _d[1];
|
|
226
|
+
if (!(cssProp in cssProps)) {
|
|
227
|
+
cssProps[cssProp] = cssPropValue;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
232
|
+
finally {
|
|
233
|
+
try {
|
|
234
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
235
|
+
}
|
|
236
|
+
finally { if (e_4) throw e_4.error; }
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
// zatial nepouzivane - v buducnosti sa takto mozu vytvorit registre browsov a formularov, ktore potom budeme vediet otvorit len na zaklade entity
|
|
240
|
+
XUtils.registerAppBrowse = function (elem, entity, formId) {
|
|
241
|
+
// console.log("***************** sme v register");
|
|
242
|
+
// console.log(elem);
|
|
243
|
+
// console.log(entity);
|
|
244
|
+
};
|
|
245
|
+
XUtils.registerAppForm = function (elem, entity, formId) {
|
|
246
|
+
var formKey = XUtilsMetadata_1.XUtilsMetadata.getXBrowseFormMetaKey(entity, formId);
|
|
247
|
+
XUtils.appFormMap[formKey] = elem;
|
|
248
|
+
};
|
|
249
|
+
XUtils.getAppForm = function (entity, formId) {
|
|
250
|
+
var formKey = XUtilsMetadata_1.XUtilsMetadata.getXBrowseFormMetaKey(entity, formId);
|
|
251
|
+
return XUtils.appFormMap[formKey];
|
|
252
|
+
};
|
|
253
|
+
XUtils.fetchMany = function (path, value, usePublicToken) {
|
|
254
|
+
return XUtils.fetch(path, value, usePublicToken);
|
|
255
|
+
};
|
|
256
|
+
// pomocna metodka pouzivajuca lazyDataTable service
|
|
257
|
+
XUtils.fetchRows = function (entity, customFilter, sortField, fields) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
+
var findParam, rowList;
|
|
260
|
+
return __generator(this, function (_a) {
|
|
261
|
+
switch (_a.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilter: customFilter, multiSortMeta: sortField ? [{ field: sortField, order: 1 }] : undefined, fields: fields };
|
|
264
|
+
return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
|
|
265
|
+
case 1:
|
|
266
|
+
rowList = (_a.sent()).rowList;
|
|
267
|
+
return [2 /*return*/, rowList];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
XUtils.fetchOne = function (path, value, usePublicToken) {
|
|
273
|
+
return XUtils.fetch(path, value, usePublicToken);
|
|
274
|
+
};
|
|
275
|
+
XUtils.fetchString = function (path, value) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var valueObj;
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, XUtils.fetch(path, value)];
|
|
281
|
+
case 1:
|
|
282
|
+
valueObj = _a.sent();
|
|
283
|
+
return [2 /*return*/, valueObj.value];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
XUtils.fetch = function (path, value, usePublicToken) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
+
var response;
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
switch (_a.label) {
|
|
293
|
+
case 0: return [4 /*yield*/, XUtils.fetchBasicJson(path, value, usePublicToken)];
|
|
294
|
+
case 1:
|
|
295
|
+
response = _a.sent();
|
|
296
|
+
return [4 /*yield*/, response.json()];
|
|
297
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
XUtils.post = function (path, value) {
|
|
303
|
+
return XUtils.fetchBasicJson(path, value);
|
|
304
|
+
};
|
|
305
|
+
XUtils.fetchBasicJson = function (path, value, usePublicToken) {
|
|
306
|
+
return XUtils.fetchBasic(path, { 'Content-Type': 'application/json' }, XUtilsCommon_1.XUtilsCommon.objectAsJSON(value), usePublicToken);
|
|
307
|
+
};
|
|
308
|
+
XUtils.fetchFile = function (path, jsonFieldValue, fileToPost) {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
310
|
+
var formData, response;
|
|
311
|
+
return __generator(this, function (_a) {
|
|
312
|
+
switch (_a.label) {
|
|
313
|
+
case 0:
|
|
314
|
+
formData = new FormData();
|
|
315
|
+
formData.append("jsonField", XUtilsCommon_1.XUtilsCommon.objectAsJSON(jsonFieldValue));
|
|
316
|
+
formData.append("fileField", fileToPost, fileToPost.name);
|
|
317
|
+
return [4 /*yield*/, XUtils.fetchBasic(path, {}, formData)];
|
|
318
|
+
case 1:
|
|
319
|
+
response = _a.sent();
|
|
320
|
+
return [4 /*yield*/, response.json()];
|
|
321
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
// nepouzivana stara Basic autentifikacia
|
|
327
|
+
XUtils.fetchBasicAuthBasic = function (path, headers, body, usePublicToken) {
|
|
328
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
329
|
+
var xToken, response, responseBody;
|
|
330
|
+
return __generator(this, function (_a) {
|
|
331
|
+
switch (_a.label) {
|
|
332
|
+
case 0:
|
|
333
|
+
if (typeof usePublicToken === 'object') {
|
|
334
|
+
xToken = usePublicToken;
|
|
335
|
+
}
|
|
336
|
+
else if (usePublicToken) {
|
|
337
|
+
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
xToken = XUtils.getXToken();
|
|
341
|
+
if (xToken === null) {
|
|
342
|
+
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Basic ".concat(Buffer.from(xToken.username + ':' + xToken.password).toString('base64')) });
|
|
346
|
+
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
347
|
+
method: 'POST',
|
|
348
|
+
headers: headers,
|
|
349
|
+
body: body
|
|
350
|
+
})];
|
|
351
|
+
case 1:
|
|
352
|
+
response = _a.sent();
|
|
353
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
354
|
+
return [4 /*yield*/, response.json()];
|
|
355
|
+
case 2:
|
|
356
|
+
responseBody = _a.sent();
|
|
357
|
+
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
358
|
+
case 3: return [2 /*return*/, response];
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
|
|
364
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
+
var xToken, response, responseBody;
|
|
366
|
+
return __generator(this, function (_a) {
|
|
367
|
+
switch (_a.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
if (typeof usePublicToken === 'object') {
|
|
370
|
+
xToken = usePublicToken;
|
|
371
|
+
}
|
|
372
|
+
else if (usePublicToken) {
|
|
373
|
+
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
xToken = XUtils.getXToken();
|
|
377
|
+
if (xToken === null) {
|
|
378
|
+
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(xToken.accessToken) });
|
|
382
|
+
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
383
|
+
method: 'POST',
|
|
384
|
+
headers: headers,
|
|
385
|
+
body: body
|
|
386
|
+
})];
|
|
387
|
+
case 1:
|
|
388
|
+
response = _a.sent();
|
|
389
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
390
|
+
return [4 /*yield*/, response.json()];
|
|
391
|
+
case 2:
|
|
392
|
+
responseBody = _a.sent();
|
|
393
|
+
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
394
|
+
case 3: return [2 /*return*/, response];
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
XUtils.fetchById = function (entity, fields, id) {
|
|
400
|
+
return XUtils.fetchOne('findRowById', { entity: entity, fields: fields, id: id });
|
|
401
|
+
};
|
|
402
|
+
XUtils.setXToken = function (xToken) {
|
|
403
|
+
XUtils.xToken = xToken;
|
|
404
|
+
};
|
|
405
|
+
XUtils.getXToken = function () {
|
|
406
|
+
return XUtils.xToken;
|
|
407
|
+
};
|
|
408
|
+
XUtils.getUsername = function () {
|
|
409
|
+
var _a, _b;
|
|
410
|
+
return (_b = (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.username;
|
|
411
|
+
};
|
|
412
|
+
XUtils.getXBackendUrl = function () {
|
|
413
|
+
if (XUtils.xBackendUrl === undefined) {
|
|
414
|
+
throw "XUtils.xBackendUrl is undefined";
|
|
415
|
+
}
|
|
416
|
+
return XUtils.xBackendUrl;
|
|
417
|
+
};
|
|
418
|
+
XUtils.setXBackendUrl = function (xBackendUrl) {
|
|
419
|
+
XUtils.xBackendUrl = xBackendUrl;
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* returns value of environment variable from configuration file .env
|
|
423
|
+
* @param envVar
|
|
424
|
+
*/
|
|
425
|
+
XUtils.getEnvVarValue = function (envVarEnum) {
|
|
426
|
+
var value = process.env[envVarEnum];
|
|
427
|
+
if (value === undefined) {
|
|
428
|
+
throw "Environment variable ".concat(envVarEnum, " - value not found. Check configuration file .env*");
|
|
429
|
+
}
|
|
430
|
+
return value;
|
|
431
|
+
};
|
|
432
|
+
// funkcionalita ktoru by bolo dobre dat do servisov
|
|
433
|
+
XUtils.removeRow = function (entity, row) {
|
|
434
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
435
|
+
var xEntity, id;
|
|
436
|
+
return __generator(this, function (_a) {
|
|
437
|
+
switch (_a.label) {
|
|
438
|
+
case 0:
|
|
439
|
+
xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(entity);
|
|
440
|
+
id = row[xEntity.idField];
|
|
441
|
+
return [4 /*yield*/, XUtils.post('removeRow', { entity: entity, id: id })];
|
|
442
|
+
case 1:
|
|
443
|
+
_a.sent();
|
|
444
|
+
return [2 /*return*/];
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
};
|
|
449
|
+
XUtils.arrayMoveElement = function (array, position, offset) {
|
|
450
|
+
var element = array[position];
|
|
451
|
+
array.splice(position, 1);
|
|
452
|
+
var positionNew = position + offset;
|
|
453
|
+
if (positionNew > array.length) {
|
|
454
|
+
positionNew = positionNew - array.length - 1; // element goes to the begin
|
|
455
|
+
}
|
|
456
|
+
else if (positionNew < 0) {
|
|
457
|
+
positionNew = array.length + positionNew + 1; // element goes to the end
|
|
458
|
+
}
|
|
459
|
+
if (positionNew >= 0 && positionNew <= array.length) {
|
|
460
|
+
array.splice(positionNew, 0, element);
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
// helper function
|
|
464
|
+
XUtils.arraySort = function (array, fieldOrStringFunction) {
|
|
465
|
+
var stringFunction;
|
|
466
|
+
if (typeof fieldOrStringFunction === 'string') {
|
|
467
|
+
stringFunction = function (item) { return item[fieldOrStringFunction]; };
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
stringFunction = fieldOrStringFunction;
|
|
471
|
+
}
|
|
472
|
+
return array.sort(function (suggestion1, suggestion2) {
|
|
473
|
+
var value1 = stringFunction(suggestion1);
|
|
474
|
+
var value2 = stringFunction(suggestion2);
|
|
475
|
+
if (value1 > value2) {
|
|
476
|
+
return 1;
|
|
477
|
+
}
|
|
478
|
+
else if (value1 < value2) {
|
|
479
|
+
return -1;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
return 0;
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
// helper
|
|
487
|
+
XUtils.isReadOnly = function (path, readOnlyInit) {
|
|
488
|
+
// ak mame path dlzky 2 a viac, field je vzdy readOnly
|
|
489
|
+
var readOnly;
|
|
490
|
+
if (!XUtilsCommon_1.XUtilsCommon.isSingleField(path)) {
|
|
491
|
+
readOnly = true;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
readOnly = readOnlyInit !== null && readOnlyInit !== void 0 ? readOnlyInit : false;
|
|
495
|
+
}
|
|
496
|
+
return readOnly;
|
|
497
|
+
};
|
|
498
|
+
XUtils.markNotNull = function (label) {
|
|
499
|
+
return label + ' *';
|
|
500
|
+
};
|
|
501
|
+
XUtils.showErrorMessage = function (message, e) {
|
|
502
|
+
var msg = message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
503
|
+
if (e instanceof XResponseError_1.XResponseError) {
|
|
504
|
+
// better error message for optimistic locking
|
|
505
|
+
if (e.xResponseErrorBody.exceptionName === 'OptimisticLockVersionMismatchError') {
|
|
506
|
+
msg += "The optimistic lock failed, someone else has changed the row during the editation. Sorry, you have to cancel the editation and start the editation again.";
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
msg += e.message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
510
|
+
msg += JSON.stringify(e.xResponseErrorBody, null, 4);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
else if (e instanceof Error) {
|
|
514
|
+
msg += "".concat(e.name, ": ").concat(e.message);
|
|
515
|
+
}
|
|
516
|
+
else if (typeof e === 'string' || typeof e === 'number') {
|
|
517
|
+
// chyba typu: throw 'nieco'
|
|
518
|
+
msg += e;
|
|
519
|
+
}
|
|
520
|
+
alert(msg);
|
|
521
|
+
};
|
|
522
|
+
// pouziva sa hlavne na inputy
|
|
523
|
+
XUtils.createErrorProps = function (error) {
|
|
524
|
+
return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } } : {};
|
|
525
|
+
};
|
|
526
|
+
// pomocna metodka - prida className do props, ak uz className v props existuje tak len pripoji dalsiu hodnotu
|
|
527
|
+
// pouzivame ju, lebo XUtils.createErrorProps nam prebijal className
|
|
528
|
+
XUtils.addClassName = function (props, className) {
|
|
529
|
+
var propsClassName = props.className;
|
|
530
|
+
if (propsClassName !== undefined) {
|
|
531
|
+
propsClassName += " " + className;
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
propsClassName = className;
|
|
535
|
+
}
|
|
536
|
+
props.className = propsClassName;
|
|
537
|
+
return props;
|
|
538
|
+
};
|
|
539
|
+
// pomocna metodka
|
|
540
|
+
// ak nie su v xErrorMap ziadne chyby, vrati ""
|
|
541
|
+
XUtils.getErrorMessages = function (xErrorMap) {
|
|
542
|
+
var e_5, _a;
|
|
543
|
+
var _b;
|
|
544
|
+
var msg = "";
|
|
545
|
+
try {
|
|
546
|
+
for (var _c = __values(Object.entries(xErrorMap)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
547
|
+
var _e = __read(_d.value, 2), field = _e[0], xError = _e[1];
|
|
548
|
+
if (xError) {
|
|
549
|
+
var errorMessage = XUtils.getErrorMessage(xError);
|
|
550
|
+
if (errorMessage) {
|
|
551
|
+
msg += "".concat((_b = xError.fieldLabel) !== null && _b !== void 0 ? _b : field, ": ").concat(errorMessage).concat(XUtilsCommon_1.XUtilsCommon.newLine);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
557
|
+
finally {
|
|
558
|
+
try {
|
|
559
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
560
|
+
}
|
|
561
|
+
finally { if (e_5) throw e_5.error; }
|
|
562
|
+
}
|
|
563
|
+
return msg;
|
|
564
|
+
};
|
|
565
|
+
XUtils.getErrorMessage = function (xError) {
|
|
566
|
+
if (xError.onChange || xError.onBlur || xError.form) {
|
|
567
|
+
var message = '';
|
|
568
|
+
if (xError.onChange) {
|
|
569
|
+
message += xError.onChange;
|
|
570
|
+
}
|
|
571
|
+
if (xError.onBlur) {
|
|
572
|
+
if (message !== '') {
|
|
573
|
+
message += ' ';
|
|
574
|
+
}
|
|
575
|
+
message += xError.onBlur;
|
|
576
|
+
}
|
|
577
|
+
if (xError.form) {
|
|
578
|
+
if (message !== '') {
|
|
579
|
+
message += ' ';
|
|
580
|
+
}
|
|
581
|
+
message += xError.form;
|
|
582
|
+
}
|
|
583
|
+
return message;
|
|
584
|
+
}
|
|
585
|
+
return undefined;
|
|
586
|
+
};
|
|
587
|
+
// pomocna metodka pouzivana (zatial len) pre autocomplete na ignorovanie velkych-malych znakov a diakritiky
|
|
588
|
+
XUtils.normalizeString = function (value) {
|
|
589
|
+
if (value) {
|
|
590
|
+
// odstranuje vselijaku moznu diakritiku, pre nas je dolezite, ze zmeni "ľščťžýáíéúäňô" na "lsctzyaieuano"
|
|
591
|
+
value = value.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
592
|
+
}
|
|
593
|
+
return value;
|
|
594
|
+
};
|
|
595
|
+
// pomocna metodka
|
|
596
|
+
XUtils.filterAnd = function (filter1, filter2) {
|
|
597
|
+
if (filter1 && filter2) {
|
|
598
|
+
return { filter: "(".concat(filter1.filter, ") AND (").concat(filter2.filter, ")"), values: __assign(__assign({}, filter1.values), filter2.values) };
|
|
599
|
+
}
|
|
600
|
+
else if (filter1 && filter2 === undefined) {
|
|
601
|
+
return filter1;
|
|
602
|
+
}
|
|
603
|
+
else if (filter1 === undefined && filter2) {
|
|
604
|
+
return filter2;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
return undefined;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
XUtils.dropdownEmptyOptionValue = " ";
|
|
611
|
+
XUtils.xBackendUrl = undefined;
|
|
612
|
+
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
613
|
+
XUtils.xToken = null;
|
|
614
|
+
// token pouzivany pre public stranky (napr. XLoginForm), meno/heslo natvrdo (lepsie ako nic)
|
|
615
|
+
XUtils.xTokenPublic = { username: "xPublicUser", password: "xPublicUserPassword123" };
|
|
616
|
+
// nacachovane metadata (setuju sa v App.fetchAndSetXMetadata)
|
|
617
|
+
XUtils.appFormMap = {};
|
|
618
|
+
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
619
|
+
XUtils.csvSeparatorOptions = [ExportImportParam_1.CsvSeparator.Semicolon, ExportImportParam_1.CsvSeparator.Comma];
|
|
620
|
+
XUtils.decimalFormatOptions = [ExportImportParam_1.CsvDecimalFormat.Comma, ExportImportParam_1.CsvDecimalFormat.Dot];
|
|
621
|
+
XUtils.csvEncodingOptions = [ExportImportParam_1.CsvEncoding.Utf8, ExportImportParam_1.CsvEncoding.Win1250];
|
|
622
|
+
XUtils.remSize = null;
|
|
623
|
+
// konstanty (zatial takto jednoducho)
|
|
624
|
+
XUtils.FIELD_LABEL_WIDTH = '10.5rem';
|
|
625
|
+
return XUtils;
|
|
626
|
+
}());
|
|
627
|
+
exports.XUtils = XUtils;
|