@michalrakus/x-react-web-lib 1.9.0 → 1.11.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 (61) hide show
  1. package/XEditBrowse.d.ts +3 -0
  2. package/XEditBrowse.js +5 -0
  3. package/XInputInterval.d.ts +3 -0
  4. package/XInputInterval.js +5 -0
  5. package/XInputIntervalBase.d.ts +3 -0
  6. package/XInputIntervalBase.js +5 -0
  7. package/XObject.d.ts +3 -0
  8. package/XObject.js +5 -0
  9. package/gulpfile.js +4 -1
  10. package/lib/administration/XBrowseMetaBrowse.d.ts +2 -1
  11. package/lib/administration/XUserBrowse.d.ts +2 -1
  12. package/lib/administration/XUserBrowse.js +1 -1
  13. package/lib/administration/XUserForm.d.ts +6 -3
  14. package/lib/administration/XUserForm.js +9 -16
  15. package/lib/components/XAutoComplete.d.ts +4 -4
  16. package/lib/components/XAutoComplete.js +10 -20
  17. package/lib/components/XAutoCompleteBase.d.ts +15 -5
  18. package/lib/components/XAutoCompleteBase.js +114 -95
  19. package/lib/components/XAutoCompleteDT.d.ts +4 -3
  20. package/lib/components/XAutoCompleteDT.js +8 -7
  21. package/lib/components/XCalendar.d.ts +2 -1
  22. package/lib/components/XCalendar.js +1 -1
  23. package/lib/components/XDropdownDT.d.ts +3 -0
  24. package/lib/components/XDropdownDT.js +14 -7
  25. package/lib/components/XDropdownForEntity.d.ts +1 -0
  26. package/lib/components/XDropdownForEntity.js +3 -1
  27. package/lib/components/{XBrowse.d.ts → XEditBrowse.d.ts} +3 -3
  28. package/lib/components/{XBrowse.js → XEditBrowse.js} +22 -22
  29. package/lib/components/XFormBase.d.ts +14 -4
  30. package/lib/components/XFormBase.js +137 -42
  31. package/lib/components/XFormDataTable2.d.ts +7 -6
  32. package/lib/components/XFormDataTable2.js +18 -38
  33. package/lib/components/XFormNavigator3.d.ts +3 -3
  34. package/lib/components/XFormNavigator3.js +2 -2
  35. package/lib/components/XInputDate.js +1 -1
  36. package/lib/components/XInputInterval.d.ts +14 -0
  37. package/lib/components/XInputInterval.js +56 -0
  38. package/lib/components/XInputIntervalBase.d.ts +10 -0
  39. package/lib/components/XInputIntervalBase.js +97 -0
  40. package/lib/components/XInputIntervalDT.d.ts +11 -0
  41. package/lib/components/XInputIntervalDT.js +43 -0
  42. package/lib/components/XLazyDataTable.d.ts +9 -2
  43. package/lib/components/XLazyDataTable.js +58 -42
  44. package/lib/components/{SearchTableParams.d.ts → XSearchBrowseParams.d.ts} +2 -2
  45. package/lib/components/XSearchButton.d.ts +2 -2
  46. package/lib/components/XSearchButton.js +8 -12
  47. package/lib/components/XSearchButtonDT.d.ts +2 -2
  48. package/lib/components/XSearchButtonDT.js +9 -5
  49. package/lib/components/XUtils.d.ts +30 -2
  50. package/lib/components/XUtils.js +95 -17
  51. package/lib/components/XUtilsConversions.d.ts +3 -0
  52. package/lib/components/XUtilsConversions.js +53 -1
  53. package/lib/components/locale/x-en.json +4 -1
  54. package/lib/serverApi/ExportImportParam.d.ts +2 -2
  55. package/lib/serverApi/FindParam.d.ts +6 -5
  56. package/lib/serverApi/XUtilsCommon.d.ts +1 -0
  57. package/lib/serverApi/XUtilsCommon.js +70 -0
  58. package/package.json +1 -1
  59. package/XBrowse.d.ts +0 -3
  60. package/XBrowse.js +0 -5
  61. /package/lib/components/{SearchTableParams.js → XSearchBrowseParams.js} +0 -0
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import React, { ReactChild } from 'react';
2
2
  import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMetaData } from 'primereact/datatable';
3
3
  import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereact/column';
4
- import { SearchTableParams } from "./SearchTableParams";
4
+ import { XSearchBrowseParams } from "./XSearchBrowseParams";
5
5
  import { XAggregateType, XCustomFilter } from "../serverApi/FindParam";
6
6
  import { XOnSaveOrCancelProp } from "./XFormBase";
7
7
  export type XBetweenFilterProp = "row" | "column" | undefined;
@@ -15,6 +15,13 @@ export interface XEditModeHandlers {
15
15
  onMoveColumnLeft: (field: string) => void;
16
16
  onMoveColumnRight: (field: string) => void;
17
17
  }
18
+ export interface XBrowseProps {
19
+ displayed?: boolean;
20
+ openForm?: (newFormElement: JSX.Element | null) => void;
21
+ }
22
+ export interface XSearchBrowseProps {
23
+ searchBrowseParams?: XSearchBrowseParams;
24
+ }
18
25
  export interface XLazyDataTableProps {
19
26
  entity: string;
20
27
  dataKey?: string;
@@ -35,7 +42,7 @@ export interface XLazyDataTableProps {
35
42
  filters?: DataTableFilterMeta;
36
43
  customFilter?: XCustomFilter;
37
44
  sortField?: string;
38
- searchTableParams?: SearchTableParams;
45
+ searchBrowseParams?: XSearchBrowseParams;
39
46
  width?: string;
40
47
  dataLoadedState?: [boolean, React.Dispatch<React.SetStateAction<boolean>>];
41
48
  editMode?: boolean;
@@ -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];
@@ -208,13 +208,15 @@ var XLazyDataTable = function (props) {
208
208
  if (props.filters) {
209
209
  filtersInit = __assign(__assign({}, filtersInit), props.filters); // items from props.filters will replace existing items in filtersInit
210
210
  }
211
- if (props.searchTableParams !== undefined) {
212
- var displayFieldFilter = props.searchTableParams.displayFieldFilter;
211
+ if (props.searchBrowseParams !== undefined) {
212
+ var displayFieldFilter = props.searchBrowseParams.displayFieldFilter;
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.searchBrowseParams.customFilterFunction, pridame filter
217
+ if (props.searchBrowseParams.customFilterFunction) {
218
+ customFilterItems = XUtils_1.XUtils.filterAnd(customFilterItems, props.searchBrowseParams.customFilterFunction());
219
+ }
218
220
  }
219
221
  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
222
  var _g = __read((0, react_1.useState)(props.sortField ? [{ field: props.sortField, order: 1 }] : []), 2), multiSortMeta = _g[0], setMultiSortMeta = _g[1];
@@ -255,7 +257,7 @@ var XLazyDataTable = function (props) {
255
257
  return __generator(this, function (_a) {
256
258
  //console.log("zavolany onPage");
257
259
  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 });
260
+ 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
261
  return [2 /*return*/];
260
262
  });
261
263
  }); };
@@ -269,7 +271,7 @@ var XLazyDataTable = function (props) {
269
271
  //console.log("zavolany onSort - this.state.multiSortMeta = " + JSON.stringify(multiSortMeta));
270
272
  //console.log("zavolany onSort - event.multiSortMeta = " + JSON.stringify(event.multiSortMeta));
271
273
  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 });
274
+ 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
275
  };
274
276
  var onClickFilter = function () {
275
277
  //console.log("zavolany onClickFilter");
@@ -281,7 +283,7 @@ var XLazyDataTable = function (props) {
281
283
  setFilters(filtersInit);
282
284
  };
283
285
  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 });
286
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
285
287
  };
286
288
  var loadDataBase = function (findParam) { return __awaiter(void 0, void 0, void 0, function () {
287
289
  var findResult;
@@ -364,11 +366,11 @@ var XLazyDataTable = function (props) {
364
366
  var onRowDoubleClick = function (event) {
365
367
  //console.log("zavolany onRowDoubleClick");
366
368
  //console.log(event.data);
367
- if (props.onEdit !== undefined) {
369
+ if (props.onEdit !== undefined && props.searchBrowseParams === undefined) {
368
370
  props.onEdit(event.data);
369
371
  }
370
- else if (props.searchTableParams !== undefined) {
371
- props.searchTableParams.onChoose(event.data);
372
+ else if (props.searchBrowseParams !== undefined) {
373
+ props.searchBrowseParams.onChoose(event.data);
372
374
  }
373
375
  };
374
376
  var onClickAddRow = function () {
@@ -449,7 +451,7 @@ var XLazyDataTable = function (props) {
449
451
  return __generator(this, function (_a) {
450
452
  switch (_a.label) {
451
453
  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 };
454
+ findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems };
453
455
  return [4 /*yield*/, findByFilter(findParam)];
454
456
  case 1:
455
457
  findResult = _a.sent();
@@ -461,7 +463,7 @@ var XLazyDataTable = function (props) {
461
463
  });
462
464
  }); };
463
465
  var createExportParams = function () {
464
- var queryParam = { filters: filtersAfterFiltering, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
466
+ var queryParam = { filters: filtersAfterFiltering, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
465
467
  return {
466
468
  path: "x-lazy-data-table-export",
467
469
  queryParam: queryParam,
@@ -472,8 +474,8 @@ var XLazyDataTable = function (props) {
472
474
  var onClickChoose = function () {
473
475
  //console.log("zavolany onClickChoose");
474
476
  if (selectedRow !== null) {
475
- if (props.searchTableParams !== undefined) {
476
- props.searchTableParams.onChoose(selectedRow);
477
+ if (props.searchBrowseParams !== undefined) {
478
+ props.searchBrowseParams.onChoose(selectedRow);
477
479
  }
478
480
  }
479
481
  else {
@@ -569,45 +571,60 @@ var XLazyDataTable = function (props) {
569
571
  }
570
572
  return betweenFilter;
571
573
  };
572
- var bodyTemplate = function (columnProps, rowData, xField) {
573
- var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(rowData, columnProps.field);
574
- var bodyValue = '';
574
+ var valueAsUI = function (value, xField) {
575
+ var valueResult = '';
575
576
  if (xField.type === "decimal") {
576
577
  // tuto zatial hack, mal by vzdy prist number
577
578
  var numberValue = null;
578
- if (typeof rowDataValue === 'string') {
579
- numberValue = parseFloat(rowDataValue);
579
+ if (typeof value === 'string') {
580
+ numberValue = parseFloat(value);
580
581
  }
581
- else if (typeof rowDataValue === 'number') {
582
- numberValue = rowDataValue;
582
+ else if (typeof value === 'number') {
583
+ numberValue = value;
583
584
  }
584
- bodyValue = (0, XUtilsConversions_1.numberAsUI)(numberValue, xField.scale);
585
+ valueResult = (0, XUtilsConversions_1.numberAsUI)(numberValue, xField.scale);
585
586
  }
586
587
  else if (xField.type === "date") {
587
588
  // tuto zatial hack, mal by prist Date
588
589
  var dateValue = null;
589
- if (typeof rowDataValue === 'string') {
590
- dateValue = new Date(rowDataValue);
590
+ if (typeof value === 'string') {
591
+ dateValue = new Date(value);
591
592
  }
592
- else if (typeof rowDataValue === 'object' && rowDataValue instanceof Date) {
593
- dateValue = rowDataValue;
593
+ else if (typeof value === 'object' && value instanceof Date) {
594
+ dateValue = value;
594
595
  }
595
- bodyValue = (0, XUtilsConversions_1.dateAsUI)(dateValue);
596
+ valueResult = (0, XUtilsConversions_1.dateAsUI)(dateValue);
596
597
  }
597
598
  else if (xField.type === "datetime") {
598
599
  // tuto zatial hack, mal by prist Date
599
600
  var dateValue = null;
600
- if (typeof rowDataValue === 'string') {
601
- dateValue = new Date(rowDataValue);
601
+ if (typeof value === 'string') {
602
+ dateValue = new Date(value);
602
603
  }
603
- else if (typeof rowDataValue === 'object' && rowDataValue instanceof Date) {
604
- dateValue = rowDataValue;
604
+ else if (typeof value === 'object' && value instanceof Date) {
605
+ dateValue = value;
605
606
  }
606
- bodyValue = (0, XUtilsConversions_1.datetimeAsUI)(dateValue);
607
+ valueResult = (0, XUtilsConversions_1.datetimeAsUI)(dateValue);
607
608
  }
608
609
  else if (xField.type === "boolean") {
609
610
  // TODO - efektivnejsie by bolo renderovat len prislusne ikonky
610
- bodyValue = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: rowDataValue, disabled: true });
611
+ valueResult = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: value, disabled: true });
612
+ }
613
+ else {
614
+ // string a ine typy
615
+ valueResult = value;
616
+ }
617
+ return valueResult;
618
+ };
619
+ var bodyTemplate = function (columnProps, rowData, xField) {
620
+ var bodyValue;
621
+ var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueOrValueListByPath(rowData, columnProps.field);
622
+ if (Array.isArray(rowDataValue)) {
623
+ var elemList = rowDataValue.map(function (value, index) { return react_1.default.createElement("div", { key: index }, valueAsUI(value, xField)); });
624
+ bodyValue = react_1.default.createElement("div", null, elemList);
625
+ }
626
+ else {
627
+ bodyValue = valueAsUI(rowDataValue, xField);
611
628
  }
612
629
  return bodyValue;
613
630
  };
@@ -633,7 +650,7 @@ var XLazyDataTable = function (props) {
633
650
  // }
634
651
  var viewHeight = void 0;
635
652
  var headerFooterHeight = void 0;
636
- if (props.searchTableParams === undefined) {
653
+ if (props.searchBrowseParams === undefined) {
637
654
  // sme v standardnom formulari
638
655
  viewHeight = '100vh';
639
656
  // experimentalne zistena vyska header/footer
@@ -702,7 +719,7 @@ var XLazyDataTable = function (props) {
702
719
  }
703
720
  // else - editMode is undefined - browse is not editable
704
721
  // export pre search button-y zatial vypneme
705
- var exportRows = (props.searchTableParams === undefined);
722
+ var exportRows = (props.searchBrowseParams === undefined);
706
723
  // pre lepsiu citatelnost vytvarame stlpce uz tu
707
724
  var columnElemList = react_1.default.Children.map(props.children, function (child) {
708
725
  // ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
@@ -805,8 +822,7 @@ var XLazyDataTable = function (props) {
805
822
  if (childColumn.props.body !== undefined) {
806
823
  body = childColumn.props.body;
807
824
  }
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") {
825
+ else {
810
826
  body = function (rowData) { return bodyTemplate(childColumn.props, rowData, xField); };
811
827
  }
812
828
  // *********** width/headerStyle ***********
@@ -859,12 +875,12 @@ var XLazyDataTable = function (props) {
859
875
  react_1.default.createElement("div", { className: "flex justify-content-center" },
860
876
  react_1.default.createElement(datatable_1.DataTable, { value: value.rowList, dataKey: dataKey, paginator: props.paginator, rows: rows, totalRecords: value.totalRecords, lazy: true, first: first, onPage: onPage, loading: loading, filterDisplay: props.filterDisplay, filters: filters, onFilter: onFilter, sortMode: "multiple", removableSort: true, multiSortMeta: multiSortMeta, onSort: onSort, selectionMode: "single", selection: selectedRow, onSelectionChange: onSelectionChange, onRowDoubleClick: onRowDoubleClick, ref: dataTableEl, className: "p-datatable-sm x-lazy-datatable", resizableColumns: true, columnResizeMode: "expand", tableStyle: tableStyle, paginatorLeft: paginatorLeft, paginatorRight: paginatorRight, scrollable: props.scrollable, scrollHeight: scrollHeight, style: style }, columnElemList)),
861
877
  react_1.default.createElement("div", { className: "flex justify-content-center" },
862
- props.onAddRow !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "addRow", icon: "pi pi-plus", label: (0, XLocale_1.xLocaleOption)('addRow'), onClick: onClickAddRow }) : null,
863
- props.onEdit !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "editRow", icon: "pi pi-pencil", label: (0, XLocale_1.xLocaleOption)('editRow'), onClick: onClickEdit }) : null,
864
- props.removeRow !== undefined && props.removeRow !== false ? react_1.default.createElement(XButton_1.XButton, { key: "removeRow", icon: "pi pi-times", label: (0, XLocale_1.xLocaleOption)('removeRow'), onClick: onClickRemoveRow }) : null,
878
+ props.onAddRow !== undefined && props.searchBrowseParams === undefined ? react_1.default.createElement(XButton_1.XButton, { key: "addRow", icon: "pi pi-plus", label: (0, XLocale_1.xLocaleOption)('addRow'), onClick: onClickAddRow }) : null,
879
+ props.onEdit !== undefined && props.searchBrowseParams === undefined ? react_1.default.createElement(XButton_1.XButton, { key: "editRow", icon: "pi pi-pencil", label: (0, XLocale_1.xLocaleOption)('editRow'), onClick: onClickEdit }) : null,
880
+ props.removeRow !== undefined && props.removeRow !== false && props.searchBrowseParams === undefined ? react_1.default.createElement(XButton_1.XButton, { key: "removeRow", icon: "pi pi-times", label: (0, XLocale_1.xLocaleOption)('removeRow'), onClick: onClickRemoveRow }) : null,
865
881
  exportRows ? react_1.default.createElement(XButton_1.XButton, { key: "exportRows", icon: "pi pi-file-export", label: (0, XLocale_1.xLocaleOption)('exportRows'), onClick: onClickExport }) : null,
866
882
  props.appButtons,
867
- props.searchTableParams !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "choose", label: (0, XLocale_1.xLocaleOption)('chooseRow'), onClick: onClickChoose }) : null,
883
+ props.searchBrowseParams !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "choose", label: (0, XLocale_1.xLocaleOption)('chooseRow'), onClick: onClickChoose }) : null,
868
884
  exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { key: "exportRowsDialog", dialogOpened: exportRowsDialogOpened, hideDialog: function () { return setExportRowsDialogOpened(false); }, rowCount: exportRowsDialogRowCount, exportParams: createExportParams }) : null)));
869
885
  };
870
886
  exports.XLazyDataTable = XLazyDataTable;
@@ -4,8 +4,8 @@ export interface XFieldFilter {
4
4
  field: string;
5
5
  constraint: DataTableFilterMetaData;
6
6
  }
7
- export interface SearchTableParams {
7
+ export interface XSearchBrowseParams {
8
8
  onChoose: (chosenRow: any) => void;
9
9
  displayFieldFilter?: XFieldFilter;
10
- customFilter?: XCustomFilter;
10
+ customFilterFunction?: () => XCustomFilter | undefined;
11
11
  }
@@ -5,8 +5,8 @@ import { XObject } from "./XObject";
5
5
  export interface XSearchButtonProps extends XFormComponentProps<XObject> {
6
6
  assocField: string;
7
7
  displayField: string;
8
- searchTable: any;
9
- assocForm?: any;
8
+ searchBrowse: JSX.Element;
9
+ assocForm?: JSX.Element;
10
10
  filter?: XFilterProp;
11
11
  size?: number;
12
12
  inputStyle?: React.CSSProperties;
@@ -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:
@@ -166,7 +166,7 @@ var XSearchButton = /** @class */ (function (_super) {
166
166
  setInputChanged(false);
167
167
  };
168
168
  var onClickSearch = function (e) {
169
- console.log("zavolany onClickSearch");
169
+ //console.log("zavolany onClickSearch");
170
170
  if (!_this.isReadOnly()) {
171
171
  setDialogOpened(true);
172
172
  // POVODNY KOD
@@ -178,13 +178,13 @@ var XSearchButton = /** @class */ (function (_super) {
178
178
  // OTAZKA - ziskavat id priamo z root objektu? potom ho vsak treba do root objektu pridat
179
179
  var id = (assocObject !== null) ? assocObject[xEntityAssoc.idField] : null;
180
180
  // klonovanim elementu pridame atribut id
181
- var assocForm = react_1.default.cloneElement(props.assocForm, { id: id }, props.assocForm.children);
181
+ var assocForm = react_1.default.cloneElement(props.assocForm, { id: id } /*, props.assocForm.children*/);
182
182
  props.form.props.openForm(assocForm);
183
183
  }
184
184
  }
185
185
  };
186
186
  var onChoose = function (chosenRow) {
187
- console.log("zavolany onChoose");
187
+ //console.log("zavolany onChoose");
188
188
  // zavrieme search dialog
189
189
  // POVODNY KOD
190
190
  //overlayPanelEl.current.hide();
@@ -199,14 +199,12 @@ var XSearchButton = /** @class */ (function (_super) {
199
199
  _this.inputTextRef.current.focus();
200
200
  }
201
201
  };
202
- // {React.createElement(props.searchTable, {searchTableParams: {onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}, ...props.searchTableProps}, null)}
203
- // <BrandSearchTable searchTableParams={{onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}} qqq="fiha"/>
204
202
  // takto cez metodku, mozno sa metodka vola len ked sa otvori dialog a usetrime nieco...
205
- var createSearchTableParams = function () {
203
+ var createSearchBrowseParams = function () {
206
204
  return {
207
205
  onChoose: onChoose,
208
206
  displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "startsWith" } } : undefined),
209
- customFilter: _this.getFilterBase(_this.props.filter)
207
+ customFilterFunction: function () { return _this.getFilterBase(_this.props.filter); }
210
208
  };
211
209
  };
212
210
  // vypocitame inputValue
@@ -215,10 +213,8 @@ var XSearchButton = /** @class */ (function (_super) {
215
213
  react_1.default.createElement("label", { htmlFor: props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
216
214
  react_1.default.createElement("div", { className: "x-search-button-base" },
217
215
  react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: this.isReadOnly(), ref: this.inputTextRef, maxLength: xDisplayField.length, size: size, style: props.inputStyle }, this.getClassNameTooltip())),
218
- react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
219
- react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, {
220
- searchTableParams: createSearchTableParams()
221
- }, props.searchTable.children))));
216
+ react_1.default.createElement(button_1.Button, { icon: "pi pi-search", onClick: onClickSearch })),
217
+ react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, { searchBrowseParams: createSearchBrowseParams() } /*, props.searchBrowse.children*/))));
222
218
  };
223
219
  return XSearchButton;
224
220
  }(XFormComponent_1.XFormComponent));
@@ -5,8 +5,8 @@ export declare const XSearchButtonDT: (props: {
5
5
  entity: string;
6
6
  assocField: string;
7
7
  displayField: string;
8
- searchTable: any;
9
- assocForm?: any;
8
+ searchBrowse: JSX.Element;
9
+ assocForm?: JSX.Element | undefined;
10
10
  rowData: any;
11
11
  readOnly?: boolean | undefined;
12
12
  }) => JSX.Element;
@@ -155,7 +155,7 @@ var XSearchButtonDT = function (props) {
155
155
  // OTAZKA - ziskavat id priamo z root objektu? potom ho vsak treba do root objektu pridat
156
156
  var id = (assocObject !== null && assocObject !== undefined) ? assocObject[xEntityAssoc.idField] : null;
157
157
  // klonovanim elementu pridame atribut id
158
- var assocForm = react_1.default.cloneElement(props.assocForm, { id: id }, props.assocForm.children);
158
+ var assocForm = react_1.default.cloneElement(props.assocForm, { id: id } /*, props.assocForm.children*/);
159
159
  props.form.props.openForm(assocForm);
160
160
  }
161
161
  }
@@ -175,14 +175,18 @@ var XSearchButtonDT = function (props) {
175
175
  inputTextRef.current.focus();
176
176
  }
177
177
  };
178
- // {React.createElement(props.searchTable, {searchTableParams: {onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}, ...props.searchTableProps}, null)}
179
- // <BrandSearchTable searchTableParams={{onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}} qqq="fiha"/>
180
178
  // vypocitame inputValue
181
179
  var inputValue = computeInputValue();
182
180
  return (react_1.default.createElement("div", null,
183
181
  react_1.default.createElement("div", { className: "x-search-button-base" },
184
182
  react_1.default.createElement(inputtext_1.InputText, { id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: readOnly, ref: inputTextRef }),
185
- react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
186
- react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, { searchTableParams: { onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined) } }, props.searchTable.children))));
183
+ react_1.default.createElement(button_1.Button, { icon: "pi pi-search", onClick: onClickSearch })),
184
+ react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, {
185
+ searchBrowseParams: {
186
+ onChoose: onChoose,
187
+ displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "startsWith" } } : undefined),
188
+ customFilterFunction: function () { return undefined; } // TODO - dorobit
189
+ }
190
+ } /*, props.searchBrowse.children*/))));
187
191
  };
188
192
  exports.XSearchButtonDT = XSearchButtonDT;
@@ -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;
@@ -58,6 +67,24 @@ export declare class XUtils {
58
67
  static removeRow(entity: string, row: any): Promise<void>;
59
68
  static arrayMoveElement(array: any[], position: number, offset: number): void;
60
69
  static arraySort(array: any[], fieldOrStringFunction: string | ((item: any) => string)): any[];
70
+ /**
71
+ * returns true, if param item is member of the array
72
+ * remark: null/undefined items in array are ignored, item = null/undefined is ignored
73
+ *
74
+ * @param array
75
+ * @param item
76
+ * @param idField
77
+ */
78
+ static arrayIncludes<T>(array: T[], item: T, idField: string): boolean;
79
+ /**
80
+ * returns intersection of 2 row lists
81
+ * remark: null/undefined items in both array1 and array2 are ignored
82
+ *
83
+ * @param array1
84
+ * @param array2
85
+ * @param idField
86
+ */
87
+ static arrayIntersect<T>(array1: T[], array2: T[], idField: string): T[];
61
88
  static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
62
89
  static markNotNull(label: string): string;
63
90
  static showErrorMessage(message: string, e: unknown): void;
@@ -70,5 +97,6 @@ export declare class XUtils {
70
97
  static getErrorMessages(xErrorMap: XErrorMap): string;
71
98
  static getErrorMessage(xError: XError): string | undefined;
72
99
  static normalizeString(value: string): string;
73
- static filterAnd(filter1: XCustomFilter | undefined, filter2: XCustomFilter | undefined): XCustomFilter | undefined;
100
+ static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
101
+ static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
74
102
  }