@michalrakus/x-react-web-lib 1.21.0 → 1.22.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/XFormHeader.d.ts +3 -0
- package/XFormHeader.js +5 -0
- package/gulpfile.js +1 -0
- package/lib/administration/XParamBrowse.js +1 -1
- package/lib/administration/XParamForm.js +2 -0
- package/lib/administration/XUserBrowse.js +1 -1
- package/lib/administration/XUserForm.js +12 -9
- package/lib/components/XCalendar.d.ts +15 -8
- package/lib/components/XCalendar.js +21 -2
- package/lib/components/XFormHeader.d.ts +4 -0
- package/lib/components/XFormHeader.js +11 -0
- package/lib/components/XInputDate.js +1 -1
- package/lib/components/XInputDateDT.js +1 -1
- package/lib/components/XLazyDataTable/XExportRowsDialog.d.ts +10 -5
- package/lib/components/XLazyDataTable/XExportRowsDialog.js +79 -44
- package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +1 -0
- package/lib/components/XLazyDataTable/XLazyDataTable.js +55 -24
- package/lib/components/XLazyDataTable/XMultilineSwitch.js +1 -1
- package/lib/components/XLazyDataTable/XOcfDropdown.js +1 -0
- package/lib/components/XUtils.d.ts +3 -1
- package/lib/components/XUtils.js +42 -10
- package/lib/components/locale/x-en.json +1 -0
- package/lib/serverApi/ExportImportParam.d.ts +28 -11
- package/lib/serverApi/ExportImportParam.js +11 -1
- package/lib/serverApi/XUtilsCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +12 -0
- package/lib/serverApi/XUtilsConversions.d.ts +11 -5
- package/lib/serverApi/XUtilsConversions.js +95 -24
- package/lib/serverApi/XUtilsMetadataCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsMetadataCommon.js +17 -0
- package/package.json +1 -1
package/XFormHeader.d.ts
ADDED
package/XFormHeader.js
ADDED
package/gulpfile.js
CHANGED
|
@@ -53,6 +53,7 @@ function generateApi(cb) {
|
|
|
53
53
|
"./lib/components/XFormBaseT",
|
|
54
54
|
"./lib/components/XFormDataTable2",
|
|
55
55
|
"./lib/components/XFormFooter",
|
|
56
|
+
"./lib/components/XFormHeader",
|
|
56
57
|
"./lib/components/XFormNavigator3",
|
|
57
58
|
"./lib/components/XHolders",
|
|
58
59
|
"./lib/components/XInputDate",
|
|
@@ -16,7 +16,7 @@ var XParamBrowse = function (props) {
|
|
|
16
16
|
// openForm pridavame automaticky v XFormNavigator3 pri renderovani komponentu
|
|
17
17
|
props.openForm(react_1.default.createElement(XParamForm_1.XParamForm, { id: selectedRow.id }));
|
|
18
18
|
};
|
|
19
|
-
return (react_1.default.createElement(XLazyDataTable_1.XLazyDataTable, { entity: "XParam", sortField: "id", rows: 30, customFilter: props.customFilter, onAddRow: onAddRow, onEdit: onEdit, removeRow: true, displayed: props.displayed },
|
|
19
|
+
return (react_1.default.createElement(XLazyDataTable_1.XLazyDataTable, { entity: "XParam", label: "Parameters", sortField: "id", rows: 30, customFilter: props.customFilter, onAddRow: onAddRow, onEdit: onEdit, removeRow: true, displayed: props.displayed },
|
|
20
20
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "id", header: "ID", width: "8rem" }),
|
|
21
21
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "code", header: "Code", width: "16rem" }),
|
|
22
22
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "name", header: "Name", width: "45rem" }),
|
|
@@ -32,6 +32,7 @@ var XInputDecimal_1 = require("../components/XInputDecimal");
|
|
|
32
32
|
var XInputDate_1 = require("../components/XInputDate");
|
|
33
33
|
var XInputText_1 = require("../components/XInputText");
|
|
34
34
|
var XFormFooter_1 = require("../components/XFormFooter");
|
|
35
|
+
var XFormHeader_1 = require("../components/XFormHeader");
|
|
35
36
|
var XParamForm = /** @class */ (function (_super) {
|
|
36
37
|
__extends(XParamForm, _super);
|
|
37
38
|
function XParamForm() {
|
|
@@ -42,6 +43,7 @@ var XParamForm = /** @class */ (function (_super) {
|
|
|
42
43
|
};
|
|
43
44
|
XParamForm.prototype.render = function () {
|
|
44
45
|
return (react_1.default.createElement("div", null,
|
|
46
|
+
react_1.default.createElement(XFormHeader_1.XFormHeader, { label: "Parameter" }),
|
|
45
47
|
react_1.default.createElement("div", { className: "x-form-row" },
|
|
46
48
|
react_1.default.createElement("div", { className: "x-form-col" },
|
|
47
49
|
react_1.default.createElement(XInputDecimal_1.XInputDecimal, { form: this, field: "id", label: "ID", readOnly: true }),
|
|
@@ -75,7 +75,7 @@ var XUserBrowse = function (props) {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}); };
|
|
78
|
-
return (react_1.default.createElement(XLazyDataTable_1.XLazyDataTable, { entity: "XUser", rows: 10, onAddRow: onAddRow, onEdit: onEdit, removeRow: onRemoveRow, displayed: props.displayed },
|
|
78
|
+
return (react_1.default.createElement(XLazyDataTable_1.XLazyDataTable, { entity: "XUser", label: "Users", rows: 10, onAddRow: onAddRow, onEdit: onEdit, removeRow: onRemoveRow, displayed: props.displayed },
|
|
79
79
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "id", header: "ID" }),
|
|
80
80
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "username", header: "Username", width: "17rem" }),
|
|
81
81
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "name", header: "Name", width: "17rem" }),
|
|
@@ -75,6 +75,7 @@ var XCheckbox_1 = require("../components/XCheckbox");
|
|
|
75
75
|
var XEnvVars_1 = require("../components/XEnvVars");
|
|
76
76
|
var XFormBaseModif_1 = require("../components/XFormBaseModif");
|
|
77
77
|
var XInputDate_1 = require("../components/XInputDate");
|
|
78
|
+
var XFormHeader_1 = require("../components/XFormHeader");
|
|
78
79
|
var XUserForm = /** @class */ (function (_super) {
|
|
79
80
|
__extends(XUserForm, _super);
|
|
80
81
|
function XUserForm(props) {
|
|
@@ -100,8 +101,9 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
100
101
|
var e_1;
|
|
101
102
|
return __generator(this, function (_a) {
|
|
102
103
|
switch (_a.label) {
|
|
103
|
-
case 0:
|
|
104
|
-
|
|
104
|
+
case 0: return [4 /*yield*/, this.validateSave()];
|
|
105
|
+
case 1:
|
|
106
|
+
if (!(_a.sent())) {
|
|
105
107
|
return [2 /*return*/];
|
|
106
108
|
}
|
|
107
109
|
// v deme nedovolime zmenit uzivatelov ktori sa pouzivaju na skusanie dema
|
|
@@ -134,18 +136,18 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
this.preSave(this.state.object);
|
|
137
|
-
_a.label =
|
|
138
|
-
case 1:
|
|
139
|
-
_a.trys.push([1, 3, , 4]);
|
|
140
|
-
return [4 /*yield*/, XUtils_1.XUtils.post('userSaveRow', { entity: this.getEntity(), object: this.state.object })];
|
|
139
|
+
_a.label = 2;
|
|
141
140
|
case 2:
|
|
142
|
-
_a.
|
|
143
|
-
return [
|
|
141
|
+
_a.trys.push([2, 4, , 5]);
|
|
142
|
+
return [4 /*yield*/, XUtils_1.XUtils.post('userSaveRow', { entity: this.getEntity(), object: this.state.object })];
|
|
144
143
|
case 3:
|
|
144
|
+
_a.sent();
|
|
145
|
+
return [3 /*break*/, 5];
|
|
146
|
+
case 4:
|
|
145
147
|
e_1 = _a.sent();
|
|
146
148
|
XUtils_1.XUtils.showErrorMessage("Save row failed.", e_1);
|
|
147
149
|
return [2 /*return*/]; // zostavame vo formulari
|
|
148
|
-
case
|
|
150
|
+
case 5:
|
|
149
151
|
this.props.openForm(null); // save zbehol, ideme naspet do browsu
|
|
150
152
|
return [2 /*return*/];
|
|
151
153
|
}
|
|
@@ -167,6 +169,7 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
167
169
|
];
|
|
168
170
|
}
|
|
169
171
|
return (react_1.default.createElement("div", null,
|
|
172
|
+
react_1.default.createElement(XFormHeader_1.XFormHeader, { label: "User" }),
|
|
170
173
|
react_1.default.createElement("div", { className: "x-form-row" },
|
|
171
174
|
react_1.default.createElement("div", { className: "x-form-col" },
|
|
172
175
|
react_1.default.createElement(XInputDecimal_1.XInputDecimal, { form: this, field: "id", label: "ID", readOnly: true, labelStyle: { width: '14rem' } }),
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { XDateScale } from "../serverApi/XUtilsConversions";
|
|
3
|
+
export declare const XCalendar: {
|
|
4
|
+
(props: {
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
value: Date | null;
|
|
7
|
+
onChange: (value: Date | null) => void;
|
|
8
|
+
readOnly?: boolean | undefined;
|
|
9
|
+
error?: string | undefined;
|
|
10
|
+
scale: XDateScale;
|
|
11
|
+
datetime?: boolean | undefined;
|
|
12
|
+
}): JSX.Element;
|
|
13
|
+
defaultProps: {
|
|
14
|
+
scale: XDateScale;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -84,7 +84,7 @@ var XCalendar = function (props) {
|
|
|
84
84
|
var onBlur = function (e) {
|
|
85
85
|
if (inputChanged) {
|
|
86
86
|
// poznamka: e.target.value aj inputValueState obsahuju tu istu string hodnotu
|
|
87
|
-
var value = (0, XUtilsConversions_1.dateFromUI)(e.target.value);
|
|
87
|
+
var value = (0, XUtilsConversions_1.dateFromUI)(e.target.value, props.scale);
|
|
88
88
|
props.onChange(value !== null && value !== void 0 ? value : null); // nekorektnu hodnotu reprezentovanu cez undefined budeme riesit akokeby user zadal null (field sa vyprazdni)
|
|
89
89
|
setInputChanged(false);
|
|
90
90
|
setInputValueState(undefined); // pre poriadok
|
|
@@ -100,9 +100,28 @@ var XCalendar = function (props) {
|
|
|
100
100
|
}
|
|
101
101
|
return inputValue;
|
|
102
102
|
};
|
|
103
|
+
var getView = function (dateScale) {
|
|
104
|
+
var view;
|
|
105
|
+
if (dateScale === XUtilsConversions_1.XDateScale.Date) {
|
|
106
|
+
view = "date";
|
|
107
|
+
}
|
|
108
|
+
else if (dateScale === XUtilsConversions_1.XDateScale.Month) {
|
|
109
|
+
view = "month";
|
|
110
|
+
}
|
|
111
|
+
else if (dateScale === XUtilsConversions_1.XDateScale.Year) {
|
|
112
|
+
view = "year";
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
116
|
+
}
|
|
117
|
+
return view;
|
|
118
|
+
};
|
|
103
119
|
var datetime = (_a = props.datetime) !== null && _a !== void 0 ? _a : false;
|
|
104
120
|
// poznamka: parseDateTime nerobi ziadny parse, nechceme aby Calendar "rusil" uzivatela pri typovani datumu
|
|
105
121
|
// konverzia (a volanie props.onChange) sa robi az pri onBlur
|
|
106
|
-
return (react_1.default.createElement(calendar_1.Calendar, __assign({ id: props.id, value: getInputValue(), onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), keepInvalid: true, parseDateTime: function (text) { return text; }, showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date', onSelect: onSelect, onBlur: onBlur }, XUtils_1.XUtils.createErrorProps(props.error))));
|
|
122
|
+
return (react_1.default.createElement(calendar_1.Calendar, __assign({ id: props.id, value: getInputValue(), onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, view: getView(props.scale), dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(props.scale), keepInvalid: true, parseDateTime: function (text) { return text; }, showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date', onSelect: onSelect, onBlur: onBlur }, XUtils_1.XUtils.createErrorProps(props.error))));
|
|
107
123
|
};
|
|
108
124
|
exports.XCalendar = XCalendar;
|
|
125
|
+
exports.XCalendar.defaultProps = {
|
|
126
|
+
scale: XUtilsConversions_1.XDateScale.Date
|
|
127
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.XFormHeader = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var XFormHeader = function (props) {
|
|
9
|
+
return (react_1.default.createElement("div", { className: "x-form-header" }, props.label));
|
|
10
|
+
};
|
|
11
|
+
exports.XFormHeader = XFormHeader;
|
|
@@ -42,7 +42,7 @@ var XInputDate = /** @class */ (function (_super) {
|
|
|
42
42
|
// note: style overrides size (width of the input according to character count)
|
|
43
43
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
44
44
|
react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
45
|
-
react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), datetime: this.xField.type === 'datetime' })));
|
|
45
|
+
react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), scale: this.xField.scale, datetime: this.xField.type === 'datetime' })));
|
|
46
46
|
};
|
|
47
47
|
return XInputDate;
|
|
48
48
|
}(XInput_1.XInput));
|
|
@@ -37,7 +37,7 @@ var XInputDateDT = /** @class */ (function (_super) {
|
|
|
37
37
|
this.onValueChangeBase(value, this.props.onChange);
|
|
38
38
|
};
|
|
39
39
|
XInputDateDT.prototype.render = function () {
|
|
40
|
-
return (react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), datetime: this.xField.type === 'datetime' }));
|
|
40
|
+
return (react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), scale: this.xField.scale, datetime: this.xField.type === 'datetime' }));
|
|
41
41
|
};
|
|
42
42
|
return XInputDateDT;
|
|
43
43
|
}(XInputDT_1.XInputDT));
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ExportType, LazyDataTableQueryParam } from "../../serverApi/ExportImportParam";
|
|
3
3
|
export interface XExportParams {
|
|
4
|
-
|
|
4
|
+
rowCount: number;
|
|
5
|
+
existsToManyAssoc: boolean;
|
|
5
6
|
queryParam: LazyDataTableQueryParam | any;
|
|
6
|
-
headers
|
|
7
|
+
headers: string[];
|
|
8
|
+
widths: string[];
|
|
9
|
+
fieldsToDuplicateValues?: string[];
|
|
7
10
|
fileName: string;
|
|
8
11
|
}
|
|
9
|
-
export
|
|
12
|
+
export interface XExportRowsDialogState {
|
|
10
13
|
dialogOpened: boolean;
|
|
14
|
+
exportParams?: XExportParams;
|
|
15
|
+
}
|
|
16
|
+
export declare const XExportRowsDialog: (props: {
|
|
17
|
+
dialogState: XExportRowsDialogState;
|
|
11
18
|
hideDialog: () => void;
|
|
12
|
-
rowCount?: number;
|
|
13
19
|
exportTypeOptions?: ExportType[];
|
|
14
|
-
exportParams: XExportParams | (() => XExportParams);
|
|
15
20
|
}) => JSX.Element;
|
|
@@ -87,46 +87,65 @@ var XUtils_1 = require("../XUtils");
|
|
|
87
87
|
var XUtilsConversions_1 = require("../../serverApi/XUtilsConversions");
|
|
88
88
|
var XLocale_1 = require("../XLocale");
|
|
89
89
|
var XExportRowsDialog = function (props) {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
var
|
|
90
|
+
var _a, _b, _c, _d, _e;
|
|
91
|
+
var _f = __read((0, react_1.useState)(ExportImportParam_1.ExportType.Excel), 2), exportType = _f[0], setExportType = _f[1];
|
|
92
|
+
var _g = __read((0, react_1.useState)(true), 2), createHeaderLine = _g[0], setCreateHeaderLine = _g[1];
|
|
93
|
+
var _h = __read((0, react_1.useState)(ExportImportParam_1.XMultilineExportType.Multiline), 2), detailRowsExport = _h[0], setDetailRowsExport = _h[1];
|
|
94
|
+
var _j = __read((0, react_1.useState)(ExportImportParam_1.CsvSeparator.Semicolon), 2), csvSeparator = _j[0], setCsvSeparator = _j[1];
|
|
95
|
+
var _k = __read((0, react_1.useState)(ExportImportParam_1.CsvDecimalFormat.Comma), 2), decimalFormat = _k[0], setDecimalFormat = _k[1];
|
|
96
|
+
var _l = __read((0, react_1.useState)(ExportImportParam_1.CsvEncoding.Win1250), 2), csvEncoding = _l[0], setCsvEncoding = _l[1];
|
|
96
97
|
// bez tejto metody by pri opetovnom otvoreni dialogu ponechal povodne hodnoty
|
|
97
98
|
var onShow = function () {
|
|
98
|
-
setExportType(ExportImportParam_1.ExportType.
|
|
99
|
-
setCreateHeaderLine(true);
|
|
99
|
+
setExportType(ExportImportParam_1.ExportType.Excel);
|
|
100
|
+
setCreateHeaderLine(true);
|
|
101
|
+
setDetailRowsExport(ExportImportParam_1.XMultilineExportType.Multiline);
|
|
100
102
|
setCsvSeparator(ExportImportParam_1.CsvSeparator.Semicolon);
|
|
101
103
|
setDecimalFormat(ExportImportParam_1.CsvDecimalFormat.Comma);
|
|
102
104
|
setCsvEncoding(ExportImportParam_1.CsvEncoding.Win1250);
|
|
103
105
|
};
|
|
104
106
|
var onExport = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
|
-
var exportParams,
|
|
107
|
+
var exportParams, apiPath, requestPayload, exportExcelParam, exportCsvParam, exportJsonParam, response, e_1, fileExt, fileName, respBlob, url, a;
|
|
106
108
|
return __generator(this, function (_a) {
|
|
107
109
|
switch (_a.label) {
|
|
108
110
|
case 0:
|
|
109
111
|
// export vykoname az po zatvoreni dialogu - moze dlho trvat a pobezi asynchronne (user zatial moze pracovat s aplikaciou)
|
|
110
112
|
// zavrieme dialog
|
|
111
113
|
props.hideDialog();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
exportParams = props.dialogState.exportParams;
|
|
115
|
+
if (exportType === ExportImportParam_1.ExportType.Excel) {
|
|
116
|
+
apiPath = "x-lazy-data-table-export-excel";
|
|
117
|
+
exportExcelParam = {
|
|
118
|
+
queryParam: exportParams.queryParam,
|
|
119
|
+
excelCsvParam: createExcelCsvParam(exportParams),
|
|
120
|
+
widths: exportParams.widths
|
|
121
|
+
};
|
|
122
|
+
requestPayload = exportExcelParam;
|
|
114
123
|
}
|
|
115
|
-
else {
|
|
116
|
-
|
|
124
|
+
else if (exportType === ExportImportParam_1.ExportType.Csv) {
|
|
125
|
+
apiPath = "x-lazy-data-table-export-csv";
|
|
126
|
+
exportCsvParam = {
|
|
127
|
+
queryParam: exportParams.queryParam,
|
|
128
|
+
excelCsvParam: createExcelCsvParam(exportParams),
|
|
129
|
+
csvParam: {
|
|
130
|
+
csvSeparator: csvSeparator, csvDecimalFormat: decimalFormat, csvEncoding: csvEncoding
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
requestPayload = exportCsvParam;
|
|
134
|
+
}
|
|
135
|
+
else if (exportType === ExportImportParam_1.ExportType.Json) {
|
|
136
|
+
apiPath = "x-lazy-data-table-export-json";
|
|
137
|
+
exportJsonParam = {
|
|
138
|
+
queryParam: exportParams.queryParam
|
|
139
|
+
};
|
|
140
|
+
requestPayload = exportJsonParam;
|
|
117
141
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
csvParam = { useHeaderLine: createHeaderLine, csvSeparator: csvSeparator, csvDecimalFormat: decimalFormat, csvEncoding: csvEncoding };
|
|
121
|
-
if (csvParam.useHeaderLine) {
|
|
122
|
-
csvParam.headers = exportParams.headers;
|
|
123
|
-
}
|
|
142
|
+
else {
|
|
143
|
+
throw "Unimplemented exportType = ".concat(exportType);
|
|
124
144
|
}
|
|
125
|
-
exportParam = { exportType: exportType, csvParam: csvParam, queryParam: exportParams.queryParam };
|
|
126
145
|
_a.label = 1;
|
|
127
146
|
case 1:
|
|
128
147
|
_a.trys.push([1, 3, , 4]);
|
|
129
|
-
return [4 /*yield*/, XUtils_1.XUtils.fetchBasicJson(
|
|
148
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchBasicJson(apiPath, requestPayload)];
|
|
130
149
|
case 2:
|
|
131
150
|
response = _a.sent();
|
|
132
151
|
return [3 /*break*/, 4];
|
|
@@ -135,7 +154,7 @@ var XExportRowsDialog = function (props) {
|
|
|
135
154
|
XUtils_1.XUtils.showErrorMessage("Export failed.", e_1);
|
|
136
155
|
return [2 /*return*/];
|
|
137
156
|
case 4:
|
|
138
|
-
fileExt = exportType;
|
|
157
|
+
fileExt = exportType === ExportImportParam_1.ExportType.Excel ? "xlsx" : exportType;
|
|
139
158
|
fileName = "".concat(exportParams.fileName, ".").concat(fileExt);
|
|
140
159
|
return [4 /*yield*/, response.blob()];
|
|
141
160
|
case 5:
|
|
@@ -149,36 +168,52 @@ var XExportRowsDialog = function (props) {
|
|
|
149
168
|
}
|
|
150
169
|
});
|
|
151
170
|
}); };
|
|
152
|
-
var
|
|
153
|
-
|
|
171
|
+
var createExcelCsvParam = function (exportParams) {
|
|
172
|
+
return {
|
|
173
|
+
headers: createHeaderLine ? exportParams.headers : undefined,
|
|
174
|
+
fieldsToDuplicateValues: exportParams.fieldsToDuplicateValues,
|
|
175
|
+
toManyAssocExport: detailRowsExport,
|
|
176
|
+
multilineTextExport: ExportImportParam_1.XMultilineExportType.Multiline // TODO - dorobit aj tuto dropdown kde si uzivatel vyberie ci chce mat v texte \n alebo nechce - aj na backende treba dorobit
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
var elem = [];
|
|
180
|
+
if (props.dialogState.dialogOpened) {
|
|
181
|
+
if (exportType === ExportImportParam_1.ExportType.Excel || exportType === ExportImportParam_1.ExportType.Csv) {
|
|
182
|
+
elem.push(react_1.default.createElement("div", { key: "expCreateHeaderLine", className: "field grid" },
|
|
183
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expCreateHeaderLine')),
|
|
184
|
+
react_1.default.createElement(checkbox_1.Checkbox, { checked: createHeaderLine, onChange: function (e) { return setCreateHeaderLine(e.checked); } })));
|
|
185
|
+
if ((_a = props.dialogState.exportParams) === null || _a === void 0 ? void 0 : _a.existsToManyAssoc) {
|
|
186
|
+
elem.push(react_1.default.createElement("div", { key: "expDetailRowsExport", className: "field grid" },
|
|
187
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expDetailRowsExport')),
|
|
188
|
+
react_1.default.createElement(dropdown_1.Dropdown, { value: detailRowsExport, options: XUtils_1.XUtils.multilineExportTypeOptions, onChange: function (e) { return setDetailRowsExport(e.value); } })));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
154
191
|
if (exportType === ExportImportParam_1.ExportType.Csv) {
|
|
155
|
-
elem
|
|
156
|
-
react_1.default.createElement("div", { className: "field grid" },
|
|
157
|
-
react_1.default.createElement("label", { className: "col-fixed", style: { width: '
|
|
158
|
-
react_1.default.createElement(checkbox_1.Checkbox, { checked: createHeaderLine, onChange: function (e) { return setCreateHeaderLine(e.checked); } })),
|
|
159
|
-
react_1.default.createElement("div", { className: "field grid" },
|
|
160
|
-
react_1.default.createElement("label", { className: "col-fixed", style: { width: '10rem' } }, (0, XLocale_1.xLocaleOption)('expCsvSeparator')),
|
|
192
|
+
elem.push([
|
|
193
|
+
react_1.default.createElement("div", { key: "expCsvSeparator", className: "field grid" },
|
|
194
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expCsvSeparator')),
|
|
161
195
|
react_1.default.createElement(dropdown_1.Dropdown, { value: csvSeparator, options: XUtils_1.XUtils.csvSeparatorOptions, onChange: function (e) { return setCsvSeparator(e.value); } })),
|
|
162
|
-
react_1.default.createElement("div", { className: "field grid" },
|
|
163
|
-
react_1.default.createElement("label", { className: "col-fixed", style: { width: '
|
|
196
|
+
react_1.default.createElement("div", { key: "expDecimalFormat", className: "field grid" },
|
|
197
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expDecimalFormat')),
|
|
164
198
|
react_1.default.createElement(dropdown_1.Dropdown, { value: decimalFormat, options: XUtils_1.XUtils.decimalFormatOptions, onChange: function (e) { return setDecimalFormat(e.value); } })),
|
|
165
|
-
react_1.default.createElement("div", { className: "field grid" },
|
|
166
|
-
react_1.default.createElement("label", { className: "col-fixed", style: { width: '
|
|
167
|
-
react_1.default.createElement(dropdown_1.Dropdown, { value: csvEncoding, options: XUtils_1.XUtils.csvEncodingOptions, onChange: function (e) { return setCsvEncoding(e.value); } }))
|
|
199
|
+
react_1.default.createElement("div", { key: "expEncoding", className: "field grid" },
|
|
200
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expEncoding')),
|
|
201
|
+
react_1.default.createElement(dropdown_1.Dropdown, { value: csvEncoding, options: XUtils_1.XUtils.csvEncodingOptions, onChange: function (e) { return setCsvEncoding(e.value); } }))
|
|
202
|
+
]);
|
|
168
203
|
}
|
|
169
204
|
}
|
|
170
205
|
// poznamka: renderovanie vnutornych komponentov Dialogu sa zavola az po otvoreni dialogu
|
|
171
|
-
return (react_1.default.createElement(dialog_1.Dialog, { visible: props.dialogOpened, onShow: onShow, onHide: function () { return props.hideDialog(); } },
|
|
172
|
-
props.rowCount ?
|
|
173
|
-
react_1.default.createElement("div", { className: "field grid" },
|
|
174
|
-
react_1.default.createElement("label", { className: "col-fixed", style: { width: '
|
|
175
|
-
react_1.default.createElement(inputtext_1.InputText, { value: (0, XUtilsConversions_1.numberAsUI)((
|
|
206
|
+
return (react_1.default.createElement(dialog_1.Dialog, { visible: props.dialogState.dialogOpened, onShow: onShow, onHide: function () { return props.hideDialog(); } },
|
|
207
|
+
((_b = props.dialogState.exportParams) === null || _b === void 0 ? void 0 : _b.rowCount) ?
|
|
208
|
+
react_1.default.createElement("div", { key: "expRowCount", className: "field grid" },
|
|
209
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expRowCount')),
|
|
210
|
+
react_1.default.createElement(inputtext_1.InputText, { value: (0, XUtilsConversions_1.numberAsUI)((_d = (_c = props.dialogState.exportParams) === null || _c === void 0 ? void 0 : _c.rowCount) !== null && _d !== void 0 ? _d : null, 0), readOnly: true }))
|
|
176
211
|
: null,
|
|
177
|
-
react_1.default.createElement("div", { className: "field grid" },
|
|
178
|
-
react_1.default.createElement("label", { className: "col-fixed", style: { width: '
|
|
179
|
-
react_1.default.createElement(dropdown_1.Dropdown, { value: exportType, options: (
|
|
212
|
+
react_1.default.createElement("div", { key: "expExportType", className: "field grid" },
|
|
213
|
+
react_1.default.createElement("label", { className: "col-fixed", style: { width: '12rem' } }, (0, XLocale_1.xLocaleOption)('expExportType')),
|
|
214
|
+
react_1.default.createElement(dropdown_1.Dropdown, { value: exportType, options: (_e = props.exportTypeOptions) !== null && _e !== void 0 ? _e : XUtils_1.XUtils.exportTypeOptions, onChange: function (e) { return setExportType(e.value); } })),
|
|
180
215
|
elem,
|
|
181
|
-
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
216
|
+
react_1.default.createElement("div", { key: "exportRows", className: "flex justify-content-center" },
|
|
182
217
|
react_1.default.createElement(XButton_1.XButton, { label: (0, XLocale_1.xLocaleOption)('exportRows'), onClick: onExport }))));
|
|
183
218
|
};
|
|
184
219
|
exports.XExportRowsDialog = XExportRowsDialog;
|
|
@@ -245,11 +245,11 @@ var XLazyDataTable = function (props) {
|
|
|
245
245
|
var _k = __read((0, react_1.useState)(XUtils_1.XUtils.createMultiSortMeta(props.sortField)), 2), multiSortMeta = _k[0], setMultiSortMeta = _k[1];
|
|
246
246
|
var _l = __read((0, react_1.useState)(null), 2), selectedRow = _l[0], setSelectedRow = _l[1];
|
|
247
247
|
var _m = __read((_a = props.dataLoadedState) !== null && _a !== void 0 ? _a : (0, react_1.useState)(false), 2), dataLoaded = _m[0], setDataLoaded = _m[1]; // priznak kde si zapiseme, ci uz sme nacitali data
|
|
248
|
-
var _o = __read((0, react_1.useState)(false), 2),
|
|
249
|
-
|
|
250
|
-
var
|
|
251
|
-
var
|
|
252
|
-
var
|
|
248
|
+
var _o = __read((0, react_1.useState)({ dialogOpened: false }), 2), exportRowsDialogState = _o[0], setExportRowsDialogState = _o[1];
|
|
249
|
+
//const [exportRowsDialogRowCount, setExportRowsDialogRowCount] = useState<number>(); // param pre dialog
|
|
250
|
+
var _p = __read((0, react_1.useState)(filtersInit), 2), filtersAfterFiltering = _p[0], setFiltersAfterFiltering = _p[1]; // sem si odkladame stav filtra po kliknuti na button Filter (chceme exportovat presne to co vidno vyfiltrovane)
|
|
251
|
+
var _q = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValueAfterFiltering = _q[0], setFtsInputValueAfterFiltering = _q[1]; // tak isto ako filtersAfterFiltering
|
|
252
|
+
var _r = __read((0, react_1.useState)(undefined), 2), optionalCustomFilterAfterFiltering = _r[0], setOptionalCustomFilterAfterFiltering = _r[1]; // tak isto ako filtersAfterFiltering
|
|
253
253
|
// parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
|
|
254
254
|
(0, react_1.useEffect)(function () {
|
|
255
255
|
// jednoduchy sposob - nepouzivame parameter props.displayed a priznak dataLoaded
|
|
@@ -430,6 +430,28 @@ var XLazyDataTable = function (props) {
|
|
|
430
430
|
}
|
|
431
431
|
return headers;
|
|
432
432
|
};
|
|
433
|
+
var getWidths = function () {
|
|
434
|
+
var e_5, _a;
|
|
435
|
+
var _b;
|
|
436
|
+
// vrati sirky stlpcov napr. ['7.75rem', '20rem', '8.5rem', '8.5rem', '6rem']
|
|
437
|
+
// nevracia aktualne sirky stlpcov (po manualnom rozsireni) ale tie ktore boli nastavene/vypocitane v kode
|
|
438
|
+
var widths = [];
|
|
439
|
+
var columns = dataTableEl.current.props.children;
|
|
440
|
+
try {
|
|
441
|
+
for (var columns_5 = __values(columns), columns_5_1 = columns_5.next(); !columns_5_1.done; columns_5_1 = columns_5.next()) {
|
|
442
|
+
var column = columns_5_1.value;
|
|
443
|
+
widths.push((_b = column.props.headerStyle) === null || _b === void 0 ? void 0 : _b.width);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
447
|
+
finally {
|
|
448
|
+
try {
|
|
449
|
+
if (columns_5_1 && !columns_5_1.done && (_a = columns_5.return)) _a.call(columns_5);
|
|
450
|
+
}
|
|
451
|
+
finally { if (e_5) throw e_5.error; }
|
|
452
|
+
}
|
|
453
|
+
return widths;
|
|
454
|
+
};
|
|
433
455
|
var hasContentTypeHtml = function () {
|
|
434
456
|
var columns = props.children;
|
|
435
457
|
return columns.some(function (column) { return column.props.contentType === "html"; });
|
|
@@ -467,7 +489,7 @@ var XLazyDataTable = function (props) {
|
|
|
467
489
|
}
|
|
468
490
|
};
|
|
469
491
|
var onClickRemoveRow = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
470
|
-
var reread,
|
|
492
|
+
var reread, e_6, e_7;
|
|
471
493
|
return __generator(this, function (_a) {
|
|
472
494
|
switch (_a.label) {
|
|
473
495
|
case 0:
|
|
@@ -482,8 +504,8 @@ var XLazyDataTable = function (props) {
|
|
|
482
504
|
reread = _a.sent();
|
|
483
505
|
return [3 /*break*/, 4];
|
|
484
506
|
case 3:
|
|
485
|
-
|
|
486
|
-
XUtils_1.XUtils.showErrorMessage((0, XLocale_1.xLocaleOption)('removeRowFailed'),
|
|
507
|
+
e_6 = _a.sent();
|
|
508
|
+
XUtils_1.XUtils.showErrorMessage((0, XLocale_1.xLocaleOption)('removeRowFailed'), e_6);
|
|
487
509
|
return [3 /*break*/, 4];
|
|
488
510
|
case 4:
|
|
489
511
|
if (reread) {
|
|
@@ -505,8 +527,8 @@ var XLazyDataTable = function (props) {
|
|
|
505
527
|
_a.sent();
|
|
506
528
|
return [3 /*break*/, 9];
|
|
507
529
|
case 8:
|
|
508
|
-
|
|
509
|
-
XUtils_1.XUtils.showErrorMessage((0, XLocale_1.xLocaleOption)('removeRowFailed'),
|
|
530
|
+
e_7 = _a.sent();
|
|
531
|
+
XUtils_1.XUtils.showErrorMessage((0, XLocale_1.xLocaleOption)('removeRowFailed'), e_7);
|
|
510
532
|
return [3 /*break*/, 9];
|
|
511
533
|
case 9:
|
|
512
534
|
loadData();
|
|
@@ -531,10 +553,11 @@ var XLazyDataTable = function (props) {
|
|
|
531
553
|
}
|
|
532
554
|
};
|
|
533
555
|
var onClickExport = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
534
|
-
var findParam, findResult;
|
|
556
|
+
var fields, findParam, findResult, exportParams;
|
|
535
557
|
return __generator(this, function (_a) {
|
|
536
558
|
switch (_a.label) {
|
|
537
559
|
case 0:
|
|
560
|
+
fields = getFields(false);
|
|
538
561
|
findParam = {
|
|
539
562
|
resultType: FindParam_1.ResultType.OnlyRowCount,
|
|
540
563
|
first: first,
|
|
@@ -544,36 +567,41 @@ var XLazyDataTable = function (props) {
|
|
|
544
567
|
customFilterItems: createXCustomFilterItems(customFilterItems, optionalCustomFilterAfterFiltering),
|
|
545
568
|
multiSortMeta: multiSortMeta,
|
|
546
569
|
entity: props.entity,
|
|
547
|
-
fields:
|
|
570
|
+
fields: fields,
|
|
548
571
|
aggregateItems: aggregateItems
|
|
549
572
|
};
|
|
550
573
|
return [4 /*yield*/, findByFilter(findParam)];
|
|
551
574
|
case 1:
|
|
552
575
|
findResult = _a.sent();
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
setExportRowsDialogOpened(true);
|
|
576
|
+
exportParams = createExportParams(fields, findResult.totalRecords);
|
|
577
|
+
setExportRowsDialogState({ dialogOpened: true, exportParams: exportParams });
|
|
556
578
|
return [2 /*return*/];
|
|
557
579
|
}
|
|
558
580
|
});
|
|
559
581
|
}); };
|
|
560
|
-
var createExportParams = function () {
|
|
582
|
+
var createExportParams = function (fields, rowCount) {
|
|
561
583
|
var queryParam = {
|
|
562
584
|
filters: filtersAfterFiltering,
|
|
563
585
|
fullTextSearch: createXFullTextSearch(ftsInputValueAfterFiltering),
|
|
564
586
|
customFilterItems: createXCustomFilterItems(customFilterItems, optionalCustomFilterAfterFiltering),
|
|
565
587
|
multiSortMeta: multiSortMeta,
|
|
566
588
|
entity: props.entity,
|
|
567
|
-
fields:
|
|
568
|
-
fieldsToDuplicateValues: props.exportFieldsToDuplicateValues
|
|
589
|
+
fields: fields
|
|
569
590
|
};
|
|
570
591
|
return {
|
|
571
|
-
|
|
592
|
+
rowCount: rowCount,
|
|
593
|
+
existsToManyAssoc: existsToManyAssoc(fields),
|
|
572
594
|
queryParam: queryParam,
|
|
573
595
|
headers: getHeaders(),
|
|
596
|
+
widths: getWidths(),
|
|
597
|
+
fieldsToDuplicateValues: props.exportFieldsToDuplicateValues,
|
|
574
598
|
fileName: "".concat(props.entity)
|
|
575
599
|
};
|
|
576
600
|
};
|
|
601
|
+
var existsToManyAssoc = function (fields) {
|
|
602
|
+
var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.entity);
|
|
603
|
+
return fields.some(function (value) { return XUtilsMetadataCommon_1.XUtilsMetadataCommon.hasPathToManyAssoc(xEntity, value); });
|
|
604
|
+
};
|
|
577
605
|
var onClickChoose = function () {
|
|
578
606
|
//console.log("zavolany onClickChoose");
|
|
579
607
|
if (selectedRow !== null) {
|
|
@@ -852,12 +880,12 @@ var XLazyDataTable = function (props) {
|
|
|
852
880
|
// display: 'flex' umiestni XCalendar elementy vedla seba
|
|
853
881
|
filterElement =
|
|
854
882
|
react_1.default.createElement("div", { style: betweenFilter === "row" ? { display: 'flex' } : undefined },
|
|
855
|
-
react_1.default.createElement(XCalendar_1.XCalendar, { value: getFilterValue1(childColumn.props.field), onChange: function (value) { return setFilterValue1(childColumn.props.field, value); }, datetime: xField.type === "datetime" }),
|
|
856
|
-
react_1.default.createElement(XCalendar_1.XCalendar, { value: getFilterValue2(childColumn.props.field), onChange: function (value) { return setFilterValue2(childColumn.props.field, value); }, datetime: xField.type === "datetime" }));
|
|
883
|
+
react_1.default.createElement(XCalendar_1.XCalendar, { value: getFilterValue1(childColumn.props.field), onChange: function (value) { return setFilterValue1(childColumn.props.field, value); }, scale: xField.scale, datetime: xField.type === "datetime" }),
|
|
884
|
+
react_1.default.createElement(XCalendar_1.XCalendar, { value: getFilterValue2(childColumn.props.field), onChange: function (value) { return setFilterValue2(childColumn.props.field, value); }, scale: xField.scale, datetime: xField.type === "datetime" }));
|
|
857
885
|
}
|
|
858
886
|
else {
|
|
859
887
|
var dateValue = getFilterValue(childColumn.props.field);
|
|
860
|
-
filterElement = react_1.default.createElement(XCalendar_1.XCalendar, { value: dateValue, onChange: function (value) { return setFilterValue(childColumn.props.field, value); }, datetime: xField.type === "datetime" });
|
|
888
|
+
filterElement = react_1.default.createElement(XCalendar_1.XCalendar, { value: dateValue, onChange: function (value) { return setFilterValue(childColumn.props.field, value); }, scale: xField.scale, datetime: xField.type === "datetime" });
|
|
861
889
|
}
|
|
862
890
|
}
|
|
863
891
|
else if (xField.type === "decimal" || xField.type === "number") {
|
|
@@ -953,13 +981,16 @@ var XLazyDataTable = function (props) {
|
|
|
953
981
|
return react_1.default.createElement(column_1.Column, { field: childColumn.props.field, header: header, footer: footer, filter: true, sortable: true, filterElement: filterElement, dataType: dataType, showFilterMenu: showFilterMenu, showClearButton: showClearButton, body: body, headerStyle: headerStyle, align: align });
|
|
954
982
|
});
|
|
955
983
|
// align-items-center centruje vertikalne (posuva smerom dolu do stredu)
|
|
984
|
+
// x-lazy-datatable-label-right-compensation - vyvazuje label, aby item-y v strede isli aspon priblizne do stredu
|
|
956
985
|
return (react_1.default.createElement("div", null,
|
|
957
986
|
react_1.default.createElement("div", { className: "flex justify-content-center align-items-center" },
|
|
987
|
+
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label" }, props.label) : null,
|
|
958
988
|
ftsInputValue ? react_1.default.createElement(XFtsInput_1.XFtsInput, { value: ftsInputValue, onChange: function (value) { return setFtsInputValue(value); } }) : null,
|
|
959
989
|
react_1.default.createElement(XButton_1.XButton, { key: "filter", label: (0, XLocale_1.xLocaleOption)('filter'), onClick: onClickFilter }),
|
|
960
990
|
react_1.default.createElement(XButton_1.XButton, { key: "clearFilter", label: (0, XLocale_1.xLocaleOption)('clearFilter'), onClick: onClickClearFilter }),
|
|
961
991
|
props.optionalCustomFilters ? react_1.default.createElement(XOcfDropdown_1.XOcfDropdown, { optionalCustomFilters: props.optionalCustomFilters, value: optionalCustomFilter, onChange: function (value) { return setOptionalCustomFilter(value); }, className: "m-1" }) : null,
|
|
962
|
-
props.multilineSwitch ? react_1.default.createElement(XMultilineSwitch_1.XMultilineSwitch, { value: multilineSwitchValue, onChange: function (value) { return setMultilineSwitchValue(value); }, className: "m-1" }) : null
|
|
992
|
+
props.multilineSwitch ? react_1.default.createElement(XMultilineSwitch_1.XMultilineSwitch, { value: multilineSwitchValue, onChange: function (value) { return setMultilineSwitchValue(value); }, className: "m-1" }) : null,
|
|
993
|
+
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label-right-compensation" }) : null),
|
|
963
994
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
964
995
|
react_1.default.createElement(datatable_1.DataTable, { value: value.rowList, dataKey: dataKey, paginator: props.paginator, rows: rows, totalRecords: value.totalRecords, lazy: true, first: first, onPage: onPage, loading: loading, filterDisplay: props.filterDisplay, filters: filters, onFilter: onFilter, sortMode: "multiple", removableSort: true, multiSortMeta: multiSortMeta, onSort: onSort, selectionMode: "single", selection: selectedRow, onSelectionChange: onSelectionChange, onRowDoubleClick: onRowDoubleClick, rowClassName: props.rowClassName, ref: dataTableEl, className: "p-datatable-sm x-lazy-datatable", resizableColumns: true, columnResizeMode: "expand", tableStyle: tableStyle, paginatorLeft: paginatorLeft, paginatorRight: paginatorRight, scrollable: props.scrollable, scrollHeight: scrollHeight, style: style }, columnElemList)),
|
|
965
996
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
@@ -970,7 +1001,7 @@ var XLazyDataTable = function (props) {
|
|
|
970
1001
|
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,
|
|
971
1002
|
props.appButtons,
|
|
972
1003
|
props.searchBrowseParams !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "choose", label: (0, XLocale_1.xLocaleOption)('chooseRow'), onClick: onClickChoose }) : null,
|
|
973
|
-
exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { key: "exportRowsDialog",
|
|
1004
|
+
exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { key: "exportRowsDialog", dialogState: exportRowsDialogState, hideDialog: function () { return setExportRowsDialogState({ dialogOpened: false }); } }) : null),
|
|
974
1005
|
hasContentTypeHtml() ? react_1.default.createElement(editor_1.Editor, { style: { display: 'none' }, showHeader: false }) : null /* we want to import css if needed (<style type="text/css" data-primereact-style-id="editor">) */));
|
|
975
1006
|
};
|
|
976
1007
|
exports.XLazyDataTable = XLazyDataTable;
|
|
@@ -15,6 +15,6 @@ var XMultilineSwitch = function (props) {
|
|
|
15
15
|
var itemTemplate = function (option) {
|
|
16
16
|
return react_1.default.createElement("i", { className: option.icon });
|
|
17
17
|
};
|
|
18
|
-
return (react_1.default.createElement(selectbutton_1.SelectButton, { value: props.value, onChange: function (e) { return props.onChange(e.value); }, options: options, optionValue: "value", itemTemplate: itemTemplate, className: props.className }));
|
|
18
|
+
return (react_1.default.createElement(selectbutton_1.SelectButton, { value: props.value, onChange: function (e) { return props.onChange(e.value); }, options: options, optionValue: "value", itemTemplate: itemTemplate, allowEmpty: false, className: props.className }));
|
|
19
19
|
};
|
|
20
20
|
exports.XMultilineSwitch = XMultilineSwitch;
|
|
@@ -31,6 +31,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
31
31
|
exports.XOcfDropdown = void 0;
|
|
32
32
|
var react_1 = __importDefault(require("react"));
|
|
33
33
|
var dropdown_1 = require("primereact/dropdown");
|
|
34
|
+
// dropdown for optional custom filter (ocf)
|
|
34
35
|
var XOcfDropdown = function (props) {
|
|
35
36
|
var onChange = function (e) {
|
|
36
37
|
var value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XToken } from "./XToken";
|
|
2
|
-
import { CsvDecimalFormat, CsvEncoding, CsvSeparator, ExportType } from "../serverApi/ExportImportParam";
|
|
2
|
+
import { CsvDecimalFormat, CsvEncoding, CsvSeparator, ExportType, XMultilineExportType } from "../serverApi/ExportImportParam";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { XEnvVar } from "./XEnvVars";
|
|
5
5
|
import { XError, XErrorMap } from "./XErrors";
|
|
@@ -36,6 +36,7 @@ export declare class XUtils {
|
|
|
36
36
|
static xTokenPublic: XToken;
|
|
37
37
|
private static appFormMap;
|
|
38
38
|
static exportTypeOptions: ExportType[];
|
|
39
|
+
static multilineExportTypeOptions: XMultilineExportType[];
|
|
39
40
|
static csvSeparatorOptions: CsvSeparator[];
|
|
40
41
|
static decimalFormatOptions: CsvDecimalFormat[];
|
|
41
42
|
static csvEncodingOptions: CsvEncoding[];
|
|
@@ -60,6 +61,7 @@ export declare class XUtils {
|
|
|
60
61
|
static fetchString(path: string, value: any): Promise<string>;
|
|
61
62
|
static fetch(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
|
|
62
63
|
static post(path: string, value: any): Promise<Response>;
|
|
64
|
+
static openExcelReport(apiPath: string, requestPayload: any, fileName?: string): Promise<boolean>;
|
|
63
65
|
static fetchBasicJson(path: string, value: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
|
64
66
|
static fetchFile(path: string, jsonFieldValue: any, fileToPost: any): Promise<any>;
|
|
65
67
|
static fetchBasicAuthBasic(path: string, headers: any, body: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
package/lib/components/XUtils.js
CHANGED
|
@@ -334,6 +334,36 @@ var XUtils = /** @class */ (function () {
|
|
|
334
334
|
XUtils.post = function (path, value) {
|
|
335
335
|
return XUtils.fetchBasicJson(path, value);
|
|
336
336
|
};
|
|
337
|
+
XUtils.openExcelReport = function (apiPath, requestPayload, fileName) {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
339
|
+
var response, e_5, fileNameExt, respBlob, url, a;
|
|
340
|
+
return __generator(this, function (_a) {
|
|
341
|
+
switch (_a.label) {
|
|
342
|
+
case 0:
|
|
343
|
+
_a.trys.push([0, 2, , 3]);
|
|
344
|
+
return [4 /*yield*/, XUtils.fetchBasicJson(apiPath, requestPayload)];
|
|
345
|
+
case 1:
|
|
346
|
+
response = _a.sent();
|
|
347
|
+
return [3 /*break*/, 3];
|
|
348
|
+
case 2:
|
|
349
|
+
e_5 = _a.sent();
|
|
350
|
+
XUtils.showErrorMessage("Nepodarilo sa vytvori\u0165/stiahnu\u0165 xlsx s\u00FAbor.", e_5); // dalsie info (apiPath, payload) by mali byt v "e"
|
|
351
|
+
return [2 /*return*/, false];
|
|
352
|
+
case 3:
|
|
353
|
+
fileNameExt = "".concat(fileName !== null && fileName !== void 0 ? fileName : apiPath, ".xlsx");
|
|
354
|
+
return [4 /*yield*/, response.blob()];
|
|
355
|
+
case 4:
|
|
356
|
+
respBlob = _a.sent();
|
|
357
|
+
url = window.URL.createObjectURL(respBlob);
|
|
358
|
+
a = document.createElement('a');
|
|
359
|
+
a.href = url;
|
|
360
|
+
a.download = fileNameExt;
|
|
361
|
+
a.click();
|
|
362
|
+
return [2 /*return*/, true];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
};
|
|
337
367
|
XUtils.fetchBasicJson = function (path, value, usePublicToken) {
|
|
338
368
|
return XUtils.fetchBasic(path, { 'Content-Type': 'application/json' }, XUtilsCommon_1.XUtilsCommon.objectAsJSON(value), usePublicToken);
|
|
339
369
|
};
|
|
@@ -538,7 +568,7 @@ var XUtils = /** @class */ (function () {
|
|
|
538
568
|
* @param idField
|
|
539
569
|
*/
|
|
540
570
|
XUtils.arrayIntersect = function (array1, array2, idField) {
|
|
541
|
-
var
|
|
571
|
+
var e_6, _a;
|
|
542
572
|
var array2IdSet = new Set();
|
|
543
573
|
try {
|
|
544
574
|
for (var array2_1 = __values(array2), array2_1_1 = array2_1.next(); !array2_1_1.done; array2_1_1 = array2_1.next()) {
|
|
@@ -548,12 +578,12 @@ var XUtils = /** @class */ (function () {
|
|
|
548
578
|
}
|
|
549
579
|
}
|
|
550
580
|
}
|
|
551
|
-
catch (
|
|
581
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
552
582
|
finally {
|
|
553
583
|
try {
|
|
554
584
|
if (array2_1_1 && !array2_1_1.done && (_a = array2_1.return)) _a.call(array2_1);
|
|
555
585
|
}
|
|
556
|
-
finally { if (
|
|
586
|
+
finally { if (e_6) throw e_6.error; }
|
|
557
587
|
}
|
|
558
588
|
return array1.filter(function (item) { return item && array2IdSet.has(item[idField]); });
|
|
559
589
|
};
|
|
@@ -642,7 +672,7 @@ var XUtils = /** @class */ (function () {
|
|
|
642
672
|
// pomocna metodka
|
|
643
673
|
// ak nie su v xErrorMap ziadne chyby, vrati ""
|
|
644
674
|
XUtils.getErrorMessages = function (xErrorMap) {
|
|
645
|
-
var
|
|
675
|
+
var e_7, _a;
|
|
646
676
|
var _b;
|
|
647
677
|
var msg = "";
|
|
648
678
|
try {
|
|
@@ -656,12 +686,12 @@ var XUtils = /** @class */ (function () {
|
|
|
656
686
|
}
|
|
657
687
|
}
|
|
658
688
|
}
|
|
659
|
-
catch (
|
|
689
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
660
690
|
finally {
|
|
661
691
|
try {
|
|
662
692
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
663
693
|
}
|
|
664
|
-
finally { if (
|
|
694
|
+
finally { if (e_7) throw e_7.error; }
|
|
665
695
|
}
|
|
666
696
|
return msg;
|
|
667
697
|
};
|
|
@@ -732,7 +762,7 @@ var XUtils = /** @class */ (function () {
|
|
|
732
762
|
};
|
|
733
763
|
// pomocna metodka
|
|
734
764
|
XUtils.filterAnd = function () {
|
|
735
|
-
var
|
|
765
|
+
var e_8, _a;
|
|
736
766
|
var filters = [];
|
|
737
767
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
738
768
|
filters[_i] = arguments[_i];
|
|
@@ -749,12 +779,12 @@ var XUtils = /** @class */ (function () {
|
|
|
749
779
|
}
|
|
750
780
|
}
|
|
751
781
|
}
|
|
752
|
-
catch (
|
|
782
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
753
783
|
finally {
|
|
754
784
|
try {
|
|
755
785
|
if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
|
|
756
786
|
}
|
|
757
|
-
finally { if (
|
|
787
|
+
finally { if (e_8) throw e_8.error; }
|
|
758
788
|
}
|
|
759
789
|
}
|
|
760
790
|
return customFilterItemsResult;
|
|
@@ -799,7 +829,9 @@ var XUtils = /** @class */ (function () {
|
|
|
799
829
|
XUtils.xTokenPublic = { username: "xPublicUser", password: "xPublicUserPassword123" };
|
|
800
830
|
// nacachovane metadata (setuju sa v App.fetchAndSetXMetadata)
|
|
801
831
|
XUtils.appFormMap = {};
|
|
802
|
-
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
832
|
+
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Excel, ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
833
|
+
// moznost Off zatial nie je implementovana
|
|
834
|
+
XUtils.multilineExportTypeOptions = [ExportImportParam_1.XMultilineExportType.Multiline, ExportImportParam_1.XMultilineExportType.Singleline /*, XMultilineExportType.Off*/];
|
|
803
835
|
XUtils.csvSeparatorOptions = [ExportImportParam_1.CsvSeparator.Semicolon, ExportImportParam_1.CsvSeparator.Comma];
|
|
804
836
|
XUtils.decimalFormatOptions = [ExportImportParam_1.CsvDecimalFormat.Comma, ExportImportParam_1.CsvDecimalFormat.Dot];
|
|
805
837
|
XUtils.csvEncodingOptions = [ExportImportParam_1.CsvEncoding.Utf8, ExportImportParam_1.CsvEncoding.Win1250];
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"expRowCount": "Row count",
|
|
17
17
|
"expExportType": "Export type",
|
|
18
18
|
"expCreateHeaderLine": "Create header line",
|
|
19
|
+
"expDetailRowsExport": "Detail rows export",
|
|
19
20
|
"expCsvSeparator": "Csv separator",
|
|
20
21
|
"expDecimalFormat": "Decimal format",
|
|
21
22
|
"expEncoding": "Encoding",
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { DataTableFilterMeta, DataTableSortMeta } from "primereact/datatable";
|
|
2
2
|
import { XCustomFilterItem, XFullTextSearch } from "./FindParam";
|
|
3
3
|
export declare enum ExportType {
|
|
4
|
+
Excel = "excel",
|
|
4
5
|
Csv = "csv",
|
|
5
6
|
Json = "json"
|
|
6
7
|
}
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export interface ExportExcelParam {
|
|
9
|
+
queryParam: LazyDataTableQueryParam;
|
|
10
|
+
excelCsvParam: ExcelCsvParam;
|
|
11
|
+
widths: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ExportCsvParam {
|
|
14
|
+
queryParam: LazyDataTableQueryParam;
|
|
15
|
+
excelCsvParam: ExcelCsvParam;
|
|
16
|
+
csvParam: CsvParam;
|
|
17
|
+
}
|
|
18
|
+
export interface ExportJsonParam {
|
|
19
|
+
queryParam: LazyDataTableQueryParam;
|
|
11
20
|
}
|
|
12
21
|
export interface LazyDataTableQueryParam {
|
|
13
22
|
filters: DataTableFilterMeta;
|
|
@@ -16,8 +25,23 @@ export interface LazyDataTableQueryParam {
|
|
|
16
25
|
multiSortMeta?: DataTableSortMeta[];
|
|
17
26
|
entity: string;
|
|
18
27
|
fields: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface ExcelCsvParam {
|
|
30
|
+
headers?: string[];
|
|
31
|
+
toManyAssocExport: XMultilineExportType;
|
|
32
|
+
multilineTextExport: XMultilineExportType;
|
|
19
33
|
fieldsToDuplicateValues?: string[];
|
|
20
34
|
}
|
|
35
|
+
export declare enum XMultilineExportType {
|
|
36
|
+
Singleline = "singleline",
|
|
37
|
+
Multiline = "multiline",
|
|
38
|
+
Off = "off"
|
|
39
|
+
}
|
|
40
|
+
export interface CsvParam {
|
|
41
|
+
csvSeparator: CsvSeparator;
|
|
42
|
+
csvDecimalFormat: CsvDecimalFormat;
|
|
43
|
+
csvEncoding: CsvEncoding;
|
|
44
|
+
}
|
|
21
45
|
export declare enum CsvSeparator {
|
|
22
46
|
Semicolon = ";",
|
|
23
47
|
Comma = ","
|
|
@@ -30,13 +54,6 @@ export declare enum CsvEncoding {
|
|
|
30
54
|
Utf8 = "utf-8",
|
|
31
55
|
Win1250 = "win1250"
|
|
32
56
|
}
|
|
33
|
-
export interface CsvParam {
|
|
34
|
-
useHeaderLine: boolean;
|
|
35
|
-
headers?: string[];
|
|
36
|
-
csvSeparator: CsvSeparator;
|
|
37
|
-
csvDecimalFormat: CsvDecimalFormat;
|
|
38
|
-
csvEncoding: CsvEncoding;
|
|
39
|
-
}
|
|
40
57
|
export declare enum ImportType {
|
|
41
58
|
Csv = "csv",
|
|
42
59
|
Json = "json"
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImportType = exports.CsvEncoding = exports.CsvDecimalFormat = exports.CsvSeparator = exports.ExportType = void 0;
|
|
3
|
+
exports.ImportType = exports.CsvEncoding = exports.CsvDecimalFormat = exports.CsvSeparator = exports.XMultilineExportType = exports.ExportType = void 0;
|
|
4
|
+
// ************** export ***************
|
|
4
5
|
var ExportType;
|
|
5
6
|
(function (ExportType) {
|
|
7
|
+
ExportType["Excel"] = "excel";
|
|
6
8
|
ExportType["Csv"] = "csv";
|
|
7
9
|
ExportType["Json"] = "json";
|
|
8
10
|
})(ExportType = exports.ExportType || (exports.ExportType = {}));
|
|
11
|
+
// exportovanie hodnot z toMany asociacii, pripadne viacriadkovych textov
|
|
12
|
+
var XMultilineExportType;
|
|
13
|
+
(function (XMultilineExportType) {
|
|
14
|
+
XMultilineExportType["Singleline"] = "singleline";
|
|
15
|
+
XMultilineExportType["Multiline"] = "multiline";
|
|
16
|
+
XMultilineExportType["Off"] = "off"; // stlpce obsahujuce viac hodnot/riadkov sa vynechaju z exportu
|
|
17
|
+
})(XMultilineExportType = exports.XMultilineExportType || (exports.XMultilineExportType = {}));
|
|
9
18
|
// vo windowse zavisi od regionalnych nastaveni, default nastavenie je ";" a preto vecsinou aj excel produkuje csv s ";" (menej sa to bije s decimalmi)
|
|
10
19
|
// takze primarne pouzivame ";" a sekundarne "," napr. pri generickom exporte do csv davame uzivatelovi na vyber
|
|
11
20
|
var CsvSeparator;
|
|
@@ -27,6 +36,7 @@ var CsvEncoding;
|
|
|
27
36
|
CsvEncoding["Utf8"] = "utf-8";
|
|
28
37
|
CsvEncoding["Win1250"] = "win1250";
|
|
29
38
|
})(CsvEncoding = exports.CsvEncoding || (exports.CsvEncoding = {}));
|
|
39
|
+
// ************** import ***************
|
|
30
40
|
var ImportType;
|
|
31
41
|
(function (ImportType) {
|
|
32
42
|
ImportType["Csv"] = "csv";
|
|
@@ -17,6 +17,7 @@ export declare class XUtilsCommon {
|
|
|
17
17
|
static dateAddMonths(date: Date | null, months: number): Date | null;
|
|
18
18
|
static dateEquals(date1: Date | null, date2: Date | null): boolean;
|
|
19
19
|
static dateDiffInYears(dateOld: Date | null, dateNew: Date | null): number | null;
|
|
20
|
+
static monthDiff(monthOld: Date | null, monthNew: Date | null): number | null;
|
|
20
21
|
static findFirstMatch(pattern: RegExp, value: string): string | null;
|
|
21
22
|
static sqlMaxDateIfNull(sqlExp: string): string;
|
|
22
23
|
static today(): Date;
|
|
@@ -297,6 +297,18 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
297
297
|
}
|
|
298
298
|
return diff;
|
|
299
299
|
};
|
|
300
|
+
// returns month diff for 2 dates of type month (YYYY-MM-01) - days are ignored
|
|
301
|
+
XUtilsCommon.monthDiff = function (monthOld, monthNew) {
|
|
302
|
+
var diff = null;
|
|
303
|
+
if (monthOld !== null && monthNew !== null) {
|
|
304
|
+
var yearCountNew = monthNew.getFullYear();
|
|
305
|
+
var monthCountNew = monthNew.getMonth();
|
|
306
|
+
var yearCountOld = monthOld.getFullYear();
|
|
307
|
+
var monthCountOld = monthOld.getMonth();
|
|
308
|
+
diff = (yearCountNew - yearCountOld) * 12 + (monthCountNew - monthCountOld);
|
|
309
|
+
}
|
|
310
|
+
return diff;
|
|
311
|
+
};
|
|
300
312
|
XUtilsCommon.findFirstMatch = function (pattern, value) {
|
|
301
313
|
var match = pattern.exec(value);
|
|
302
314
|
return match != null ? match[0] : null;
|
|
@@ -6,13 +6,19 @@ export declare function stringAsDB(value: string | null): string;
|
|
|
6
6
|
export declare function intFromUI(stringValue: string): number | null | undefined;
|
|
7
7
|
export declare function numberAsUI(value: number | null, fractionDigits?: number): string;
|
|
8
8
|
export declare function numberFromModel(value: any): number | null;
|
|
9
|
+
export declare function numberFromString(valueString: string): number | null;
|
|
10
|
+
export declare enum XDateScale {
|
|
11
|
+
Date = 1,
|
|
12
|
+
Month = 2,
|
|
13
|
+
Year = 3
|
|
14
|
+
}
|
|
9
15
|
export declare function dateFromModel(value: any): Date | null;
|
|
10
|
-
export declare function dateFromUI(valueString: string): Date | null | undefined;
|
|
11
|
-
export declare function dateAsUI(value: Date | null): string;
|
|
16
|
+
export declare function dateFromUI(valueString: string, dateScale?: XDateScale): Date | null | undefined;
|
|
17
|
+
export declare function dateAsUI(value: Date | null, dateScale?: XDateScale): string;
|
|
12
18
|
export declare function datetimeAsUI(value: Date | null): string;
|
|
13
19
|
export declare function timeFromModel(value: any): Date | null;
|
|
14
|
-
export declare function dateFormatUI(): string;
|
|
15
|
-
export declare function dateFormatCalendar(): string;
|
|
20
|
+
export declare function dateFormatUI(dateScale?: XDateScale): string;
|
|
21
|
+
export declare function dateFormatCalendar(dateScale?: XDateScale): string;
|
|
16
22
|
export declare function datetimeFormatUI(): string;
|
|
17
23
|
export declare function intervalFromUI(valueString: string): IPostgresInterval | null | undefined;
|
|
18
24
|
export declare function intervalAsUI(valueInterval: IPostgresInterval | null): string;
|
|
@@ -32,4 +38,4 @@ export declare enum AsUIType {
|
|
|
32
38
|
*/
|
|
33
39
|
export declare function convertObject(entity: string, object: any, fromModel: boolean, asUI: AsUIType | undefined): void;
|
|
34
40
|
export declare function convertValue(xField: XField, value: any, fromModel: boolean, asUI: AsUIType | undefined): any;
|
|
35
|
-
export declare function convertValueBase(fieldType: string,
|
|
41
|
+
export declare function convertValueBase(fieldType: string, scale: number | undefined, value: any, fromModel: boolean, asUI: AsUIType | undefined): any;
|
|
@@ -27,7 +27,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
27
27
|
return ar;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.convertValueBase = exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromUI = exports.dateFromModel = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
30
|
+
exports.convertValueBase = exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromUI = exports.dateFromModel = exports.XDateScale = exports.numberFromString = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
31
31
|
var XUtilsCommon_1 = require("./XUtilsCommon");
|
|
32
32
|
var XLocale_1 = require("../components/XLocale");
|
|
33
33
|
var XUtilsMetadataCommon_1 = require("./XUtilsMetadataCommon");
|
|
@@ -95,6 +95,23 @@ function numberFromModel(value) {
|
|
|
95
95
|
return numberValue;
|
|
96
96
|
}
|
|
97
97
|
exports.numberFromModel = numberFromModel;
|
|
98
|
+
// konvertuje hodnotu napr. 12.34
|
|
99
|
+
function numberFromString(valueString) {
|
|
100
|
+
var numberValue = parseFloat(valueString);
|
|
101
|
+
if (isNaN(numberValue)) {
|
|
102
|
+
numberValue = null;
|
|
103
|
+
}
|
|
104
|
+
return numberValue;
|
|
105
|
+
}
|
|
106
|
+
exports.numberFromString = numberFromString;
|
|
107
|
+
// upresnenie typu datumu - pouzivame typ number, lebo zneuzivame atribut scale v TypeORM na zadanie upresnenia
|
|
108
|
+
var XDateScale;
|
|
109
|
+
(function (XDateScale) {
|
|
110
|
+
XDateScale[XDateScale["Date"] = 1] = "Date";
|
|
111
|
+
XDateScale[XDateScale["Month"] = 2] = "Month";
|
|
112
|
+
XDateScale[XDateScale["Year"] = 3] = "Year"; // yyyy
|
|
113
|
+
})(XDateScale = exports.XDateScale || (exports.XDateScale = {}));
|
|
114
|
+
//export type XDateType = "month" | "year" | "date";
|
|
98
115
|
// v modeli na klientovi by mal byt vzdy Date, teraz je tam niekedy string (z json-u zo servera) a niekedy Date (z komponentu)
|
|
99
116
|
// provizorne zatial takato konverzia
|
|
100
117
|
function dateFromModel(value) {
|
|
@@ -108,9 +125,10 @@ function dateFromModel(value) {
|
|
|
108
125
|
return dateValue;
|
|
109
126
|
}
|
|
110
127
|
exports.dateFromModel = dateFromModel;
|
|
111
|
-
function dateFromUI(valueString) {
|
|
128
|
+
function dateFromUI(valueString, dateScale) {
|
|
129
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
112
130
|
// converts valueString (e.g. 21.2.2024) into Date
|
|
113
|
-
// if
|
|
131
|
+
// if valueString is invalid, returns undefined
|
|
114
132
|
var valueDate = undefined;
|
|
115
133
|
if (valueString === '') {
|
|
116
134
|
valueDate = null;
|
|
@@ -120,22 +138,46 @@ function dateFromUI(valueString) {
|
|
|
120
138
|
var day = void 0;
|
|
121
139
|
var month = null;
|
|
122
140
|
var year = null;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
if (dateScale === XDateScale.Date) {
|
|
142
|
+
// format "dd.mm.yyyy"
|
|
143
|
+
var posDot = valueString.indexOf('.');
|
|
144
|
+
if (posDot === -1) {
|
|
145
|
+
day = intFromUI(valueString);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
day = intFromUI(valueString.substring(0, posDot));
|
|
149
|
+
var rest = valueString.substring(posDot + 1);
|
|
150
|
+
var posDot2 = rest.indexOf('.');
|
|
151
|
+
if (posDot2 === -1) {
|
|
152
|
+
month = intFromUI(rest);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
month = intFromUI(rest.substring(0, posDot2));
|
|
156
|
+
year = intFromUI(rest.substring(posDot2 + 1));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
126
159
|
}
|
|
127
|
-
else {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
132
|
-
month = intFromUI(
|
|
160
|
+
else if (dateScale === XDateScale.Month) {
|
|
161
|
+
// format "mm.yyyy"
|
|
162
|
+
day = 1;
|
|
163
|
+
var posDot = valueString.indexOf('.');
|
|
164
|
+
if (posDot === -1) {
|
|
165
|
+
month = intFromUI(valueString);
|
|
133
166
|
}
|
|
134
167
|
else {
|
|
135
|
-
month = intFromUI(
|
|
136
|
-
year = intFromUI(
|
|
168
|
+
month = intFromUI(valueString.substring(0, posDot));
|
|
169
|
+
year = intFromUI(valueString.substring(posDot + 1));
|
|
137
170
|
}
|
|
138
171
|
}
|
|
172
|
+
else if (dateScale === XDateScale.Year) {
|
|
173
|
+
// format "yyyy"
|
|
174
|
+
day = 1;
|
|
175
|
+
month = 1;
|
|
176
|
+
year = intFromUI(valueString);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
180
|
+
}
|
|
139
181
|
// doplnime mesiac a rok ak uzivatel nezadal (ak mame undefined, tak umyselne nedoplname)
|
|
140
182
|
if (month === null) {
|
|
141
183
|
month = XUtilsCommon_1.XUtilsCommon.today().getMonth() + 1; // o 1 mesiac viac (januar je 0)
|
|
@@ -163,9 +205,10 @@ function dateFromUI(valueString) {
|
|
|
163
205
|
return valueDate;
|
|
164
206
|
}
|
|
165
207
|
exports.dateFromUI = dateFromUI;
|
|
166
|
-
function dateAsUI(value) {
|
|
208
|
+
function dateAsUI(value, dateScale) {
|
|
209
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
167
210
|
if (value !== null) {
|
|
168
|
-
return (0, XUtilsCommon_1.dateFormat)(value, dateFormatUI());
|
|
211
|
+
return (0, XUtilsCommon_1.dateFormat)(value, dateFormatUI(dateScale));
|
|
169
212
|
}
|
|
170
213
|
else {
|
|
171
214
|
return "";
|
|
@@ -208,12 +251,40 @@ function timeFromModel(value) {
|
|
|
208
251
|
return timeValue;
|
|
209
252
|
}
|
|
210
253
|
exports.timeFromModel = timeFromModel;
|
|
211
|
-
function dateFormatUI() {
|
|
212
|
-
|
|
254
|
+
function dateFormatUI(dateScale) {
|
|
255
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
256
|
+
var format;
|
|
257
|
+
if (dateScale === XDateScale.Date) {
|
|
258
|
+
format = "dd.mm.yyyy";
|
|
259
|
+
}
|
|
260
|
+
else if (dateScale === XDateScale.Month) {
|
|
261
|
+
format = "mm.yyyy";
|
|
262
|
+
}
|
|
263
|
+
else if (dateScale === XDateScale.Year) {
|
|
264
|
+
format = "yyyy";
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
268
|
+
}
|
|
269
|
+
return format;
|
|
213
270
|
}
|
|
214
271
|
exports.dateFormatUI = dateFormatUI;
|
|
215
|
-
function dateFormatCalendar() {
|
|
216
|
-
|
|
272
|
+
function dateFormatCalendar(dateScale) {
|
|
273
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
274
|
+
var format;
|
|
275
|
+
if (dateScale === XDateScale.Date) {
|
|
276
|
+
format = "dd.mm.yy";
|
|
277
|
+
}
|
|
278
|
+
else if (dateScale === XDateScale.Month) {
|
|
279
|
+
format = "mm.yy";
|
|
280
|
+
}
|
|
281
|
+
else if (dateScale === XDateScale.Year) {
|
|
282
|
+
format = "yy";
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
286
|
+
}
|
|
287
|
+
return format;
|
|
217
288
|
}
|
|
218
289
|
exports.dateFormatCalendar = dateFormatCalendar;
|
|
219
290
|
function datetimeFormatUI() {
|
|
@@ -349,21 +420,21 @@ function convertValue(xField, value, fromModel, asUI) {
|
|
|
349
420
|
return convertValueBase(xField.type, xField.scale, value, fromModel, asUI);
|
|
350
421
|
}
|
|
351
422
|
exports.convertValue = convertValue;
|
|
352
|
-
function convertValueBase(fieldType,
|
|
423
|
+
function convertValueBase(fieldType, scale, value, fromModel, asUI) {
|
|
353
424
|
if (fieldType === "decimal") {
|
|
354
425
|
if (fromModel) {
|
|
355
426
|
value = numberFromModel(value);
|
|
356
427
|
}
|
|
357
428
|
if (asUI && asUI !== AsUIType.Excel) {
|
|
358
|
-
value = numberAsUI(value,
|
|
429
|
+
value = numberAsUI(value, scale);
|
|
359
430
|
}
|
|
360
431
|
}
|
|
361
432
|
else if (fieldType === "date") {
|
|
362
433
|
if (fromModel) {
|
|
363
434
|
value = dateFromModel(value);
|
|
364
435
|
}
|
|
365
|
-
if (asUI && asUI !== AsUIType.Excel) {
|
|
366
|
-
value = dateAsUI(value);
|
|
436
|
+
if (asUI && (asUI !== AsUIType.Excel || scale === XDateScale.Month || scale === XDateScale.Year)) {
|
|
437
|
+
value = dateAsUI(value, scale);
|
|
367
438
|
}
|
|
368
439
|
}
|
|
369
440
|
else if (fieldType === "datetime") {
|
|
@@ -13,6 +13,7 @@ export declare class XUtilsMetadataCommon {
|
|
|
13
13
|
static getXField(xEntity: XEntity, field: string): XField;
|
|
14
14
|
static getXFieldByPathBase(xEntity: XEntity, path: string): XField | undefined;
|
|
15
15
|
static getXFieldByPath(xEntity: XEntity, path: string): XField;
|
|
16
|
+
static hasPathToManyAssoc(xEntity: XEntity, path: string): boolean;
|
|
16
17
|
static getXFieldByPathStr(entity: string, path: string): XField;
|
|
17
18
|
static getXAssocBase(xEntity: XEntity, assocField: string): XAssoc | undefined;
|
|
18
19
|
static getXAssocByPath(xEntity: XEntity, path: string): XAssoc;
|
|
@@ -91,6 +91,23 @@ var XUtilsMetadataCommon = /** @class */ (function () {
|
|
|
91
91
|
return XUtilsMetadataCommon.getXFieldByPath(xAssocEntity, restPath);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
// returns true if path contains some toMany assoc
|
|
95
|
+
XUtilsMetadataCommon.hasPathToManyAssoc = function (xEntity, path) {
|
|
96
|
+
var _a = __read(XUtilsCommon_1.XUtilsCommon.getFieldAndRestPath(path), 2), field = _a[0], restPath = _a[1];
|
|
97
|
+
if (restPath === null) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
var xAssoc = XUtilsMetadataCommon.getXAssoc(xEntity, field);
|
|
102
|
+
if (xAssoc.relationType === "one-to-many" || xAssoc.relationType === "many-to-many") {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
var xAssocEntity = XUtilsMetadataCommon.getXEntity(xAssoc.entityName);
|
|
107
|
+
return XUtilsMetadataCommon.hasPathToManyAssoc(xAssocEntity, restPath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
94
111
|
XUtilsMetadataCommon.getXFieldByPathStr = function (entity, path) {
|
|
95
112
|
return XUtilsMetadataCommon.getXFieldByPath(XUtilsMetadataCommon.getXEntity(entity), path);
|
|
96
113
|
};
|