@michalrakus/x-react-web-lib 1.12.0 → 1.14.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 (63) hide show
  1. package/XFormCol.d.ts +3 -0
  2. package/XFormCol.js +5 -0
  3. package/XFormInlineRow.d.ts +3 -0
  4. package/XFormInlineRow.js +5 -0
  5. package/XFormRow.d.ts +3 -0
  6. package/XFormRow.js +5 -0
  7. package/XFormRowCol.d.ts +3 -0
  8. package/XFormRowCol.js +5 -0
  9. package/XUtilsConversions.d.ts +1 -1
  10. package/XUtilsConversions.js +1 -1
  11. package/XUtilsMetadataCommon.d.ts +3 -0
  12. package/XUtilsMetadataCommon.js +5 -0
  13. package/gulpfile.js +8 -2
  14. package/lib/components/XAutoComplete.d.ts +4 -2
  15. package/lib/components/XAutoComplete.js +13 -11
  16. package/lib/components/XAutoCompleteBase.d.ts +5 -0
  17. package/lib/components/XAutoCompleteBase.js +34 -3
  18. package/lib/components/XAutoCompleteDT.js +4 -4
  19. package/lib/components/XCalendar.js +1 -1
  20. package/lib/components/XDropdown.js +2 -2
  21. package/lib/components/XDropdownDT.js +4 -4
  22. package/lib/components/XDropdownDTFilter.d.ts +3 -0
  23. package/lib/components/XDropdownDTFilter.js +7 -6
  24. package/lib/components/XDropdownForEntity.js +2 -2
  25. package/lib/components/XEditBrowse.js +4 -3
  26. package/lib/components/XExportRowsDialog.js +1 -1
  27. package/lib/components/XFieldSelector.js +4 -4
  28. package/lib/components/XFormDataTable2.d.ts +15 -9
  29. package/lib/components/XFormDataTable2.js +42 -32
  30. package/lib/components/XFormRowCol/XFormCol.d.ts +8 -0
  31. package/lib/components/XFormRowCol/XFormCol.js +12 -0
  32. package/lib/components/XFormRowCol/XFormInlineRow.d.ts +8 -0
  33. package/lib/components/XFormRowCol/XFormInlineRow.js +12 -0
  34. package/lib/components/XFormRowCol/XFormRow.d.ts +8 -0
  35. package/lib/components/XFormRowCol/XFormRow.js +12 -0
  36. package/lib/components/XFormRowCol/XFormRowCol.d.ts +9 -0
  37. package/lib/components/XFormRowCol/XFormRowCol.js +30 -0
  38. package/lib/components/XFtsInput.js +1 -1
  39. package/lib/components/XInput.js +2 -2
  40. package/lib/components/XInputDT.js +2 -2
  41. package/lib/components/XInputDateDT.js +1 -1
  42. package/lib/components/XInputFileList.js +6 -6
  43. package/lib/components/XInputIntervalBase.js +1 -1
  44. package/lib/components/XInputText.js +1 -1
  45. package/lib/components/XInputTextDT.js +3 -3
  46. package/lib/components/XInputTextarea.js +1 -1
  47. package/lib/components/XLazyDataTable.d.ts +19 -1
  48. package/lib/components/XLazyDataTable.js +26 -45
  49. package/lib/components/XSearchButton.js +4 -4
  50. package/lib/components/XSearchButtonDT.js +3 -3
  51. package/lib/components/XSearchButtonOld.js +5 -5
  52. package/lib/components/XToOneAssocButton.js +3 -3
  53. package/lib/components/XUtils.d.ts +8 -0
  54. package/lib/components/XUtils.js +25 -2
  55. package/lib/components/XUtilsMetadata.d.ts +1 -19
  56. package/lib/components/XUtilsMetadata.js +8 -186
  57. package/lib/components/locale/x-en.json +4 -1
  58. package/lib/{components → serverApi}/XUtilsConversions.d.ts +18 -1
  59. package/lib/serverApi/XUtilsConversions.js +330 -0
  60. package/lib/serverApi/XUtilsMetadataCommon.d.ts +30 -0
  61. package/lib/serverApi/XUtilsMetadataCommon.js +208 -0
  62. package/package.json +2 -2
  63. package/lib/components/XUtilsConversions.js +0 -177
@@ -105,7 +105,7 @@ var XButton_1 = require("./XButton");
105
105
  var XUtils_1 = require("./XUtils");
106
106
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
107
107
  var XDropdownDTFilter_1 = require("./XDropdownDTFilter");
108
- var XUtilsConversions_1 = require("./XUtilsConversions");
108
+ var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
109
109
  var FindParam_1 = require("../serverApi/FindParam");
110
110
  var XButtonIconSmall_1 = require("./XButtonIconSmall");
111
111
  var tristatecheckbox_1 = require("primereact/tristatecheckbox");
@@ -116,10 +116,11 @@ var XCalendar_1 = require("./XCalendar");
116
116
  var XInputDecimalBase_1 = require("./XInputDecimalBase");
117
117
  var XLocale_1 = require("./XLocale");
118
118
  var XFtsInput_1 = require("./XFtsInput");
119
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
119
120
  var XLazyDataTable = function (props) {
120
121
  var _a;
121
122
  // must be here, is used in createInitFilters()
122
- var xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.entity);
123
+ var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.entity);
123
124
  var createAggregateItems = function () {
124
125
  var e_1, _a;
125
126
  var aggregateItems = [];
@@ -152,7 +153,7 @@ var XLazyDataTable = function (props) {
152
153
  var column = columns_2_1.value;
153
154
  var xLazyColumn = column; // nevedel som to krajsie...
154
155
  var field = xLazyColumn.props.field;
155
- var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntity, field);
156
+ var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, field);
156
157
  // TODO column.props.dropdownInFilter - pre "menu" by bolo fajn mat zoznam "enumov"
157
158
  var filterMatchMode = getFilterMatchMode(xField);
158
159
  initFilters[field] = createFilterItem(props.filterDisplay, { value: null, matchMode: filterMatchMode });
@@ -170,7 +171,7 @@ var XLazyDataTable = function (props) {
170
171
  var getFilterMatchMode = function (xField) {
171
172
  var filterMatchMode;
172
173
  if (xField.type === "string") {
173
- filterMatchMode = api_1.FilterMatchMode.STARTS_WITH;
174
+ filterMatchMode = api_1.FilterMatchMode.CONTAINS;
174
175
  }
175
176
  // zatial vsetky ostatne EQUALS
176
177
  else if (xField.type === "decimal" || xField.type === "number" || xField.type === "date" || xField.type === "datetime" || xField.type === "boolean") {
@@ -259,7 +260,7 @@ var XLazyDataTable = function (props) {
259
260
  }
260
261
  }); // eslint-disable-line react-hooks/exhaustive-deps
261
262
  // TODO - preco je to tu? presunut dole ak sa da...
262
- var dataKey = props.dataKey !== undefined ? props.dataKey : XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.entity).idField;
263
+ var dataKey = props.dataKey !== undefined ? props.dataKey : XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.entity).idField;
263
264
  var onPage = function (event) { return __awaiter(void 0, void 0, void 0, function () {
264
265
  return __generator(this, function (_a) {
265
266
  //console.log("zavolany onPage");
@@ -468,6 +469,14 @@ var XLazyDataTable = function (props) {
468
469
  }
469
470
  });
470
471
  }); };
472
+ var onClickAppButtonForRow = function (onClick) {
473
+ if (selectedRow !== null) {
474
+ onClick(selectedRow);
475
+ }
476
+ else {
477
+ alert((0, XLocale_1.xLocaleOption)('pleaseSelectRow'));
478
+ }
479
+ };
471
480
  var onClickExport = function () { return __awaiter(void 0, void 0, void 0, function () {
472
481
  var findParam, findResult;
473
482
  return __generator(this, function (_a) {
@@ -594,47 +603,15 @@ var XLazyDataTable = function (props) {
594
603
  return betweenFilter;
595
604
  };
596
605
  var valueAsUI = function (value, xField) {
597
- var valueResult = '';
598
- if (xField.type === "decimal") {
599
- // tuto zatial hack, mal by vzdy prist number
600
- var numberValue = null;
601
- if (typeof value === 'string') {
602
- numberValue = parseFloat(value);
603
- }
604
- else if (typeof value === 'number') {
605
- numberValue = value;
606
- }
607
- valueResult = (0, XUtilsConversions_1.numberAsUI)(numberValue, xField.scale);
608
- }
609
- else if (xField.type === "date") {
610
- // tuto zatial hack, mal by prist Date
611
- var dateValue = null;
612
- if (typeof value === 'string') {
613
- dateValue = new Date(value);
614
- }
615
- else if (typeof value === 'object' && value instanceof Date) {
616
- dateValue = value;
617
- }
618
- valueResult = (0, XUtilsConversions_1.dateAsUI)(dateValue);
619
- }
620
- else if (xField.type === "datetime") {
621
- // tuto zatial hack, mal by prist Date
622
- var dateValue = null;
623
- if (typeof value === 'string') {
624
- dateValue = new Date(value);
625
- }
626
- else if (typeof value === 'object' && value instanceof Date) {
627
- dateValue = value;
628
- }
629
- valueResult = (0, XUtilsConversions_1.datetimeAsUI)(dateValue);
630
- }
631
- else if (xField.type === "boolean") {
606
+ var valueResult;
607
+ if (xField.type === "boolean") {
632
608
  // TODO - efektivnejsie by bolo renderovat len prislusne ikonky
633
609
  valueResult = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: value, disabled: true });
634
610
  }
635
611
  else {
636
- // string a ine typy
637
- valueResult = value;
612
+ // ine typy - convertValue vrati string
613
+ // mame zapnutu konverziu fromModel, lebo z json-u nam prichadzaju objekty typu string (napr. pri datumoch)
614
+ valueResult = (0, XUtilsConversions_1.convertValue)(xField, value, true, XUtilsConversions_1.AsUIType.Form);
638
615
  }
639
616
  return valueResult;
640
617
  };
@@ -743,12 +720,12 @@ var XLazyDataTable = function (props) {
743
720
  // export pre search button-y zatial vypneme
744
721
  var exportRows = (props.searchBrowseParams === undefined);
745
722
  // pre lepsiu citatelnost vytvarame stlpce uz tu
746
- var columnElemList = react_1.default.Children.map(props.children, function (child) {
723
+ var columnElemList = react_1.default.Children.map(props.children.filter(function (child) { return XUtils_1.XUtils.xViewStatus(child.props.columnViewStatus) !== XUtils_1.XViewStatus.Hidden; }), function (child) {
747
724
  // ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
748
725
  // priklad je na https://soshace.com/building-react-components-using-children-props-and-context-api/
749
726
  // (vzdy musime robit manipulacie so stlpcom, lebo potrebujeme pridat filter={true} sortable={true}
750
727
  var childColumn = child; // nevedel som to krajsie...
751
- var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntity, childColumn.props.field);
728
+ var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, childColumn.props.field);
752
729
  // *********** header ***********
753
730
  var headerLabel = childColumn.props.header !== undefined ? childColumn.props.header : childColumn.props.field;
754
731
  var header;
@@ -782,7 +759,7 @@ var XLazyDataTable = function (props) {
782
759
  }
783
760
  else if (childColumn.props.dropdownInFilter) {
784
761
  var dropdownValue = getDropdownFilterValue(childColumn.props.field);
785
- filterElement = react_1.default.createElement(XDropdownDTFilter_1.XDropdownDTFilter, { entity: props.entity, path: childColumn.props.field, value: dropdownValue, onValueChange: onDropdownFilterChange });
762
+ filterElement = react_1.default.createElement(XDropdownDTFilter_1.XDropdownDTFilter, { entity: props.entity, path: childColumn.props.field, value: dropdownValue, onValueChange: onDropdownFilterChange, filter: childColumn.props.dropdownFilter, sortField: childColumn.props.dropdownSortField });
786
763
  }
787
764
  else if (xField.type === "date" || xField.type === "datetime") {
788
765
  betweenFilter = getBetweenFilter(childColumn.props.betweenFilter, props.betweenFilter);
@@ -903,6 +880,7 @@ var XLazyDataTable = function (props) {
903
880
  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,
904
881
  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,
905
882
  exportRows ? react_1.default.createElement(XButton_1.XButton, { key: "exportRows", icon: "pi pi-file-export", label: (0, XLocale_1.xLocaleOption)('exportRows'), onClick: onClickExport }) : null,
883
+ props.appButtonsForRow ? props.appButtonsForRow.map(function (xAppButton) { return react_1.default.createElement(XButton_1.XButton, { key: xAppButton.key, icon: xAppButton.icon, label: xAppButton.label, onClick: function () { return onClickAppButtonForRow(xAppButton.onClick); } }); }) : null,
906
884
  props.appButtons,
907
885
  props.searchBrowseParams !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "choose", label: (0, XLocale_1.xLocaleOption)('chooseRow'), onClick: onClickChoose }) : null,
908
886
  exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { key: "exportRowsDialog", dialogOpened: exportRowsDialogOpened, hideDialog: function () { return setExportRowsDialogOpened(false); }, rowCount: exportRowsDialogRowCount, exportParams: createExportParams }) : null)));
@@ -924,3 +902,6 @@ var XLazyColumn = function (props) {
924
902
  return (null);
925
903
  };
926
904
  exports.XLazyColumn = XLazyColumn;
905
+ exports.XLazyColumn.defaultProps = {
906
+ columnViewStatus: true // XViewStatus.ReadWrite
907
+ };
@@ -71,13 +71,13 @@ var inputtext_1 = require("primereact/inputtext");
71
71
  var button_1 = require("primereact/button");
72
72
  var XUtils_1 = require("./XUtils");
73
73
  var dialog_1 = require("primereact/dialog");
74
- var XUtilsMetadata_1 = require("./XUtilsMetadata");
75
74
  var XFormComponent_1 = require("./XFormComponent");
75
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
76
76
  var XSearchButton = /** @class */ (function (_super) {
77
77
  __extends(XSearchButton, _super);
78
78
  function XSearchButton(props) {
79
79
  var _this = _super.call(this, props) || this;
80
- _this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity()), props.assocField);
80
+ _this.xAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXAssocToOne(XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.form.getEntity()), props.assocField);
81
81
  _this.inputTextRef = react_1.default.createRef();
82
82
  // POVODNY KOD
83
83
  //this.overlayPanelEl = React.createRef();
@@ -99,8 +99,8 @@ var XSearchButton = /** @class */ (function (_super) {
99
99
  var _this = this;
100
100
  var _a;
101
101
  var props = this.props;
102
- var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
103
- var xDisplayField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntityAssoc, props.displayField);
102
+ var xEntityAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.xAssoc.entityName);
103
+ var xDisplayField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntityAssoc, props.displayField);
104
104
  // tu boli hook-y kedysi...
105
105
  var inputChanged = this.state.inputChanged;
106
106
  var setInputChanged = function (inputChanged) { _this.setState({ inputChanged: inputChanged }); };
@@ -81,7 +81,7 @@ var XUtils_1 = require("./XUtils");
81
81
  var inputtext_1 = require("primereact/inputtext");
82
82
  var button_1 = require("primereact/button");
83
83
  var dialog_1 = require("primereact/dialog");
84
- var XUtilsMetadata_1 = require("./XUtilsMetadata");
84
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
85
85
  var XSearchButtonDT = function (props) {
86
86
  var inputTextRef = (0, react_1.useRef)(null);
87
87
  var _a = __read((0, react_1.useState)(false), 2), inputChanged = _a[0], setInputChanged = _a[1]; // priznak, ci uzivatel typovanim zmenil hodnotu v inpute
@@ -147,8 +147,8 @@ var XSearchButtonDT = function (props) {
147
147
  }
148
148
  else {
149
149
  if (props.assocForm !== undefined) {
150
- var xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.entity);
151
- var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntityForAssocToOne(xEntity, props.assocField);
150
+ var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.entity);
151
+ var xEntityAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntityForAssocToOne(xEntity, props.assocField);
152
152
  if (props.rowData !== null) {
153
153
  var assocObject = props.rowData[props.assocField];
154
154
  // OTAZKA - ziskavat id priamo z root objektu? potom ho vsak treba do root objektu pridat
@@ -81,14 +81,14 @@ var inputtext_1 = require("primereact/inputtext");
81
81
  var button_1 = require("primereact/button");
82
82
  var XUtils_1 = require("./XUtils");
83
83
  var dialog_1 = require("primereact/dialog");
84
- var XUtilsMetadata_1 = require("./XUtilsMetadata");
84
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
85
85
  var XSearchButtonOld = function (props) {
86
86
  var _a, _b, _c;
87
87
  props.form.addField(props.assocField + '.' + props.displayField);
88
- var xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity());
89
- var xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(xEntity, props.assocField);
90
- var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(xAssoc.entityName);
91
- var xDisplayField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntityAssoc, props.displayField);
88
+ var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.form.getEntity());
89
+ var xAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXAssocToOne(xEntity, props.assocField);
90
+ var xEntityAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(xAssoc.entityName);
91
+ var xDisplayField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntityAssoc, props.displayField);
92
92
  // POVODNY KOD
93
93
  //const overlayPanelEl = useRef<any>(null);
94
94
  var inputTextEl = (0, react_1.useRef)(null);
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.XToOneAssocButton = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var button_1 = require("primereact/button");
9
- var XUtilsMetadata_1 = require("./XUtilsMetadata");
10
9
  var XUtils_1 = require("./XUtils");
10
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
11
11
  var XToOneAssocButton = function (props) {
12
12
  // mozno lepsie by bolo sem dat xEntityAssoc.idField ale postaci aj *FAKE*
13
13
  props.form.addField(props.assocField + '.*FAKE*');
@@ -15,8 +15,8 @@ var XToOneAssocButton = function (props) {
15
15
  var object = props.form.state.object;
16
16
  var assocObject = object !== null ? object[props.assocField] : null;
17
17
  var onClickButton = function (e) {
18
- var xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity());
19
- var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntityForAssocToOne(xEntity, props.assocField);
18
+ var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.form.getEntity());
19
+ var xEntityAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntityForAssocToOne(xEntity, props.assocField);
20
20
  // OTAZKA - ziskavat id priamo z root objektu? potom ho vsak treba do root objektu pridat
21
21
  var id = assocObject !== null ? assocObject[xEntityAssoc.idField] : null;
22
22
  // klonovanim elementu pridame atribut id
@@ -13,6 +13,12 @@ export declare enum OperationType {
13
13
  Update = 2,
14
14
  Remove = 3
15
15
  }
16
+ export declare enum XViewStatus {
17
+ ReadWrite = 0,
18
+ ReadOnly = 1,
19
+ Hidden = 2
20
+ }
21
+ export type XViewStatusOrBoolean = XViewStatus | boolean;
16
22
  export interface IPostgresInterval {
17
23
  years?: number;
18
24
  months?: number;
@@ -103,5 +109,7 @@ export declare class XUtils {
103
109
  static normalizeString(value: string): string;
104
110
  static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
105
111
  static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
112
+ static filterIdIn(idField: string, idList: number[]): XCustomFilter;
106
113
  static isTableRowInserted(tableRow: any): boolean;
114
+ static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
107
115
  }
@@ -83,12 +83,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
83
83
  return to.concat(ar || Array.prototype.slice.call(from));
84
84
  };
85
85
  Object.defineProperty(exports, "__esModule", { value: true });
86
- exports.XUtils = exports.OperationType = void 0;
86
+ exports.XUtils = exports.XViewStatus = exports.OperationType = void 0;
87
87
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
88
88
  var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
89
89
  var ExportImportParam_1 = require("../serverApi/ExportImportParam");
90
90
  var XResponseError_1 = require("./XResponseError");
91
91
  var FindParam_1 = require("../serverApi/FindParam");
92
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
92
93
  var OperationType;
93
94
  (function (OperationType) {
94
95
  OperationType[OperationType["None"] = 0] = "None";
@@ -96,6 +97,12 @@ var OperationType;
96
97
  OperationType[OperationType["Update"] = 2] = "Update";
97
98
  OperationType[OperationType["Remove"] = 3] = "Remove";
98
99
  })(OperationType = exports.OperationType || (exports.OperationType = {}));
100
+ var XViewStatus;
101
+ (function (XViewStatus) {
102
+ XViewStatus[XViewStatus["ReadWrite"] = 0] = "ReadWrite";
103
+ XViewStatus[XViewStatus["ReadOnly"] = 1] = "ReadOnly";
104
+ XViewStatus[XViewStatus["Hidden"] = 2] = "Hidden";
105
+ })(XViewStatus = exports.XViewStatus || (exports.XViewStatus = {}));
99
106
  var XUtils = /** @class */ (function () {
100
107
  function XUtils() {
101
108
  }
@@ -454,7 +461,7 @@ var XUtils = /** @class */ (function () {
454
461
  return __generator(this, function (_a) {
455
462
  switch (_a.label) {
456
463
  case 0:
457
- xEntity = XUtilsMetadata_1.XUtilsMetadata.getXEntity(entity);
464
+ xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(entity);
458
465
  id = row[xEntity.idField];
459
466
  return [4 /*yield*/, XUtils.post('removeRow', { entity: entity, id: id })];
460
467
  case 1:
@@ -724,10 +731,26 @@ var XUtils = /** @class */ (function () {
724
731
  return customFilterItemsResult;
725
732
  };
726
733
  // pomocna metodka
734
+ // ak je idList prazdny, vytvori podmienku id IN (0) a nevrati ziadne zaznamy
735
+ XUtils.filterIdIn = function (idField, idList) {
736
+ return { where: "[".concat(idField, "] IN (:...idList)"), params: { "idList": idList.length > 0 ? idList : [0] } };
737
+ };
738
+ // pomocna metodka
727
739
  XUtils.isTableRowInserted = function (tableRow) {
728
740
  var _a;
729
741
  return (_a = tableRow.__x_generatedRowId) !== null && _a !== void 0 ? _a : false; // specialny priznak, ze sme vygenerovali id-cko
730
742
  };
743
+ // pomocna metodka
744
+ XUtils.xViewStatus = function (xViewStatusOrBoolean) {
745
+ var xViewStatus;
746
+ if (typeof xViewStatusOrBoolean === "boolean") {
747
+ xViewStatus = xViewStatusOrBoolean ? XViewStatus.ReadWrite : XViewStatus.Hidden;
748
+ }
749
+ else {
750
+ xViewStatus = xViewStatusOrBoolean;
751
+ }
752
+ return xViewStatus;
753
+ };
731
754
  XUtils.dropdownEmptyOptionValue = " ";
732
755
  XUtils.xBackendUrl = undefined;
733
756
  // nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
@@ -1,25 +1,10 @@
1
- import { XAssoc, XEntity, XField, XRelationType } from "../serverApi/XEntityMetadata";
1
+ import { XField } from "../serverApi/XEntityMetadata";
2
2
  import { XBrowseMeta } from "../serverApi/XBrowseMetadata";
3
3
  import { XBetweenFilterProp } from "./XLazyDataTable";
4
4
  export declare class XUtilsMetadata {
5
- private static xEntityMap;
6
5
  private static xBrowseMetaMap;
7
6
  static fetchAndSetXEntityMap(): Promise<any>;
8
7
  static fetchAndSetXBrowseMetaMap(): Promise<any>;
9
- static getXEntity(entity: string): XEntity;
10
- static getXField(xEntity: XEntity, field: string): XField;
11
- static getXFieldByPath(xEntity: XEntity, path: string): XField;
12
- static getXFieldByPathStr(entity: string, path: string): XField;
13
- static getXAssocByPath(xEntity: XEntity, path: string): XAssoc;
14
- static getLastXAssocByPath(xEntity: XEntity, path: string): XAssoc;
15
- static getXAssocToOne(xEntity: XEntity, assocField: string): XAssoc;
16
- static getXAssocToMany(xEntity: XEntity, assocField: string): XAssoc;
17
- static getXAssocToOneByAssocEntity(xEntity: XEntity, assocEntityName: string): XAssoc;
18
- static getXAssocToManyByAssocEntity(xEntity: XEntity, assocEntityName: string): XAssoc;
19
- static getXEntityForAssocToOne(xEntity: XEntity, assocField: string): XEntity;
20
- static getXEntityForAssocToMany(xEntity: XEntity, assocField: string): XEntity;
21
- static getXFieldList(xEntity: XEntity): XField[];
22
- static getXAssocList(xEntity: XEntity, relationTypeList?: XRelationType[]): XAssoc[];
23
8
  static getParamsForInputNumber(xField: XField): {
24
9
  useGrouping: boolean;
25
10
  fractionDigits?: number;
@@ -33,7 +18,4 @@ export declare class XUtilsMetadata {
33
18
  static getXBrowseMeta(entity: string, browseId?: string): XBrowseMeta;
34
19
  static setXBrowseMeta(entity: string, browseId: string | undefined, xBrowseMeta: XBrowseMeta): void;
35
20
  static getXBrowseFormMetaKey(entity: string, browseId?: string): string;
36
- private static getXAssoc;
37
- private static getXAssocByAssocEntity;
38
- private static getXEntityForAssoc;
39
21
  }
@@ -35,37 +35,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __values = (this && this.__values) || function(o) {
55
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
- if (m) return m.call(o);
57
- if (o && typeof o.length === "number") return {
58
- next: function () {
59
- if (o && i >= o.length) o = void 0;
60
- return { value: o && o[i++], done: !o };
61
- }
62
- };
63
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
- };
65
38
  Object.defineProperty(exports, "__esModule", { value: true });
66
39
  exports.XUtilsMetadata = void 0;
67
40
  var XUtils_1 = require("./XUtils");
68
- var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
41
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
69
42
  // idelany nazov: UtilsEntityMetadata - ale strasne dlhy
70
43
  // tato funkcionalita by mala ist bud do tried XEntity, XField alebo lepsie do nejakeho servisu
71
44
  // ekvivalentna funkcionalita sa nachadza aj na servri v servise XEntityMetadataService.ts (TODO - v buducnosti spravit spolocnu triedu/servis)
@@ -74,16 +47,16 @@ var XUtilsMetadata = /** @class */ (function () {
74
47
  }
75
48
  XUtilsMetadata.fetchAndSetXEntityMap = function () {
76
49
  return __awaiter(this, void 0, void 0, function () {
77
- var _a;
78
- return __generator(this, function (_b) {
79
- switch (_b.label) {
50
+ var _a, _b;
51
+ return __generator(this, function (_c) {
52
+ switch (_c.label) {
80
53
  case 0:
81
- if (!(XUtilsMetadata.xEntityMap === undefined)) return [3 /*break*/, 2];
82
- _a = XUtilsMetadata;
54
+ if (!(XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntityMap() === undefined)) return [3 /*break*/, 2];
55
+ _b = (_a = XUtilsMetadataCommon_1.XUtilsMetadataCommon).setXEntityMap;
83
56
  return [4 /*yield*/, XUtils_1.XUtils.fetch("getXEntityMap", { dummy: "dummy" })];
84
57
  case 1:
85
- _a.xEntityMap = _b.sent();
86
- _b.label = 2;
58
+ _b.apply(_a, [_c.sent()]);
59
+ _c.label = 2;
87
60
  case 2: return [2 /*return*/];
88
61
  }
89
62
  });
@@ -106,111 +79,6 @@ var XUtilsMetadata = /** @class */ (function () {
106
79
  });
107
80
  });
108
81
  };
109
- XUtilsMetadata.getXEntity = function (entity) {
110
- var xEntity = XUtilsMetadata.xEntityMap[entity];
111
- if (xEntity === undefined) {
112
- throw "Entity ".concat(entity, " was not found in entity metadata");
113
- }
114
- return xEntity;
115
- };
116
- XUtilsMetadata.getXField = function (xEntity, field) {
117
- // TODO - pozor, vo fieldMap su aj asociacie, trebalo by zmenit vytvaranie metadat tak aby tam tie asociacie neboli
118
- var xField = xEntity.fieldMap[field];
119
- if (xField === undefined) {
120
- throw "Field ".concat(field, " was not found in entity ").concat(xEntity.name);
121
- }
122
- return xField;
123
- };
124
- XUtilsMetadata.getXFieldByPath = function (xEntity, path) {
125
- var _a = __read(XUtilsCommon_1.XUtilsCommon.getFieldAndRestPath(path), 2), field = _a[0], restPath = _a[1];
126
- if (restPath === null) {
127
- return XUtilsMetadata.getXField(xEntity, field);
128
- }
129
- else {
130
- var xAssoc = XUtilsMetadata.getXAssoc(xEntity, field);
131
- var xAssocEntity = XUtilsMetadata.getXEntity(xAssoc.entityName);
132
- return XUtilsMetadata.getXFieldByPath(xAssocEntity, restPath);
133
- }
134
- };
135
- XUtilsMetadata.getXFieldByPathStr = function (entity, path) {
136
- return XUtilsMetadata.getXFieldByPath(XUtilsMetadata.getXEntity(entity), path);
137
- };
138
- XUtilsMetadata.getXAssocByPath = function (xEntity, path) {
139
- var _a = __read(XUtilsCommon_1.XUtilsCommon.getFieldAndRestPath(path), 2), field = _a[0], restPath = _a[1];
140
- if (restPath === null) {
141
- return XUtilsMetadata.getXAssoc(xEntity, field);
142
- }
143
- else {
144
- var xAssoc = XUtilsMetadata.getXAssoc(xEntity, field);
145
- var xAssocEntity = XUtilsMetadata.getXEntity(xAssoc.entityName);
146
- return XUtilsMetadata.getXAssocByPath(xAssocEntity, restPath);
147
- }
148
- };
149
- // for path assoc1.assoc2.field returns assoc2 (last assoc before field)
150
- XUtilsMetadata.getLastXAssocByPath = function (xEntity, path) {
151
- var pathToAssoc = XUtilsCommon_1.XUtilsCommon.getPathToAssoc(path);
152
- return XUtilsMetadata.getXAssocByPath(xEntity, pathToAssoc);
153
- };
154
- XUtilsMetadata.getXAssocToOne = function (xEntity, assocField) {
155
- return XUtilsMetadata.getXAssoc(xEntity, assocField, ["many-to-one", "one-to-one"]);
156
- };
157
- XUtilsMetadata.getXAssocToMany = function (xEntity, assocField) {
158
- return XUtilsMetadata.getXAssoc(xEntity, assocField, ["one-to-many", "many-to-many"]);
159
- };
160
- XUtilsMetadata.getXAssocToOneByAssocEntity = function (xEntity, assocEntityName) {
161
- return XUtilsMetadata.getXAssocByAssocEntity(xEntity, assocEntityName, ["many-to-one", "one-to-one"]);
162
- };
163
- XUtilsMetadata.getXAssocToManyByAssocEntity = function (xEntity, assocEntityName) {
164
- return XUtilsMetadata.getXAssocByAssocEntity(xEntity, assocEntityName, ["one-to-many", "many-to-many"]);
165
- };
166
- XUtilsMetadata.getXEntityForAssocToOne = function (xEntity, assocField) {
167
- return XUtilsMetadata.getXEntityForAssoc(XUtilsMetadata.getXAssocToOne(xEntity, assocField));
168
- };
169
- XUtilsMetadata.getXEntityForAssocToMany = function (xEntity, assocField) {
170
- return XUtilsMetadata.getXEntityForAssoc(XUtilsMetadata.getXAssocToMany(xEntity, assocField));
171
- };
172
- XUtilsMetadata.getXFieldList = function (xEntity) {
173
- var e_1, _a;
174
- var xFieldList = [];
175
- try {
176
- for (var _b = __values(Object.entries(xEntity.fieldMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
177
- var _d = __read(_c.value, 2), key = _d[0], xField = _d[1];
178
- // assoc fieldy sa nachadzaju aj v xEntity.fieldMap ako typ number (netusim preco), preto ich vyfiltrujeme
179
- if (xEntity.assocMap[xField.name] === undefined) {
180
- xFieldList.push(xField);
181
- }
182
- }
183
- }
184
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
185
- finally {
186
- try {
187
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
188
- }
189
- finally { if (e_1) throw e_1.error; }
190
- }
191
- return xFieldList;
192
- };
193
- XUtilsMetadata.getXAssocList = function (xEntity, relationTypeList) {
194
- var e_2, _a;
195
- //const xAssocList: XAssoc[] = Array.from(xEntity.assocMap, (v: XAssoc, k: string) => v);
196
- var xAssocList = [];
197
- try {
198
- for (var _b = __values(Object.entries(xEntity.assocMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
199
- var _d = __read(_c.value, 2), key = _d[0], xAssoc = _d[1];
200
- if (relationTypeList === undefined || relationTypeList.includes(xAssoc.relationType)) {
201
- xAssocList.push(xAssoc);
202
- }
203
- }
204
- }
205
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
206
- finally {
207
- try {
208
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
209
- }
210
- finally { if (e_2) throw e_2.error; }
211
- }
212
- return xAssocList;
213
- };
214
82
  // docasne sem, kym nemame jednotny XInputDecimal/XInputDecimalDT
215
83
  XUtilsMetadata.getParamsForInputNumber = function (xField) {
216
84
  var useGrouping = true;
@@ -399,52 +267,6 @@ var XUtilsMetadata = /** @class */ (function () {
399
267
  }
400
268
  return key;
401
269
  };
402
- XUtilsMetadata.getXAssoc = function (xEntity, assocField, relationTypeList) {
403
- var xAssoc = xEntity.assocMap[assocField];
404
- if (xAssoc === undefined) {
405
- throw "Assoc ".concat(assocField, " was not found in entity = ").concat(xEntity.name);
406
- }
407
- // relationTypeList is optional and is only for check (not to get some unwanted type of assoc)
408
- if (relationTypeList !== undefined && !relationTypeList.includes(xAssoc.relationType)) {
409
- throw "Assoc ".concat(assocField, " in entity ").concat(xEntity.name, " is of type ").concat(xAssoc.relationType, " and required type is ").concat(JSON.stringify(relationTypeList));
410
- }
411
- return xAssoc;
412
- };
413
- XUtilsMetadata.getXAssocByAssocEntity = function (xEntity, assocEntityName, relationTypeList) {
414
- var e_3, _a;
415
- var xAssocFound = undefined;
416
- try {
417
- for (var _b = __values(Object.entries(xEntity.assocMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
418
- var _d = __read(_c.value, 2), key = _d[0], xAssoc = _d[1];
419
- if (xAssoc.entityName === assocEntityName) {
420
- if (xAssocFound === undefined) {
421
- xAssocFound = xAssoc;
422
- }
423
- else {
424
- throw "In entity ".concat(xEntity.name, " found more then 1 assoc for assocEntityName = ").concat(assocEntityName);
425
- }
426
- }
427
- }
428
- }
429
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
430
- finally {
431
- try {
432
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
433
- }
434
- finally { if (e_3) throw e_3.error; }
435
- }
436
- if (xAssocFound === undefined) {
437
- throw "Assoc for assocEntityName = ".concat(assocEntityName, " not found in entity ").concat(xEntity.name);
438
- }
439
- // relationTypeList is optional and is only for check (not to get some unwanted type of assoc)
440
- if (relationTypeList !== undefined && !relationTypeList.includes(xAssocFound.relationType)) {
441
- throw "Assoc for assocEntityName = ".concat(assocEntityName, " in entity ").concat(xEntity.name, " is of type ").concat(xAssocFound.relationType, " and required type is ").concat(JSON.stringify(relationTypeList));
442
- }
443
- return xAssocFound;
444
- };
445
- XUtilsMetadata.getXEntityForAssoc = function (xAssoc) {
446
- return XUtilsMetadata.getXEntity(xAssoc.entityName);
447
- };
448
270
  //static CHAR_SIZE: number = 0.57; // 0.57rem (8px)
449
271
  XUtilsMetadata.CHAR_SIZE = 0.5; // 0.5rem (7px) - skusime
450
272
  return XUtilsMetadata;
@@ -24,6 +24,9 @@
24
24
  "fileDownloadFailed": "File download failed.",
25
25
  "fieldSetSaveEditConfirm": "Are you sure to save the form?",
26
26
  "fieldSetCancelEditConfirm": "Are you sure to cancel editing? All changes will be lost.",
27
- "fieldSetRemoveFieldConfirm": "Are you sure to remove the field?"
27
+ "fieldSetRemoveFieldConfirm": "Are you sure to remove the field?",
28
+ "upload": "Upload",
29
+ "yes": "yes",
30
+ "no": "no"
28
31
  }
29
32
  }
@@ -1,6 +1,8 @@
1
- import { IPostgresInterval } from "./XUtils";
1
+ import { IPostgresInterval } from "../components/XUtils";
2
+ import { XField } from "./XEntityMetadata";
2
3
  export declare function stringFromUI(stringValue: string): string | null;
3
4
  export declare function stringAsUI(value: string | null): string;
5
+ export declare function stringAsDB(value: string | null): string;
4
6
  export declare function numberFromUI(stringValue: string): number | null;
5
7
  export declare function numberAsUI(value: number | null, fractionDigits?: number): string;
6
8
  export declare function numberFromModel(value: any): number | null;
@@ -13,3 +15,18 @@ export declare function dateFormatCalendar(): string;
13
15
  export declare function datetimeFormatUI(): string;
14
16
  export declare function intervalFromUI(valueString: string): IPostgresInterval | null | undefined;
15
17
  export declare function intervalAsUI(valueInterval: IPostgresInterval | null): string;
18
+ export declare function booleanAsUIText(value: boolean | null): string;
19
+ export declare enum AsUIType {
20
+ Form = 1,
21
+ Text = 2
22
+ }
23
+ /**
24
+ * converts values of object
25
+ *
26
+ * @param entity
27
+ * @param object
28
+ * @param fromModel
29
+ * @param asUI
30
+ */
31
+ export declare function convertObject(entity: string, object: any, fromModel: boolean, asUI: AsUIType | undefined): void;
32
+ export declare function convertValue(xField: XField, value: any, fromModel: boolean, asUI: AsUIType | undefined): any;