@michalrakus/x-react-web-lib 1.8.0 → 1.10.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/XInputInterval.d.ts +3 -0
- package/XInputInterval.js +5 -0
- package/XInputIntervalBase.d.ts +3 -0
- package/XInputIntervalBase.js +5 -0
- package/gulpfile.js +84 -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 +9 -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 +16 -13
- package/lib/components/XDropdownDT.js +135 -128
- package/lib/components/XDropdownDTFilter.d.ts +7 -7
- package/lib/components/XDropdownDTFilter.js +121 -121
- package/lib/components/XDropdownForEntity.d.ts +26 -25
- package/lib/components/XDropdownForEntity.js +151 -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 +68 -59
- package/lib/components/XFormBase.js +613 -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 +144 -143
- package/lib/components/XFormDataTable2.js +679 -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/XInputInterval.d.ts +14 -0
- package/lib/components/XInputInterval.js +56 -0
- package/lib/components/XInputIntervalBase.d.ts +10 -0
- package/lib/components/XInputIntervalBase.js +97 -0
- package/lib/components/XInputIntervalDT.d.ts +11 -0
- package/lib/components/XInputIntervalDT.js +43 -0
- 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 +899 -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 +84 -74
- package/lib/components/XUtils.js +664 -627
- package/lib/components/XUtilsConversions.d.ts +15 -12
- package/lib/components/XUtilsConversions.js +177 -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 +35 -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 +14 -13
- package/lib/serverApi/XUtilsCommon.js +180 -110
- package/package.json +1 -1
|
@@ -1,526 +1,613 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var __values = (this && this.__values) || function(o) {
|
|
65
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
|
-
if (m) return m.call(o);
|
|
67
|
-
if (o && typeof o.length === "number") return {
|
|
68
|
-
next: function () {
|
|
69
|
-
if (o && i >= o.length) o = void 0;
|
|
70
|
-
return { value: o && o[i++], done: !o };
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
|
-
};
|
|
75
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
76
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
|
-
if (!m) return o;
|
|
78
|
-
var i = m.call(o), r, ar = [], e;
|
|
79
|
-
try {
|
|
80
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
81
|
-
}
|
|
82
|
-
catch (error) { e = { error: error }; }
|
|
83
|
-
finally {
|
|
84
|
-
try {
|
|
85
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
86
|
-
}
|
|
87
|
-
finally { if (e) throw e.error; }
|
|
88
|
-
}
|
|
89
|
-
return ar;
|
|
90
|
-
};
|
|
91
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
-
exports.XFormBase = exports.Form = void 0;
|
|
93
|
-
var react_1 = require("react");
|
|
94
|
-
var XUtils_1 = require("./XUtils");
|
|
95
|
-
// class decorator ktory nastavuje property entity (dalo by sa to nastavovat v konstruktore ale decorator je menej ukecany)
|
|
96
|
-
// ma sa pouzivat len na triedach odvodenych od XFormBase - obmedzenie som vsak nevedel nakodit
|
|
97
|
-
// property sa nastavi az po zbehnuti konstruktora
|
|
98
|
-
// pozor - decorator je vykopirovany do projektoveho suboru XLibItems.ts, lebo ked je umiestneny tu tak nefunguje pre class-y v projekte!
|
|
99
|
-
function Form(entity) {
|
|
100
|
-
// sem (mozno) moze prist registracia formu-u
|
|
101
|
-
return function (constructor) {
|
|
102
|
-
return /** @class */ (function (_super) {
|
|
103
|
-
__extends(class_1, _super);
|
|
104
|
-
function class_1() {
|
|
105
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
106
|
-
_this.entity = entity;
|
|
107
|
-
return _this;
|
|
108
|
-
}
|
|
109
|
-
return class_1;
|
|
110
|
-
}(constructor));
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
exports.Form = Form;
|
|
114
|
-
var XFormBase = /** @class */ (function (_super) {
|
|
115
|
-
__extends(XFormBase, _super);
|
|
116
|
-
function XFormBase(props) {
|
|
117
|
-
var _this = _super.call(this, props) || this;
|
|
118
|
-
// check
|
|
119
|
-
if (props.id !== undefined && props.object !== undefined) {
|
|
120
|
-
throw "Form cannot have both props id and object defined. Only one of them can be defined.";
|
|
121
|
-
}
|
|
122
|
-
//this.entity = props.entity; - nastavuje sa cez decorator @Form
|
|
123
|
-
var object = null;
|
|
124
|
-
if (props.id === undefined) {
|
|
125
|
-
// add row operation
|
|
126
|
-
if (props.object !== undefined) {
|
|
127
|
-
object = props.object;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
object = {}; // empty new object
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
_this.fields = new Set();
|
|
134
|
-
_this.state = {
|
|
135
|
-
object: object,
|
|
136
|
-
errorMap: {}
|
|
137
|
-
};
|
|
138
|
-
_this.xFormComponentList = [];
|
|
139
|
-
_this.xFormDataTableList = [];
|
|
140
|
-
_this.
|
|
141
|
-
_this.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// TODO -
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
for (var
|
|
444
|
-
var
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
return
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __values = (this && this.__values) || function(o) {
|
|
65
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
|
+
if (m) return m.call(o);
|
|
67
|
+
if (o && typeof o.length === "number") return {
|
|
68
|
+
next: function () {
|
|
69
|
+
if (o && i >= o.length) o = void 0;
|
|
70
|
+
return { value: o && o[i++], done: !o };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
|
+
};
|
|
75
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
76
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
|
+
if (!m) return o;
|
|
78
|
+
var i = m.call(o), r, ar = [], e;
|
|
79
|
+
try {
|
|
80
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
81
|
+
}
|
|
82
|
+
catch (error) { e = { error: error }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e) throw e.error; }
|
|
88
|
+
}
|
|
89
|
+
return ar;
|
|
90
|
+
};
|
|
91
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
+
exports.XFormBase = exports.Form = void 0;
|
|
93
|
+
var react_1 = require("react");
|
|
94
|
+
var XUtils_1 = require("./XUtils");
|
|
95
|
+
// class decorator ktory nastavuje property entity (dalo by sa to nastavovat v konstruktore ale decorator je menej ukecany)
|
|
96
|
+
// ma sa pouzivat len na triedach odvodenych od XFormBase - obmedzenie som vsak nevedel nakodit
|
|
97
|
+
// property sa nastavi az po zbehnuti konstruktora
|
|
98
|
+
// pozor - decorator je vykopirovany do projektoveho suboru XLibItems.ts, lebo ked je umiestneny tu tak nefunguje pre class-y v projekte!
|
|
99
|
+
function Form(entity) {
|
|
100
|
+
// sem (mozno) moze prist registracia formu-u
|
|
101
|
+
return function (constructor) {
|
|
102
|
+
return /** @class */ (function (_super) {
|
|
103
|
+
__extends(class_1, _super);
|
|
104
|
+
function class_1() {
|
|
105
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
106
|
+
_this.entity = entity;
|
|
107
|
+
return _this;
|
|
108
|
+
}
|
|
109
|
+
return class_1;
|
|
110
|
+
}(constructor));
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
exports.Form = Form;
|
|
114
|
+
var XFormBase = /** @class */ (function (_super) {
|
|
115
|
+
__extends(XFormBase, _super);
|
|
116
|
+
function XFormBase(props) {
|
|
117
|
+
var _this = _super.call(this, props) || this;
|
|
118
|
+
// check
|
|
119
|
+
if (props.id !== undefined && props.object !== undefined) {
|
|
120
|
+
throw "Form cannot have both props id and object defined. Only one of them can be defined.";
|
|
121
|
+
}
|
|
122
|
+
//this.entity = props.entity; - nastavuje sa cez decorator @Form
|
|
123
|
+
var object = null;
|
|
124
|
+
if (props.id === undefined) {
|
|
125
|
+
// add row operation
|
|
126
|
+
if (props.object !== undefined) {
|
|
127
|
+
object = props.object;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
object = {}; // empty new object
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
_this.fields = new Set();
|
|
134
|
+
_this.state = {
|
|
135
|
+
object: object,
|
|
136
|
+
errorMap: {}
|
|
137
|
+
};
|
|
138
|
+
_this.xFormComponentList = [];
|
|
139
|
+
_this.xFormDataTableList = [];
|
|
140
|
+
_this.assocToValidateList = [];
|
|
141
|
+
_this.assocToSortList = [];
|
|
142
|
+
_this.onClickSave = _this.onClickSave.bind(_this);
|
|
143
|
+
_this.onClickCancel = _this.onClickCancel.bind(_this);
|
|
144
|
+
return _this;
|
|
145
|
+
}
|
|
146
|
+
XFormBase.prototype.componentDidMount = function () {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
var object, operationType, _a, _b, assocToSort, assocRowList;
|
|
149
|
+
var e_1, _c;
|
|
150
|
+
return __generator(this, function (_d) {
|
|
151
|
+
switch (_d.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
//console.log("volany XFormBase.componentDidMount()");
|
|
154
|
+
// kontrola (musi byt tu, v konstruktore este property nie je nastavena)
|
|
155
|
+
if (this.entity === undefined) {
|
|
156
|
+
throw "XFormBase: Property entity is not defined - use decorator @Form.";
|
|
157
|
+
}
|
|
158
|
+
if (!(this.props.id !== undefined)) return [3 /*break*/, 2];
|
|
159
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchById(this.entity, Array.from(this.fields), this.props.id)];
|
|
160
|
+
case 1:
|
|
161
|
+
//console.log('XFormBase.componentDidMount ide nacitat objekt');
|
|
162
|
+
//console.log(this.fields);
|
|
163
|
+
object = _d.sent();
|
|
164
|
+
operationType = XUtils_1.OperationType.Update;
|
|
165
|
+
try {
|
|
166
|
+
// sortovanie, aby sme nemuseli sortovat v DB (neviem co je efektivnejsie)
|
|
167
|
+
for (_a = __values(this.assocToSortList), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
168
|
+
assocToSort = _b.value;
|
|
169
|
+
assocRowList = object[assocToSort.assoc];
|
|
170
|
+
if (assocRowList) {
|
|
171
|
+
object[assocToSort.assoc] = XUtils_1.XUtils.arraySort(assocRowList, assocToSort.sortField);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
176
|
+
finally {
|
|
177
|
+
try {
|
|
178
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
179
|
+
}
|
|
180
|
+
finally { if (e_1) throw e_1.error; }
|
|
181
|
+
}
|
|
182
|
+
return [3 /*break*/, 3];
|
|
183
|
+
case 2:
|
|
184
|
+
// add new row
|
|
185
|
+
object = this.state.object;
|
|
186
|
+
operationType = XUtils_1.OperationType.Insert;
|
|
187
|
+
_d.label = 3;
|
|
188
|
+
case 3:
|
|
189
|
+
this.preInitForm(object, operationType);
|
|
190
|
+
//console.log("volany XFormBase.componentDidMount() - ideme setnut object");
|
|
191
|
+
this.setState({ object: object } /*, () => console.log("volany XFormBase.componentDidMount() - callback setState")*/);
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
XFormBase.prototype.getEntity = function () {
|
|
198
|
+
if (this.entity === undefined) {
|
|
199
|
+
throw "Entity is undefined";
|
|
200
|
+
}
|
|
201
|
+
return this.entity;
|
|
202
|
+
};
|
|
203
|
+
XFormBase.prototype.getXObject = function () {
|
|
204
|
+
if (this.state.object === null) {
|
|
205
|
+
throw "XFormBase: this.state.object is null";
|
|
206
|
+
}
|
|
207
|
+
return this.state.object;
|
|
208
|
+
};
|
|
209
|
+
XFormBase.prototype.getObject = function () {
|
|
210
|
+
return this.getXObject();
|
|
211
|
+
};
|
|
212
|
+
XFormBase.prototype.isAddRow = function () {
|
|
213
|
+
return this.props.id === undefined;
|
|
214
|
+
};
|
|
215
|
+
XFormBase.prototype.onFieldChange = function (field, value, error, onChange, assocObjectChange) {
|
|
216
|
+
var object = this.getXObject();
|
|
217
|
+
object[field] = value;
|
|
218
|
+
var errorMap = this.state.errorMap;
|
|
219
|
+
errorMap[field] = __assign(__assign({}, errorMap[field]), { onChange: error });
|
|
220
|
+
// tu zavolame onChange komponentu - object uz ma zapisanu zmenenu hodnotu, onChange nasledne zmeni dalsie hodnoty a nasledne sa zavola setState
|
|
221
|
+
if (onChange) {
|
|
222
|
+
onChange({ object: object, assocObjectChange: assocObjectChange });
|
|
223
|
+
}
|
|
224
|
+
// TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
|
|
225
|
+
this.setState({ object: object, errorMap: errorMap });
|
|
226
|
+
};
|
|
227
|
+
XFormBase.prototype.onTableFieldChange = function (rowData, field, value, error, onChange, assocObjectChange) {
|
|
228
|
+
var object = this.getXObject();
|
|
229
|
+
rowData[field] = value;
|
|
230
|
+
// nastavime error do rowData do tech fieldu
|
|
231
|
+
var errorMap = XFormBase.getXRowTechData(rowData).errorMap;
|
|
232
|
+
errorMap[field] = __assign(__assign({}, errorMap[field]), { onChange: error });
|
|
233
|
+
// tu zavolame onChange komponentu - object uz ma zapisanu zmenenu hodnotu, onChange nasledne zmeni dalsie hodnoty a nasledne sa zavola setState
|
|
234
|
+
if (onChange) {
|
|
235
|
+
onChange({ object: object, tableRow: rowData, assocObjectChange: assocObjectChange });
|
|
236
|
+
}
|
|
237
|
+
// TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
|
|
238
|
+
this.setState({ object: object /*, errorMap: errorMap*/ });
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* @deprecated - mal by sa pouzivat onTableFieldChange
|
|
242
|
+
*/
|
|
243
|
+
XFormBase.prototype.onObjectDataChange = function (row, onChange) {
|
|
244
|
+
var object = this.state.object;
|
|
245
|
+
// tu zavolame onChange komponentu - object uz ma zapisanu zmenenu hodnotu, onChange nasledne zmeni dalsie hodnoty a nasledne sa zavola setState
|
|
246
|
+
if (onChange) {
|
|
247
|
+
// TODO - assocObjectChange dorobit
|
|
248
|
+
onChange({ object: object, tableRow: row, assocObjectChange: undefined });
|
|
249
|
+
}
|
|
250
|
+
// TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
|
|
251
|
+
this.setState({ object: object });
|
|
252
|
+
};
|
|
253
|
+
// lepsi nazov ako onObjectDataChange
|
|
254
|
+
// ak niekto zmenil this.state.object alebo this.state.errorMap, zmena sa prejavi vo formulari
|
|
255
|
+
// pouzivame napr. po zavolani onChange na XInputText
|
|
256
|
+
XFormBase.prototype.setStateXForm = function () {
|
|
257
|
+
// TODO - je to ok ze object menime takto?
|
|
258
|
+
// TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
|
|
259
|
+
this.setState({ object: this.state.object, errorMap: this.state.errorMap });
|
|
260
|
+
};
|
|
261
|
+
XFormBase.prototype.onTableAddRow = function (assocField, newRow, dataKey, selectedRow) {
|
|
262
|
+
var object = this.getXObject();
|
|
263
|
+
var rowList = object[assocField];
|
|
264
|
+
// ak vieme id-cko a id-cko nie je vyplnene, tak ho vygenerujeme (predpokladame ze id-cko je vzdy number)
|
|
265
|
+
// id-cka potrebujeme, lebo by nam bez nich nekorektne fungovala tabulka
|
|
266
|
+
// asi cistejsie by bolo citat id-cka zo sekvencie z DB, ale MySql nema sekvencie na styl Oracle
|
|
267
|
+
if (dataKey !== undefined) {
|
|
268
|
+
var newRowId = newRow[dataKey];
|
|
269
|
+
if (newRowId === undefined || newRowId === null) {
|
|
270
|
+
newRow[dataKey] = XFormBase.getNextRowId(rowList, dataKey);
|
|
271
|
+
newRow.__x_generatedRowId = true; // specialny priznak, ze sme vygenerovali id-cko - pred insertom do DB toto id-cko vynullujeme aby sa vygenerovalo realne id-cko
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
var index = undefined;
|
|
275
|
+
if (selectedRow !== undefined) {
|
|
276
|
+
var selectedRowIndex = rowList.indexOf(selectedRow);
|
|
277
|
+
if (selectedRowIndex > -1) {
|
|
278
|
+
index = selectedRowIndex + 1;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (index !== undefined) {
|
|
282
|
+
rowList.splice(index, 0, newRow);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
rowList.push(newRow); // na koniec
|
|
286
|
+
}
|
|
287
|
+
// TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
|
|
288
|
+
this.setState({ object: object });
|
|
289
|
+
};
|
|
290
|
+
XFormBase.getNextRowId = function (rowList, dataKey) {
|
|
291
|
+
var e_2, _a;
|
|
292
|
+
var maxId = 0;
|
|
293
|
+
try {
|
|
294
|
+
for (var rowList_1 = __values(rowList), rowList_1_1 = rowList_1.next(); !rowList_1_1.done; rowList_1_1 = rowList_1.next()) {
|
|
295
|
+
var row = rowList_1_1.value;
|
|
296
|
+
var id = row[dataKey];
|
|
297
|
+
if (id > maxId) {
|
|
298
|
+
maxId = id;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
303
|
+
finally {
|
|
304
|
+
try {
|
|
305
|
+
if (rowList_1_1 && !rowList_1_1.done && (_a = rowList_1.return)) _a.call(rowList_1);
|
|
306
|
+
}
|
|
307
|
+
finally { if (e_2) throw e_2.error; }
|
|
308
|
+
}
|
|
309
|
+
return maxId + 1;
|
|
310
|
+
};
|
|
311
|
+
XFormBase.prototype.onTableRemoveRow = function (assocField, row) {
|
|
312
|
+
var object = this.getXObject();
|
|
313
|
+
var rowList = object[assocField];
|
|
314
|
+
// poznamka: indexOf pri vyhladavani pouziva strict equality (===), 2 objekty su rovnake len ak porovnavame 2 smerniky na totozny objekt
|
|
315
|
+
var index = rowList.indexOf(row);
|
|
316
|
+
if (index === -1) {
|
|
317
|
+
throw "Unexpected error - element 'row' not found in 'rowList'";
|
|
318
|
+
}
|
|
319
|
+
rowList.splice(index, 1);
|
|
320
|
+
// TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
|
|
321
|
+
this.setState({ object: object });
|
|
322
|
+
};
|
|
323
|
+
XFormBase.getXRowTechData = function (row) {
|
|
324
|
+
// ak este nemame rowTechData, tak ho vytvorime
|
|
325
|
+
if (row.__x_rowTechData === undefined) {
|
|
326
|
+
// field '__x_rowTechData' vytvorime takymto specialnym sposobom, aby mal "enumerable: false", tympadom ho JSON.stringify nezaserializuje
|
|
327
|
+
// pri posielani objektu formulara na backend (pozor, zaroven sa neda tento field iterovat cez in operator a pod.)
|
|
328
|
+
var xRowTechData = { xFormComponentDTList: [], errorMap: {} };
|
|
329
|
+
Object.defineProperty(row, '__x_rowTechData', {
|
|
330
|
+
value: xRowTechData,
|
|
331
|
+
writable: false,
|
|
332
|
+
enumerable: false
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return row.__x_rowTechData;
|
|
336
|
+
};
|
|
337
|
+
XFormBase.prototype.addField = function (field) {
|
|
338
|
+
this.fields.add(field);
|
|
339
|
+
};
|
|
340
|
+
XFormBase.prototype.addXFormComponent = function (xFormComponent) {
|
|
341
|
+
this.xFormComponentList.push(xFormComponent);
|
|
342
|
+
};
|
|
343
|
+
XFormBase.prototype.findXFormComponent = function (field) {
|
|
344
|
+
var e_3, _a;
|
|
345
|
+
try {
|
|
346
|
+
// TODO - vytvorit mapu (field, ref(xFormComponent)), bude to rychlejsie
|
|
347
|
+
// vytvorit len mapu (a list zrusit) je problem - mozme mat pre jeden field viacero (napr. asociacnych) componentov
|
|
348
|
+
for (var _b = __values(this.xFormComponentList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
349
|
+
var xFormComponent = _c.value;
|
|
350
|
+
if (xFormComponent.getField() === field) {
|
|
351
|
+
return xFormComponent;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
356
|
+
finally {
|
|
357
|
+
try {
|
|
358
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
359
|
+
}
|
|
360
|
+
finally { if (e_3) throw e_3.error; }
|
|
361
|
+
}
|
|
362
|
+
return undefined;
|
|
363
|
+
};
|
|
364
|
+
XFormBase.prototype.addXFormDataTable = function (xFormDataTable) {
|
|
365
|
+
this.xFormDataTableList.push(xFormDataTable);
|
|
366
|
+
};
|
|
367
|
+
XFormBase.prototype.addAssocToValidate = function (oneToManyAssoc) {
|
|
368
|
+
this.assocToValidateList.push(oneToManyAssoc);
|
|
369
|
+
};
|
|
370
|
+
XFormBase.prototype.addAssocToSort = function (oneToManyAssoc, sortField) {
|
|
371
|
+
this.assocToSortList.push({ assoc: oneToManyAssoc, sortField: sortField });
|
|
372
|
+
};
|
|
373
|
+
XFormBase.prototype.formReadOnlyBase = function (field) {
|
|
374
|
+
// TODO - bude this.state.object vzdycky !== undefined?
|
|
375
|
+
return this.formReadOnly(this.state.object, field);
|
|
376
|
+
};
|
|
377
|
+
XFormBase.prototype.onClickSave = function () {
|
|
378
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
379
|
+
var isAddRow, object, e_4;
|
|
380
|
+
return __generator(this, function (_a) {
|
|
381
|
+
switch (_a.label) {
|
|
382
|
+
case 0:
|
|
383
|
+
//console.log("zavolany onClickSave");
|
|
384
|
+
if (!this.validateSave()) {
|
|
385
|
+
return [2 /*return*/];
|
|
386
|
+
}
|
|
387
|
+
// docasne na testovanie
|
|
388
|
+
// const object: T | null = this.state.object;
|
|
389
|
+
// if (object !== null) {
|
|
390
|
+
// const carDate = object['carDatetime'];
|
|
391
|
+
// if (carDate !== undefined && carDate !== null) {
|
|
392
|
+
// //(object as XObject)['carDate'] = dateFormat(carDate, 'yyyy-mm-dd');
|
|
393
|
+
// console.log(dateFormat(carDate, 'yyyy-mm-dd HH:MM:ss'))
|
|
394
|
+
// console.log(carDate.getHours());
|
|
395
|
+
// console.log(carDate.getMinutes());
|
|
396
|
+
// console.log(carDate.getSeconds());
|
|
397
|
+
// }
|
|
398
|
+
// }
|
|
399
|
+
this.preSave(this.state.object);
|
|
400
|
+
isAddRow = this.isAddRow();
|
|
401
|
+
_a.label = 1;
|
|
402
|
+
case 1:
|
|
403
|
+
_a.trys.push([1, 3, , 4]);
|
|
404
|
+
return [4 /*yield*/, this.saveRow()];
|
|
405
|
+
case 2:
|
|
406
|
+
object = _a.sent();
|
|
407
|
+
return [3 /*break*/, 4];
|
|
408
|
+
case 3:
|
|
409
|
+
e_4 = _a.sent();
|
|
410
|
+
XUtils_1.XUtils.showErrorMessage("Save row failed.", e_4);
|
|
411
|
+
return [2 /*return*/]; // zostavame vo formulari
|
|
412
|
+
case 4:
|
|
413
|
+
if (this.props.onSaveOrCancel !== undefined) {
|
|
414
|
+
// formular je zobrazeny v dialogu
|
|
415
|
+
this.props.onSaveOrCancel(object, isAddRow ? XUtils_1.OperationType.Insert : XUtils_1.OperationType.Update);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
this.props.openForm(null); // standardny rezim; save zbehol, ideme naspet do browsu
|
|
419
|
+
}
|
|
420
|
+
return [2 /*return*/];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
XFormBase.prototype.onClickCancel = function () {
|
|
426
|
+
if (this.props.onSaveOrCancel !== undefined) {
|
|
427
|
+
this.props.onSaveOrCancel(null, XUtils_1.OperationType.None); // formular je zobrazeny v dialogu
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
// standardny rezim
|
|
431
|
+
// openForm pridavame automaticky v XFormNavigator2 pri renderovani komponentu
|
|
432
|
+
// null - vrati sa do predchadzajuceho formularu, z ktoreho bol otvoreny
|
|
433
|
+
this.props.openForm(null);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
XFormBase.prototype.validateSave = function () {
|
|
437
|
+
var e_5, _a, e_6, _b;
|
|
438
|
+
var xErrorMap = this.validateForm();
|
|
439
|
+
// zatial takto jednoducho
|
|
440
|
+
var msg = XUtils_1.XUtils.getErrorMessages(xErrorMap);
|
|
441
|
+
try {
|
|
442
|
+
// este spracujeme editovatelne tabulky
|
|
443
|
+
for (var _c = __values(this.xFormDataTableList), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
444
|
+
var xFormDataTable = _d.value;
|
|
445
|
+
//msg += xFormDataTable.getErrorMessages();
|
|
446
|
+
msg += this.getErrorMessagesForAssoc(xFormDataTable.props.assocField);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
450
|
+
finally {
|
|
451
|
+
try {
|
|
452
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
453
|
+
}
|
|
454
|
+
finally { if (e_5) throw e_5.error; }
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
// este spracujeme oneToMany asociacie, ktore boli explicitne uvedene, ze ich treba validovat
|
|
458
|
+
// (validaciu treba nakodit vo formulari, zavolat z metody validate() a ukoncit zavolanim XFormBase.saveErrorsIntoXRowTechData)
|
|
459
|
+
for (var _e = __values(this.assocToValidateList), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
460
|
+
var assocToValidate = _f.value;
|
|
461
|
+
msg += this.getErrorMessagesForAssoc(assocToValidate);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
465
|
+
finally {
|
|
466
|
+
try {
|
|
467
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
468
|
+
}
|
|
469
|
+
finally { if (e_6) throw e_6.error; }
|
|
470
|
+
}
|
|
471
|
+
var ok = true;
|
|
472
|
+
if (msg !== "") {
|
|
473
|
+
alert(msg);
|
|
474
|
+
ok = false;
|
|
475
|
+
}
|
|
476
|
+
return ok;
|
|
477
|
+
};
|
|
478
|
+
XFormBase.prototype.validateForm = function () {
|
|
479
|
+
var e_7, _a;
|
|
480
|
+
var xErrorMap = this.fieldValidation();
|
|
481
|
+
// form validation
|
|
482
|
+
var xErrors = this.validate(this.getXObject());
|
|
483
|
+
try {
|
|
484
|
+
for (var _b = __values(Object.entries(xErrors)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
485
|
+
var _d = __read(_c.value, 2), field = _d[0], error = _d[1];
|
|
486
|
+
if (error) {
|
|
487
|
+
// skusime zistit label
|
|
488
|
+
var xFormComponent = this.findXFormComponent(field);
|
|
489
|
+
var fieldLabel = xFormComponent ? xFormComponent.getLabel() : undefined;
|
|
490
|
+
xErrorMap[field] = __assign(__assign({}, xErrorMap[field]), { form: error, fieldLabel: fieldLabel });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
495
|
+
finally {
|
|
496
|
+
try {
|
|
497
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
498
|
+
}
|
|
499
|
+
finally { if (e_7) throw e_7.error; }
|
|
500
|
+
}
|
|
501
|
+
// TODO - optimalizacia - netreba setovat stav ak by sme sli prec z formulara (ak by zbehla validacia aj save a isli by sme naspet do browsu)
|
|
502
|
+
// setujeme aj this.state.object, lebo mohli pribudnut/odbudnut chyby na rowData v editovatelnych tabulkach
|
|
503
|
+
this.setState({ object: this.state.object, errorMap: xErrorMap });
|
|
504
|
+
return xErrorMap;
|
|
505
|
+
};
|
|
506
|
+
XFormBase.prototype.fieldValidation = function () {
|
|
507
|
+
var e_8, _a, e_9, _b;
|
|
508
|
+
var xErrorMap = {};
|
|
509
|
+
try {
|
|
510
|
+
for (var _c = __values(this.xFormComponentList), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
511
|
+
var xFormComponent = _d.value;
|
|
512
|
+
var errorItem = xFormComponent.validate();
|
|
513
|
+
if (errorItem) {
|
|
514
|
+
//console.log("Mame field = " + errorItem.field);
|
|
515
|
+
xErrorMap[errorItem.field] = errorItem.xError;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
520
|
+
finally {
|
|
521
|
+
try {
|
|
522
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
523
|
+
}
|
|
524
|
+
finally { if (e_8) throw e_8.error; }
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
for (var _e = __values(this.xFormDataTableList), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
528
|
+
var xFormDataTable = _f.value;
|
|
529
|
+
xFormDataTable.validate();
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
533
|
+
finally {
|
|
534
|
+
try {
|
|
535
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
536
|
+
}
|
|
537
|
+
finally { if (e_9) throw e_9.error; }
|
|
538
|
+
}
|
|
539
|
+
return xErrorMap;
|
|
540
|
+
};
|
|
541
|
+
XFormBase.prototype.getErrorMessagesForAssoc = function (oneToManyAssoc) {
|
|
542
|
+
var e_10, _a;
|
|
543
|
+
var msg = "";
|
|
544
|
+
var object = this.getXObject();
|
|
545
|
+
var rowList = object[oneToManyAssoc];
|
|
546
|
+
if (!Array.isArray(rowList)) {
|
|
547
|
+
throw "Array for the assoc ".concat(oneToManyAssoc, " not found in the form object");
|
|
548
|
+
}
|
|
549
|
+
try {
|
|
550
|
+
for (var rowList_2 = __values(rowList), rowList_2_1 = rowList_2.next(); !rowList_2_1.done; rowList_2_1 = rowList_2.next()) {
|
|
551
|
+
var row = rowList_2_1.value;
|
|
552
|
+
var xRowTechData = XFormBase.getXRowTechData(row);
|
|
553
|
+
msg += XUtils_1.XUtils.getErrorMessages(xRowTechData.errorMap);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
557
|
+
finally {
|
|
558
|
+
try {
|
|
559
|
+
if (rowList_2_1 && !rowList_2_1.done && (_a = rowList_2.return)) _a.call(rowList_2);
|
|
560
|
+
}
|
|
561
|
+
finally { if (e_10) throw e_10.error; }
|
|
562
|
+
}
|
|
563
|
+
return msg;
|
|
564
|
+
};
|
|
565
|
+
// can be called from AppForm in case of custom validation on oneToMany assoc
|
|
566
|
+
XFormBase.saveErrorsIntoXRowTechData = function (row, xErrors) {
|
|
567
|
+
var e_11, _a;
|
|
568
|
+
var xErrorMap = {};
|
|
569
|
+
try {
|
|
570
|
+
for (var _b = __values(Object.entries(xErrors)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
571
|
+
var _d = __read(_c.value, 2), field = _d[0], error = _d[1];
|
|
572
|
+
if (error) {
|
|
573
|
+
xErrorMap[field] = { form: error };
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
578
|
+
finally {
|
|
579
|
+
try {
|
|
580
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
581
|
+
}
|
|
582
|
+
finally { if (e_11) throw e_11.error; }
|
|
583
|
+
}
|
|
584
|
+
var xRowTechData = XFormBase.getXRowTechData(row);
|
|
585
|
+
xRowTechData.errorMap = xErrorMap;
|
|
586
|
+
};
|
|
587
|
+
// this method can be overriden in subclass if needed
|
|
588
|
+
// (the purpose is to put the whole form to read only mode (maybe with exception a few fields))
|
|
589
|
+
// if returns true for the param "field", then the field is read only, otherwise the property readOnly of the XInput* is processed
|
|
590
|
+
XFormBase.prototype.formReadOnly = function (object, field) {
|
|
591
|
+
return false;
|
|
592
|
+
};
|
|
593
|
+
// this method can be overriden in subclass if needed (to modify/save object after read from DB and before set into the form)
|
|
594
|
+
XFormBase.prototype.preInitForm = function (object, operationType) {
|
|
595
|
+
};
|
|
596
|
+
// this method can be overriden in subclass if needed (custom validation)
|
|
597
|
+
XFormBase.prototype.validate = function (object) {
|
|
598
|
+
return {};
|
|
599
|
+
};
|
|
600
|
+
// this method can be overriden in subclass if needed (to modify object before save)
|
|
601
|
+
XFormBase.prototype.preSave = function (object) {
|
|
602
|
+
};
|
|
603
|
+
// this method can be overriden in subclass if needed (to use another service then default 'saveRow')
|
|
604
|
+
XFormBase.prototype.saveRow = function () {
|
|
605
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
606
|
+
return __generator(this, function (_a) {
|
|
607
|
+
return [2 /*return*/, XUtils_1.XUtils.fetch('saveRow', { entity: this.getEntity(), object: this.state.object, reload: this.props.onSaveOrCancel !== undefined })];
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
return XFormBase;
|
|
612
|
+
}(react_1.Component));
|
|
613
|
+
exports.XFormBase = XFormBase;
|