@michalrakus/x-react-web-lib 1.0.0 → 1.2.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/FindParam.d.ts +3 -0
- package/FindParam.js +5 -0
- package/LICENSE.md +21 -0
- package/XButtonIconNarrow.d.ts +3 -0
- package/XButtonIconNarrow.js +5 -0
- package/XButtonIconSmall.d.ts +3 -0
- package/XButtonIconSmall.js +5 -0
- package/XFieldChangeEvent.d.ts +3 -0
- package/XFieldChangeEvent.js +5 -0
- package/XInputTextarea.d.ts +3 -0
- package/XInputTextarea.js +5 -0
- package/gulpfile.js +5 -0
- package/lib/administration/XBrowseMetaBrowse.js +2 -1
- package/lib/administration/XBrowseMetaForm.js +4 -2
- package/lib/administration/XUserBrowse.js +3 -2
- package/lib/administration/XUserForm.js +5 -3
- package/lib/components/SearchTableParams.d.ts +8 -2
- package/lib/components/SourceCodeLinkEntity.js +3 -2
- package/lib/components/XAutoComplete.d.ts +10 -7
- package/lib/components/XAutoComplete.js +37 -41
- package/lib/components/XAutoCompleteBase.d.ts +8 -5
- package/lib/components/XAutoCompleteBase.js +86 -43
- package/lib/components/XAutoCompleteDT.d.ts +33 -0
- package/lib/components/XAutoCompleteDT.js +141 -0
- package/lib/components/XBrowse.js +11 -5
- package/lib/components/XButton.d.ts +3 -1
- package/lib/components/XButton.js +3 -2
- package/lib/components/XButtonIconNarrow.d.ts +10 -0
- package/lib/components/XButtonIconNarrow.js +25 -0
- package/lib/components/XButtonIconSmall.d.ts +3 -1
- package/lib/components/XButtonIconSmall.js +2 -1
- package/lib/components/XChangePasswordForm.js +12 -7
- package/lib/components/XCheckbox.d.ts +8 -10
- package/lib/components/XCheckbox.js +39 -31
- package/lib/components/XCheckboxDT.js +2 -1
- package/lib/components/XDataTable.js +16 -10
- package/lib/components/XDropdown.d.ts +7 -5
- package/lib/components/XDropdown.js +24 -45
- package/lib/components/XDropdownDT.js +10 -5
- package/lib/components/XDropdownDTFilter.js +12 -7
- package/lib/components/XDropdownFormDTFilter.js +12 -7
- package/lib/components/XEditColumnDialog.js +12 -7
- package/lib/components/XErrors.d.ts +1 -0
- package/lib/components/XExportRowsDialog.js +13 -8
- package/lib/components/XFieldChangeEvent.d.ts +11 -0
- package/lib/components/XFieldChangeEvent.js +2 -0
- package/lib/components/XFieldSelector.js +11 -6
- package/lib/components/XFormBase.d.ts +17 -8
- package/lib/components/XFormBase.js +127 -48
- package/lib/components/XFormBaseT.js +3 -1
- package/lib/components/XFormComponent.d.ts +19 -7
- package/lib/components/XFormComponent.js +89 -49
- package/lib/components/XFormComponentDT.d.ts +30 -0
- package/lib/components/XFormComponentDT.js +119 -0
- package/lib/components/XFormDataTable2.d.ts +53 -8
- package/lib/components/XFormDataTable2.js +270 -57
- package/lib/components/XFormFooter.js +2 -1
- package/lib/components/XFormNavigator3.js +18 -7
- package/lib/components/XHolders.js +4 -2
- package/lib/components/XInput.d.ts +13 -0
- package/lib/components/XInput.js +38 -0
- package/lib/components/XInputDT.d.ts +11 -0
- package/lib/components/XInputDT.js +37 -0
- package/lib/components/XInputDate.d.ts +2 -1
- package/lib/components/XInputDate.js +7 -4
- package/lib/components/XInputDateDT.js +3 -2
- package/lib/components/XInputDecimal.d.ts +9 -2
- package/lib/components/XInputDecimal.js +63 -45
- package/lib/components/XInputDecimalDT.d.ts +10 -8
- package/lib/components/XInputDecimalDT.js +59 -36
- package/lib/components/XInputText.d.ts +7 -11
- package/lib/components/XInputText.js +22 -49
- package/lib/components/XInputTextDT.js +4 -4
- package/lib/components/XInputTextarea.d.ts +18 -0
- package/lib/components/XInputTextarea.js +85 -0
- package/lib/components/XLazyDataTable.d.ts +8 -0
- package/lib/components/XLazyDataTable.js +187 -85
- package/lib/components/XLoginDialog.js +2 -1
- package/lib/components/XLoginForm.js +11 -6
- package/lib/components/XResponseError.js +4 -2
- package/lib/components/XSearchButton.d.ts +8 -7
- package/lib/components/XSearchButton.js +32 -51
- package/lib/components/XSearchButtonDT.js +15 -10
- package/lib/components/XSearchButtonOld.js +13 -8
- package/lib/components/XToOneAssocButton.js +2 -1
- package/lib/components/XUtils.d.ts +13 -1
- package/lib/components/XUtils.js +125 -5
- package/lib/components/XUtilsConversions.d.ts +1 -0
- package/lib/components/XUtilsConversions.js +24 -3
- package/lib/components/XUtilsMetadata.d.ts +4 -1
- package/lib/components/XUtilsMetadata.js +62 -14
- package/lib/components/useXToken.js +1 -1
- package/lib/serverApi/ExportImportParam.d.ts +3 -3
- package/lib/serverApi/FindParam.d.ts +12 -14
- package/lib/serverApi/FindParam.js +14 -0
- package/lib/serverApi/XUtilsCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +6 -2
- package/package.json +24 -25
package/FindParam.d.ts
ADDED
package/FindParam.js
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2023 Michal Rakus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/gulpfile.js
CHANGED
|
@@ -17,12 +17,15 @@ function generateApi(cb) {
|
|
|
17
17
|
"./lib/components/XAutoComplete",
|
|
18
18
|
"./lib/components/XAutoCompleteBase",
|
|
19
19
|
"./lib/components/XButton",
|
|
20
|
+
"./lib/components/XButtonIconNarrow",
|
|
21
|
+
"./lib/components/XButtonIconSmall",
|
|
20
22
|
"./lib/components/XBrowse",
|
|
21
23
|
"./lib/components/XChangePasswordForm",
|
|
22
24
|
"./lib/components/XCheckbox",
|
|
23
25
|
"./lib/components/XDropdown",
|
|
24
26
|
"./lib/components/XEnvVars",
|
|
25
27
|
"./lib/components/XErrors",
|
|
28
|
+
"./lib/components/XFieldChangeEvent",
|
|
26
29
|
"./lib/components/XFormBase",
|
|
27
30
|
"./lib/components/XFormBaseT",
|
|
28
31
|
"./lib/components/XFormDataTable2",
|
|
@@ -32,6 +35,7 @@ function generateApi(cb) {
|
|
|
32
35
|
"./lib/components/XInputDate",
|
|
33
36
|
"./lib/components/XInputDecimal",
|
|
34
37
|
"./lib/components/XInputText",
|
|
38
|
+
"./lib/components/XInputTextarea",
|
|
35
39
|
"./lib/components/XLazyDataTable",
|
|
36
40
|
"./lib/components/XLoginDialog",
|
|
37
41
|
"./lib/components/XLoginForm",
|
|
@@ -42,6 +46,7 @@ function generateApi(cb) {
|
|
|
42
46
|
"./lib/components/XUtilsConversions",
|
|
43
47
|
"./lib/components/XUtilsMetadata",
|
|
44
48
|
|
|
49
|
+
"./lib/serverApi/FindParam",
|
|
45
50
|
"./lib/serverApi/XUtilsCommon",
|
|
46
51
|
|
|
47
52
|
"./lib/administration/XUserBrowse",
|
|
@@ -7,7 +7,7 @@ exports.XBrowseMetaBrowse = void 0;
|
|
|
7
7
|
var XLazyDataTable_1 = require("../components/XLazyDataTable");
|
|
8
8
|
var react_1 = __importDefault(require("react"));
|
|
9
9
|
var XBrowseMetaForm_1 = require("./XBrowseMetaForm");
|
|
10
|
-
|
|
10
|
+
var XBrowseMetaBrowse = function (props) {
|
|
11
11
|
var onEdit = function (selectedRow) {
|
|
12
12
|
// openForm pridavame automaticky v XFormNavigator3 pri renderovani komponentu
|
|
13
13
|
props.openForm(react_1.default.createElement(XBrowseMetaForm_1.XBrowseMetaForm, { id: selectedRow.idXBrowseMeta }));
|
|
@@ -18,3 +18,4 @@ exports.XBrowseMetaBrowse = function (props) {
|
|
|
18
18
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "browseId", header: "Browse ID", width: "17rem" }),
|
|
19
19
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "rows", header: "Rows" })));
|
|
20
20
|
};
|
|
21
|
+
exports.XBrowseMetaBrowse = XBrowseMetaBrowse;
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -54,7 +56,7 @@ var XBrowseMetaForm = /** @class */ (function (_super) {
|
|
|
54
56
|
react_1.default.createElement(XFormFooter_1.XFormFooter, { form: this })));
|
|
55
57
|
};
|
|
56
58
|
XBrowseMetaForm = __decorate([
|
|
57
|
-
XFormBase_1.Form("XBrowseMeta")
|
|
59
|
+
(0, XFormBase_1.Form)("XBrowseMeta")
|
|
58
60
|
], XBrowseMetaForm);
|
|
59
61
|
return XBrowseMetaForm;
|
|
60
62
|
}(XFormBase_1.XFormBase));
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
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;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -44,7 +44,7 @@ var XLazyDataTable_1 = require("../components/XLazyDataTable");
|
|
|
44
44
|
var react_1 = __importDefault(require("react"));
|
|
45
45
|
var XUserForm_1 = require("./XUserForm");
|
|
46
46
|
var XUtils_1 = require("../components/XUtils");
|
|
47
|
-
|
|
47
|
+
var XUserBrowse = function (props) {
|
|
48
48
|
var onAddRow = function () {
|
|
49
49
|
// openForm pridavame automaticky v XFormNavigator3 pri renderovani komponentu
|
|
50
50
|
props.openForm(react_1.default.createElement(XUserForm_1.XUserForm, { object: { enabled: true } }));
|
|
@@ -81,6 +81,7 @@ exports.XUserBrowse = function (props) {
|
|
|
81
81
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "name", header: "Name", width: "17rem" }),
|
|
82
82
|
react_1.default.createElement(XLazyDataTable_1.XLazyColumn, { field: "enabled", header: "Enabled" })));
|
|
83
83
|
};
|
|
84
|
+
exports.XUserBrowse = XUserBrowse;
|
|
84
85
|
// zatial nepouzivane - prichystane do buducnosti
|
|
85
86
|
// ak by sme mali class komponenty, dal by sa pouzit decorator, pri formularoch mame class komponenty
|
|
86
87
|
XUtils_1.XUtils.registerAppBrowse(react_1.default.createElement(exports.XUserBrowse, null), "XUser");
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -36,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
38
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
37
39
|
function step(op) {
|
|
38
40
|
if (f) throw new TypeError("Generator is already executing.");
|
|
39
|
-
while (_) try {
|
|
41
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
40
42
|
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;
|
|
41
43
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
42
44
|
switch (op[0]) {
|
|
@@ -179,7 +181,7 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
179
181
|
react_1.default.createElement(XFormFooter_1.XFormFooter, { form: this })));
|
|
180
182
|
};
|
|
181
183
|
XUserForm = __decorate([
|
|
182
|
-
XFormBase_1.Form("XUser"),
|
|
184
|
+
(0, XFormBase_1.Form)("XUser"),
|
|
183
185
|
__metadata("design:paramtypes", [Object])
|
|
184
186
|
], XUserForm);
|
|
185
187
|
return XUserForm;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { DataTableFilterMetaData } from "primereact/datatable";
|
|
2
|
+
import { XCustomFilter } from "../serverApi/FindParam";
|
|
3
|
+
export interface XFieldFilter {
|
|
4
|
+
field: string;
|
|
5
|
+
constraint: DataTableFilterMetaData;
|
|
6
|
+
}
|
|
1
7
|
export interface SearchTableParams {
|
|
2
8
|
onChoose: (chosenRow: any) => void;
|
|
3
|
-
|
|
4
|
-
|
|
9
|
+
displayFieldFilter?: XFieldFilter;
|
|
10
|
+
customFilter?: XCustomFilter;
|
|
5
11
|
}
|
|
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SourceCodeLinkEntity = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
|
-
|
|
8
|
+
var SourceCodeLinkEntity = function (props) {
|
|
9
9
|
return (react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
10
|
-
react_1.default.createElement("a", { className: "source-code-link", href: "https://github.com/michalrakus/demo-nest-server-app/blob/master/src/model/"
|
|
10
|
+
react_1.default.createElement("a", { className: "source-code-link", href: "https://github.com/michalrakus/demo-nest-server-app/blob/master/src/model/".concat(props.sourceCodeFile), target: "_blank", rel: "noopener noreferrer" },
|
|
11
11
|
"Source code entity: ",
|
|
12
12
|
props.sourceCodeFile)));
|
|
13
13
|
};
|
|
14
|
+
exports.SourceCodeLinkEntity = SourceCodeLinkEntity;
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { XFormComponent, XFormComponentProps } from "./XFormComponent";
|
|
2
|
+
import { XFilterProp, XFormComponent, XFormComponentProps } from "./XFormComponent";
|
|
3
3
|
import { XAssoc } from "../serverApi/XEntityMetadata";
|
|
4
4
|
import { OperationType } from "./XUtils";
|
|
5
5
|
import { XError } from "./XErrors";
|
|
6
|
-
|
|
6
|
+
import { XObject } from "./XObject";
|
|
7
|
+
export interface XAutoCompleteProps extends XFormComponentProps<XObject> {
|
|
7
8
|
assocField: string;
|
|
8
|
-
displayField: string;
|
|
9
|
+
displayField: string | ((suggestion: any) => string);
|
|
9
10
|
searchTable?: any;
|
|
10
11
|
assocForm?: any;
|
|
12
|
+
filter?: XFilterProp;
|
|
11
13
|
size?: number;
|
|
12
14
|
inputStyle?: React.CSSProperties;
|
|
13
15
|
}
|
|
14
|
-
export declare class XAutoComplete extends XFormComponent<XAutoCompleteProps> {
|
|
16
|
+
export declare class XAutoComplete extends XFormComponent<XObject, XAutoCompleteProps> {
|
|
15
17
|
protected xAssoc: XAssoc;
|
|
16
18
|
protected errorInBase: string | undefined;
|
|
17
19
|
state: {
|
|
18
20
|
suggestions: any[];
|
|
19
21
|
};
|
|
20
22
|
constructor(props: XAutoCompleteProps);
|
|
23
|
+
getDisplayFieldOrId(): string;
|
|
21
24
|
componentDidMount(): void;
|
|
22
25
|
readAndSetSuggestions(): Promise<void>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
getField(): string;
|
|
27
|
+
isNotNull(): boolean;
|
|
28
|
+
getValue(): any | null;
|
|
26
29
|
onChangeAutoCompleteBase(object: any, objectChange: OperationType): void;
|
|
27
30
|
onErrorChangeAutoCompleteBase(error: string | undefined): void;
|
|
28
31
|
validate(): {
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
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");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -27,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
27
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
30
|
function step(op) {
|
|
29
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
31
33
|
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;
|
|
32
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
35
|
switch (op[0]) {
|
|
@@ -69,10 +71,22 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
69
71
|
};
|
|
70
72
|
_this.onChangeAutoCompleteBase = _this.onChangeAutoCompleteBase.bind(_this);
|
|
71
73
|
_this.onErrorChangeAutoCompleteBase = _this.onErrorChangeAutoCompleteBase.bind(_this);
|
|
72
|
-
props.form.addField(props.assocField + '.' +
|
|
74
|
+
props.form.addField(props.assocField + '.' + _this.getDisplayFieldOrId());
|
|
73
75
|
return _this;
|
|
74
76
|
}
|
|
77
|
+
XAutoComplete.prototype.getDisplayFieldOrId = function () {
|
|
78
|
+
// toto je hack - ak ratame displayField cez funkciu, tak nam potom chyba (hociaky) atribut asociovaneho objektu
|
|
79
|
+
// podobne ako na XFormDataTable2, podsunieme id-ckovy atribut
|
|
80
|
+
if (typeof this.props.displayField === 'string') {
|
|
81
|
+
return this.props.displayField; // vsetko ok
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// v displayField mame funkciu, zistime id-ckovy atribut
|
|
85
|
+
return XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName).idField;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
75
88
|
XAutoComplete.prototype.componentDidMount = function () {
|
|
89
|
+
console.log("volany XAutoComplete.componentDidMount()");
|
|
76
90
|
this.readAndSetSuggestions();
|
|
77
91
|
};
|
|
78
92
|
XAutoComplete.prototype.readAndSetSuggestions = function () {
|
|
@@ -80,41 +94,31 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
80
94
|
var suggestions;
|
|
81
95
|
return __generator(this, function (_a) {
|
|
82
96
|
switch (_a.label) {
|
|
83
|
-
case 0: return [4 /*yield*/, XUtils_1.XUtils.
|
|
97
|
+
case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), typeof this.props.displayField === 'string' ? this.props.displayField : undefined)];
|
|
84
98
|
case 1:
|
|
85
99
|
suggestions = _a.sent();
|
|
100
|
+
// ak mame funkciu, zosortujeme tu
|
|
101
|
+
if (typeof this.props.displayField === 'function') {
|
|
102
|
+
suggestions = XUtils_1.XUtils.arraySort(suggestions, this.props.displayField);
|
|
103
|
+
}
|
|
86
104
|
this.setState({ suggestions: suggestions });
|
|
87
105
|
return [2 /*return*/];
|
|
88
106
|
}
|
|
89
107
|
});
|
|
90
108
|
});
|
|
91
109
|
};
|
|
92
|
-
XAutoComplete.prototype.
|
|
93
|
-
|
|
94
|
-
// TODO - zohladnit aj aktualny readOnly stav
|
|
95
|
-
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
96
|
-
if (!readOnly) {
|
|
97
|
-
return this.props.assocField;
|
|
98
|
-
}
|
|
99
|
-
return undefined;
|
|
110
|
+
XAutoComplete.prototype.getField = function () {
|
|
111
|
+
return this.props.assocField;
|
|
100
112
|
};
|
|
101
|
-
XAutoComplete.prototype.
|
|
102
|
-
|
|
103
|
-
// TODO - zohladnit aj aktualny readOnly stav
|
|
104
|
-
return !this.xAssoc.isNullable && !((_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false);
|
|
113
|
+
XAutoComplete.prototype.isNotNull = function () {
|
|
114
|
+
return !this.xAssoc.isNullable;
|
|
105
115
|
};
|
|
106
|
-
XAutoComplete.prototype.
|
|
107
|
-
var
|
|
108
|
-
var assocObject = object !== null ? object[this.props.assocField] : null;
|
|
109
|
-
// ak je undefined, pre istotu dame na null, null je standard
|
|
110
|
-
if (assocObject === undefined) {
|
|
111
|
-
assocObject = null;
|
|
112
|
-
}
|
|
116
|
+
XAutoComplete.prototype.getValue = function () {
|
|
117
|
+
var assocObject = this.getValueFromObject();
|
|
113
118
|
return assocObject;
|
|
114
119
|
};
|
|
115
120
|
XAutoComplete.prototype.onChangeAutoCompleteBase = function (object, objectChange) {
|
|
116
|
-
|
|
117
|
-
this.props.form.onFieldChange(this.props.assocField, object, error);
|
|
121
|
+
this.onValueChangeBase(object, this.props.onChange, objectChange);
|
|
118
122
|
if (objectChange !== XUtils_1.OperationType.None) {
|
|
119
123
|
// zmenil sa zaznam dobrovolnika v DB
|
|
120
124
|
// zatial len refreshneme z DB
|
|
@@ -129,30 +133,22 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
129
133
|
// overrides method in XFormComponent
|
|
130
134
|
XAutoComplete.prototype.validate = function () {
|
|
131
135
|
if (this.errorInBase) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// error message dame na onChange, mohli by sme aj na onSet (predtym onBlur), je to jedno viac-menej
|
|
135
|
-
return { field: field, xError: { onChange: this.errorInBase } };
|
|
136
|
-
}
|
|
136
|
+
// error message dame na onChange, mohli by sme aj na onSet (predtym onBlur), je to jedno viac-menej
|
|
137
|
+
return { field: this.getField(), xError: { onChange: this.errorInBase, fieldLabel: this.getLabel() } };
|
|
137
138
|
}
|
|
138
139
|
// zavolame povodnu metodu
|
|
139
140
|
return _super.prototype.validate.call(this);
|
|
140
141
|
};
|
|
141
142
|
XAutoComplete.prototype.render = function () {
|
|
142
|
-
var _a, _b, _c, _d;
|
|
143
143
|
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
var readOnly = (_b = this.props.readOnly) !== null && _b !== void 0 ? _b : false;
|
|
150
|
-
var size = (_c = this.props.size) !== null && _c !== void 0 ? _c : xDisplayField.length;
|
|
151
|
-
var labelStyle = (_d = this.props.labelStyle) !== null && _d !== void 0 ? _d : { width: XUtils_1.XUtils.FIELD_LABEL_WIDTH };
|
|
144
|
+
//const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
145
|
+
// TODO - readOnly
|
|
146
|
+
// TODO - size
|
|
147
|
+
//const size = this.props.size ?? xDisplayField.length;
|
|
152
148
|
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
153
149
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
154
|
-
react_1.default.createElement("label", { htmlFor: this.props.assocField, className: "col-fixed", style:
|
|
155
|
-
react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.
|
|
150
|
+
react_1.default.createElement("label", { htmlFor: this.props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
151
|
+
react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.getValue(), suggestions: this.state.suggestions, onChange: this.onChangeAutoCompleteBase, field: this.props.displayField, valueForm: this.props.assocForm, idField: xEntityAssoc.idField, error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase })));
|
|
156
152
|
};
|
|
157
153
|
return XAutoComplete;
|
|
158
154
|
}(XFormComponent_1.XFormComponent));
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Component } from "react";
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import { AutoCompleteChangeEvent } from "primereact/autocomplete";
|
|
2
3
|
import { OperationType } from "./XUtils";
|
|
3
4
|
export interface XAutoCompleteBaseProps {
|
|
4
5
|
value: any;
|
|
5
6
|
suggestions: any[];
|
|
6
7
|
onChange: (object: any, objectChange: OperationType) => void;
|
|
7
|
-
field: string;
|
|
8
|
+
field: string | ((suggestion: any) => string);
|
|
8
9
|
valueForm?: any;
|
|
9
10
|
idField?: string;
|
|
10
|
-
|
|
11
|
+
maxLength?: number;
|
|
11
12
|
error?: string;
|
|
12
13
|
onErrorChange: (error: string | undefined) => void;
|
|
13
14
|
setFocusOnCreate?: boolean;
|
|
@@ -25,17 +26,19 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
25
26
|
formDialogInitObjectForInsert: any | undefined;
|
|
26
27
|
constructor(props: XAutoCompleteBaseProps);
|
|
27
28
|
componentDidMount(): void;
|
|
29
|
+
getDisplayValue(suggestion: any): string;
|
|
28
30
|
completeMethod(event: {
|
|
29
31
|
query: string;
|
|
30
32
|
}): void;
|
|
31
|
-
onChange(e:
|
|
33
|
+
onChange(e: AutoCompleteChangeEvent): void;
|
|
32
34
|
onSelect(e: any): void;
|
|
33
|
-
onBlur(e:
|
|
35
|
+
onBlur(e: React.FocusEvent<HTMLInputElement>): void;
|
|
34
36
|
createErrorMessage(): string;
|
|
35
37
|
setFocusToInput(): void;
|
|
36
38
|
setObjectValue(object: any, objectChange: OperationType): void;
|
|
37
39
|
formDialogOnSaveOrCancel(object: any | null, objectChange: OperationType): void;
|
|
38
40
|
formDialogOnHide(): void;
|
|
39
41
|
computeInputValue(): any;
|
|
42
|
+
itemTemplate(suggestion: any, index: number): React.ReactNode;
|
|
40
43
|
render(): JSX.Element;
|
|
41
44
|
}
|