@michalrakus/x-react-web-lib 1.3.0 → 1.4.1
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/XCalendar.d.ts +3 -0
- package/XCalendar.js +5 -0
- package/XDropdownForEntity.d.ts +3 -0
- package/XDropdownForEntity.js +5 -0
- package/XInputDecimalBase.d.ts +3 -0
- package/XInputDecimalBase.js +5 -0
- package/gulpfile.js +4 -1
- package/lib/components/XAutoCompleteBase.js +4 -0
- package/lib/components/XCalendar.d.ts +8 -0
- package/lib/components/XCalendar.js +27 -0
- package/lib/components/XDropdown.d.ts +2 -7
- package/lib/components/XDropdown.js +8 -90
- package/lib/components/XDropdownDTFilter.js +8 -7
- package/lib/components/XDropdownForEntity.d.ts +24 -0
- package/lib/components/XDropdownForEntity.js +148 -0
- package/lib/components/XFieldSelector.js +4 -3
- package/lib/components/XFormComponent.d.ts +3 -0
- package/lib/components/XFormComponent.js +3 -1
- package/lib/components/XFormDataTable2.js +1 -1
- package/lib/components/XInputDate.d.ts +12 -8
- package/lib/components/XInputDate.js +49 -44
- package/lib/components/XInputDecimalBase.d.ts +12 -0
- package/lib/components/XInputDecimalBase.js +18 -0
- package/lib/components/XLazyDataTable.d.ts +10 -1
- package/lib/components/XLazyDataTable.js +135 -51
- package/lib/components/XUtilsMetadata.d.ts +6 -2
- package/lib/components/XUtilsMetadata.js +79 -18
- package/lib/serverApi/XEntityMetadata.d.ts +3 -2
- package/lib/serverApi/XUtilsCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +9 -0
- package/package.json +1 -1
|
@@ -127,7 +127,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
127
127
|
return XUtilsMetadata.getXField(xEntity, field);
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
var xAssoc = XUtilsMetadata.
|
|
130
|
+
var xAssoc = XUtilsMetadata.getXAssoc(xEntity, field);
|
|
131
131
|
var xAssocEntity = XUtilsMetadata.getXEntity(xAssoc.entityName);
|
|
132
132
|
return XUtilsMetadata.getXFieldByPath(xAssocEntity, restPath);
|
|
133
133
|
}
|
|
@@ -135,17 +135,33 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
135
135
|
XUtilsMetadata.getXFieldByPathStr = function (entity, path) {
|
|
136
136
|
return XUtilsMetadata.getXFieldByPath(XUtilsMetadata.getXEntity(entity), path);
|
|
137
137
|
};
|
|
138
|
+
XUtilsMetadata.getXAssocByPath = function (xEntity, path) {
|
|
139
|
+
var _a = __read(XUtilsCommon_1.XUtilsCommon.getFieldAndRestPath(path), 2), field = _a[0], restPath = _a[1];
|
|
140
|
+
if (restPath === null) {
|
|
141
|
+
return XUtilsMetadata.getXAssoc(xEntity, field);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
var xAssoc = XUtilsMetadata.getXAssoc(xEntity, field);
|
|
145
|
+
var xAssocEntity = XUtilsMetadata.getXEntity(xAssoc.entityName);
|
|
146
|
+
return XUtilsMetadata.getXAssocByPath(xAssocEntity, restPath);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// for path assoc1.assoc2.field returns assoc2 (last assoc before field)
|
|
150
|
+
XUtilsMetadata.getLastXAssocByPath = function (xEntity, path) {
|
|
151
|
+
var pathToAssoc = XUtilsCommon_1.XUtilsCommon.getPathToAssoc(path);
|
|
152
|
+
return XUtilsMetadata.getXAssocByPath(xEntity, pathToAssoc);
|
|
153
|
+
};
|
|
138
154
|
XUtilsMetadata.getXAssocToOne = function (xEntity, assocField) {
|
|
139
|
-
return XUtilsMetadata.getXAssoc(xEntity,
|
|
155
|
+
return XUtilsMetadata.getXAssoc(xEntity, assocField, ["many-to-one", "one-to-one"]);
|
|
140
156
|
};
|
|
141
157
|
XUtilsMetadata.getXAssocToMany = function (xEntity, assocField) {
|
|
142
|
-
return XUtilsMetadata.getXAssoc(xEntity,
|
|
158
|
+
return XUtilsMetadata.getXAssoc(xEntity, assocField, ["one-to-many", "many-to-many"]);
|
|
143
159
|
};
|
|
144
160
|
XUtilsMetadata.getXAssocToOneByAssocEntity = function (xEntity, assocEntityName) {
|
|
145
|
-
return XUtilsMetadata.getXAssocByAssocEntity(xEntity,
|
|
161
|
+
return XUtilsMetadata.getXAssocByAssocEntity(xEntity, assocEntityName, ["many-to-one", "one-to-one"]);
|
|
146
162
|
};
|
|
147
163
|
XUtilsMetadata.getXAssocToManyByAssocEntity = function (xEntity, assocEntityName) {
|
|
148
|
-
return XUtilsMetadata.getXAssocByAssocEntity(xEntity,
|
|
164
|
+
return XUtilsMetadata.getXAssocByAssocEntity(xEntity, assocEntityName, ["one-to-many", "many-to-many"]);
|
|
149
165
|
};
|
|
150
166
|
XUtilsMetadata.getXEntityForAssocToOne = function (xEntity, assocField) {
|
|
151
167
|
return XUtilsMetadata.getXEntityForAssoc(XUtilsMetadata.getXAssocToOne(xEntity, assocField));
|
|
@@ -160,7 +176,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
160
176
|
for (var _b = __values(Object.entries(xEntity.fieldMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
161
177
|
var _d = __read(_c.value, 2), key = _d[0], xField = _d[1];
|
|
162
178
|
// assoc fieldy sa nachadzaju aj v xEntity.fieldMap ako typ number (netusim preco), preto ich vyfiltrujeme
|
|
163
|
-
if (xEntity.
|
|
179
|
+
if (xEntity.assocMap[xField.name] === undefined) {
|
|
164
180
|
xFieldList.push(xField);
|
|
165
181
|
}
|
|
166
182
|
}
|
|
@@ -174,6 +190,27 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
174
190
|
}
|
|
175
191
|
return xFieldList;
|
|
176
192
|
};
|
|
193
|
+
XUtilsMetadata.getXAssocList = function (xEntity, relationTypeList) {
|
|
194
|
+
var e_2, _a;
|
|
195
|
+
//const xAssocList: XAssoc[] = Array.from(xEntity.assocMap, (v: XAssoc, k: string) => v);
|
|
196
|
+
var xAssocList = [];
|
|
197
|
+
try {
|
|
198
|
+
for (var _b = __values(Object.entries(xEntity.assocMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
199
|
+
var _d = __read(_c.value, 2), key = _d[0], xAssoc = _d[1];
|
|
200
|
+
if (relationTypeList === undefined || relationTypeList.includes(xAssoc.relationType)) {
|
|
201
|
+
xAssocList.push(xAssoc);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
206
|
+
finally {
|
|
207
|
+
try {
|
|
208
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
209
|
+
}
|
|
210
|
+
finally { if (e_2) throw e_2.error; }
|
|
211
|
+
}
|
|
212
|
+
return xAssocList;
|
|
213
|
+
};
|
|
177
214
|
// docasne sem, kym nemame jednotny XInputDecimal/XInputDecimalDT
|
|
178
215
|
XUtilsMetadata.getParamsForInputNumber = function (xField) {
|
|
179
216
|
var useGrouping = true;
|
|
@@ -209,7 +246,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
209
246
|
}
|
|
210
247
|
return { useGrouping: useGrouping, fractionDigits: fractionDigits, min: min, max: max, size: size };
|
|
211
248
|
};
|
|
212
|
-
XUtilsMetadata.computeColumnWidth = function (xField, filterMenuInFilterRow, formColumnType, header, sortableButtonInHeader, filterButtonInHeader) {
|
|
249
|
+
XUtilsMetadata.computeColumnWidth = function (xField, betweenFilter, filterMenuInFilterRow, formColumnType, header, sortableButtonInHeader, filterButtonInHeader) {
|
|
213
250
|
var width;
|
|
214
251
|
if (formColumnType === undefined) {
|
|
215
252
|
// lazy datatable (no inputs, no buttons, only text and padding)
|
|
@@ -221,10 +258,10 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
221
258
|
width = XUtilsMetadata.computeColumnWidthBase(size, 0.5 + 0.5);
|
|
222
259
|
}
|
|
223
260
|
else if (xField.type === "date") {
|
|
224
|
-
width = XUtilsMetadata.computeColumnWidthBase(10, 0.
|
|
261
|
+
width = XUtilsMetadata.computeColumnWidthBase(10, 0.25 + 1.25 + 0.25); // napr. 31.12.2021, 1.25 rem date picker button
|
|
225
262
|
}
|
|
226
263
|
else if (xField.type === "datetime") {
|
|
227
|
-
width = XUtilsMetadata.computeColumnWidthBase(10 + 9, 0.
|
|
264
|
+
width = XUtilsMetadata.computeColumnWidthBase(10 + 9, 0.25 + 1.25 + 0.25); // napr. 31.12.2021 03:03:00
|
|
228
265
|
}
|
|
229
266
|
else if (xField.type === "boolean") {
|
|
230
267
|
width = 1.43 + 0.5 + 0.5; // checkbox ma sirku 20px
|
|
@@ -232,6 +269,9 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
232
269
|
else {
|
|
233
270
|
throw "XField ".concat(xField.name, ": unknown xField.type = ").concat(xField.type);
|
|
234
271
|
}
|
|
272
|
+
if (betweenFilter === "row" && width) {
|
|
273
|
+
width *= 2;
|
|
274
|
+
}
|
|
235
275
|
}
|
|
236
276
|
else {
|
|
237
277
|
// form datatable (formColumnType is defined)
|
|
@@ -243,12 +283,25 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
243
283
|
else if (xField.type === "decimal" || xField.type === "number") {
|
|
244
284
|
var size = XUtilsMetadata.getParamsForInputNumber(xField).size;
|
|
245
285
|
width = XUtilsMetadata.computeColumnWidthBase(size, padding + padding);
|
|
286
|
+
if (betweenFilter === "row" && width) {
|
|
287
|
+
width *= 2; // not tested, only estimation
|
|
288
|
+
}
|
|
246
289
|
}
|
|
247
290
|
else if (xField.type === "date") {
|
|
248
|
-
|
|
291
|
+
if (betweenFilter === "row") {
|
|
292
|
+
width = (0.21 + 6 + 1.25 + 0.21) * 2; // not tested, only estimation
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
width = 0.21 + 6 + 2.36 + 0.21; // padding + input (also in App.css defined) + button + padding
|
|
296
|
+
}
|
|
249
297
|
}
|
|
250
298
|
else if (xField.type === "datetime") {
|
|
251
|
-
|
|
299
|
+
if (betweenFilter === "row") {
|
|
300
|
+
width = (0.21 + 10 + 1.25 + 0.21) * 2; // not tested, only estimation
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
width = 0.21 + 10 + 2.36 + 0.21; // padding + input (also in App.css defined) + button + padding
|
|
304
|
+
}
|
|
252
305
|
}
|
|
253
306
|
else if (xField.type === "boolean") {
|
|
254
307
|
width = 1.43 + 0.5 + 0.5; // checkbox ma sirku 20px
|
|
@@ -346,18 +399,22 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
346
399
|
}
|
|
347
400
|
return key;
|
|
348
401
|
};
|
|
349
|
-
XUtilsMetadata.getXAssoc = function (xEntity,
|
|
350
|
-
var xAssoc = assocMap[assocField];
|
|
402
|
+
XUtilsMetadata.getXAssoc = function (xEntity, assocField, relationTypeList) {
|
|
403
|
+
var xAssoc = xEntity.assocMap[assocField];
|
|
351
404
|
if (xAssoc === undefined) {
|
|
352
405
|
throw "Assoc ".concat(assocField, " was not found in entity = ").concat(xEntity.name);
|
|
353
406
|
}
|
|
407
|
+
// relationTypeList is optional and is only for check (not to get some unwanted type of assoc)
|
|
408
|
+
if (relationTypeList !== undefined && !relationTypeList.includes(xAssoc.relationType)) {
|
|
409
|
+
throw "Assoc ".concat(assocField, " in entity ").concat(xEntity.name, " is of type ").concat(xAssoc.relationType, " and required type is ").concat(JSON.stringify(relationTypeList));
|
|
410
|
+
}
|
|
354
411
|
return xAssoc;
|
|
355
412
|
};
|
|
356
|
-
XUtilsMetadata.getXAssocByAssocEntity = function (xEntity,
|
|
357
|
-
var
|
|
413
|
+
XUtilsMetadata.getXAssocByAssocEntity = function (xEntity, assocEntityName, relationTypeList) {
|
|
414
|
+
var e_3, _a;
|
|
358
415
|
var xAssocFound = undefined;
|
|
359
416
|
try {
|
|
360
|
-
for (var _b = __values(Object.entries(assocMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
417
|
+
for (var _b = __values(Object.entries(xEntity.assocMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
361
418
|
var _d = __read(_c.value, 2), key = _d[0], xAssoc = _d[1];
|
|
362
419
|
if (xAssoc.entityName === assocEntityName) {
|
|
363
420
|
if (xAssocFound === undefined) {
|
|
@@ -369,16 +426,20 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
369
426
|
}
|
|
370
427
|
}
|
|
371
428
|
}
|
|
372
|
-
catch (
|
|
429
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
373
430
|
finally {
|
|
374
431
|
try {
|
|
375
432
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
376
433
|
}
|
|
377
|
-
finally { if (
|
|
434
|
+
finally { if (e_3) throw e_3.error; }
|
|
378
435
|
}
|
|
379
436
|
if (xAssocFound === undefined) {
|
|
380
437
|
throw "Assoc for assocEntityName = ".concat(assocEntityName, " not found in entity ").concat(xEntity.name);
|
|
381
438
|
}
|
|
439
|
+
// relationTypeList is optional and is only for check (not to get some unwanted type of assoc)
|
|
440
|
+
if (relationTypeList !== undefined && !relationTypeList.includes(xAssocFound.relationType)) {
|
|
441
|
+
throw "Assoc for assocEntityName = ".concat(assocEntityName, " in entity ").concat(xEntity.name, " is of type ").concat(xAssocFound.relationType, " and required type is ").concat(JSON.stringify(relationTypeList));
|
|
442
|
+
}
|
|
382
443
|
return xAssocFound;
|
|
383
444
|
};
|
|
384
445
|
XUtilsMetadata.getXEntityForAssoc = function (xAssoc) {
|
|
@@ -5,8 +5,7 @@ export interface XEntity {
|
|
|
5
5
|
name: string;
|
|
6
6
|
idField: string;
|
|
7
7
|
fieldMap: XFieldMap;
|
|
8
|
-
|
|
9
|
-
assocToManyMap: XAssocMap;
|
|
8
|
+
assocMap: XAssocMap;
|
|
10
9
|
}
|
|
11
10
|
export interface XFieldMap {
|
|
12
11
|
[name: string]: XField;
|
|
@@ -23,7 +22,9 @@ export interface XField {
|
|
|
23
22
|
scale?: number;
|
|
24
23
|
width?: number;
|
|
25
24
|
}
|
|
25
|
+
export type XRelationType = "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many";
|
|
26
26
|
export interface XAssoc {
|
|
27
|
+
relationType: XRelationType;
|
|
27
28
|
name: string;
|
|
28
29
|
entityName: string;
|
|
29
30
|
inverseAssocName?: string;
|
|
@@ -3,6 +3,7 @@ export declare class XUtilsCommon {
|
|
|
3
3
|
static getValueByPath(object: any, path: string): any;
|
|
4
4
|
static getFieldListForPath(path: string): string[];
|
|
5
5
|
static getFieldAndRestPath(path: string): [string, string | null];
|
|
6
|
+
static getPathToAssoc(path: string): string;
|
|
6
7
|
static isSingleField(path: string): boolean;
|
|
7
8
|
static objectAsJSON(value: any): string;
|
|
8
9
|
static getDayName(date: Date | null | undefined): string | undefined;
|
|
@@ -52,6 +52,15 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
52
52
|
return [assocField, restPath];
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
+
XUtilsCommon.getPathToAssoc = function (path) {
|
|
56
|
+
var posDot = path.lastIndexOf(".");
|
|
57
|
+
if (posDot === -1) {
|
|
58
|
+
throw "Path to assoc could not be retrieved. Path ".concat(path, " must have at least 2 items.");
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return path.substring(0, posDot);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
55
64
|
XUtilsCommon.isSingleField = function (path) {
|
|
56
65
|
return path.indexOf(".") === -1;
|
|
57
66
|
};
|