@michalrakus/x-react-web-lib 1.28.0 → 1.29.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.
@@ -335,8 +335,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
335
335
  maxRows: this.props.lazyLoadMaxRows + 1,
336
336
  fullTextSearch: { fields: this.getFields(), value: event.query.trim(), splitValue: this.props.splitQueryValue, matchMode: "contains" },
337
337
  entity: this.props.suggestionsQuery.entity,
338
- filterItems: XUtils_1.XUtils.createCustomFilterItems(filter),
339
- multiSortMeta: XUtils_1.XUtils.createMultiSortMeta(this.getSortField()),
338
+ filterItems: XUtilsCommon_1.XUtilsCommon.createCustomFilterItems(filter),
339
+ multiSortMeta: XUtilsCommon_1.XUtilsCommon.createMultiSortMeta(this.getSortField()),
340
340
  fields: this.props.suggestionsQuery.fields
341
341
  };
342
342
  return [4 /*yield*/, XUtils_1.XUtils.fetchOne('x-lazy-auto-complete-suggestions', suggestionsRequest)];
@@ -346,7 +346,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
346
346
  // ak sme nesortovali v DB (co je draha operacia) tak zosortujeme teraz
347
347
  // (itemTemplateString sa vola duplicitne ale pre tych cca 20 zaznamov je to ok)
348
348
  if (this.props.suggestionsQuery.sortField === undefined) {
349
- filteredSuggestions = XUtils_1.XUtils.arraySort(filteredSuggestions, this.itemTemplateString);
349
+ filteredSuggestions = XUtilsCommon_1.XUtilsCommon.arraySort(filteredSuggestions, this.itemTemplateString);
350
350
  }
351
351
  // ak mame o 1 zaznam viac ako je lazyLoadMaxRows, zmenime posledny zaznam na ...
352
352
  // TODO - lepsie by bolo posledny zaznam vyhodit a popisok ... zobrazit do footer-a (odpadnu problemy z pripadnou selekciou pseudozaznamu ...)
@@ -727,17 +727,13 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
727
727
  // Dialog pre konkretny form:
728
728
  // <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitValuesForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
729
729
  // formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
730
- return (react_1.default.createElement("div", { className: "x-auto-complete-base", style: { width: this.props.width, maxWidth: this.props.maxWidth } },
731
- react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ key: "autoComplete", value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, itemTemplate: this.itemTemplate, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, minLength: this.props.minLength, scrollHeight: this.props.scrollHeight, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(error), { inputClassName: this.props.inputClassName, showEmptyMessage: true })),
732
- buttons,
733
- this.props.valueForm != undefined ?
734
- react_1.default.createElement(dialog_1.Dialog, { key: "dialogForm", className: "x-dialog-without-header", visible: this.state.formDialogOpened, onHide: this.formDialogOnHide }, react_1.default.cloneElement(this.props.valueForm, {
730
+ return (react_1.default.createElement.apply(react_1.default, __spreadArray(__spreadArray(["div", { className: "x-auto-complete-base", style: { width: this.props.width, maxWidth: this.props.maxWidth } }, react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, itemTemplate: this.itemTemplate, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, minLength: this.props.minLength, scrollHeight: this.props.scrollHeight, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(error), { inputClassName: this.props.inputClassName, showEmptyMessage: true }))], __read(buttons), false), [this.props.valueForm != undefined ?
731
+ react_1.default.createElement(dialog_1.Dialog, { key: "dialog-form", className: "x-dialog-without-header", visible: this.state.formDialogOpened, onHide: this.formDialogOnHide }, react_1.default.cloneElement(this.props.valueForm, {
735
732
  id: this.formDialogObjectId, initValues: this.formDialogInitValuesForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
736
733
  } /*, this.props.valueForm.children*/))
737
- : undefined,
738
- this.props.searchBrowse != undefined && !readOnly ?
739
- react_1.default.createElement(dialog_1.Dialog, { key: "dialogBrowse", className: "x-dialog-without-header", visible: this.state.searchDialogOpened, onHide: this.searchDialogOnHide }, react_1.default.cloneElement(this.props.searchBrowse, { searchBrowseParams: this.createSearchBrowseParams() } /*, props.searchBrowse.children*/))
740
- : undefined));
734
+ : undefined, this.props.searchBrowse != undefined && !readOnly ?
735
+ react_1.default.createElement(dialog_1.Dialog, { key: "dialog-browse", className: "x-dialog-without-header", visible: this.state.searchDialogOpened, onHide: this.searchDialogOnHide }, react_1.default.cloneElement(this.props.searchBrowse, { searchBrowseParams: this.createSearchBrowseParams() } /*, props.searchBrowse.children*/))
736
+ : undefined], false)));
741
737
  };
742
738
  XAutoCompleteBase.valueMoreSuggestions = "...";
743
739
  XAutoCompleteBase.defaultProps = {
@@ -110,6 +110,7 @@ var XUtilsMetadata_1 = require("./XUtilsMetadata");
110
110
  var XUtils_1 = require("./XUtils");
111
111
  var XLazyDataTable_1 = require("./XLazyDataTable/XLazyDataTable");
112
112
  var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
113
+ var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
113
114
  // TODO - pouzit extends XEditBrowseBase, ako je tomu pri CarForm?
114
115
  var XEditBrowse = /** @class */ (function (_super) {
115
116
  __extends(XEditBrowse, _super);
@@ -281,7 +282,7 @@ var XEditBrowse = /** @class */ (function (_super) {
281
282
  var index = this.getIndexForColumn(field);
282
283
  if (index !== undefined) {
283
284
  var xBrowseMeta = this.state.xBrowseMeta;
284
- XUtils_1.XUtils.arrayMoveElement(xBrowseMeta.columnMetaList, index, offset);
285
+ XUtilsCommon_1.XUtilsCommon.arrayMoveElement(xBrowseMeta.columnMetaList, index, offset);
285
286
  // TODO - tu mozno treba setnut funkciu - koli moznej asynchronicite
286
287
  this.setState({ xBrowseMeta: xBrowseMeta });
287
288
  }
@@ -169,7 +169,7 @@ var XFormBase = /** @class */ (function (_super) {
169
169
  assocToSort = _b.value;
170
170
  assocRowList = object[assocToSort.assoc];
171
171
  if (assocRowList) {
172
- object[assocToSort.assoc] = XUtils_1.XUtils.arraySort(assocRowList, assocToSort.sortField);
172
+ object[assocToSort.assoc] = XUtilsCommon_1.XUtilsCommon.arraySort(assocRowList, assocToSort.sortField);
173
173
  }
174
174
  }
175
175
  }
@@ -26,7 +26,7 @@ export interface XFormDataTableProps {
26
26
  rows?: number;
27
27
  filterDisplay: "menu" | "row" | "none";
28
28
  sortable: boolean;
29
- sortField?: string;
29
+ sortField: string;
30
30
  scrollable: boolean;
31
31
  scrollWidth?: string;
32
32
  scrollHeight?: string;
@@ -48,6 +48,7 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
48
48
  static defaultProps: {
49
49
  filterDisplay: string;
50
50
  sortable: boolean;
51
+ sortField: string;
51
52
  scrollable: boolean;
52
53
  scrollWidth: string;
53
54
  scrollHeight: string;
@@ -116,6 +117,7 @@ export interface XFormAutoCompleteColumnProps extends XFormColumnBaseProps {
116
117
  searchBrowse?: JSX.Element;
117
118
  assocForm?: JSX.Element;
118
119
  filter?: XTableFieldFilterProp;
120
+ fields?: string[];
119
121
  suggestions?: any[];
120
122
  }
121
123
  export interface XFormSearchButtonColumnProps extends XFormColumnBaseProps {
@@ -404,7 +404,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
404
404
  }
405
405
  else if (columnProps.type === "autoComplete") {
406
406
  var columnPropsAutoComplete = columnProps;
407
- body = react_1.default.createElement(XAutoCompleteDT_1.XAutoCompleteDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsAutoComplete.assocField, displayField: columnPropsAutoComplete.displayField, searchBrowse: columnPropsAutoComplete.searchBrowse, assocForm: columnPropsAutoComplete.assocForm, filter: columnPropsAutoComplete.filter, suggestions: columnPropsAutoComplete.suggestions, rowData: rowData, readOnly: readOnly });
407
+ body = react_1.default.createElement(XAutoCompleteDT_1.XAutoCompleteDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsAutoComplete.assocField, displayField: columnPropsAutoComplete.displayField, searchBrowse: columnPropsAutoComplete.searchBrowse, assocForm: columnPropsAutoComplete.assocForm, filter: columnPropsAutoComplete.filter, fields: columnPropsAutoComplete.fields, suggestions: columnPropsAutoComplete.suggestions, rowData: rowData, readOnly: readOnly });
408
408
  }
409
409
  else if (columnProps.type === "searchButton") {
410
410
  var columnPropsSearchButton = columnProps;
@@ -527,7 +527,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
527
527
  };
528
528
  XFormDataTable2.prototype.render = function () {
529
529
  var _this = this;
530
- var _a, _b, _c;
530
+ var _a, _b;
531
531
  var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.getEntity());
532
532
  var paginator = this.props.paginator !== undefined ? this.props.paginator : false;
533
533
  var rows = undefined;
@@ -540,8 +540,14 @@ var XFormDataTable2 = /** @class */ (function (_super) {
540
540
  }
541
541
  }
542
542
  var filterDisplay = this.props.filterDisplay !== "none" ? this.props.filterDisplay : undefined;
543
- // default sortovanie - ak mame insert tak nesortujeme (drzime poradie v akom user zaznam vytvoril), ak mame update tak podla id zosortujeme (nech je to zobrazene vzdy rovnako)
544
- var sortField = (_a = this.props.sortField) !== null && _a !== void 0 ? _a : (this.props.form.isAddRow() ? undefined : xEntity.idField);
543
+ var sortField = this.props.sortField;
544
+ if (sortField === "idFieldOnUpdate") {
545
+ // default sortovanie - ak mame insert tak nesortujeme (drzime poradie v akom user zaznam vytvoril), ak mame update tak podla id zosortujeme (nech je to zobrazene vzdy rovnako)
546
+ sortField = (this.props.form.isAddRow() ? undefined : xEntity.idField);
547
+ }
548
+ else if (sortField === "none") {
549
+ sortField = undefined;
550
+ }
545
551
  var label = this.props.label !== undefined ? this.props.label : this.props.assocField;
546
552
  var readOnly = this.isReadOnly();
547
553
  // v bloku function (child) nejde pouzit priamo this, thisLocal uz ide pouzit
@@ -679,8 +685,8 @@ var XFormDataTable2 = /** @class */ (function (_super) {
679
685
  var removeRowLabel = undefined;
680
686
  if (this.props.showAddRemoveButtons) {
681
687
  // calling xLocaleOption does not work in standard default values initialisation place (public static defaultProps)
682
- addRowLabel = (_b = this.props.addRowLabel) !== null && _b !== void 0 ? _b : (0, XLocale_1.xLocaleOption)('addRow');
683
- removeRowLabel = (_c = this.props.removeRowLabel) !== null && _c !== void 0 ? _c : (0, XLocale_1.xLocaleOption)('removeRow');
688
+ addRowLabel = (_a = this.props.addRowLabel) !== null && _a !== void 0 ? _a : (0, XLocale_1.xLocaleOption)('addRow');
689
+ removeRowLabel = (_b = this.props.removeRowLabel) !== null && _b !== void 0 ? _b : (0, XLocale_1.xLocaleOption)('removeRow');
684
690
  }
685
691
  return (react_1.default.createElement("div", null,
686
692
  react_1.default.createElement("div", { className: "flex justify-content-center" },
@@ -696,6 +702,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
696
702
  XFormDataTable2.defaultProps = {
697
703
  filterDisplay: "none",
698
704
  sortable: false,
705
+ sortField: "idFieldOnUpdate",
699
706
  scrollable: true,
700
707
  scrollWidth: '100%',
701
708
  scrollHeight: '200vh',
@@ -3,7 +3,7 @@ import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMe
3
3
  import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereact/column';
4
4
  import { XViewStatusOrBoolean } from "../XUtils";
5
5
  import { XSearchBrowseParams } from "../XSearchBrowseParams";
6
- import { XAggregateType, XCustomFilter } from "../../serverApi/FindParam";
6
+ import { XAggregateFunction, XCustomFilter } from "../../serverApi/FindParam";
7
7
  import { XOnSaveOrCancelProp } from "../XFormBase";
8
8
  import { IconType } from "primereact/utils";
9
9
  import { ButtonProps } from "primereact/button";
@@ -110,7 +110,7 @@ export interface XLazyColumnProps {
110
110
  betweenFilter?: XBetweenFilterProp | "noBetween";
111
111
  width?: string;
112
112
  contentType?: XContentType;
113
- aggregateType?: XAggregateType;
113
+ aggregateType?: XAggregateFunction;
114
114
  columnViewStatus: XViewStatusOrBoolean;
115
115
  filterElement?: XFilterElementProp;
116
116
  body?: React.ReactNode | ((data: any, options: ColumnBodyOptions) => React.ReactNode);
@@ -144,7 +144,7 @@ var XLazyDataTable = function (props) {
144
144
  var column = columns_1_1.value;
145
145
  var xLazyColumn = column; // nevedel som to krajsie...
146
146
  if (xLazyColumn.props.aggregateType) {
147
- aggregateItems.push({ field: xLazyColumn.props.field, aggregateType: xLazyColumn.props.aggregateType });
147
+ aggregateItems.push({ field: xLazyColumn.props.field, aggregateFunction: xLazyColumn.props.aggregateType });
148
148
  }
149
149
  }
150
150
  }
@@ -217,7 +217,7 @@ var XLazyDataTable = function (props) {
217
217
  };
218
218
  // premenne platne pre cely component (obdoba member premennych v class-e)
219
219
  var dataTableEl = (0, react_1.useRef)(null);
220
- var customFilterItems = XUtils_1.XUtils.createCustomFilterItems(props.customFilter);
220
+ var customFilterItems = XUtilsCommon_1.XUtilsCommon.createCustomFilterItems(props.customFilter);
221
221
  var aggregateItems = createAggregateItems();
222
222
  var _b = __read((0, react_1.useState)({ rowList: [], totalRecords: 0, aggregateValues: [] }), 2), value = _b[0], setValue = _b[1];
223
223
  var _c = __read((0, react_1.useState)(false), 2), loading = _c[0], setLoading = _c[1];
@@ -234,7 +234,7 @@ var XLazyDataTable = function (props) {
234
234
  }
235
235
  // ak mame props.searchBrowseParams.customFilterFunction, pridame filter
236
236
  if (props.searchBrowseParams.customFilter) {
237
- customFilterItems = XUtils_1.XUtils.filterAnd(customFilterItems, XUtils_1.XUtils.evalFilter(props.searchBrowseParams.customFilter));
237
+ customFilterItems = XUtilsCommon_1.XUtilsCommon.filterAnd(customFilterItems, XUtils_1.XUtils.evalFilter(props.searchBrowseParams.customFilter));
238
238
  }
239
239
  }
240
240
  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)
@@ -242,7 +242,7 @@ var XLazyDataTable = function (props) {
242
242
  var _g = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValue = _g[0], setFtsInputValue = _g[1];
243
243
  var _h = __read((0, react_1.useState)(undefined), 2), optionalCustomFilter = _h[0], setOptionalCustomFilter = _h[1];
244
244
  var _j = __read((0, react_1.useState)(props.multilineSwitchInitValue), 2), multilineSwitchValue = _j[0], setMultilineSwitchValue = _j[1];
245
- var _k = __read((0, react_1.useState)(XUtils_1.XUtils.createMultiSortMeta(props.sortField)), 2), multiSortMeta = _k[0], setMultiSortMeta = _k[1];
245
+ var _k = __read((0, react_1.useState)(XUtilsCommon_1.XUtilsCommon.createMultiSortMeta(props.sortField)), 2), multiSortMeta = _k[0], setMultiSortMeta = _k[1];
246
246
  var _l = __read((0, react_1.useState)(null), 2), selectedRow = _l[0], setSelectedRow = _l[1];
247
247
  var _m = __read((_a = props.dataLoadedState) !== null && _a !== void 0 ? _a : (0, react_1.useState)(false), 2), dataLoaded = _m[0], setDataLoaded = _m[1]; // priznak kde si zapiseme, ci uz sme nacitali data
248
248
  var _o = __read((0, react_1.useState)({ dialogOpened: false }), 2), exportRowsDialogState = _o[0], setExportRowsDialogState = _o[1];
@@ -380,7 +380,7 @@ var XLazyDataTable = function (props) {
380
380
  return xFullTextSearch;
381
381
  };
382
382
  var createXCustomFilterItems = function (customFilterItems, optionalCustomFilter) {
383
- return XUtils_1.XUtils.filterAnd(customFilterItems, optionalCustomFilter === null || optionalCustomFilter === void 0 ? void 0 : optionalCustomFilter.filter);
383
+ return XUtilsCommon_1.XUtilsCommon.filterAnd(customFilterItems, optionalCustomFilter === null || optionalCustomFilter === void 0 ? void 0 : optionalCustomFilter.filter);
384
384
  };
385
385
  var getFields = function (addPropsFields) {
386
386
  // krasne zobrazi cely objekt!
@@ -73,6 +73,7 @@ var XUtils_1 = require("./XUtils");
73
73
  var dialog_1 = require("primereact/dialog");
74
74
  var XFormComponent_1 = require("./XFormComponent");
75
75
  var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
76
+ var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
76
77
  var XSearchButton = /** @class */ (function (_super) {
77
78
  __extends(XSearchButton, _super);
78
79
  function XSearchButton(props) {
@@ -138,7 +139,7 @@ var XSearchButton = /** @class */ (function (_super) {
138
139
  case 1:
139
140
  displayFieldFilter = { where: "[".concat(props.displayField, "] LIKE :xDisplayFieldValue"), params: { "xDisplayFieldValue": "".concat(e.target.value, "%") } };
140
141
  customFilter = this.getFilterBase(this.props.filter);
141
- return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, XUtils_1.XUtils.filterAnd(displayFieldFilter, customFilter))];
142
+ return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, XUtilsCommon_1.XUtilsCommon.filterAnd(displayFieldFilter, customFilter))];
142
143
  case 2:
143
144
  rows = _a.sent();
144
145
  if (rows.length === 0) {
@@ -3,7 +3,7 @@ import { CsvDecimalFormat, CsvEncoding, CsvSeparator, ExportType, XMultilineExpo
3
3
  import React from "react";
4
4
  import { XEnvVar } from "./XEnvVars";
5
5
  import { XError, XErrorMap } from "./XErrors";
6
- import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
6
+ import { XCustomFilter } from "../serverApi/FindParam";
7
7
  import { DataTableSortMeta } from "primereact/datatable";
8
8
  import { XObject } from "./XObject";
9
9
  import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
@@ -86,26 +86,6 @@ export declare class XUtils {
86
86
  */
87
87
  static getEnvVarValue(envVarEnum: XEnvVar): string;
88
88
  static removeRow(entity: string, row: any): Promise<void>;
89
- static arrayMoveElement(array: any[], position: number, offset: number): void;
90
- static arraySort(array: any[], fieldOrStringFunction: string | ((item: any) => string)): any[];
91
- /**
92
- * returns true, if param item is member of the array
93
- * remark: null/undefined items in array are ignored, item = null/undefined is ignored
94
- *
95
- * @param array
96
- * @param item
97
- * @param idField
98
- */
99
- static arrayIncludes<T>(array: T[], item: T, idField: string): boolean;
100
- /**
101
- * returns intersection of 2 row lists
102
- * remark: null/undefined items in both array1 and array2 are ignored
103
- *
104
- * @param array1
105
- * @param array2
106
- * @param idField
107
- */
108
- static arrayIntersect<T>(array1: T[], array2: T[], idField: string): T[];
109
89
  static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
110
90
  static isReadOnlyTableField(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined, object: XObject | null, tableRow: any): boolean;
111
91
  static markNotNull(label: string): string;
@@ -119,10 +99,6 @@ export declare class XUtils {
119
99
  static getErrorMessages(xErrorMap: XErrorMap): string;
120
100
  static getErrorMessage(xError: XError): string | undefined;
121
101
  static normalizeString(value: string): string;
122
- static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
123
- static createMultiSortMeta(sortField: string | DataTableSortMeta[] | undefined): DataTableSortMeta[] | undefined;
124
- static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
125
- static filterIdIn(idField: string, idList: number[]): XCustomFilter;
126
102
  static evalFilter(filter: XFilterOrFunction | undefined): XCustomFilter | undefined;
127
103
  static isTableRowInserted(tableRow: any): boolean;
128
104
  static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
@@ -73,15 +73,6 @@ 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
- };
85
76
  Object.defineProperty(exports, "__esModule", { value: true });
86
77
  exports.XUtils = exports.XViewStatus = exports.OperationType = void 0;
87
78
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
@@ -276,7 +267,7 @@ var XUtils = /** @class */ (function () {
276
267
  return __generator(this, function (_a) {
277
268
  switch (_a.label) {
278
269
  case 0:
279
- findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: XUtils.createMultiSortMeta(sortField), fields: fields };
270
+ findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtilsCommon_1.XUtilsCommon.createCustomFilterItems(customFilter), multiSortMeta: XUtilsCommon_1.XUtilsCommon.createMultiSortMeta(sortField), fields: fields };
280
271
  return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
281
272
  case 1:
282
273
  rowList = (_a.sent()).rowList;
@@ -292,7 +283,7 @@ var XUtils = /** @class */ (function () {
292
283
  return __generator(this, function (_a) {
293
284
  switch (_a.label) {
294
285
  case 0:
295
- findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter) };
286
+ findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, entity: entity, customFilterItems: XUtilsCommon_1.XUtilsCommon.createCustomFilterItems(customFilter) };
296
287
  return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
297
288
  case 1:
298
289
  totalRecords = (_a.sent()).totalRecords;
@@ -526,85 +517,6 @@ var XUtils = /** @class */ (function () {
526
517
  });
527
518
  });
528
519
  };
529
- // TODO - prehodit do XUtilsCommon
530
- XUtils.arrayMoveElement = function (array, position, offset) {
531
- var element = array[position];
532
- array.splice(position, 1);
533
- var positionNew = position + offset;
534
- if (positionNew > array.length) {
535
- positionNew = positionNew - array.length - 1; // element goes to the begin
536
- }
537
- else if (positionNew < 0) {
538
- positionNew = array.length + positionNew + 1; // element goes to the end
539
- }
540
- if (positionNew >= 0 && positionNew <= array.length) {
541
- array.splice(positionNew, 0, element);
542
- }
543
- };
544
- // TODO - prehodit do XUtilsCommon
545
- XUtils.arraySort = function (array, fieldOrStringFunction) {
546
- var stringFunction;
547
- if (typeof fieldOrStringFunction === 'string') {
548
- stringFunction = function (item) { return item[fieldOrStringFunction]; };
549
- }
550
- else {
551
- stringFunction = fieldOrStringFunction;
552
- }
553
- return array.sort(function (suggestion1, suggestion2) {
554
- var value1 = stringFunction(suggestion1);
555
- var value2 = stringFunction(suggestion2);
556
- if (value1 > value2) {
557
- return 1;
558
- }
559
- else if (value1 < value2) {
560
- return -1;
561
- }
562
- else {
563
- return 0;
564
- }
565
- });
566
- };
567
- // TODO - prehodit do XUtilsCommon
568
- /**
569
- * returns true, if param item is member of the array
570
- * remark: null/undefined items in array are ignored, item = null/undefined is ignored
571
- *
572
- * @param array
573
- * @param item
574
- * @param idField
575
- */
576
- XUtils.arrayIncludes = function (array, item, idField) {
577
- return item && array.some(function (arrayItem) { return arrayItem && arrayItem[idField] === item[idField]; });
578
- };
579
- // TODO - prehodit do XUtilsCommon
580
- /**
581
- * returns intersection of 2 row lists
582
- * remark: null/undefined items in both array1 and array2 are ignored
583
- *
584
- * @param array1
585
- * @param array2
586
- * @param idField
587
- */
588
- XUtils.arrayIntersect = function (array1, array2, idField) {
589
- var e_6, _a;
590
- var array2IdSet = new Set();
591
- try {
592
- for (var array2_1 = __values(array2), array2_1_1 = array2_1.next(); !array2_1_1.done; array2_1_1 = array2_1.next()) {
593
- var item = array2_1_1.value;
594
- if (item) {
595
- array2IdSet.add(item[idField]);
596
- }
597
- }
598
- }
599
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
600
- finally {
601
- try {
602
- if (array2_1_1 && !array2_1_1.done && (_a = array2_1.return)) _a.call(array2_1);
603
- }
604
- finally { if (e_6) throw e_6.error; }
605
- }
606
- return array1.filter(function (item) { return item && array2IdSet.has(item[idField]); });
607
- };
608
520
  // helper
609
521
  XUtils.isReadOnly = function (path, readOnlyInit) {
610
522
  // ak mame path dlzky 2 a viac, field je vzdy readOnly
@@ -696,7 +608,7 @@ var XUtils = /** @class */ (function () {
696
608
  // pomocna metodka
697
609
  // ak nie su v xErrorMap ziadne chyby, vrati ""
698
610
  XUtils.getErrorMessages = function (xErrorMap) {
699
- var e_7, _a;
611
+ var e_6, _a;
700
612
  var _b;
701
613
  var msg = "";
702
614
  try {
@@ -710,12 +622,12 @@ var XUtils = /** @class */ (function () {
710
622
  }
711
623
  }
712
624
  }
713
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
625
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
714
626
  finally {
715
627
  try {
716
628
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
717
629
  }
718
- finally { if (e_7) throw e_7.error; }
630
+ finally { if (e_6) throw e_6.error; }
719
631
  }
720
632
  return msg;
721
633
  };
@@ -749,75 +661,6 @@ var XUtils = /** @class */ (function () {
749
661
  }
750
662
  return value;
751
663
  };
752
- // pomocna metodka - konvertuje XCustomFilter -> XCustomFilterItem[]
753
- XUtils.createCustomFilterItems = function (customFilter) {
754
- var customFilterItems = undefined;
755
- if (customFilter) {
756
- if (Array.isArray(customFilter)) {
757
- customFilterItems = customFilter;
758
- }
759
- else {
760
- customFilterItems = [customFilter];
761
- }
762
- }
763
- return customFilterItems;
764
- };
765
- // pomocna metodka - konvertuje sortField -> DataTableSortMeta[]
766
- XUtils.createMultiSortMeta = function (sortField) {
767
- var multiSortMeta = undefined;
768
- if (sortField) {
769
- if (Array.isArray(sortField)) {
770
- multiSortMeta = sortField;
771
- }
772
- else {
773
- // default order is asc, supported is also value in form "<column name> desc"
774
- var order = 1;
775
- var fieldAndOrder = sortField.split(' ');
776
- if (fieldAndOrder.length === 2) {
777
- sortField = fieldAndOrder[0];
778
- if (fieldAndOrder[1].toLowerCase() === "desc") {
779
- order = -1;
780
- }
781
- }
782
- multiSortMeta = [{ field: sortField, order: order }];
783
- }
784
- }
785
- return multiSortMeta;
786
- };
787
- // pomocna metodka
788
- XUtils.filterAnd = function () {
789
- var e_8, _a;
790
- var filters = [];
791
- for (var _i = 0; _i < arguments.length; _i++) {
792
- filters[_i] = arguments[_i];
793
- }
794
- var customFilterItemsResult = undefined;
795
- if (filters.length > 0) {
796
- customFilterItemsResult = [];
797
- try {
798
- for (var filters_1 = __values(filters), filters_1_1 = filters_1.next(); !filters_1_1.done; filters_1_1 = filters_1.next()) {
799
- var filter = filters_1_1.value;
800
- var customFilterItems = XUtils.createCustomFilterItems(filter);
801
- if (customFilterItems) {
802
- customFilterItemsResult.push.apply(customFilterItemsResult, __spreadArray([], __read(customFilterItems), false));
803
- }
804
- }
805
- }
806
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
807
- finally {
808
- try {
809
- if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
810
- }
811
- finally { if (e_8) throw e_8.error; }
812
- }
813
- }
814
- return customFilterItemsResult;
815
- };
816
- // pomocna metodka
817
- // ak je idList prazdny, vytvori podmienku id IN (0) a nevrati ziadne zaznamy
818
- XUtils.filterIdIn = function (idField, idList) {
819
- return { where: "[".concat(idField, "] IN (:...idList)"), params: { "idList": idList.length > 0 ? idList : [0] } };
820
- };
821
664
  // pomocna metodka
822
665
  XUtils.evalFilter = function (filter) {
823
666
  var customFilter = undefined;
@@ -12,6 +12,7 @@
12
12
  "removeRowConfirm": "Are you sure to remove the selected row?",
13
13
  "removeRowFailed": "Remove row failed.",
14
14
  "newRow": "new row",
15
+ "ok": "Ok",
15
16
  "save": "Save",
16
17
  "cancel": "Cancel",
17
18
  "expRowCount": "Row count",
@@ -27,8 +28,12 @@
27
28
  "fieldSetSaveEditConfirm": "Are you sure to save the form?",
28
29
  "fieldSetCancelEditConfirm": "Are you sure to cancel editing? All changes will be lost.",
29
30
  "fieldSetRemoveFieldConfirm": "Are you sure to remove the field?",
31
+ "runStatisticMissingDateField": "Warning:\nThe following statistic fields have date field not filled in:\n\"{fieldsWithoutDate}\".\nNo condition for date will be applied for these statistic fields.",
30
32
  "upload": "Upload",
31
33
  "yes": "yes",
32
- "no": "no"
34
+ "no": "no",
35
+ "dateFrom": "Date from",
36
+ "dateTo": "Date to",
37
+ "year": "Year"
33
38
  }
34
39
  }
@@ -19,15 +19,15 @@ export interface XFullTextSearch {
19
19
  splitValue: boolean;
20
20
  matchMode: 'startsWith' | 'contains' | 'endsWith' | 'equals';
21
21
  }
22
- export declare enum XAggregateType {
22
+ export declare enum XAggregateFunction {
23
23
  Min = "MIN",
24
24
  Max = "MAX",
25
25
  Sum = "SUM",
26
26
  Avg = "AVG"
27
27
  }
28
- export interface XAggregateItem {
28
+ export interface XSimpleAggregateItem {
29
29
  field: string;
30
- aggregateType: XAggregateType;
30
+ aggregateFunction: XAggregateFunction;
31
31
  }
32
32
  export interface FindParam {
33
33
  resultType: ResultType;
@@ -39,7 +39,7 @@ export interface FindParam {
39
39
  multiSortMeta?: DataTableSortMeta[];
40
40
  entity: string;
41
41
  fields?: string[];
42
- aggregateItems?: XAggregateItem[];
42
+ aggregateItems?: XSimpleAggregateItem[];
43
43
  }
44
44
  export interface XLazyAutoCompleteSuggestionsRequest {
45
45
  maxRows: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XAggregateType = exports.ResultType = void 0;
3
+ exports.XAggregateFunction = exports.ResultType = void 0;
4
4
  // TODO - replaced with DataTableFilterMetaData
5
5
  // export interface FilterValue {
6
6
  // value : string;
@@ -22,10 +22,10 @@ var ResultType;
22
22
  ResultType[ResultType["RowCountAndPagedRows"] = 2] = "RowCountAndPagedRows";
23
23
  ResultType[ResultType["AllRows"] = 3] = "AllRows";
24
24
  })(ResultType = exports.ResultType || (exports.ResultType = {}));
25
- var XAggregateType;
26
- (function (XAggregateType) {
27
- XAggregateType["Min"] = "MIN";
28
- XAggregateType["Max"] = "MAX";
29
- XAggregateType["Sum"] = "SUM";
30
- XAggregateType["Avg"] = "AVG";
31
- })(XAggregateType = exports.XAggregateType || (exports.XAggregateType = {}));
25
+ var XAggregateFunction;
26
+ (function (XAggregateFunction) {
27
+ XAggregateFunction["Min"] = "MIN";
28
+ XAggregateFunction["Max"] = "MAX";
29
+ XAggregateFunction["Sum"] = "SUM";
30
+ XAggregateFunction["Avg"] = "AVG";
31
+ })(XAggregateFunction = exports.XAggregateFunction || (exports.XAggregateFunction = {}));
@@ -1,4 +1,6 @@
1
1
  import { XEntity, XField } from "./XEntityMetadata";
2
+ import { XCustomFilter, XCustomFilterItem } from "./FindParam";
3
+ import { DataTableSortMeta } from "primereact/datatable";
2
4
  export declare class XUtilsCommon {
3
5
  static newLine: string;
4
6
  static getValueByPath(object: any, path: string): any;
@@ -15,6 +17,33 @@ export declare class XUtilsCommon {
15
17
  static displayValueAsUI(prefix: string | null, value: any, xField: XField | undefined): string;
16
18
  static objectAsJSON(value: any): string;
17
19
  static arrayCreateMap<ID, T>(array: T[], idField: string): Map<ID, T>;
20
+ static arrayMoveElement(array: any[], position: number, offset: number): void;
21
+ static arraySort(array: any[], fieldOrValueFunction: string | ((item: any) => any)): any[];
22
+ /**
23
+ * returns true, if param item is member of the array
24
+ * remark: null/undefined items in array are ignored, item = null/undefined is ignored
25
+ *
26
+ * @param array
27
+ * @param item
28
+ * @param idField
29
+ */
30
+ static arrayIncludes<T>(array: T[], item: T, idField: string): boolean;
31
+ /**
32
+ * returns intersection of 2 row lists
33
+ * remark: null/undefined items in both array1 and array2 are ignored
34
+ *
35
+ * @param array1
36
+ * @param array2
37
+ * @param idField
38
+ */
39
+ static arrayIntersect<T>(array1: T[], array2: T[], idField: string): T[];
40
+ static createCustomFilter(filter: string | undefined | null): XCustomFilterItem | undefined;
41
+ static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
42
+ static createMultiSortMeta(sortField: string | DataTableSortMeta[] | undefined): DataTableSortMeta[] | undefined;
43
+ static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
44
+ static filterIdIn(idField: string, idList: number[]): XCustomFilter;
45
+ static createPathFieldExp(pathFieldOrPathFieldExp: string): string;
46
+ static isPathField(pathFieldOrPathFieldExp: string): boolean;
18
47
  static getDayName(date: Date | null | undefined): string | undefined;
19
48
  static dateAddDays(date: Date | null, days: number): Date | null;
20
49
  static dateAddMonths(date: Date | null, months: number): Date | null;
@@ -292,6 +292,171 @@ var XUtilsCommon = /** @class */ (function () {
292
292
  }
293
293
  return idRowMap;
294
294
  };
295
+ XUtilsCommon.arrayMoveElement = function (array, position, offset) {
296
+ var element = array[position];
297
+ array.splice(position, 1);
298
+ var positionNew = position + offset;
299
+ if (positionNew > array.length) {
300
+ positionNew = positionNew - array.length - 1; // element goes to the begin
301
+ }
302
+ else if (positionNew < 0) {
303
+ positionNew = array.length + positionNew + 1; // element goes to the end
304
+ }
305
+ if (positionNew >= 0 && positionNew <= array.length) {
306
+ array.splice(positionNew, 0, element);
307
+ }
308
+ };
309
+ XUtilsCommon.arraySort = function (array, fieldOrValueFunction) {
310
+ var valueFunction;
311
+ if (typeof fieldOrValueFunction === 'string') {
312
+ valueFunction = function (item) { return item[fieldOrValueFunction]; };
313
+ }
314
+ else {
315
+ valueFunction = fieldOrValueFunction;
316
+ }
317
+ return array.sort(function (suggestion1, suggestion2) {
318
+ var value1 = valueFunction(suggestion1);
319
+ var value2 = valueFunction(suggestion2);
320
+ if (value1 > value2) {
321
+ return 1;
322
+ }
323
+ else if (value1 < value2) {
324
+ return -1;
325
+ }
326
+ else {
327
+ return 0;
328
+ }
329
+ });
330
+ };
331
+ /**
332
+ * returns true, if param item is member of the array
333
+ * remark: null/undefined items in array are ignored, item = null/undefined is ignored
334
+ *
335
+ * @param array
336
+ * @param item
337
+ * @param idField
338
+ */
339
+ XUtilsCommon.arrayIncludes = function (array, item, idField) {
340
+ return item && array.some(function (arrayItem) { return arrayItem && arrayItem[idField] === item[idField]; });
341
+ };
342
+ /**
343
+ * returns intersection of 2 row lists
344
+ * remark: null/undefined items in both array1 and array2 are ignored
345
+ *
346
+ * @param array1
347
+ * @param array2
348
+ * @param idField
349
+ */
350
+ XUtilsCommon.arrayIntersect = function (array1, array2, idField) {
351
+ var e_5, _a;
352
+ var array2IdSet = new Set();
353
+ try {
354
+ for (var array2_1 = __values(array2), array2_1_1 = array2_1.next(); !array2_1_1.done; array2_1_1 = array2_1.next()) {
355
+ var item = array2_1_1.value;
356
+ if (item) {
357
+ array2IdSet.add(item[idField]);
358
+ }
359
+ }
360
+ }
361
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
362
+ finally {
363
+ try {
364
+ if (array2_1_1 && !array2_1_1.done && (_a = array2_1.return)) _a.call(array2_1);
365
+ }
366
+ finally { if (e_5) throw e_5.error; }
367
+ }
368
+ return array1.filter(function (item) { return item && array2IdSet.has(item[idField]); });
369
+ };
370
+ // ************* XCustomFilter/XCustomFilterItem/DataTableSortMeta **************
371
+ // pomocna metodka - aby sme nemuseli v kode vypisovat {where: <filter>, params: {}}
372
+ XUtilsCommon.createCustomFilter = function (filter) {
373
+ var customFilterItem = undefined;
374
+ if (filter) {
375
+ customFilterItem = { where: filter, params: {} };
376
+ }
377
+ return customFilterItem;
378
+ };
379
+ // pomocna metodka - konvertuje XCustomFilter -> XCustomFilterItem[]
380
+ XUtilsCommon.createCustomFilterItems = function (customFilter) {
381
+ var customFilterItems = undefined;
382
+ if (customFilter) {
383
+ if (Array.isArray(customFilter)) {
384
+ customFilterItems = customFilter;
385
+ }
386
+ else {
387
+ customFilterItems = [customFilter];
388
+ }
389
+ }
390
+ return customFilterItems;
391
+ };
392
+ // pomocna metodka - konvertuje sortField -> DataTableSortMeta[]
393
+ XUtilsCommon.createMultiSortMeta = function (sortField) {
394
+ var multiSortMeta = undefined;
395
+ if (sortField) {
396
+ if (Array.isArray(sortField)) {
397
+ multiSortMeta = sortField;
398
+ }
399
+ else {
400
+ // default order is asc, supported is also value in form "<column name> desc"
401
+ var order = 1;
402
+ var fieldAndOrder = sortField.split(' ');
403
+ if (fieldAndOrder.length === 2) {
404
+ sortField = fieldAndOrder[0];
405
+ if (fieldAndOrder[1].toLowerCase() === "desc") {
406
+ order = -1;
407
+ }
408
+ }
409
+ multiSortMeta = [{ field: sortField, order: order }];
410
+ }
411
+ }
412
+ return multiSortMeta;
413
+ };
414
+ // pomocna metodka
415
+ XUtilsCommon.filterAnd = function () {
416
+ var e_6, _a;
417
+ var filters = [];
418
+ for (var _i = 0; _i < arguments.length; _i++) {
419
+ filters[_i] = arguments[_i];
420
+ }
421
+ var customFilterItemsResult = undefined;
422
+ if (filters.length > 0) {
423
+ customFilterItemsResult = [];
424
+ try {
425
+ for (var filters_1 = __values(filters), filters_1_1 = filters_1.next(); !filters_1_1.done; filters_1_1 = filters_1.next()) {
426
+ var filter = filters_1_1.value;
427
+ var customFilterItems = XUtilsCommon.createCustomFilterItems(filter);
428
+ if (customFilterItems) {
429
+ customFilterItemsResult.push.apply(customFilterItemsResult, __spreadArray([], __read(customFilterItems), false));
430
+ }
431
+ }
432
+ }
433
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
434
+ finally {
435
+ try {
436
+ if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
437
+ }
438
+ finally { if (e_6) throw e_6.error; }
439
+ }
440
+ }
441
+ return customFilterItemsResult;
442
+ };
443
+ // pomocna metodka
444
+ // ak je idList prazdny, vytvori podmienku id IN (0) a nevrati ziadne zaznamy
445
+ XUtilsCommon.filterIdIn = function (idField, idList) {
446
+ return { where: "[".concat(idField, "] IN (:...idList)"), params: { "idList": idList.length > 0 ? idList : [0] } };
447
+ };
448
+ // helper
449
+ XUtilsCommon.createPathFieldExp = function (pathFieldOrPathFieldExp) {
450
+ // if fieldOrPathFieldExp is only pathField (e.g. attrX or assocA.attrB) then make path field expression (enclose field into [])
451
+ if (XUtilsCommon.isPathField(pathFieldOrPathFieldExp)) {
452
+ pathFieldOrPathFieldExp = "[".concat(pathFieldOrPathFieldExp, "]");
453
+ }
454
+ return pathFieldOrPathFieldExp;
455
+ };
456
+ // helper
457
+ XUtilsCommon.isPathField = function (pathFieldOrPathFieldExp) {
458
+ return /^[a-zA-Z0-9_.]+$/.test(pathFieldOrPathFieldExp);
459
+ };
295
460
  XUtilsCommon.getDayName = function (date) {
296
461
  var days = ['nedeľa', 'pondelok', 'utorok', 'streda', 'štvrtok', 'piatok', 'sobota'];
297
462
  return date ? days[date.getDay()] : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rimraf lib",