@michalrakus/x-react-web-lib 1.9.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.
Files changed (34) hide show
  1. package/XInputInterval.d.ts +3 -0
  2. package/XInputInterval.js +5 -0
  3. package/XInputIntervalBase.d.ts +3 -0
  4. package/XInputIntervalBase.js +5 -0
  5. package/gulpfile.js +2 -0
  6. package/lib/components/XAutoComplete.js +1 -1
  7. package/lib/components/XCalendar.d.ts +2 -1
  8. package/lib/components/XCalendar.js +1 -1
  9. package/lib/components/XDropdownDT.d.ts +3 -0
  10. package/lib/components/XDropdownDT.js +14 -7
  11. package/lib/components/XDropdownForEntity.d.ts +1 -0
  12. package/lib/components/XDropdownForEntity.js +3 -1
  13. package/lib/components/XFormBase.d.ts +9 -0
  14. package/lib/components/XFormBase.js +117 -30
  15. package/lib/components/XFormDataTable2.d.ts +2 -1
  16. package/lib/components/XFormDataTable2.js +15 -22
  17. package/lib/components/XInputDate.js +1 -1
  18. package/lib/components/XInputInterval.d.ts +14 -0
  19. package/lib/components/XInputInterval.js +56 -0
  20. package/lib/components/XInputIntervalBase.d.ts +10 -0
  21. package/lib/components/XInputIntervalBase.js +97 -0
  22. package/lib/components/XInputIntervalDT.d.ts +11 -0
  23. package/lib/components/XInputIntervalDT.js +43 -0
  24. package/lib/components/XLazyDataTable.js +43 -29
  25. package/lib/components/XSearchButton.js +1 -1
  26. package/lib/components/XUtils.d.ts +12 -2
  27. package/lib/components/XUtils.js +51 -14
  28. package/lib/components/XUtilsConversions.d.ts +3 -0
  29. package/lib/components/XUtilsConversions.js +53 -1
  30. package/lib/serverApi/ExportImportParam.d.ts +2 -2
  31. package/lib/serverApi/FindParam.d.ts +6 -5
  32. package/lib/serverApi/XUtilsCommon.d.ts +1 -0
  33. package/lib/serverApi/XUtilsCommon.js +70 -0
  34. package/package.json +1 -1
@@ -0,0 +1,56 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.XInputInterval = void 0;
33
+ var react_1 = __importDefault(require("react"));
34
+ var XInput_1 = require("./XInput");
35
+ var XInputIntervalBase_1 = require("./XInputIntervalBase");
36
+ var XInputInterval = /** @class */ (function (_super) {
37
+ __extends(XInputInterval, _super);
38
+ function XInputInterval(props) {
39
+ var _this = _super.call(this, props) || this;
40
+ _this.onValueChange = _this.onValueChange.bind(_this);
41
+ return _this;
42
+ }
43
+ XInputInterval.prototype.getValue = function () {
44
+ return this.getValueFromObject();
45
+ };
46
+ XInputInterval.prototype.onValueChange = function (value) {
47
+ this.onValueChangeBase(value, this.props.onChange);
48
+ };
49
+ XInputInterval.prototype.render = function () {
50
+ return (react_1.default.createElement("div", { className: "field grid" },
51
+ react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
52
+ react_1.default.createElement(XInputIntervalBase_1.XInputIntervalBase, __assign({ id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), style: this.props.inputStyle }, this.getClassNameTooltip()))));
53
+ };
54
+ return XInputInterval;
55
+ }(XInput_1.XInput));
56
+ exports.XInputInterval = XInputInterval;
@@ -0,0 +1,10 @@
1
+ import { CSSProperties } from "react";
2
+ import { IPostgresInterval } from "./XUtils";
3
+ export declare const XInputIntervalBase: (props: {
4
+ id?: string | undefined;
5
+ value: IPostgresInterval | null;
6
+ onChange: (value: IPostgresInterval | null) => void;
7
+ readOnly?: boolean | undefined;
8
+ error?: string | undefined;
9
+ style?: CSSProperties | undefined;
10
+ }) => JSX.Element;
@@ -0,0 +1,97 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __read = (this && this.__read) || function (o, n) {
37
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
38
+ if (!m) return o;
39
+ var i = m.call(o), r, ar = [], e;
40
+ try {
41
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42
+ }
43
+ catch (error) { e = { error: error }; }
44
+ finally {
45
+ try {
46
+ if (r && !r.done && (m = i["return"])) m.call(i);
47
+ }
48
+ finally { if (e) throw e.error; }
49
+ }
50
+ return ar;
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.XInputIntervalBase = void 0;
54
+ var inputtext_1 = require("primereact/inputtext");
55
+ var react_1 = __importStar(require("react"));
56
+ var XUtilsConversions_1 = require("./XUtilsConversions");
57
+ var XUtils_1 = require("./XUtils");
58
+ // zatial podporuje len hours a minutes - TODO - pridat aj seconds, ale cez nejaky prepinac
59
+ var XInputIntervalBase = function (props) {
60
+ // true, ak uzivatel typuje hodnotu ale hodnota sa este neda skonvertovat na korektny interval (este nevieme vytvorit IPostgresInterval)
61
+ // false, ak uz mame v inpute korektnu hodnotu - vtedy zavolame props.onChange a posleme mu IPostgresInterval
62
+ var _a = __read((0, react_1.useState)(false), 2), inputChanged = _a[0], setInputChanged = _a[1];
63
+ // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
64
+ var _b = __read((0, react_1.useState)(undefined), 2), inputValueState = _b[0], setInputValueState = _b[1];
65
+ var onChange = function (e) {
66
+ // conversion to IPostgresInterval will be done in onBlur
67
+ setInputChanged(true);
68
+ setInputValueState(e.target.value);
69
+ };
70
+ var onBlur = function (e) {
71
+ // optimalizacia - testujeme len ak inputChanged === true
72
+ if (inputChanged) {
73
+ // convert e.target.value (e.g. 10:29) into IPostgresInterval (e.g. {hours: 10, minutes: 29})
74
+ var valueInterval = (0, XUtilsConversions_1.intervalFromUI)(e.target.value);
75
+ if (valueInterval === undefined) {
76
+ // user odisiel z inputu a nechal tam nevalidnu hodnotu - zapiseme hodnotu null, nech nemusime kontrolovat field pri validacii
77
+ valueInterval = null;
78
+ }
79
+ props.onChange(valueInterval);
80
+ setInputChanged(false);
81
+ setInputValueState(undefined); // pre poriadok
82
+ }
83
+ };
84
+ var getInputValue = function () {
85
+ var inputValue;
86
+ if (inputChanged) {
87
+ inputValue = inputValueState;
88
+ }
89
+ else {
90
+ inputValue = (0, XUtilsConversions_1.intervalAsUI)(props.value);
91
+ }
92
+ return inputValue;
93
+ };
94
+ // remark - width:'3.5rem' is default, can be overriden by value from props.style, if needed
95
+ return (react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.id, value: getInputValue(), onChange: onChange, onBlur: onBlur, readOnly: props.readOnly }, XUtils_1.XUtils.createErrorProps(props.error), { style: __assign({ width: '3.5rem' }, props.style) })));
96
+ };
97
+ exports.XInputIntervalBase = XInputIntervalBase;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { IPostgresInterval } from "./XUtils";
3
+ import { XInputDT, XInputDTProps } from "./XInputDT";
4
+ export interface XInputIntervalDTProps extends XInputDTProps {
5
+ }
6
+ export declare class XInputIntervalDT extends XInputDT<XInputIntervalDTProps> {
7
+ constructor(props: XInputIntervalDTProps);
8
+ getValue(): IPostgresInterval | null;
9
+ onValueChange(value: IPostgresInterval | null): void;
10
+ render(): JSX.Element;
11
+ }
@@ -0,0 +1,43 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.XInputIntervalDT = void 0;
22
+ var react_1 = __importDefault(require("react"));
23
+ var XInputIntervalBase_1 = require("./XInputIntervalBase");
24
+ var XInputDT_1 = require("./XInputDT");
25
+ var XInputIntervalDT = /** @class */ (function (_super) {
26
+ __extends(XInputIntervalDT, _super);
27
+ function XInputIntervalDT(props) {
28
+ var _this = _super.call(this, props) || this;
29
+ _this.onValueChange = _this.onValueChange.bind(_this);
30
+ return _this;
31
+ }
32
+ XInputIntervalDT.prototype.getValue = function () {
33
+ return this.getValueFromRowData();
34
+ };
35
+ XInputIntervalDT.prototype.onValueChange = function (value) {
36
+ this.onValueChangeBase(value, this.props.onChange);
37
+ };
38
+ XInputIntervalDT.prototype.render = function () {
39
+ return (react_1.default.createElement(XInputIntervalBase_1.XInputIntervalBase, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError() }));
40
+ };
41
+ return XInputIntervalDT;
42
+ }(XInputDT_1.XInputDT));
43
+ exports.XInputIntervalDT = XInputIntervalDT;
@@ -198,7 +198,7 @@ var XLazyDataTable = function (props) {
198
198
  };
199
199
  // premenne platne pre cely component (obdoba member premennych v class-e)
200
200
  var dataTableEl = (0, react_1.useRef)(null);
201
- var customFilter = props.customFilter;
201
+ var customFilterItems = XUtils_1.XUtils.createCustomFilterItems(props.customFilter);
202
202
  var aggregateItems = createAggregateItems();
203
203
  var _b = __read((0, react_1.useState)({ rowList: [], totalRecords: 0, aggregateValues: [] }), 2), value = _b[0], setValue = _b[1];
204
204
  var _c = __read((0, react_1.useState)(false), 2), loading = _c[0], setLoading = _c[1];
@@ -213,8 +213,8 @@ var XLazyDataTable = function (props) {
213
213
  if (displayFieldFilter !== undefined) {
214
214
  filtersInit[displayFieldFilter.field] = createFilterItem(props.filterDisplay, displayFieldFilter.constraint);
215
215
  }
216
- // ak mame props.searchTableParams.customFilter, pridame ho
217
- customFilter = XUtils_1.XUtils.filterAnd(customFilter, props.searchTableParams.customFilter);
216
+ // ak mame props.searchTableParams.customFilterItems, pridame ho
217
+ customFilterItems = XUtils_1.XUtils.filterAnd(customFilterItems, props.searchTableParams.customFilter);
218
218
  }
219
219
  var _f = __read((0, react_1.useState)(filtersInit), 2), filters = _f[0], setFilters = _f[1]; // filtrovanie na "controlled manner" (moze sa sem nainicializovat nejaka hodnota)
220
220
  var _g = __read((0, react_1.useState)(props.sortField ? [{ field: props.sortField, order: 1 }] : []), 2), multiSortMeta = _g[0], setMultiSortMeta = _g[1];
@@ -255,7 +255,7 @@ var XLazyDataTable = function (props) {
255
255
  return __generator(this, function (_a) {
256
256
  //console.log("zavolany onPage");
257
257
  setFirst(event.first);
258
- loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: event.first, rows: rows, filters: filters, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
258
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: event.first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
259
259
  return [2 /*return*/];
260
260
  });
261
261
  }); };
@@ -269,7 +269,7 @@ var XLazyDataTable = function (props) {
269
269
  //console.log("zavolany onSort - this.state.multiSortMeta = " + JSON.stringify(multiSortMeta));
270
270
  //console.log("zavolany onSort - event.multiSortMeta = " + JSON.stringify(event.multiSortMeta));
271
271
  setMultiSortMeta(event.multiSortMeta);
272
- loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilter: customFilter, multiSortMeta: event.multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
272
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: event.multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
273
273
  };
274
274
  var onClickFilter = function () {
275
275
  //console.log("zavolany onClickFilter");
@@ -281,7 +281,7 @@ var XLazyDataTable = function (props) {
281
281
  setFilters(filtersInit);
282
282
  };
283
283
  var loadData = function () {
284
- loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
284
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
285
285
  };
286
286
  var loadDataBase = function (findParam) { return __awaiter(void 0, void 0, void 0, function () {
287
287
  var findResult;
@@ -449,7 +449,7 @@ var XLazyDataTable = function (props) {
449
449
  return __generator(this, function (_a) {
450
450
  switch (_a.label) {
451
451
  case 0:
452
- findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems };
452
+ findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems };
453
453
  return [4 /*yield*/, findByFilter(findParam)];
454
454
  case 1:
455
455
  findResult = _a.sent();
@@ -461,7 +461,7 @@ var XLazyDataTable = function (props) {
461
461
  });
462
462
  }); };
463
463
  var createExportParams = function () {
464
- var queryParam = { filters: filtersAfterFiltering, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
464
+ var queryParam = { filters: filtersAfterFiltering, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
465
465
  return {
466
466
  path: "x-lazy-data-table-export",
467
467
  queryParam: queryParam,
@@ -569,45 +569,60 @@ var XLazyDataTable = function (props) {
569
569
  }
570
570
  return betweenFilter;
571
571
  };
572
- var bodyTemplate = function (columnProps, rowData, xField) {
573
- var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(rowData, columnProps.field);
574
- var bodyValue = '';
572
+ var valueAsUI = function (value, xField) {
573
+ var valueResult = '';
575
574
  if (xField.type === "decimal") {
576
575
  // tuto zatial hack, mal by vzdy prist number
577
576
  var numberValue = null;
578
- if (typeof rowDataValue === 'string') {
579
- numberValue = parseFloat(rowDataValue);
577
+ if (typeof value === 'string') {
578
+ numberValue = parseFloat(value);
580
579
  }
581
- else if (typeof rowDataValue === 'number') {
582
- numberValue = rowDataValue;
580
+ else if (typeof value === 'number') {
581
+ numberValue = value;
583
582
  }
584
- bodyValue = (0, XUtilsConversions_1.numberAsUI)(numberValue, xField.scale);
583
+ valueResult = (0, XUtilsConversions_1.numberAsUI)(numberValue, xField.scale);
585
584
  }
586
585
  else if (xField.type === "date") {
587
586
  // tuto zatial hack, mal by prist Date
588
587
  var dateValue = null;
589
- if (typeof rowDataValue === 'string') {
590
- dateValue = new Date(rowDataValue);
588
+ if (typeof value === 'string') {
589
+ dateValue = new Date(value);
591
590
  }
592
- else if (typeof rowDataValue === 'object' && rowDataValue instanceof Date) {
593
- dateValue = rowDataValue;
591
+ else if (typeof value === 'object' && value instanceof Date) {
592
+ dateValue = value;
594
593
  }
595
- bodyValue = (0, XUtilsConversions_1.dateAsUI)(dateValue);
594
+ valueResult = (0, XUtilsConversions_1.dateAsUI)(dateValue);
596
595
  }
597
596
  else if (xField.type === "datetime") {
598
597
  // tuto zatial hack, mal by prist Date
599
598
  var dateValue = null;
600
- if (typeof rowDataValue === 'string') {
601
- dateValue = new Date(rowDataValue);
599
+ if (typeof value === 'string') {
600
+ dateValue = new Date(value);
602
601
  }
603
- else if (typeof rowDataValue === 'object' && rowDataValue instanceof Date) {
604
- dateValue = rowDataValue;
602
+ else if (typeof value === 'object' && value instanceof Date) {
603
+ dateValue = value;
605
604
  }
606
- bodyValue = (0, XUtilsConversions_1.datetimeAsUI)(dateValue);
605
+ valueResult = (0, XUtilsConversions_1.datetimeAsUI)(dateValue);
607
606
  }
608
607
  else if (xField.type === "boolean") {
609
608
  // TODO - efektivnejsie by bolo renderovat len prislusne ikonky
610
- bodyValue = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: rowDataValue, disabled: true });
609
+ valueResult = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: value, disabled: true });
610
+ }
611
+ else {
612
+ // string a ine typy
613
+ valueResult = value;
614
+ }
615
+ return valueResult;
616
+ };
617
+ var bodyTemplate = function (columnProps, rowData, xField) {
618
+ var bodyValue;
619
+ var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueOrValueListByPath(rowData, columnProps.field);
620
+ if (Array.isArray(rowDataValue)) {
621
+ var elemList = rowDataValue.map(function (value, index) { return react_1.default.createElement("div", { key: index }, valueAsUI(value, xField)); });
622
+ bodyValue = react_1.default.createElement("div", null, elemList);
623
+ }
624
+ else {
625
+ bodyValue = valueAsUI(rowDataValue, xField);
611
626
  }
612
627
  return bodyValue;
613
628
  };
@@ -805,8 +820,7 @@ var XLazyDataTable = function (props) {
805
820
  if (childColumn.props.body !== undefined) {
806
821
  body = childColumn.props.body;
807
822
  }
808
- // TODO - mozno by bolo dobre vytvarat body pre kazdy typ fieldu, nech je to vsetko konzistentne
809
- else if (xField.type === "decimal" || xField.type === "date" || xField.type === "datetime" || xField.type === "boolean") {
823
+ else {
810
824
  body = function (rowData) { return bodyTemplate(childColumn.props, rowData, xField); };
811
825
  }
812
826
  // *********** width/headerStyle ***********
@@ -136,7 +136,7 @@ var XSearchButton = /** @class */ (function (_super) {
136
136
  setValueToModel(null); // prazdny retazec znamena null hodnotu
137
137
  return [3 /*break*/, 3];
138
138
  case 1:
139
- displayFieldFilter = { filter: "[".concat(props.displayField, "] LIKE :xDisplayFieldValue"), values: { "xDisplayFieldValue": "".concat(e.target.value, "%") } };
139
+ displayFieldFilter = { where: "[".concat(props.displayField, "] LIKE :xDisplayFieldValue"), params: { "xDisplayFieldValue": "".concat(e.target.value, "%") } };
140
140
  customFilter = this.getFilterBase(this.props.filter);
141
141
  return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, XUtils_1.XUtils.filterAnd(displayFieldFilter, customFilter))];
142
142
  case 2:
@@ -3,13 +3,22 @@ import { CsvDecimalFormat, CsvEncoding, CsvSeparator, ExportType } from "../serv
3
3
  import React from "react";
4
4
  import { XEnvVar } from "./XEnvVars";
5
5
  import { XError, XErrorMap } from "./XErrors";
6
- import { XCustomFilter } from "../serverApi/FindParam";
6
+ import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
7
7
  export declare enum OperationType {
8
8
  None = 0,
9
9
  Insert = 1,
10
10
  Update = 2,
11
11
  Remove = 3
12
12
  }
13
+ export interface IPostgresInterval {
14
+ years?: number;
15
+ months?: number;
16
+ days?: number;
17
+ hours?: number;
18
+ minutes?: number;
19
+ seconds?: number;
20
+ milliseconds?: number;
21
+ }
13
22
  export declare class XUtils {
14
23
  static dropdownEmptyOptionValue: string;
15
24
  static xBackendUrl: string | undefined;
@@ -70,5 +79,6 @@ export declare class XUtils {
70
79
  static getErrorMessages(xErrorMap: XErrorMap): string;
71
80
  static getErrorMessage(xError: XError): string | undefined;
72
81
  static normalizeString(value: string): string;
73
- static filterAnd(filter1: XCustomFilter | undefined, filter2: XCustomFilter | undefined): XCustomFilter | undefined;
82
+ static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
83
+ static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
74
84
  }
@@ -73,6 +73,15 @@ var __read = (this && this.__read) || function (o, n) {
73
73
  }
74
74
  return ar;
75
75
  };
76
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
77
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
78
+ if (ar || !(i in from)) {
79
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
80
+ ar[i] = from[i];
81
+ }
82
+ }
83
+ return to.concat(ar || Array.prototype.slice.call(from));
84
+ };
76
85
  Object.defineProperty(exports, "__esModule", { value: true });
77
86
  exports.XUtils = exports.OperationType = void 0;
78
87
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
@@ -260,7 +269,7 @@ var XUtils = /** @class */ (function () {
260
269
  return __generator(this, function (_a) {
261
270
  switch (_a.label) {
262
271
  case 0:
263
- findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilter: customFilter, multiSortMeta: sortField ? [{ field: sortField, order: 1 }] : undefined, fields: fields };
272
+ findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: sortField ? [{ field: sortField, order: 1 }] : undefined, fields: fields };
264
273
  return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
265
274
  case 1:
266
275
  rowList = (_a.sent()).rowList;
@@ -446,6 +455,7 @@ var XUtils = /** @class */ (function () {
446
455
  });
447
456
  });
448
457
  };
458
+ // TODO - prehodit do XUtilsCommon
449
459
  XUtils.arrayMoveElement = function (array, position, offset) {
450
460
  var element = array[position];
451
461
  array.splice(position, 1);
@@ -460,7 +470,7 @@ var XUtils = /** @class */ (function () {
460
470
  array.splice(positionNew, 0, element);
461
471
  }
462
472
  };
463
- // helper function
473
+ // TODO - prehodit do XUtilsCommon
464
474
  XUtils.arraySort = function (array, fieldOrStringFunction) {
465
475
  var stringFunction;
466
476
  if (typeof fieldOrStringFunction === 'string') {
@@ -592,20 +602,47 @@ var XUtils = /** @class */ (function () {
592
602
  }
593
603
  return value;
594
604
  };
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
+ // pomocna metodka - konvertuje XCustomFilter -> XCustomFilterItem[]
606
+ XUtils.createCustomFilterItems = function (customFilter) {
607
+ var customFilterItems = undefined;
608
+ if (customFilter) {
609
+ if (Array.isArray(customFilter)) {
610
+ customFilterItems = customFilter;
611
+ }
612
+ else {
613
+ customFilterItems = [customFilter];
614
+ }
605
615
  }
606
- else {
607
- return undefined;
616
+ return customFilterItems;
617
+ };
618
+ // pomocna metodka
619
+ XUtils.filterAnd = function () {
620
+ var e_6, _a;
621
+ var filters = [];
622
+ for (var _i = 0; _i < arguments.length; _i++) {
623
+ filters[_i] = arguments[_i];
624
+ }
625
+ var customFilterItemsResult = undefined;
626
+ if (filters.length > 0) {
627
+ customFilterItemsResult = [];
628
+ try {
629
+ for (var filters_1 = __values(filters), filters_1_1 = filters_1.next(); !filters_1_1.done; filters_1_1 = filters_1.next()) {
630
+ var filter = filters_1_1.value;
631
+ var customFilterItems = XUtils.createCustomFilterItems(filter);
632
+ if (customFilterItems) {
633
+ customFilterItemsResult.push.apply(customFilterItemsResult, __spreadArray([], __read(customFilterItems), false));
634
+ }
635
+ }
636
+ }
637
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
638
+ finally {
639
+ try {
640
+ if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
641
+ }
642
+ finally { if (e_6) throw e_6.error; }
643
+ }
608
644
  }
645
+ return customFilterItemsResult;
609
646
  };
610
647
  XUtils.dropdownEmptyOptionValue = " ";
611
648
  XUtils.xBackendUrl = undefined;
@@ -1,3 +1,4 @@
1
+ import { IPostgresInterval } from "./XUtils";
1
2
  export declare function stringFromUI(stringValue: string): string | null;
2
3
  export declare function stringAsUI(value: string | null): string;
3
4
  export declare function numberFromUI(stringValue: string): number | null;
@@ -10,3 +11,5 @@ export declare function timeFromModel(value: any): Date | null;
10
11
  export declare function dateFormatUI(): string;
11
12
  export declare function dateFormatCalendar(): string;
12
13
  export declare function datetimeFormatUI(): string;
14
+ export declare function intervalFromUI(valueString: string): IPostgresInterval | null | undefined;
15
+ export declare function intervalAsUI(valueInterval: IPostgresInterval | null): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromModel = exports.numberFromModel = exports.numberAsUI = exports.numberFromUI = exports.stringAsUI = exports.stringFromUI = void 0;
3
+ exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromModel = exports.numberFromModel = exports.numberAsUI = exports.numberFromUI = exports.stringAsUI = exports.stringFromUI = void 0;
4
4
  var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
5
5
  function stringFromUI(stringValue) {
6
6
  var value;
@@ -123,3 +123,55 @@ function datetimeFormatUI() {
123
123
  return "dd.mm.yyyy HH:MM:ss";
124
124
  }
125
125
  exports.datetimeFormatUI = datetimeFormatUI;
126
+ function intervalFromUI(valueString) {
127
+ // convert e.target.value (e.g. 10:29) into IPostgresInterval (e.g. {hours: 10, minutes: 29})
128
+ // if stringValue is invalid, returns undefined
129
+ var valueInterval = undefined;
130
+ if (valueString === '') {
131
+ valueInterval = null;
132
+ }
133
+ else {
134
+ var posColon = valueString.indexOf(':');
135
+ if (posColon === -1) {
136
+ var minutes = parseInt(valueString);
137
+ if (!isNaN(minutes)) {
138
+ var hours = Math.floor(minutes / 60);
139
+ minutes = minutes - (hours * 60);
140
+ valueInterval = { hours: hours, minutes: minutes };
141
+ }
142
+ }
143
+ else {
144
+ var hours = parseInt(valueString.substring(0, posColon));
145
+ var minutes = parseInt(valueString.substring(posColon + 1));
146
+ if (!isNaN(hours) && !isNaN(minutes)) {
147
+ if (minutes >= 60) {
148
+ var hoursFromMinutes = Math.floor(minutes / 60);
149
+ hours += hoursFromMinutes;
150
+ minutes = minutes - (hoursFromMinutes * 60);
151
+ }
152
+ valueInterval = { hours: hours, minutes: minutes };
153
+ }
154
+ }
155
+ }
156
+ return valueInterval;
157
+ }
158
+ exports.intervalFromUI = intervalFromUI;
159
+ function intervalAsUI(valueInterval) {
160
+ var _a, _b;
161
+ // conversion e.g. {hours: 10, minutes: 29} => '10:29'
162
+ var valueString;
163
+ if (valueInterval !== null) {
164
+ var hours = (_a = valueInterval.hours) !== null && _a !== void 0 ? _a : 0;
165
+ var minutes = (_b = valueInterval.minutes) !== null && _b !== void 0 ? _b : 0;
166
+ //const seconds: number = value.seconds ?? 0;
167
+ if (valueInterval.days) {
168
+ hours += valueInterval.days * 24;
169
+ }
170
+ valueString = "".concat(hours.toString(), ":").concat(minutes.toString().padStart(2, '0'));
171
+ }
172
+ else {
173
+ valueString = ''; // null
174
+ }
175
+ return valueString;
176
+ }
177
+ exports.intervalAsUI = intervalAsUI;
@@ -1,5 +1,5 @@
1
1
  import { DataTableFilterMeta, DataTableSortMeta } from "primereact/datatable";
2
- import { XCustomFilter } from "./FindParam";
2
+ import { XCustomFilterItem } from "./FindParam";
3
3
  export declare enum ExportType {
4
4
  Csv = "csv",
5
5
  Json = "json"
@@ -11,7 +11,7 @@ export interface ExportParam {
11
11
  }
12
12
  export interface LazyDataTableQueryParam {
13
13
  filters: DataTableFilterMeta;
14
- customFilter?: XCustomFilter;
14
+ customFilterItems?: XCustomFilterItem[];
15
15
  multiSortMeta?: DataTableSortMeta[];
16
16
  entity: string;
17
17
  fields: string[];
@@ -4,13 +4,14 @@ export declare enum ResultType {
4
4
  RowCountAndPagedRows = 1,
5
5
  AllRows = 2
6
6
  }
7
- export interface XCustomFilterValues {
7
+ export interface XParams {
8
8
  [key: string]: any;
9
9
  }
10
- export interface XCustomFilter {
11
- filter: string;
12
- values: XCustomFilterValues;
10
+ export interface XCustomFilterItem {
11
+ where: string;
12
+ params: XParams;
13
13
  }
14
+ export type XCustomFilter = XCustomFilterItem | XCustomFilterItem[];
14
15
  export declare enum XAggregateType {
15
16
  Min = "MIN",
16
17
  Max = "MAX",
@@ -26,7 +27,7 @@ export interface FindParam {
26
27
  first?: number;
27
28
  rows?: number;
28
29
  filters?: DataTableFilterMeta;
29
- customFilter?: XCustomFilter;
30
+ customFilterItems?: XCustomFilterItem[];
30
31
  multiSortMeta?: DataTableSortMeta[];
31
32
  entity: string;
32
33
  fields?: string[];
@@ -1,6 +1,7 @@
1
1
  export declare class XUtilsCommon {
2
2
  static newLine: string;
3
3
  static getValueByPath(object: any, path: string): any;
4
+ static getValueOrValueListByPath(object: any, path: string): any | any[];
4
5
  static getFieldListForPath(path: string): string[];
5
6
  static getFieldAndRestPath(path: string): [string, string | null];
6
7
  static getPathToAssoc(path: string): string;