@michalrakus/x-react-web-lib 1.10.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/XEditBrowse.d.ts +3 -0
  2. package/XEditBrowse.js +5 -0
  3. package/XObject.d.ts +3 -0
  4. package/XObject.js +5 -0
  5. package/gulpfile.js +2 -1
  6. package/lib/administration/XBrowseMetaBrowse.d.ts +2 -1
  7. package/lib/administration/XUserBrowse.d.ts +2 -1
  8. package/lib/administration/XUserBrowse.js +1 -1
  9. package/lib/administration/XUserForm.d.ts +6 -3
  10. package/lib/administration/XUserForm.js +9 -16
  11. package/lib/components/XAutoComplete.d.ts +6 -4
  12. package/lib/components/XAutoComplete.js +13 -22
  13. package/lib/components/XAutoCompleteBase.d.ts +15 -5
  14. package/lib/components/XAutoCompleteBase.js +115 -96
  15. package/lib/components/XAutoCompleteDT.d.ts +4 -3
  16. package/lib/components/XAutoCompleteDT.js +8 -7
  17. package/lib/components/XCheckboxDT.d.ts +2 -1
  18. package/lib/components/XCheckboxDT.js +2 -9
  19. package/lib/components/XDropdownDT.d.ts +2 -2
  20. package/lib/components/XDropdownDT.js +2 -3
  21. package/lib/components/{XBrowse.d.ts → XEditBrowse.d.ts} +3 -3
  22. package/lib/components/{XBrowse.js → XEditBrowse.js} +22 -22
  23. package/lib/components/XFormBase.d.ts +10 -9
  24. package/lib/components/XFormBase.js +20 -12
  25. package/lib/components/XFormComponent.d.ts +3 -3
  26. package/lib/components/XFormComponentDT.d.ts +4 -4
  27. package/lib/components/XFormComponentDT.js +10 -11
  28. package/lib/components/XFormDataTable2.d.ts +10 -8
  29. package/lib/components/XFormDataTable2.js +36 -28
  30. package/lib/components/XFormNavigator3.d.ts +3 -3
  31. package/lib/components/XFormNavigator3.js +2 -2
  32. package/lib/components/XInputDateDT.d.ts +2 -1
  33. package/lib/components/XInputDateDT.js +2 -9
  34. package/lib/components/XInputTextDT.d.ts +2 -1
  35. package/lib/components/XInputTextDT.js +2 -9
  36. package/lib/components/XLazyDataTable.d.ts +9 -2
  37. package/lib/components/XLazyDataTable.js +17 -15
  38. package/lib/components/{SearchTableParams.d.ts → XSearchBrowseParams.d.ts} +2 -2
  39. package/lib/components/XSearchButton.d.ts +2 -2
  40. package/lib/components/XSearchButton.js +7 -11
  41. package/lib/components/XSearchButtonDT.d.ts +4 -3
  42. package/lib/components/XSearchButtonDT.js +10 -6
  43. package/lib/components/XUtils.d.ts +24 -1
  44. package/lib/components/XUtils.js +92 -8
  45. package/lib/components/locale/x-en.json +4 -1
  46. package/package.json +1 -1
  47. package/XBrowse.d.ts +0 -3
  48. package/XBrowse.js +0 -5
  49. /package/lib/components/{SearchTableParams.js → XSearchBrowseParams.js} +0 -0
@@ -110,11 +110,11 @@ var XFormNavigator3 = /** @class */ (function (_super) {
110
110
  };
111
111
  XFormNavigator3.prototype.render = function () {
112
112
  var _this = this;
113
- var formElements = this.props.rootFormElement !== null ? __spreadArray([this.props.rootFormElement], __read(this.state.formElements), false) : this.state.formElements;
113
+ var formElements = this.props.rootFormElement ? __spreadArray([this.props.rootFormElement], __read(this.state.formElements), false) : this.state.formElements;
114
114
  var forms = formElements.map(function (formElement, index) {
115
115
  var displayed = (index === formElements.length - 1);
116
116
  // klonovanim elementu pridame atribut openForm={this.openForm} (nemusime tento atribut pridavat pri vytvarani elementu)
117
- var formElementCloned = react_1.default.cloneElement(formElement, { openForm: _this.openForm, displayed: displayed }, formElement.children);
117
+ var formElementCloned = react_1.default.cloneElement(formElement, { openForm: _this.openForm, displayed: displayed } /*, (formElement as any).children*/);
118
118
  // prvych n - 1 komponentov skryjeme cez display: "none" a az posledny vyrenderujeme naozaj (cez display: "block")
119
119
  // TODO - do buducnosti - ak nechceme drzat stav componentu cez display: "none", staci vratit null (komponent vobec nevyrenderujeme)
120
120
  var display = (displayed ? "block" : "none");
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { XFormBase } from "./XFormBase";
3
3
  import { XField } from "../serverApi/XEntityMetadata";
4
+ import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
4
5
  export declare const XInputDateDT: (props: {
5
6
  form: XFormBase;
6
7
  xField: XField;
7
8
  field: string;
8
9
  rowData: any;
9
- readOnly?: boolean | undefined;
10
+ readOnly?: XTableFieldReadOnlyProp | undefined;
10
11
  }) => JSX.Element;
@@ -8,18 +8,10 @@ var XUtilsConversions_1 = require("./XUtilsConversions");
8
8
  var calendar_1 = require("primereact/calendar");
9
9
  var react_1 = __importDefault(require("react"));
10
10
  var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
11
+ var XUtils_1 = require("./XUtils");
11
12
  var XInputDateDT = function (props) {
12
13
  var showTime = (props.xField.type === 'datetime');
13
14
  var cssClassName = showTime ? 'x-input-datetime' : 'x-input-date';
14
- // ak mame path, field je vzdy readOnly
15
- var readOnly;
16
- var posDot = props.field.indexOf(".");
17
- if (posDot !== -1) {
18
- readOnly = true;
19
- }
20
- else {
21
- readOnly = props.readOnly !== undefined ? props.readOnly : false;
22
- }
23
15
  var onValueChange = function (field, rowData, newValue) {
24
16
  // z Calendar prichadza e.value - typ Date alebo null
25
17
  // zmenime hodnotu v modeli (odtial sa hodnota cita)
@@ -47,6 +39,7 @@ var XInputDateDT = function (props) {
47
39
  }
48
40
  // fieldValue zostalo undefined (konvertujeme null -> undefined) - Calendar pozaduje undefined, nechce null
49
41
  }
42
+ var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
50
43
  // TODO - nefunguje dobre pridavanie noveho riadku - su tam stare neupdatnute hodnoty - este to asi neopravili https://github.com/primefaces/primereact/issues/1277
51
44
  // test mame na TestovaciForm
52
45
  // appendTo={document.body} appenduje overlay panel na element body - eliminuje problem s overflow (pozri poznamku v XDropdownDTFilter)
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { XFormBase } from "./XFormBase";
3
+ import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
3
4
  export declare const XInputTextDT: (props: {
4
5
  form: XFormBase;
5
6
  entity: string;
6
7
  field: string;
7
8
  rowData: any;
8
- readOnly?: boolean | undefined;
9
+ readOnly?: XTableFieldReadOnlyProp | undefined;
9
10
  }) => JSX.Element;
@@ -9,17 +9,9 @@ var inputtext_1 = require("primereact/inputtext");
9
9
  var XUtilsConversions_1 = require("./XUtilsConversions");
10
10
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
11
11
  var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
12
+ var XUtils_1 = require("./XUtils");
12
13
  var XInputTextDT = function (props) {
13
14
  var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPathStr(props.entity, props.field);
14
- // ak mame path, field je vzdy readOnly
15
- var readOnly;
16
- var posDot = props.field.indexOf(".");
17
- if (posDot !== -1) {
18
- readOnly = true;
19
- }
20
- else {
21
- readOnly = props.readOnly !== undefined ? props.readOnly : false;
22
- }
23
15
  var onValueChange = function (field, rowData, newValue) {
24
16
  // zmenime hodnotu v modeli (odtial sa hodnota cita)
25
17
  rowData[field] = (0, XUtilsConversions_1.stringFromUI)(newValue);
@@ -37,6 +29,7 @@ var XInputTextDT = function (props) {
37
29
  // konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli (a tiez aby korektne pridal novy riadok)
38
30
  fieldValue = (0, XUtilsConversions_1.stringAsUI)(rowDataValue);
39
31
  }
32
+ var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
40
33
  return (react_1.default.createElement(inputtext_1.InputText, { id: props.field, value: fieldValue, onChange: function (e) { return onValueChange(props.field, props.rowData, e.target.value); }, readOnly: readOnly, maxLength: xField.length, className: "x-input-to-resize" }));
41
34
  };
42
35
  exports.XInputTextDT = XInputTextDT;
@@ -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;
@@ -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.customFilterItems, pridame ho
217
- customFilterItems = XUtils_1.XUtils.filterAnd(customFilterItems, 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];
@@ -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 () {
@@ -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 {
@@ -648,7 +650,7 @@ var XLazyDataTable = function (props) {
648
650
  // }
649
651
  var viewHeight = void 0;
650
652
  var headerFooterHeight = void 0;
651
- if (props.searchTableParams === undefined) {
653
+ if (props.searchBrowseParams === undefined) {
652
654
  // sme v standardnom formulari
653
655
  viewHeight = '100vh';
654
656
  // experimentalne zistena vyska header/footer
@@ -717,7 +719,7 @@ var XLazyDataTable = function (props) {
717
719
  }
718
720
  // else - editMode is undefined - browse is not editable
719
721
  // export pre search button-y zatial vypneme
720
- var exportRows = (props.searchTableParams === undefined);
722
+ var exportRows = (props.searchBrowseParams === undefined);
721
723
  // pre lepsiu citatelnost vytvarame stlpce uz tu
722
724
  var columnElemList = react_1.default.Children.map(props.children, function (child) {
723
725
  // ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
@@ -873,12 +875,12 @@ var XLazyDataTable = function (props) {
873
875
  react_1.default.createElement("div", { className: "flex justify-content-center" },
874
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)),
875
877
  react_1.default.createElement("div", { className: "flex justify-content-center" },
876
- 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,
877
- 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,
878
- 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,
879
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,
880
882
  props.appButtons,
881
- 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,
882
884
  exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { key: "exportRowsDialog", dialogOpened: exportRowsDialogOpened, hideDialog: function () { return setExportRowsDialogOpened(false); }, rowCount: exportRowsDialogRowCount, exportParams: createExportParams }) : null)));
883
885
  };
884
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;
@@ -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));
@@ -1,12 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { XFormBase } from "./XFormBase";
3
+ import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
3
4
  export declare const XSearchButtonDT: (props: {
4
5
  form: XFormBase;
5
6
  entity: string;
6
7
  assocField: string;
7
8
  displayField: string;
8
- searchTable: any;
9
- assocForm?: any;
9
+ searchBrowse: JSX.Element;
10
+ assocForm?: JSX.Element | undefined;
10
11
  rowData: any;
11
- readOnly?: boolean | undefined;
12
+ readOnly?: XTableFieldReadOnlyProp | undefined;
12
13
  }) => JSX.Element;
@@ -102,7 +102,6 @@ var XSearchButtonDT = function (props) {
102
102
  }
103
103
  return inputValue;
104
104
  };
105
- var readOnly = props.readOnly !== undefined ? props.readOnly : false;
106
105
  var onInputValueChange = function (e) {
107
106
  setInputChanged(true);
108
107
  setInputValueState(e.target.value);
@@ -155,7 +154,7 @@ var XSearchButtonDT = function (props) {
155
154
  // OTAZKA - ziskavat id priamo z root objektu? potom ho vsak treba do root objektu pridat
156
155
  var id = (assocObject !== null && assocObject !== undefined) ? assocObject[xEntityAssoc.idField] : null;
157
156
  // klonovanim elementu pridame atribut id
158
- var assocForm = react_1.default.cloneElement(props.assocForm, { id: id }, props.assocForm.children);
157
+ var assocForm = react_1.default.cloneElement(props.assocForm, { id: id } /*, props.assocForm.children*/);
159
158
  props.form.props.openForm(assocForm);
160
159
  }
161
160
  }
@@ -175,14 +174,19 @@ var XSearchButtonDT = function (props) {
175
174
  inputTextRef.current.focus();
176
175
  }
177
176
  };
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
177
  // vypocitame inputValue
181
178
  var inputValue = computeInputValue();
179
+ var readOnly = XUtils_1.XUtils.isReadOnlyTableField(undefined, props.readOnly, props.form.state.object, props.rowData);
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;
@@ -4,6 +4,9 @@ import React from "react";
4
4
  import { XEnvVar } from "./XEnvVars";
5
5
  import { XError, XErrorMap } from "./XErrors";
6
6
  import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
7
+ import { DataTableSortMeta } from "primereact/datatable";
8
+ import { XObject } from "./XObject";
9
+ import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
7
10
  export declare enum OperationType {
8
11
  None = 0,
9
12
  Insert = 1,
@@ -44,7 +47,7 @@ export declare class XUtils {
44
47
  static registerAppForm(elem: any, entity: string, formId?: string): void;
45
48
  static getAppForm(entity: string, formId?: string): any;
46
49
  static fetchMany(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any[]>;
47
- static fetchRows(entity: string, customFilter?: XCustomFilter | undefined, sortField?: string, fields?: string[]): Promise<any[]>;
50
+ static fetchRows(entity: string, customFilter?: XCustomFilter | undefined, sortField?: string | DataTableSortMeta[] | undefined, fields?: string[]): Promise<any[]>;
48
51
  static fetchOne(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
49
52
  static fetchString(path: string, value: any): Promise<string>;
50
53
  static fetch(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
@@ -67,7 +70,26 @@ export declare class XUtils {
67
70
  static removeRow(entity: string, row: any): Promise<void>;
68
71
  static arrayMoveElement(array: any[], position: number, offset: number): void;
69
72
  static arraySort(array: any[], fieldOrStringFunction: string | ((item: any) => string)): any[];
73
+ /**
74
+ * returns true, if param item is member of the array
75
+ * remark: null/undefined items in array are ignored, item = null/undefined is ignored
76
+ *
77
+ * @param array
78
+ * @param item
79
+ * @param idField
80
+ */
81
+ static arrayIncludes<T>(array: T[], item: T, idField: string): boolean;
82
+ /**
83
+ * returns intersection of 2 row lists
84
+ * remark: null/undefined items in both array1 and array2 are ignored
85
+ *
86
+ * @param array1
87
+ * @param array2
88
+ * @param idField
89
+ */
90
+ static arrayIntersect<T>(array1: T[], array2: T[], idField: string): T[];
70
91
  static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
92
+ static isReadOnlyTableField(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined, object: XObject | null, tableRow: any): boolean;
71
93
  static markNotNull(label: string): string;
72
94
  static showErrorMessage(message: string, e: unknown): void;
73
95
  static createErrorProps(error: string | undefined): {};
@@ -81,4 +103,5 @@ export declare class XUtils {
81
103
  static normalizeString(value: string): string;
82
104
  static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
83
105
  static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
106
+ static isTableRowInserted(tableRow: any): boolean;
84
107
  }
@@ -265,11 +265,20 @@ var XUtils = /** @class */ (function () {
265
265
  // pomocna metodka pouzivajuca lazyDataTable service
266
266
  XUtils.fetchRows = function (entity, customFilter, sortField, fields) {
267
267
  return __awaiter(this, void 0, void 0, function () {
268
- var findParam, rowList;
268
+ var multiSortMeta, findParam, rowList;
269
269
  return __generator(this, function (_a) {
270
270
  switch (_a.label) {
271
271
  case 0:
272
- findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: sortField ? [{ field: sortField, order: 1 }] : undefined, fields: fields };
272
+ multiSortMeta = undefined;
273
+ if (sortField) {
274
+ if (Array.isArray(sortField)) {
275
+ multiSortMeta = sortField;
276
+ }
277
+ else {
278
+ multiSortMeta = [{ field: sortField, order: 1 }];
279
+ }
280
+ }
281
+ findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: multiSortMeta, fields: fields };
273
282
  return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
274
283
  case 1:
275
284
  rowList = (_a.sent()).rowList;
@@ -493,6 +502,47 @@ var XUtils = /** @class */ (function () {
493
502
  }
494
503
  });
495
504
  };
505
+ // TODO - prehodit do XUtilsCommon
506
+ /**
507
+ * returns true, if param item is member of the array
508
+ * remark: null/undefined items in array are ignored, item = null/undefined is ignored
509
+ *
510
+ * @param array
511
+ * @param item
512
+ * @param idField
513
+ */
514
+ XUtils.arrayIncludes = function (array, item, idField) {
515
+ return item && array.some(function (arrayItem) { return arrayItem && arrayItem[idField] === item[idField]; });
516
+ };
517
+ // TODO - prehodit do XUtilsCommon
518
+ /**
519
+ * returns intersection of 2 row lists
520
+ * remark: null/undefined items in both array1 and array2 are ignored
521
+ *
522
+ * @param array1
523
+ * @param array2
524
+ * @param idField
525
+ */
526
+ XUtils.arrayIntersect = function (array1, array2, idField) {
527
+ var e_5, _a;
528
+ var array2IdSet = new Set();
529
+ try {
530
+ for (var array2_1 = __values(array2), array2_1_1 = array2_1.next(); !array2_1_1.done; array2_1_1 = array2_1.next()) {
531
+ var item = array2_1_1.value;
532
+ if (item) {
533
+ array2IdSet.add(item[idField]);
534
+ }
535
+ }
536
+ }
537
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
538
+ finally {
539
+ try {
540
+ if (array2_1_1 && !array2_1_1.done && (_a = array2_1.return)) _a.call(array2_1);
541
+ }
542
+ finally { if (e_5) throw e_5.error; }
543
+ }
544
+ return array1.filter(function (item) { return item && array2IdSet.has(item[idField]); });
545
+ };
496
546
  // helper
497
547
  XUtils.isReadOnly = function (path, readOnlyInit) {
498
548
  // ak mame path dlzky 2 a viac, field je vzdy readOnly
@@ -505,6 +555,35 @@ var XUtils = /** @class */ (function () {
505
555
  }
506
556
  return readOnly;
507
557
  };
558
+ // docasna funkcia, kym sa vsade nebude pouzivat XFormComponentDT a jej isReadOnly()
559
+ XUtils.isReadOnlyTableField = function (path, readOnly, object, tableRow) {
560
+ var isReadOnly;
561
+ if (path && !XUtilsCommon_1.XUtilsCommon.isSingleField(path)) {
562
+ // if the length of field is 2 or more, then readOnly
563
+ isReadOnly = true;
564
+ }
565
+ // formReadOnlyBase is called on the level XFormDataTable2
566
+ // else if (this.props.form.formReadOnlyBase("xxx")) {
567
+ // isReadOnly = true;
568
+ // }
569
+ else if (typeof readOnly === 'boolean') {
570
+ isReadOnly = readOnly;
571
+ }
572
+ else if (typeof readOnly === 'function') {
573
+ // TODO - tazko povedat ci niekedy bude object === null (asi ano vid metodu getFilterBase)
574
+ if (object) {
575
+ isReadOnly = readOnly(object, tableRow);
576
+ }
577
+ else {
578
+ isReadOnly = true;
579
+ }
580
+ }
581
+ else {
582
+ // readOnly is undefined
583
+ isReadOnly = false;
584
+ }
585
+ return isReadOnly;
586
+ };
508
587
  XUtils.markNotNull = function (label) {
509
588
  return label + ' *';
510
589
  };
@@ -549,7 +628,7 @@ var XUtils = /** @class */ (function () {
549
628
  // pomocna metodka
550
629
  // ak nie su v xErrorMap ziadne chyby, vrati ""
551
630
  XUtils.getErrorMessages = function (xErrorMap) {
552
- var e_5, _a;
631
+ var e_6, _a;
553
632
  var _b;
554
633
  var msg = "";
555
634
  try {
@@ -563,12 +642,12 @@ var XUtils = /** @class */ (function () {
563
642
  }
564
643
  }
565
644
  }
566
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
645
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
567
646
  finally {
568
647
  try {
569
648
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
570
649
  }
571
- finally { if (e_5) throw e_5.error; }
650
+ finally { if (e_6) throw e_6.error; }
572
651
  }
573
652
  return msg;
574
653
  };
@@ -617,7 +696,7 @@ var XUtils = /** @class */ (function () {
617
696
  };
618
697
  // pomocna metodka
619
698
  XUtils.filterAnd = function () {
620
- var e_6, _a;
699
+ var e_7, _a;
621
700
  var filters = [];
622
701
  for (var _i = 0; _i < arguments.length; _i++) {
623
702
  filters[_i] = arguments[_i];
@@ -634,16 +713,21 @@ var XUtils = /** @class */ (function () {
634
713
  }
635
714
  }
636
715
  }
637
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
716
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
638
717
  finally {
639
718
  try {
640
719
  if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
641
720
  }
642
- finally { if (e_6) throw e_6.error; }
721
+ finally { if (e_7) throw e_7.error; }
643
722
  }
644
723
  }
645
724
  return customFilterItemsResult;
646
725
  };
726
+ // pomocna metodka
727
+ XUtils.isTableRowInserted = function (tableRow) {
728
+ var _a;
729
+ return (_a = tableRow.__x_generatedRowId) !== null && _a !== void 0 ? _a : false; // specialny priznak, ze sme vygenerovali id-cko
730
+ };
647
731
  XUtils.dropdownEmptyOptionValue = " ";
648
732
  XUtils.xBackendUrl = undefined;
649
733
  // nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
@@ -21,6 +21,9 @@
21
21
  "expEncoding": "Encoding",
22
22
  "fileUploadSizeToBig": "Upload of file \"{fileName}\" was canceled: file size {fileSize} is more than maximum allowed size {maxFileSize}.",
23
23
  "fileUploadFailed": "Upload of file \"{fileName}\" failed.",
24
- "fileDownloadFailed": "File download failed."
24
+ "fileDownloadFailed": "File download failed.",
25
+ "fieldSetSaveEditConfirm": "Are you sure to save the form?",
26
+ "fieldSetCancelEditConfirm": "Are you sure to cancel editing? All changes will be lost.",
27
+ "fieldSetRemoveFieldConfirm": "Are you sure to remove the field?"
25
28
  }
26
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rimraf lib",
package/XBrowse.d.ts DELETED
@@ -1,3 +0,0 @@
1
- // generated by gulp
2
-
3
- export * from './lib/components/XBrowse';
package/XBrowse.js DELETED
@@ -1,5 +0,0 @@
1
- // generated by gulp
2
-
3
- 'use strict';
4
-
5
- module.exports = require('./lib/components/XBrowse.js');