@michalrakus/x-react-web-lib 1.12.0 → 1.13.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.
- package/XUtilsConversions.d.ts +1 -1
- package/XUtilsConversions.js +1 -1
- package/XUtilsMetadataCommon.d.ts +3 -0
- package/XUtilsMetadataCommon.js +5 -0
- package/gulpfile.js +3 -2
- package/lib/components/XAutoComplete.d.ts +3 -1
- package/lib/components/XAutoComplete.js +14 -8
- package/lib/components/XAutoCompleteBase.d.ts +4 -0
- package/lib/components/XAutoCompleteBase.js +33 -2
- package/lib/components/XAutoCompleteDT.js +4 -4
- package/lib/components/XCalendar.js +1 -1
- package/lib/components/XDropdown.js +2 -2
- package/lib/components/XDropdownDT.js +4 -4
- package/lib/components/XDropdownDTFilter.js +2 -2
- package/lib/components/XDropdownForEntity.js +2 -2
- package/lib/components/XEditBrowse.js +4 -3
- package/lib/components/XExportRowsDialog.js +1 -1
- package/lib/components/XFieldSelector.js +4 -4
- package/lib/components/XFormDataTable2.js +13 -12
- package/lib/components/XFtsInput.js +1 -1
- package/lib/components/XInput.js +2 -2
- package/lib/components/XInputDT.js +2 -2
- package/lib/components/XInputDateDT.js +1 -1
- package/lib/components/XInputFileList.js +6 -6
- package/lib/components/XInputIntervalBase.js +1 -1
- package/lib/components/XInputText.js +1 -1
- package/lib/components/XInputTextDT.js +3 -3
- package/lib/components/XInputTextarea.js +1 -1
- package/lib/components/XLazyDataTable.d.ts +9 -0
- package/lib/components/XLazyDataTable.js +21 -43
- package/lib/components/XSearchButton.js +4 -4
- package/lib/components/XSearchButtonDT.js +3 -3
- package/lib/components/XSearchButtonOld.js +5 -5
- package/lib/components/XToOneAssocButton.js +3 -3
- package/lib/components/XUtils.js +2 -1
- package/lib/components/XUtilsMetadata.d.ts +1 -19
- package/lib/components/XUtilsMetadata.js +8 -186
- package/lib/components/locale/x-en.json +4 -1
- package/lib/{components → serverApi}/XUtilsConversions.d.ts +18 -1
- package/lib/serverApi/XUtilsConversions.js +330 -0
- package/lib/serverApi/XUtilsMetadataCommon.d.ts +30 -0
- package/lib/serverApi/XUtilsMetadataCommon.js +208 -0
- package/package.json +2 -2
- package/lib/components/XUtilsConversions.js +0 -177
|
@@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
exports.XInputIntervalBase = void 0;
|
|
54
54
|
var inputtext_1 = require("primereact/inputtext");
|
|
55
55
|
var react_1 = __importStar(require("react"));
|
|
56
|
-
var XUtilsConversions_1 = require("
|
|
56
|
+
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
57
57
|
var XUtils_1 = require("./XUtils");
|
|
58
58
|
// zatial podporuje len hours a minutes - TODO - pridat aj seconds, ale cez nejaky prepinac
|
|
59
59
|
var XInputIntervalBase = function (props) {
|
|
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.XInputText = void 0;
|
|
33
33
|
var react_1 = __importDefault(require("react"));
|
|
34
|
-
var XUtilsConversions_1 = require("
|
|
34
|
+
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
35
35
|
var inputtext_1 = require("primereact/inputtext");
|
|
36
36
|
var XInput_1 = require("./XInput");
|
|
37
37
|
var XInputText = /** @class */ (function (_super) {
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.XInputTextDT = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var inputtext_1 = require("primereact/inputtext");
|
|
9
|
-
var XUtilsConversions_1 = require("
|
|
10
|
-
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
9
|
+
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
11
10
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
12
11
|
var XUtils_1 = require("./XUtils");
|
|
12
|
+
var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
|
|
13
13
|
var XInputTextDT = function (props) {
|
|
14
|
-
var xField =
|
|
14
|
+
var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPathStr(props.entity, props.field);
|
|
15
15
|
var onValueChange = function (field, rowData, newValue) {
|
|
16
16
|
// zmenime hodnotu v modeli (odtial sa hodnota cita)
|
|
17
17
|
rowData[field] = (0, XUtilsConversions_1.stringFromUI)(newValue);
|
|
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.XInputTextarea = void 0;
|
|
33
33
|
var react_1 = __importDefault(require("react"));
|
|
34
|
-
var XUtilsConversions_1 = require("
|
|
34
|
+
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
35
35
|
var XInput_1 = require("./XInput");
|
|
36
36
|
var inputtextarea_1 = require("primereact/inputtextarea");
|
|
37
37
|
var XUtils_1 = require("./XUtils");
|
|
@@ -4,7 +4,15 @@ import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereac
|
|
|
4
4
|
import { XSearchBrowseParams } from "./XSearchBrowseParams";
|
|
5
5
|
import { XAggregateType, XCustomFilter } from "../serverApi/FindParam";
|
|
6
6
|
import { XOnSaveOrCancelProp } from "./XFormBase";
|
|
7
|
+
import { IconType } from "primereact/utils";
|
|
8
|
+
import { ButtonProps } from "primereact/button";
|
|
7
9
|
export type XBetweenFilterProp = "row" | "column" | undefined;
|
|
10
|
+
export interface XAppButtonForRow {
|
|
11
|
+
key?: string;
|
|
12
|
+
icon?: IconType<ButtonProps>;
|
|
13
|
+
label: string;
|
|
14
|
+
onClick: (selectedRow: any) => void;
|
|
15
|
+
}
|
|
8
16
|
export interface XEditModeHandlers {
|
|
9
17
|
onStart: () => void;
|
|
10
18
|
onSave: () => void;
|
|
@@ -38,6 +46,7 @@ export interface XLazyDataTableProps {
|
|
|
38
46
|
onEdit?: (selectedRow: any) => void;
|
|
39
47
|
removeRow?: ((selectedRow: any) => Promise<boolean>) | boolean;
|
|
40
48
|
onRemoveRow?: XOnSaveOrCancelProp;
|
|
49
|
+
appButtonsForRow?: XAppButtonForRow[];
|
|
41
50
|
appButtons?: any;
|
|
42
51
|
filters?: DataTableFilterMeta;
|
|
43
52
|
customFilter?: XCustomFilter;
|
|
@@ -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("
|
|
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 =
|
|
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 =
|
|
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.
|
|
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 :
|
|
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 === "
|
|
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
|
-
//
|
|
637
|
-
|
|
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
|
};
|
|
@@ -748,7 +725,7 @@ var XLazyDataTable = function (props) {
|
|
|
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 =
|
|
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;
|
|
@@ -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)));
|
|
@@ -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 =
|
|
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 =
|
|
103
|
-
var xDisplayField =
|
|
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
|
|
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 =
|
|
151
|
-
var xEntityAssoc =
|
|
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
|
|
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 =
|
|
89
|
-
var xAssoc =
|
|
90
|
-
var xEntityAssoc =
|
|
91
|
-
var xDisplayField =
|
|
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 =
|
|
19
|
-
var xEntityAssoc =
|
|
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
|
package/lib/components/XUtils.js
CHANGED
|
@@ -89,6 +89,7 @@ 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";
|
|
@@ -454,7 +455,7 @@ var XUtils = /** @class */ (function () {
|
|
|
454
455
|
return __generator(this, function (_a) {
|
|
455
456
|
switch (_a.label) {
|
|
456
457
|
case 0:
|
|
457
|
-
xEntity =
|
|
458
|
+
xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(entity);
|
|
458
459
|
id = row[xEntity.idField];
|
|
459
460
|
return [4 /*yield*/, XUtils.post('removeRow', { entity: entity, id: id })];
|
|
460
461
|
case 1:
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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 (
|
|
79
|
-
switch (
|
|
50
|
+
var _a, _b;
|
|
51
|
+
return __generator(this, function (_c) {
|
|
52
|
+
switch (_c.label) {
|
|
80
53
|
case 0:
|
|
81
|
-
if (!(
|
|
82
|
-
_a =
|
|
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
|
|
86
|
-
|
|
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 "
|
|
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;
|