@michalrakus/x-react-web-lib 1.21.0 → 1.23.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/XMultiSelect.d.ts +3 -0
- package/XMultiSelect.js +5 -0
- package/XMultiSelectBase.d.ts +3 -0
- package/XMultiSelectBase.js +5 -0
- package/gulpfile.js +3 -0
- package/lib/administration/XBrowseMetaBrowse.d.ts +2 -2
- package/lib/administration/XBrowseMetaForm.d.ts +2 -2
- package/lib/administration/XParamBrowse.d.ts +2 -2
- package/lib/administration/XParamBrowse.js +1 -1
- package/lib/administration/XParamForm.d.ts +2 -2
- package/lib/administration/XParamForm.js +2 -0
- package/lib/administration/XUserBrowse.d.ts +2 -2
- package/lib/administration/XUserBrowse.js +1 -1
- package/lib/administration/XUserForm.d.ts +2 -2
- package/lib/administration/XUserForm.js +12 -9
- package/lib/components/SourceCodeLinkEntity.d.ts +2 -2
- package/lib/components/XAutoComplete.d.ts +2 -1
- package/lib/components/XAutoComplete.js +2 -2
- package/lib/components/XAutoCompleteBase.d.ts +5 -11
- package/lib/components/XAutoCompleteBase.js +28 -11
- package/lib/components/XAutoCompleteDT.d.ts +1 -1
- package/lib/components/XButton.d.ts +1 -1
- package/lib/components/XButtonIconMedium.d.ts +1 -1
- package/lib/components/XButtonIconNarrow.d.ts +1 -1
- package/lib/components/XButtonIconSmall.d.ts +1 -1
- package/lib/components/XCalendar.d.ts +16 -9
- package/lib/components/XCalendar.js +21 -2
- package/lib/components/XChangePasswordForm.d.ts +2 -2
- package/lib/components/XCheckboxDT.d.ts +2 -2
- package/lib/components/XDataTable.d.ts +2 -2
- package/lib/components/XDropdown.d.ts +2 -2
- package/lib/components/XDropdown.js +1 -1
- package/lib/components/XDropdownDT.d.ts +2 -2
- package/lib/components/XDropdownDTFilter.d.ts +2 -2
- package/lib/components/XDropdownForEntity.d.ts +2 -2
- package/lib/components/XDropdownForEntity.js +1 -1
- package/lib/components/XDropdownFormDTFilter.d.ts +2 -2
- package/lib/components/XEditBrowse.d.ts +2 -2
- package/lib/components/XEditColumnDialog.d.ts +2 -2
- package/lib/components/XEditor.d.ts +1 -1
- package/lib/components/XEditorBase.d.ts +1 -1
- package/lib/components/XEditorBase.js +1 -1
- package/lib/components/XFieldSelector.d.ts +2 -2
- package/lib/components/XFormComponent.d.ts +1 -0
- package/lib/components/XFormDataTable2.d.ts +1 -1
- package/lib/components/XFormFooter.d.ts +2 -2
- package/lib/components/XFormHeader.d.ts +4 -0
- package/lib/components/XFormHeader.js +11 -0
- package/lib/components/XFormNavigator3.d.ts +2 -2
- package/lib/components/XFormRowCol/XFormCol.d.ts +1 -1
- package/lib/components/XFormRowCol/XFormInlineRow.d.ts +1 -1
- package/lib/components/XFormRowCol/XFormRow.d.ts +1 -1
- package/lib/components/XFormRowCol/XFormRowCol.d.ts +1 -1
- package/lib/components/XFtsInput.d.ts +2 -2
- package/lib/components/XHolders.d.ts +3 -3
- package/lib/components/XInputDate.d.ts +2 -2
- package/lib/components/XInputDate.js +1 -1
- package/lib/components/XInputDateDT.d.ts +2 -2
- package/lib/components/XInputDateDT.js +1 -1
- package/lib/components/XInputDecimal.d.ts +1 -1
- package/lib/components/XInputDecimalBase.d.ts +2 -2
- package/lib/components/XInputDecimalDT.d.ts +2 -2
- package/lib/components/XInputDecimalDT.js +1 -1
- package/lib/components/XInputFileList.d.ts +2 -1
- package/lib/components/XInputInterval.d.ts +1 -1
- package/lib/components/XInputIntervalBase.d.ts +2 -2
- package/lib/components/XInputIntervalBase.js +1 -1
- package/lib/components/XInputIntervalDT.d.ts +2 -2
- package/lib/components/XInputText.d.ts +2 -2
- package/lib/components/XInputText.js +14 -3
- package/lib/components/XInputTextDT.d.ts +2 -2
- package/lib/components/XInputTextarea.d.ts +1 -1
- package/lib/components/XInputTextarea.js +13 -3
- package/lib/components/XInputTextareaBase.d.ts +3 -1
- package/lib/components/XInputTextareaBase.js +1 -1
- package/lib/components/XInputTextareaDT.d.ts +2 -2
- package/lib/components/XLazyDataTable/XExportRowsDialog.d.ts +12 -7
- package/lib/components/XLazyDataTable/XExportRowsDialog.js +79 -44
- package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +2 -1
- package/lib/components/XLazyDataTable/XLazyDataTable.js +55 -24
- package/lib/components/XLazyDataTable/XMultilineSwitch.d.ts +2 -2
- package/lib/components/XLazyDataTable/XMultilineSwitch.js +1 -1
- package/lib/components/XLazyDataTable/XOcfDropdown.d.ts +2 -2
- package/lib/components/XLazyDataTable/XOcfDropdown.js +1 -0
- package/lib/components/XLoginDialog.d.ts +2 -2
- package/lib/components/XLoginForm.d.ts +2 -2
- package/lib/components/XMultiSelect.d.ts +25 -0
- package/lib/components/XMultiSelect.js +97 -0
- package/lib/components/XMultiSelectBase.d.ts +27 -0
- package/lib/components/XMultiSelectBase.js +145 -0
- package/lib/components/XSearchBrowseParams.d.ts +1 -1
- package/lib/components/XSearchButton.d.ts +1 -1
- package/lib/components/XSearchButtonDT.d.ts +2 -2
- package/lib/components/XSearchButtonOld.d.ts +1 -1
- package/lib/components/XToOneAssocButton.d.ts +2 -2
- package/lib/components/XToken.d.ts +1 -1
- package/lib/components/XUtils.d.ts +12 -3
- package/lib/components/XUtils.js +83 -31
- 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 +4 -1
- package/lib/serverApi/XUtilsMetadataCommon.js +26 -3
- package/package.json +3 -3
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
52
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
53
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
54
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
55
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
56
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
57
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
61
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
62
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
63
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
64
|
+
function step(op) {
|
|
65
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
68
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
+
switch (op[0]) {
|
|
70
|
+
case 0: case 1: t = op; break;
|
|
71
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
72
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
73
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
74
|
+
default:
|
|
75
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
76
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
77
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
78
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
79
|
+
if (t[2]) _.ops.pop();
|
|
80
|
+
_.trys.pop(); continue;
|
|
81
|
+
}
|
|
82
|
+
op = body.call(thisArg, _);
|
|
83
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
84
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
88
|
+
exports.XMultiSelectBase = void 0;
|
|
89
|
+
var react_1 = __importStar(require("react"));
|
|
90
|
+
var XUtils_1 = require("./XUtils");
|
|
91
|
+
var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
|
|
92
|
+
var multiselect_1 = require("primereact/multiselect");
|
|
93
|
+
var XMultiSelectBase = /** @class */ (function (_super) {
|
|
94
|
+
__extends(XMultiSelectBase, _super);
|
|
95
|
+
function XMultiSelectBase(props) {
|
|
96
|
+
var _this = _super.call(this, props) || this;
|
|
97
|
+
if (!_this.props.optionsQuery) {
|
|
98
|
+
throw "XMultiSelectBase.optionsQuery: unexpected error - prop optionsQuery is undefined";
|
|
99
|
+
}
|
|
100
|
+
_this.idField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(_this.props.optionsQuery.entity).idField;
|
|
101
|
+
_this.state = {
|
|
102
|
+
options: []
|
|
103
|
+
};
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
XMultiSelectBase.prototype.componentDidMount = function () {
|
|
107
|
+
this.loadOptions();
|
|
108
|
+
};
|
|
109
|
+
XMultiSelectBase.prototype.loadOptions = function () {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var options;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0:
|
|
115
|
+
if (!this.props.optionsQuery) {
|
|
116
|
+
throw "XMultiSelectBase.optionsQuery: unexpected error - prop optionsQuery is undefined";
|
|
117
|
+
}
|
|
118
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.props.optionsQuery.entity, XUtils_1.XUtils.evalFilter(this.props.optionsQuery.filter), this.getSortField(), this.props.optionsQuery.fields)];
|
|
119
|
+
case 1:
|
|
120
|
+
options = _a.sent();
|
|
121
|
+
this.setState({ options: options });
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
XMultiSelectBase.prototype.getSortField = function () {
|
|
128
|
+
var sortField = this.props.optionsQuery.sortField;
|
|
129
|
+
if (!sortField) {
|
|
130
|
+
// ako default pouzivame displayField
|
|
131
|
+
sortField = this.props.displayField;
|
|
132
|
+
}
|
|
133
|
+
return sortField;
|
|
134
|
+
};
|
|
135
|
+
XMultiSelectBase.prototype.render = function () {
|
|
136
|
+
var _this = this;
|
|
137
|
+
// propertiesy na Dropdown-e: readOnly vyseduje, disabled znemoznuje vyber polozky
|
|
138
|
+
return (react_1.default.createElement(multiselect_1.MultiSelect, __assign({ options: this.state.options, optionLabel: this.props.displayField, dataKey: this.idField, maxSelectedLabels: this.props.maxSelectedLabels, display: "chip", value: this.props.value, onChange: function (e) { return _this.props.onChange(e.value); }, readOnly: this.props.readOnly, disabled: this.props.readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(this.props.error))));
|
|
139
|
+
};
|
|
140
|
+
XMultiSelectBase.defaultProps = {
|
|
141
|
+
//scrollHeight: '15rem' // primereact has 200px
|
|
142
|
+
};
|
|
143
|
+
return XMultiSelectBase;
|
|
144
|
+
}(react_1.Component));
|
|
145
|
+
exports.XMultiSelectBase = XMultiSelectBase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { XFormBase } from "./XFormBase";
|
|
2
|
+
import React from "react";
|
|
3
3
|
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
4
4
|
export declare const XSearchButtonDT: (props: {
|
|
5
5
|
form: XFormBase;
|
|
@@ -10,4 +10,4 @@ export declare const XSearchButtonDT: (props: {
|
|
|
10
10
|
assocForm?: JSX.Element | undefined;
|
|
11
11
|
rowData: any;
|
|
12
12
|
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
13
|
-
}) => JSX.Element;
|
|
13
|
+
}) => React.JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { XFormBase } from "./XFormBase";
|
|
2
|
+
import React from "react";
|
|
3
3
|
export declare const XToOneAssocButton: (props: {
|
|
4
4
|
form: XFormBase;
|
|
5
5
|
assocField: string;
|
|
6
6
|
assocForm: any;
|
|
7
7
|
label?: string | undefined;
|
|
8
|
-
}) => JSX.Element;
|
|
8
|
+
}) => React.JSX.Element;
|
|
@@ -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";
|
|
@@ -7,7 +7,6 @@ import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
|
|
|
7
7
|
import { DataTableSortMeta } from "primereact/datatable";
|
|
8
8
|
import { XObject } from "./XObject";
|
|
9
9
|
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
10
|
-
import { XFilterOrFunction } from "./XAutoCompleteBase";
|
|
11
10
|
export declare enum OperationType {
|
|
12
11
|
None = 0,
|
|
13
12
|
Insert = 1,
|
|
@@ -29,6 +28,13 @@ export interface IPostgresInterval {
|
|
|
29
28
|
seconds?: number;
|
|
30
29
|
milliseconds?: number;
|
|
31
30
|
}
|
|
31
|
+
export type XFilterOrFunction = XCustomFilter | (() => XCustomFilter | undefined);
|
|
32
|
+
export interface XQuery {
|
|
33
|
+
entity: string;
|
|
34
|
+
filter?: XFilterOrFunction;
|
|
35
|
+
sortField?: string | DataTableSortMeta[];
|
|
36
|
+
fields?: string[];
|
|
37
|
+
}
|
|
32
38
|
export declare class XUtils {
|
|
33
39
|
static dropdownEmptyOptionValue: string;
|
|
34
40
|
static xBackendUrl: string | undefined;
|
|
@@ -36,6 +42,7 @@ export declare class XUtils {
|
|
|
36
42
|
static xTokenPublic: XToken;
|
|
37
43
|
private static appFormMap;
|
|
38
44
|
static exportTypeOptions: ExportType[];
|
|
45
|
+
static multilineExportTypeOptions: XMultilineExportType[];
|
|
39
46
|
static csvSeparatorOptions: CsvSeparator[];
|
|
40
47
|
static decimalFormatOptions: CsvDecimalFormat[];
|
|
41
48
|
static csvEncodingOptions: CsvEncoding[];
|
|
@@ -60,6 +67,7 @@ export declare class XUtils {
|
|
|
60
67
|
static fetchString(path: string, value: any): Promise<string>;
|
|
61
68
|
static fetch(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
|
|
62
69
|
static post(path: string, value: any): Promise<Response>;
|
|
70
|
+
static openExcelReport(apiPath: string, requestPayload: any, fileName?: string): Promise<boolean>;
|
|
63
71
|
static fetchBasicJson(path: string, value: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
|
64
72
|
static fetchFile(path: string, jsonFieldValue: any, fileToPost: any): Promise<any>;
|
|
65
73
|
static fetchBasicAuthBasic(path: string, headers: any, body: any, usePublicToken?: boolean | XToken): Promise<Response>;
|
|
@@ -67,6 +75,7 @@ export declare class XUtils {
|
|
|
67
75
|
static fetchById(entity: string, fields: string[], id: number): Promise<any>;
|
|
68
76
|
static setXToken(xToken: XToken | null): void;
|
|
69
77
|
static getXToken(): XToken | null;
|
|
78
|
+
static getAccessToken(): Promise<string>;
|
|
70
79
|
static getUsername(): string | undefined;
|
|
71
80
|
static getXBackendUrl(): string;
|
|
72
81
|
static setXBackendUrl(xBackendUrl: string | undefined): void;
|
|
@@ -100,7 +109,7 @@ export declare class XUtils {
|
|
|
100
109
|
static isReadOnlyTableField(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined, object: XObject | null, tableRow: any): boolean;
|
|
101
110
|
static markNotNull(label: string): string;
|
|
102
111
|
static showErrorMessage(message: string, e: unknown): void;
|
|
103
|
-
static
|
|
112
|
+
static createTooltipOrErrorProps(error: string | undefined, tooltip?: string | undefined): object;
|
|
104
113
|
static addClassName(props: {
|
|
105
114
|
[key: string]: any;
|
|
106
115
|
}, className: string): {
|
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
|
};
|
|
@@ -394,36 +424,26 @@ var XUtils = /** @class */ (function () {
|
|
|
394
424
|
};
|
|
395
425
|
XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
|
|
396
426
|
return __awaiter(this, void 0, void 0, function () {
|
|
397
|
-
var
|
|
427
|
+
var accessToken, response, responseBody;
|
|
398
428
|
return __generator(this, function (_a) {
|
|
399
429
|
switch (_a.label) {
|
|
400
|
-
case 0:
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
else if (usePublicToken) {
|
|
405
|
-
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
xToken = XUtils.getXToken();
|
|
409
|
-
if (xToken === null) {
|
|
410
|
-
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(xToken.accessToken) });
|
|
430
|
+
case 0: return [4 /*yield*/, XUtils.getAccessToken()];
|
|
431
|
+
case 1:
|
|
432
|
+
accessToken = _a.sent();
|
|
433
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(accessToken) });
|
|
414
434
|
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
415
435
|
method: 'POST',
|
|
416
436
|
headers: headers,
|
|
417
437
|
body: body
|
|
418
438
|
})];
|
|
419
|
-
case
|
|
439
|
+
case 2:
|
|
420
440
|
response = _a.sent();
|
|
421
|
-
if (!!response.ok) return [3 /*break*/,
|
|
441
|
+
if (!!response.ok) return [3 /*break*/, 4];
|
|
422
442
|
return [4 /*yield*/, response.json()];
|
|
423
|
-
case
|
|
443
|
+
case 3:
|
|
424
444
|
responseBody = _a.sent();
|
|
425
445
|
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
426
|
-
case
|
|
446
|
+
case 4: return [2 /*return*/, response];
|
|
427
447
|
}
|
|
428
448
|
});
|
|
429
449
|
});
|
|
@@ -437,6 +457,34 @@ var XUtils = /** @class */ (function () {
|
|
|
437
457
|
XUtils.getXToken = function () {
|
|
438
458
|
return XUtils.xToken;
|
|
439
459
|
};
|
|
460
|
+
XUtils.getAccessToken = function () {
|
|
461
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
+
var xToken, accessToken;
|
|
463
|
+
return __generator(this, function (_a) {
|
|
464
|
+
switch (_a.label) {
|
|
465
|
+
case 0:
|
|
466
|
+
xToken = XUtils.getXToken();
|
|
467
|
+
if (xToken === null) {
|
|
468
|
+
throw "Unexpected error - XUtils.xToken is null (no user signed in)";
|
|
469
|
+
}
|
|
470
|
+
if (!(typeof xToken.accessToken === 'function')) return [3 /*break*/, 2];
|
|
471
|
+
return [4 /*yield*/, xToken.accessToken()];
|
|
472
|
+
case 1:
|
|
473
|
+
accessToken = _a.sent(); // ziskame access token volanim getAccessTokenSilently (pripadne podobnym)
|
|
474
|
+
return [3 /*break*/, 3];
|
|
475
|
+
case 2:
|
|
476
|
+
if (xToken.accessToken !== undefined) {
|
|
477
|
+
accessToken = xToken.accessToken; // mame rovno access token
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
throw "Unexpected error - XUtils.xToken.accessToken is undefined";
|
|
481
|
+
}
|
|
482
|
+
_a.label = 3;
|
|
483
|
+
case 3: return [2 /*return*/, accessToken];
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
};
|
|
440
488
|
XUtils.getUsername = function () {
|
|
441
489
|
var _a, _b;
|
|
442
490
|
return (_b = (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.username;
|
|
@@ -538,7 +586,7 @@ var XUtils = /** @class */ (function () {
|
|
|
538
586
|
* @param idField
|
|
539
587
|
*/
|
|
540
588
|
XUtils.arrayIntersect = function (array1, array2, idField) {
|
|
541
|
-
var
|
|
589
|
+
var e_6, _a;
|
|
542
590
|
var array2IdSet = new Set();
|
|
543
591
|
try {
|
|
544
592
|
for (var array2_1 = __values(array2), array2_1_1 = array2_1.next(); !array2_1_1.done; array2_1_1 = array2_1.next()) {
|
|
@@ -548,12 +596,12 @@ var XUtils = /** @class */ (function () {
|
|
|
548
596
|
}
|
|
549
597
|
}
|
|
550
598
|
}
|
|
551
|
-
catch (
|
|
599
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
552
600
|
finally {
|
|
553
601
|
try {
|
|
554
602
|
if (array2_1_1 && !array2_1_1.done && (_a = array2_1.return)) _a.call(array2_1);
|
|
555
603
|
}
|
|
556
|
-
finally { if (
|
|
604
|
+
finally { if (e_6) throw e_6.error; }
|
|
557
605
|
}
|
|
558
606
|
return array1.filter(function (item) { return item && array2IdSet.has(item[idField]); });
|
|
559
607
|
};
|
|
@@ -623,8 +671,10 @@ var XUtils = /** @class */ (function () {
|
|
|
623
671
|
alert(msg);
|
|
624
672
|
};
|
|
625
673
|
// pouziva sa hlavne na inputy
|
|
626
|
-
XUtils.
|
|
627
|
-
|
|
674
|
+
XUtils.createTooltipOrErrorProps = function (error, tooltip) {
|
|
675
|
+
// error ma prednost, ak nemame error, dame tooltip ak mame
|
|
676
|
+
return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } }
|
|
677
|
+
: (tooltip ? { tooltip: tooltip, tooltipOptions: { position: 'bottom' } } : {});
|
|
628
678
|
};
|
|
629
679
|
// pomocna metodka - prida className do props, ak uz className v props existuje tak len pripoji dalsiu hodnotu
|
|
630
680
|
// pouzivame ju, lebo XUtils.createErrorProps nam prebijal className
|
|
@@ -642,7 +692,7 @@ var XUtils = /** @class */ (function () {
|
|
|
642
692
|
// pomocna metodka
|
|
643
693
|
// ak nie su v xErrorMap ziadne chyby, vrati ""
|
|
644
694
|
XUtils.getErrorMessages = function (xErrorMap) {
|
|
645
|
-
var
|
|
695
|
+
var e_7, _a;
|
|
646
696
|
var _b;
|
|
647
697
|
var msg = "";
|
|
648
698
|
try {
|
|
@@ -656,12 +706,12 @@ var XUtils = /** @class */ (function () {
|
|
|
656
706
|
}
|
|
657
707
|
}
|
|
658
708
|
}
|
|
659
|
-
catch (
|
|
709
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
660
710
|
finally {
|
|
661
711
|
try {
|
|
662
712
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
663
713
|
}
|
|
664
|
-
finally { if (
|
|
714
|
+
finally { if (e_7) throw e_7.error; }
|
|
665
715
|
}
|
|
666
716
|
return msg;
|
|
667
717
|
};
|
|
@@ -732,7 +782,7 @@ var XUtils = /** @class */ (function () {
|
|
|
732
782
|
};
|
|
733
783
|
// pomocna metodka
|
|
734
784
|
XUtils.filterAnd = function () {
|
|
735
|
-
var
|
|
785
|
+
var e_8, _a;
|
|
736
786
|
var filters = [];
|
|
737
787
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
738
788
|
filters[_i] = arguments[_i];
|
|
@@ -749,12 +799,12 @@ var XUtils = /** @class */ (function () {
|
|
|
749
799
|
}
|
|
750
800
|
}
|
|
751
801
|
}
|
|
752
|
-
catch (
|
|
802
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
753
803
|
finally {
|
|
754
804
|
try {
|
|
755
805
|
if (filters_1_1 && !filters_1_1.done && (_a = filters_1.return)) _a.call(filters_1);
|
|
756
806
|
}
|
|
757
|
-
finally { if (
|
|
807
|
+
finally { if (e_8) throw e_8.error; }
|
|
758
808
|
}
|
|
759
809
|
}
|
|
760
810
|
return customFilterItemsResult;
|
|
@@ -799,7 +849,9 @@ var XUtils = /** @class */ (function () {
|
|
|
799
849
|
XUtils.xTokenPublic = { username: "xPublicUser", password: "xPublicUserPassword123" };
|
|
800
850
|
// nacachovane metadata (setuju sa v App.fetchAndSetXMetadata)
|
|
801
851
|
XUtils.appFormMap = {};
|
|
802
|
-
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
852
|
+
XUtils.exportTypeOptions = [ExportImportParam_1.ExportType.Excel, ExportImportParam_1.ExportType.Csv, ExportImportParam_1.ExportType.Json];
|
|
853
|
+
// moznost Off zatial nie je implementovana
|
|
854
|
+
XUtils.multilineExportTypeOptions = [ExportImportParam_1.XMultilineExportType.Multiline, ExportImportParam_1.XMultilineExportType.Singleline /*, XMultilineExportType.Off*/];
|
|
803
855
|
XUtils.csvSeparatorOptions = [ExportImportParam_1.CsvSeparator.Semicolon, ExportImportParam_1.CsvSeparator.Comma];
|
|
804
856
|
XUtils.decimalFormatOptions = [ExportImportParam_1.CsvDecimalFormat.Comma, ExportImportParam_1.CsvDecimalFormat.Dot];
|
|
805
857
|
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;
|