@michalrakus/x-react-web-lib 1.17.0 → 1.19.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 (43) hide show
  1. package/lib/components/XAutoComplete.d.ts +9 -9
  2. package/lib/components/XAutoComplete.js +7 -78
  3. package/lib/components/XAutoCompleteBase.d.ts +39 -7
  4. package/lib/components/XAutoCompleteBase.js +351 -64
  5. package/lib/components/XAutoCompleteDT.d.ts +10 -6
  6. package/lib/components/XAutoCompleteDT.js +3 -69
  7. package/lib/components/XCalendar.d.ts +1 -2
  8. package/lib/components/XCalendar.js +79 -10
  9. package/lib/components/XFormBase.js +5 -1
  10. package/lib/components/XFormComponent.js +9 -6
  11. package/lib/components/XFormDataTable2.d.ts +15 -1
  12. package/lib/components/XFormDataTable2.js +24 -4
  13. package/lib/components/XFormRowCol/XFormCol.d.ts +1 -0
  14. package/lib/components/XFormRowCol/XFormCol.js +1 -1
  15. package/lib/components/XFormRowCol/XFormInlineRow.d.ts +1 -0
  16. package/lib/components/XFormRowCol/XFormInlineRow.js +1 -1
  17. package/lib/components/XFormRowCol/XFormRow.d.ts +1 -0
  18. package/lib/components/XFormRowCol/XFormRow.js +1 -1
  19. package/lib/components/XFormRowCol/XFormRowCol.d.ts +1 -0
  20. package/lib/components/XFormRowCol/XFormRowCol.js +1 -1
  21. package/lib/components/XInputDate.d.ts +0 -1
  22. package/lib/components/XInputDate.js +4 -18
  23. package/lib/components/XInputDateDT.d.ts +9 -10
  24. package/lib/components/XInputDateDT.js +35 -39
  25. package/lib/components/XInputDecimal.js +1 -1
  26. package/lib/components/XInputTextarea.js +1 -1
  27. package/lib/components/XInputTextareaDT.d.ts +12 -0
  28. package/lib/components/XInputTextareaDT.js +44 -0
  29. package/lib/components/XLazyDataTable.d.ts +4 -2
  30. package/lib/components/XLazyDataTable.js +17 -4
  31. package/lib/components/XSearchBrowseParams.d.ts +2 -2
  32. package/lib/components/XSearchButton.js +2 -2
  33. package/lib/components/XSearchButtonDT.js +2 -2
  34. package/lib/components/XUtils.d.ts +4 -0
  35. package/lib/components/XUtils.js +51 -11
  36. package/lib/components/XUtilsMetadata.js +1 -1
  37. package/lib/serverApi/FindParam.d.ts +12 -2
  38. package/lib/serverApi/FindParam.js +3 -2
  39. package/lib/serverApi/XUtilsCommon.d.ts +5 -0
  40. package/lib/serverApi/XUtilsCommon.js +43 -0
  41. package/lib/serverApi/XUtilsConversions.d.ts +1 -0
  42. package/lib/serverApi/XUtilsConversions.js +63 -5
  43. package/package.json +1 -1
@@ -1,48 +1,44 @@
1
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
+ })();
2
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
19
  };
5
20
  Object.defineProperty(exports, "__esModule", { value: true });
6
21
  exports.XInputDateDT = void 0;
7
- var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
8
- var calendar_1 = require("primereact/calendar");
9
22
  var react_1 = __importDefault(require("react"));
10
- var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
11
- var XUtils_1 = require("./XUtils");
12
- var XInputDateDT = function (props) {
13
- var showTime = (props.xField.type === 'datetime');
14
- var cssClassName = showTime ? 'x-input-datetime' : 'x-input-date';
15
- var onValueChange = function (field, rowData, newValue) {
16
- // z Calendar prichadza e.value - typ Date alebo null
17
- // zmenime hodnotu v modeli (odtial sa hodnota cita)
18
- rowData[field] = newValue;
19
- // kedze "rowData" je sucastou "props.form.state.object", tak nam staci zavolat setState({object: object}), aby sa zmena prejavila
20
- props.form.onObjectDataChange();
21
- };
22
- var fieldValue = undefined;
23
- // test na undefined je tu koli insertu noveho riadku
24
- if (props.rowData !== undefined && props.rowData !== null) {
25
- var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(props.rowData, props.field);
26
- // pre istotu dame na null, null je standard
27
- //if (rowDataValue === undefined) {
28
- // rowDataValue = null;
29
- //}
30
- // TODO - konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli
31
- // - otestovat ci zmena na null funguje dobre -
32
- //fieldValue = stringAsUI(rowDataValue);
33
- // tuto zatial hack, mal by prist Date
34
- if (typeof rowDataValue === 'string') {
35
- fieldValue = new Date(rowDataValue);
36
- }
37
- else if (typeof rowDataValue === 'object' && rowDataValue instanceof Date) {
38
- fieldValue = rowDataValue;
39
- }
40
- // fieldValue zostalo undefined (konvertujeme null -> undefined) - Calendar pozaduje undefined, nechce null
23
+ var XInputDT_1 = require("./XInputDT");
24
+ var XCalendar_1 = require("./XCalendar");
25
+ var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
26
+ var XInputDateDT = /** @class */ (function (_super) {
27
+ __extends(XInputDateDT, _super);
28
+ function XInputDateDT(props) {
29
+ var _this = _super.call(this, props) || this;
30
+ _this.onValueChange = _this.onValueChange.bind(_this);
31
+ return _this;
41
32
  }
42
- var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
43
- // TODO - nefunguje dobre pridavanie noveho riadku - su tam stare neupdatnute hodnoty - este to asi neopravili https://github.com/primefaces/primereact/issues/1277
44
- // test mame na TestovaciForm
45
- // appendTo={document.body} appenduje overlay panel na element body - eliminuje problem s overflow (pozri poznamku v XDropdownDTFilter)
46
- return (react_1.default.createElement(calendar_1.Calendar, { appendTo: document.body, id: props.field, value: fieldValue, onChange: function (e) { return onValueChange(props.field, props.rowData, e.value); }, disabled: readOnly, showIcon: true, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), showTime: showTime, showSeconds: showTime, inputClassName: cssClassName, showOnFocus: false }));
47
- };
33
+ XInputDateDT.prototype.getValue = function () {
34
+ return (0, XUtilsConversions_1.dateFromModel)(this.getValueFromRowData());
35
+ };
36
+ XInputDateDT.prototype.onValueChange = function (value) {
37
+ this.onValueChangeBase(value, this.props.onChange);
38
+ };
39
+ XInputDateDT.prototype.render = function () {
40
+ return (react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), datetime: this.xField.type === 'datetime' }));
41
+ };
42
+ return XInputDateDT;
43
+ }(XInputDT_1.XInputDT));
48
44
  exports.XInputDateDT = XInputDateDT;
@@ -72,7 +72,7 @@ var XInputDecimal = /** @class */ (function (_super) {
72
72
  var label = this.getLabel();
73
73
  return (react_1.default.createElement("div", { className: "field grid" },
74
74
  label !== undefined ? react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, label) : null,
75
- react_1.default.createElement(inputnumber_1.InputNumber, __assign({ id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), mode: "decimal", locale: "de-DE", useGrouping: useGrouping, minFractionDigits: fractionDigits, maxFractionDigits: fractionDigits, min: min, max: max, size: sizeInput, style: this.props.inputStyle }, this.getClassNameTooltip(), { onBlur: this.onBlur }))));
75
+ react_1.default.createElement(inputnumber_1.InputNumber, __assign({ id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), mode: "decimal", locale: "de-DE", useGrouping: useGrouping, minFractionDigits: fractionDigits, maxFractionDigits: fractionDigits, min: min, max: max, size: sizeInput, inputStyle: this.props.inputStyle }, this.getClassNameTooltip(), { onBlur: this.onBlur }))));
76
76
  };
77
77
  return XInputDecimal;
78
78
  }(XInput_1.XInput));
@@ -34,7 +34,7 @@ var XInputTextarea = /** @class */ (function (_super) {
34
34
  return this.getValueFromObject();
35
35
  };
36
36
  XInputTextarea.prototype.onValueChange = function (value) {
37
- this.onValueChangeBase(value);
37
+ this.onValueChangeBase(value, this.props.onChange);
38
38
  };
39
39
  XInputTextarea.prototype.getLabelStyle = function () {
40
40
  var _a;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { XInputDT, XInputDTProps } from "./XInputDT";
3
+ export interface XInputTextareaDTProps extends XInputDTProps {
4
+ rows: number;
5
+ autoResize?: boolean;
6
+ }
7
+ export declare class XInputTextareaDT extends XInputDT<XInputTextareaDTProps> {
8
+ constructor(props: XInputTextareaDTProps);
9
+ getValue(): string | null;
10
+ onValueChange(value: string | null): void;
11
+ render(): JSX.Element;
12
+ }
@@ -0,0 +1,44 @@
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.XInputTextareaDT = void 0;
22
+ var react_1 = __importDefault(require("react"));
23
+ var XInputDT_1 = require("./XInputDT");
24
+ var XInputTextareaBase_1 = require("./XInputTextareaBase");
25
+ var XInputTextareaDT = /** @class */ (function (_super) {
26
+ __extends(XInputTextareaDT, _super);
27
+ function XInputTextareaDT(props) {
28
+ var _this = _super.call(this, props) || this;
29
+ _this.onValueChange = _this.onValueChange.bind(_this);
30
+ return _this;
31
+ }
32
+ XInputTextareaDT.prototype.getValue = function () {
33
+ return this.getValueFromRowData();
34
+ };
35
+ XInputTextareaDT.prototype.onValueChange = function (value) {
36
+ this.onValueChangeBase(value, this.props.onChange);
37
+ };
38
+ // pouzivame cols = undefined, sirka je urcena sirkou stlpca (width: 100%)
39
+ XInputTextareaDT.prototype.render = function () {
40
+ return (react_1.default.createElement(XInputTextareaBase_1.XInputTextareaBase, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, style: { width: '100%' }, rows: this.props.rows, cols: undefined, autoResize: this.props.autoResize, error: this.getError() }));
41
+ };
42
+ return XInputTextareaDT;
43
+ }(XInputDT_1.XInputDT));
44
+ exports.XInputTextareaDT = XInputTextareaDT;
@@ -1,5 +1,5 @@
1
1
  import React, { ReactChild } from 'react';
2
- import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMetaData } from 'primereact/datatable';
2
+ import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMetaData, DataTableSortMeta } from 'primereact/datatable';
3
3
  import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereact/column';
4
4
  import { XViewStatusOrBoolean } from "./XUtils";
5
5
  import { XSearchBrowseParams } from "./XSearchBrowseParams";
@@ -51,11 +51,13 @@ export interface XLazyDataTableProps {
51
51
  appButtons?: any;
52
52
  filters?: DataTableFilterMeta;
53
53
  customFilter?: XCustomFilter;
54
- sortField?: string;
54
+ sortField?: string | DataTableSortMeta[];
55
55
  fullTextSearch: boolean | string[];
56
+ fields?: string[];
56
57
  multiLineSwitch: boolean;
57
58
  searchBrowseParams?: XSearchBrowseParams;
58
59
  width?: string;
60
+ rowClassName?: (data: any) => object | string | undefined;
59
61
  dataLoadedState?: [boolean, React.Dispatch<React.SetStateAction<boolean>>];
60
62
  editMode?: boolean;
61
63
  editModeHandlers?: XEditModeHandlers;
@@ -96,6 +96,15 @@ var __read = (this && this.__read) || function (o, n) {
96
96
  }
97
97
  return ar;
98
98
  };
99
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
100
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
101
+ if (ar || !(i in from)) {
102
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
103
+ ar[i] = from[i];
104
+ }
105
+ }
106
+ return to.concat(ar || Array.prototype.slice.call(from));
107
+ };
99
108
  Object.defineProperty(exports, "__esModule", { value: true });
100
109
  exports.XLazyColumn = exports.XLazyDataTable = void 0;
101
110
  var react_1 = __importStar(require("react"));
@@ -220,15 +229,15 @@ var XLazyDataTable = function (props) {
220
229
  filtersInit[displayFieldFilter.field] = createFilterItem(props.filterDisplay, displayFieldFilter.constraint);
221
230
  }
222
231
  // ak mame props.searchBrowseParams.customFilterFunction, pridame filter
223
- if (props.searchBrowseParams.customFilterFunction) {
224
- customFilterItems = XUtils_1.XUtils.filterAnd(customFilterItems, props.searchBrowseParams.customFilterFunction());
232
+ if (props.searchBrowseParams.customFilter) {
233
+ customFilterItems = XUtils_1.XUtils.filterAnd(customFilterItems, XUtils_1.XUtils.evalFilter(props.searchBrowseParams.customFilter));
225
234
  }
226
235
  }
227
236
  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)
228
237
  var initFtsInputValue = props.fullTextSearch ? createInitFtsInputValue() : undefined;
229
238
  var _g = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValue = _g[0], setFtsInputValue = _g[1];
230
239
  var _h = __read((0, react_1.useState)(true), 2), multiLineSwitchValue = _h[0], setMultiLineSwitchValue = _h[1];
231
- var _j = __read((0, react_1.useState)(props.sortField ? [{ field: props.sortField, order: 1 }] : []), 2), multiSortMeta = _j[0], setMultiSortMeta = _j[1];
240
+ var _j = __read((0, react_1.useState)(XUtils_1.XUtils.createMultiSortMeta(props.sortField)), 2), multiSortMeta = _j[0], setMultiSortMeta = _j[1];
232
241
  var _k = __read((0, react_1.useState)(null), 2), selectedRow = _k[0], setSelectedRow = _k[1];
233
242
  var _l = __read((_a = props.dataLoadedState) !== null && _a !== void 0 ? _a : (0, react_1.useState)(false), 2), dataLoaded = _l[0], setDataLoaded = _l[1]; // priznak kde si zapiseme, ci uz sme nacitali data
234
243
  var _m = __read((0, react_1.useState)(false), 2), exportRowsDialogOpened = _m[0], setExportRowsDialogOpened = _m[1];
@@ -335,6 +344,7 @@ var XLazyDataTable = function (props) {
335
344
  xFullTextSearch = {
336
345
  fields: Array.isArray(props.fullTextSearch) ? props.fullTextSearch : undefined,
337
346
  value: ftsInputValue.value,
347
+ splitValue: true,
338
348
  matchMode: ftsInputValue.matchMode
339
349
  };
340
350
  }
@@ -359,6 +369,9 @@ var XLazyDataTable = function (props) {
359
369
  }
360
370
  finally { if (e_3) throw e_3.error; }
361
371
  }
372
+ if (props.fields) {
373
+ fields.push.apply(fields, __spreadArray([], __read(props.fields), false));
374
+ }
362
375
  return fields;
363
376
  };
364
377
  var getHeaders = function () {
@@ -887,7 +900,7 @@ var XLazyDataTable = function (props) {
887
900
  react_1.default.createElement(XButton_1.XButton, { key: "clearFilter", label: (0, XLocale_1.xLocaleOption)('clearFilter'), onClick: onClickClearFilter }),
888
901
  props.multiLineSwitch ? react_1.default.createElement(inputswitch_1.InputSwitch, { checked: multiLineSwitchValue, onChange: function (e) { return setMultiLineSwitchValue(e.value); }, className: "m-1" }) : null),
889
902
  react_1.default.createElement("div", { className: "flex justify-content-center" },
890
- 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)),
903
+ 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, rowClassName: props.rowClassName, 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)),
891
904
  react_1.default.createElement("div", { className: "flex justify-content-center" },
892
905
  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,
893
906
  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,
@@ -1,5 +1,5 @@
1
1
  import { DataTableFilterMetaData } from "primereact/datatable";
2
- import { XCustomFilter } from "../serverApi/FindParam";
2
+ import { XFilterOrFunction } from "./XAutoCompleteBase";
3
3
  export interface XFieldFilter {
4
4
  field: string;
5
5
  constraint: DataTableFilterMetaData;
@@ -7,5 +7,5 @@ export interface XFieldFilter {
7
7
  export interface XSearchBrowseParams {
8
8
  onChoose: (chosenRow: any) => void;
9
9
  displayFieldFilter?: XFieldFilter;
10
- customFilterFunction?: () => XCustomFilter | undefined;
10
+ customFilter?: XFilterOrFunction;
11
11
  }
@@ -203,8 +203,8 @@ var XSearchButton = /** @class */ (function (_super) {
203
203
  var createSearchBrowseParams = function () {
204
204
  return {
205
205
  onChoose: onChoose,
206
- displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "startsWith" } } : undefined),
207
- customFilterFunction: function () { return _this.getFilterBase(_this.props.filter); }
206
+ displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "contains" } } : undefined),
207
+ customFilter: function () { return _this.getFilterBase(_this.props.filter); }
208
208
  };
209
209
  };
210
210
  // vypocitame inputValue
@@ -184,8 +184,8 @@ var XSearchButtonDT = function (props) {
184
184
  react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, {
185
185
  searchBrowseParams: {
186
186
  onChoose: onChoose,
187
- displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "startsWith" } } : undefined),
188
- customFilterFunction: function () { return undefined; } // TODO - dorobit
187
+ displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "contains" } } : undefined),
188
+ customFilter: undefined // TODO - dorobit
189
189
  }
190
190
  } /*, props.searchBrowse.children*/))));
191
191
  };
@@ -7,6 +7,7 @@ import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
7
7
  import { DataTableSortMeta } from "primereact/datatable";
8
8
  import { XObject } from "./XObject";
9
9
  import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
10
+ import { XFilterOrFunction } from "./XAutoCompleteBase";
10
11
  export declare enum OperationType {
11
12
  None = 0,
12
13
  Insert = 1,
@@ -54,6 +55,7 @@ export declare class XUtils {
54
55
  static getAppForm(entity: string, formId?: string): any;
55
56
  static fetchMany(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any[]>;
56
57
  static fetchRows(entity: string, customFilter?: XCustomFilter | undefined, sortField?: string | DataTableSortMeta[] | undefined, fields?: string[]): Promise<any[]>;
58
+ static fetchRowCount(entity: string, customFilter?: XCustomFilter | undefined): Promise<number>;
57
59
  static fetchOne(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
58
60
  static fetchString(path: string, value: any): Promise<string>;
59
61
  static fetch(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
@@ -108,8 +110,10 @@ export declare class XUtils {
108
110
  static getErrorMessage(xError: XError): string | undefined;
109
111
  static normalizeString(value: string): string;
110
112
  static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
113
+ static createMultiSortMeta(sortField: string | DataTableSortMeta[] | undefined): DataTableSortMeta[] | undefined;
111
114
  static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
112
115
  static filterIdIn(idField: string, idList: number[]): XCustomFilter;
116
+ static evalFilter(filter: XFilterOrFunction | undefined): XCustomFilter | undefined;
113
117
  static isTableRowInserted(tableRow: any): boolean;
114
118
  static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
115
119
  }
@@ -272,20 +272,11 @@ var XUtils = /** @class */ (function () {
272
272
  // pomocna metodka pouzivajuca lazyDataTable service
273
273
  XUtils.fetchRows = function (entity, customFilter, sortField, fields) {
274
274
  return __awaiter(this, void 0, void 0, function () {
275
- var multiSortMeta, findParam, rowList;
275
+ var findParam, rowList;
276
276
  return __generator(this, function (_a) {
277
277
  switch (_a.label) {
278
278
  case 0:
279
- multiSortMeta = undefined;
280
- if (sortField) {
281
- if (Array.isArray(sortField)) {
282
- multiSortMeta = sortField;
283
- }
284
- else {
285
- multiSortMeta = [{ field: sortField, order: 1 }];
286
- }
287
- }
288
- findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: multiSortMeta, fields: fields };
279
+ findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: XUtils.createMultiSortMeta(sortField), fields: fields };
289
280
  return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
290
281
  case 1:
291
282
  rowList = (_a.sent()).rowList;
@@ -294,6 +285,22 @@ var XUtils = /** @class */ (function () {
294
285
  });
295
286
  });
296
287
  };
288
+ // pomocna metodka pouzivajuca lazyDataTable service
289
+ XUtils.fetchRowCount = function (entity, customFilter) {
290
+ return __awaiter(this, void 0, void 0, function () {
291
+ var findParam, totalRecords;
292
+ return __generator(this, function (_a) {
293
+ switch (_a.label) {
294
+ case 0:
295
+ findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter) };
296
+ return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
297
+ case 1:
298
+ totalRecords = (_a.sent()).totalRecords;
299
+ return [2 /*return*/, totalRecords];
300
+ }
301
+ });
302
+ });
303
+ };
297
304
  XUtils.fetchOne = function (path, value, usePublicToken) {
298
305
  return XUtils.fetch(path, value, usePublicToken);
299
306
  };
@@ -701,6 +708,28 @@ var XUtils = /** @class */ (function () {
701
708
  }
702
709
  return customFilterItems;
703
710
  };
711
+ // pomocna metodka - konvertuje sortField -> DataTableSortMeta[]
712
+ XUtils.createMultiSortMeta = function (sortField) {
713
+ var multiSortMeta = undefined;
714
+ if (sortField) {
715
+ if (Array.isArray(sortField)) {
716
+ multiSortMeta = sortField;
717
+ }
718
+ else {
719
+ // default order is asc, supported is also value in form "<column name> desc"
720
+ var order = 1;
721
+ var fieldAndOrder = sortField.split(' ');
722
+ if (fieldAndOrder.length === 2) {
723
+ sortField = fieldAndOrder[0];
724
+ if (fieldAndOrder[1].toLowerCase() === "desc") {
725
+ order = -1;
726
+ }
727
+ }
728
+ multiSortMeta = [{ field: sortField, order: order }];
729
+ }
730
+ }
731
+ return multiSortMeta;
732
+ };
704
733
  // pomocna metodka
705
734
  XUtils.filterAnd = function () {
706
735
  var e_7, _a;
@@ -736,6 +765,17 @@ var XUtils = /** @class */ (function () {
736
765
  return { where: "[".concat(idField, "] IN (:...idList)"), params: { "idList": idList.length > 0 ? idList : [0] } };
737
766
  };
738
767
  // pomocna metodka
768
+ XUtils.evalFilter = function (filter) {
769
+ var customFilter = undefined;
770
+ if (typeof filter === 'object') {
771
+ customFilter = filter;
772
+ }
773
+ if (typeof filter === 'function') {
774
+ customFilter = filter();
775
+ }
776
+ return customFilter;
777
+ };
778
+ // pomocna metodka
739
779
  XUtils.isTableRowInserted = function (tableRow) {
740
780
  var _a;
741
781
  return (_a = tableRow.__x_generatedRowId) !== null && _a !== void 0 ? _a : false; // specialny priznak, ze sme vygenerovali id-cko
@@ -143,7 +143,7 @@ var XUtilsMetadata = /** @class */ (function () {
143
143
  }
144
144
  else {
145
145
  // form datatable (formColumnType is defined)
146
- if (formColumnType === "inputSimple") {
146
+ if (formColumnType === "inputSimple" || formColumnType === "textarea") {
147
147
  var padding = 0.21 + 0.07 + 0.5; // padding is 2.94px + 1px border + 7px padding in input
148
148
  if (xField.type === "string") {
149
149
  width = XUtilsMetadata.computeColumnWidthBase(xField.length, padding + padding); // padding left + right
@@ -1,8 +1,9 @@
1
1
  import { DataTableFilterMeta, DataTableSortMeta } from "primereact/datatable";
2
2
  export declare enum ResultType {
3
3
  OnlyRowCount = 0,
4
- RowCountAndPagedRows = 1,
5
- AllRows = 2
4
+ OnlyPagedRows = 1,
5
+ RowCountAndPagedRows = 2,
6
+ AllRows = 3
6
7
  }
7
8
  export interface XParams {
8
9
  [key: string]: any;
@@ -15,6 +16,7 @@ export type XCustomFilter = XCustomFilterItem | XCustomFilterItem[];
15
16
  export interface XFullTextSearch {
16
17
  fields?: string[];
17
18
  value: string;
19
+ splitValue: boolean;
18
20
  matchMode: 'startsWith' | 'contains' | 'endsWith' | 'equals';
19
21
  }
20
22
  export declare enum XAggregateType {
@@ -39,3 +41,11 @@ export interface FindParam {
39
41
  fields?: string[];
40
42
  aggregateItems?: XAggregateItem[];
41
43
  }
44
+ export interface XLazyAutoCompleteSuggestionsRequest {
45
+ maxRows: number;
46
+ fullTextSearch?: XFullTextSearch;
47
+ entity: string;
48
+ filterItems?: XCustomFilterItem[];
49
+ multiSortMeta?: DataTableSortMeta[];
50
+ fields?: string[];
51
+ }
@@ -18,8 +18,9 @@ exports.XAggregateType = exports.ResultType = void 0;
18
18
  var ResultType;
19
19
  (function (ResultType) {
20
20
  ResultType[ResultType["OnlyRowCount"] = 0] = "OnlyRowCount";
21
- ResultType[ResultType["RowCountAndPagedRows"] = 1] = "RowCountAndPagedRows";
22
- ResultType[ResultType["AllRows"] = 2] = "AllRows";
21
+ ResultType[ResultType["OnlyPagedRows"] = 1] = "OnlyPagedRows";
22
+ ResultType[ResultType["RowCountAndPagedRows"] = 2] = "RowCountAndPagedRows";
23
+ ResultType[ResultType["AllRows"] = 3] = "AllRows";
23
24
  })(ResultType = exports.ResultType || (exports.ResultType = {}));
24
25
  var XAggregateType;
25
26
  (function (XAggregateType) {
@@ -2,14 +2,19 @@ export declare class XUtilsCommon {
2
2
  static newLine: string;
3
3
  static getValueByPath(object: any, path: string): any;
4
4
  static getValueOrValueListByPath(object: any, path: string): any | any[];
5
+ static setValueByPath(object: any, path: string, value: any): void;
5
6
  static getFieldListForPath(path: string): string[];
6
7
  static getFieldAndRestPath(path: string): [string, string | null];
7
8
  static getPathToAssoc(path: string): string;
9
+ static getPathToAssocAndField(path: string): [string | null, string];
8
10
  static isSingleField(path: string): boolean;
11
+ static getPrefixAndField(path: string): [string | null, string];
9
12
  static objectAsJSON(value: any): string;
10
13
  static getDayName(date: Date | null | undefined): string | undefined;
11
14
  static dateAddDays(date: Date | null, days: number): Date | null;
12
15
  static findFirstMatch(pattern: RegExp, value: string): string | null;
13
16
  static sqlMaxDateIfNull(sqlExp: string): string;
17
+ static today(): Date;
18
+ static isInt(stringValue: string): boolean;
14
19
  }
15
20
  export declare const dateFormat: any;
@@ -108,6 +108,20 @@ var XUtilsCommon = /** @class */ (function () {
108
108
  }
109
109
  }
110
110
  };
111
+ XUtilsCommon.setValueByPath = function (object, path, value) {
112
+ var _a = __read(XUtilsCommon.getPathToAssocAndField(path), 2), pathToAssoc = _a[0], field = _a[1];
113
+ if (pathToAssoc !== null) {
114
+ var assocObject = XUtilsCommon.getValueByPath(object, pathToAssoc);
115
+ // if null or undefined or is not object, then error
116
+ if (assocObject === null || assocObject === undefined || typeof assocObject !== 'object') {
117
+ console.log("XUtilsCommon.setValueByPath: could not set value ".concat(value, " into object property ").concat(path, ". Assoc object not found (found value: ").concat(assocObject, "). Main object:"));
118
+ console.log(object);
119
+ throw "setValueByPath: could not set value ".concat(value, " into object property ").concat(path, ". Assoc object not found. The main object can be seen in log.");
120
+ }
121
+ object = assocObject;
122
+ }
123
+ object[field] = value;
124
+ };
111
125
  XUtilsCommon.getFieldListForPath = function (path) {
112
126
  return path.split('.');
113
127
  };
@@ -131,9 +145,29 @@ var XUtilsCommon = /** @class */ (function () {
131
145
  return path.substring(0, posDot);
132
146
  }
133
147
  };
148
+ XUtilsCommon.getPathToAssocAndField = function (path) {
149
+ var posDot = path.lastIndexOf(".");
150
+ if (posDot === -1) {
151
+ return [null, path];
152
+ }
153
+ else {
154
+ return [path.substring(0, posDot), path.substring(posDot + 1)];
155
+ }
156
+ };
134
157
  XUtilsCommon.isSingleField = function (path) {
135
158
  return path.indexOf(".") === -1;
136
159
  };
160
+ XUtilsCommon.getPrefixAndField = function (path) {
161
+ var posDot = path.indexOf(":");
162
+ if (posDot === -1) {
163
+ return [null, path];
164
+ }
165
+ else {
166
+ var prefix = path.substring(0, posDot);
167
+ var pathOnly = path.substring(posDot + 1);
168
+ return [prefix, pathOnly];
169
+ }
170
+ };
137
171
  XUtilsCommon.objectAsJSON = function (value) {
138
172
  // sem treba dat nejaku pre nas vhodnu serializaciu
139
173
  // zatial provizorne robene cez antipatern - modifikaciu prototype funcii primitivnych typov
@@ -176,6 +210,15 @@ var XUtilsCommon = /** @class */ (function () {
176
210
  XUtilsCommon.sqlMaxDateIfNull = function (sqlExp) {
177
211
  return "coalesce(".concat(sqlExp, ", '9999-12-31'::DATE)");
178
212
  };
213
+ XUtilsCommon.today = function () {
214
+ var today = new Date();
215
+ today.setHours(0, 0, 0, 0);
216
+ return today;
217
+ };
218
+ // vrati true ak sa string sklada iba z cislic, moze mat + alebo - na zaciatku
219
+ XUtilsCommon.isInt = function (stringValue) {
220
+ return /^[-+]?\d+$/.test(stringValue);
221
+ };
179
222
  XUtilsCommon.newLine = '\n';
180
223
  return XUtilsCommon;
181
224
  }());
@@ -7,6 +7,7 @@ export declare function intFromUI(stringValue: string): number | null | undefine
7
7
  export declare function numberAsUI(value: number | null, fractionDigits?: number): string;
8
8
  export declare function numberFromModel(value: any): number | null;
9
9
  export declare function dateFromModel(value: any): Date | null;
10
+ export declare function dateFromUI(valueString: string): Date | null | undefined;
10
11
  export declare function dateAsUI(value: Date | null): string;
11
12
  export declare function datetimeAsUI(value: Date | null): string;
12
13
  export declare function timeFromModel(value: any): Date | null;