@michalrakus/x-react-web-lib 1.10.0 → 1.11.1
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/XEditBrowse.d.ts +3 -0
- package/XEditBrowse.js +5 -0
- package/XObject.d.ts +3 -0
- package/XObject.js +5 -0
- package/gulpfile.js +2 -1
- package/lib/administration/XBrowseMetaBrowse.d.ts +2 -1
- package/lib/administration/XUserBrowse.d.ts +2 -1
- package/lib/administration/XUserBrowse.js +1 -1
- package/lib/administration/XUserForm.d.ts +6 -3
- package/lib/administration/XUserForm.js +9 -16
- package/lib/components/XAutoComplete.d.ts +6 -4
- package/lib/components/XAutoComplete.js +13 -22
- package/lib/components/XAutoCompleteBase.d.ts +15 -5
- package/lib/components/XAutoCompleteBase.js +115 -96
- package/lib/components/XAutoCompleteDT.d.ts +4 -3
- package/lib/components/XAutoCompleteDT.js +8 -7
- package/lib/components/XCheckboxDT.d.ts +2 -1
- package/lib/components/XCheckboxDT.js +2 -9
- package/lib/components/XDropdownDT.d.ts +2 -2
- package/lib/components/XDropdownDT.js +2 -3
- package/lib/components/{XBrowse.d.ts → XEditBrowse.d.ts} +3 -3
- package/lib/components/{XBrowse.js → XEditBrowse.js} +22 -22
- package/lib/components/XFormBase.d.ts +10 -9
- package/lib/components/XFormBase.js +20 -12
- package/lib/components/XFormComponent.d.ts +3 -3
- package/lib/components/XFormComponentDT.d.ts +4 -4
- package/lib/components/XFormComponentDT.js +10 -11
- package/lib/components/XFormDataTable2.d.ts +10 -8
- package/lib/components/XFormDataTable2.js +36 -28
- package/lib/components/XFormNavigator3.d.ts +3 -3
- package/lib/components/XFormNavigator3.js +2 -2
- package/lib/components/XInputDateDT.d.ts +2 -1
- package/lib/components/XInputDateDT.js +2 -9
- package/lib/components/XInputTextDT.d.ts +2 -1
- package/lib/components/XInputTextDT.js +2 -9
- package/lib/components/XLazyDataTable.d.ts +9 -2
- package/lib/components/XLazyDataTable.js +17 -15
- package/lib/components/{SearchTableParams.d.ts → XSearchBrowseParams.d.ts} +2 -2
- package/lib/components/XSearchButton.d.ts +2 -2
- package/lib/components/XSearchButton.js +7 -11
- package/lib/components/XSearchButtonDT.d.ts +4 -3
- package/lib/components/XSearchButtonDT.js +10 -6
- package/lib/components/XUtils.d.ts +24 -1
- package/lib/components/XUtils.js +92 -8
- package/lib/components/locale/x-en.json +4 -1
- package/package.json +1 -1
- package/XBrowse.d.ts +0 -3
- package/XBrowse.js +0 -5
- /package/lib/components/{SearchTableParams.js → XSearchBrowseParams.js} +0 -0
package/XEditBrowse.d.ts
ADDED
package/XEditBrowse.js
ADDED
package/XObject.d.ts
ADDED
package/XObject.js
ADDED
package/gulpfile.js
CHANGED
|
@@ -21,7 +21,6 @@ function generateApi(cb) {
|
|
|
21
21
|
"./lib/components/useXToken",
|
|
22
22
|
"./lib/components/XAutoComplete",
|
|
23
23
|
"./lib/components/XAutoCompleteBase",
|
|
24
|
-
"./lib/components/XBrowse",
|
|
25
24
|
"./lib/components/XButton",
|
|
26
25
|
"./lib/components/XButtonIconMedium",
|
|
27
26
|
"./lib/components/XButtonIconNarrow",
|
|
@@ -31,6 +30,7 @@ function generateApi(cb) {
|
|
|
31
30
|
"./lib/components/XCheckbox",
|
|
32
31
|
"./lib/components/XDropdown",
|
|
33
32
|
"./lib/components/XDropdownForEntity",
|
|
33
|
+
"./lib/components/XEditBrowse",
|
|
34
34
|
"./lib/components/XEnvVars",
|
|
35
35
|
"./lib/components/XErrors",
|
|
36
36
|
"./lib/components/XExportRowsDialog",
|
|
@@ -54,6 +54,7 @@ function generateApi(cb) {
|
|
|
54
54
|
"./lib/components/XLocale",
|
|
55
55
|
"./lib/components/XLoginDialog",
|
|
56
56
|
"./lib/components/XLoginForm",
|
|
57
|
+
"./lib/components/XObject",
|
|
57
58
|
"./lib/components/XSearchButton",
|
|
58
59
|
"./lib/components/XToken",
|
|
59
60
|
"./lib/components/XToOneAssocButton",
|
|
@@ -47,7 +47,7 @@ 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
|
-
props.openForm(react_1.default.createElement(XUserForm_1.XUserForm,
|
|
50
|
+
props.openForm(react_1.default.createElement(XUserForm_1.XUserForm, null));
|
|
51
51
|
};
|
|
52
52
|
var onEdit = function (selectedRow) {
|
|
53
53
|
// openForm pridavame automaticky v XFormNavigator3 pri renderovani komponentu
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { XFormProps } from "../components/XFormBase";
|
|
3
|
+
import { OperationType } from "../components/XUtils";
|
|
3
4
|
import { XFormBaseModif } from "../components/XFormBaseModif";
|
|
5
|
+
import { XObject } from "../components/XObject";
|
|
4
6
|
export declare class XUserForm extends XFormBaseModif {
|
|
5
|
-
constructor(props:
|
|
6
|
-
|
|
7
|
+
constructor(props: XFormProps);
|
|
8
|
+
createNewObject(): XObject;
|
|
9
|
+
preInitForm(object: XObject, operationType: OperationType.Insert | OperationType.Update): void;
|
|
7
10
|
onClickSave(): Promise<void>;
|
|
8
11
|
render(): JSX.Element;
|
|
9
12
|
}
|
|
@@ -85,22 +85,15 @@ var XUserForm = /** @class */ (function (_super) {
|
|
|
85
85
|
_this.onClickSave = _this.onClickSave.bind(_this);
|
|
86
86
|
return _this;
|
|
87
87
|
}
|
|
88
|
-
XUserForm.prototype.
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (username === XUtils_1.XUtils.getUsername() || (XUtils_1.XUtils.demo() && (username === 'jozko' || username === 'xman'))) {
|
|
98
|
-
this.setState({ usernameEnabledReadOnly: true });
|
|
99
|
-
}
|
|
100
|
-
return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
88
|
+
XUserForm.prototype.createNewObject = function () {
|
|
89
|
+
return { enabled: true, admin: false, version: 0 };
|
|
90
|
+
};
|
|
91
|
+
XUserForm.prototype.preInitForm = function (object, operationType) {
|
|
92
|
+
// aktualny user si nemoze zmenit username, enabled a admin status
|
|
93
|
+
var username = this.getXObject().username;
|
|
94
|
+
if (operationType === XUtils_1.OperationType.Update && (username === XUtils_1.XUtils.getUsername() || (XUtils_1.XUtils.demo() && (username === 'xman')))) {
|
|
95
|
+
this.setState({ usernameEnabledReadOnly: true });
|
|
96
|
+
}
|
|
104
97
|
};
|
|
105
98
|
XUserForm.prototype.onClickSave = function () {
|
|
106
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -4,12 +4,15 @@ import { XAssoc } from "../serverApi/XEntityMetadata";
|
|
|
4
4
|
import { OperationType } from "./XUtils";
|
|
5
5
|
import { XError } from "./XErrors";
|
|
6
6
|
import { XObject } from "./XObject";
|
|
7
|
+
import { DataTableSortMeta } from "primereact/datatable";
|
|
7
8
|
export interface XAutoCompleteProps extends XFormComponentProps<XObject> {
|
|
8
9
|
assocField: string;
|
|
9
|
-
displayField: string
|
|
10
|
-
|
|
11
|
-
assocForm?:
|
|
10
|
+
displayField: string;
|
|
11
|
+
searchBrowse?: JSX.Element;
|
|
12
|
+
assocForm?: JSX.Element;
|
|
12
13
|
filter?: XFilterProp;
|
|
14
|
+
sortField?: string | DataTableSortMeta[];
|
|
15
|
+
suggestions?: any[];
|
|
13
16
|
size?: number;
|
|
14
17
|
inputStyle?: React.CSSProperties;
|
|
15
18
|
}
|
|
@@ -20,7 +23,6 @@ export declare class XAutoComplete extends XFormComponent<XObject, XAutoComplete
|
|
|
20
23
|
suggestions: any[];
|
|
21
24
|
};
|
|
22
25
|
constructor(props: XAutoCompleteProps);
|
|
23
|
-
getDisplayFieldOrId(): string;
|
|
24
26
|
componentDidMount(): void;
|
|
25
27
|
readAndSetSuggestions(): Promise<void>;
|
|
26
28
|
getField(): string;
|
|
@@ -71,38 +71,27 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
71
71
|
};
|
|
72
72
|
_this.onChangeAutoCompleteBase = _this.onChangeAutoCompleteBase.bind(_this);
|
|
73
73
|
_this.onErrorChangeAutoCompleteBase = _this.onErrorChangeAutoCompleteBase.bind(_this);
|
|
74
|
-
props.form.addField(props.assocField + '.' +
|
|
74
|
+
props.form.addField(props.assocField + '.' + props.displayField);
|
|
75
75
|
return _this;
|
|
76
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
|
-
};
|
|
88
77
|
XAutoComplete.prototype.componentDidMount = function () {
|
|
89
78
|
//console.log("volany XAutoComplete.componentDidMount()");
|
|
90
79
|
this.readAndSetSuggestions();
|
|
91
80
|
};
|
|
92
81
|
XAutoComplete.prototype.readAndSetSuggestions = function () {
|
|
82
|
+
var _a;
|
|
93
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
94
84
|
var suggestions;
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
97
|
-
case 0:
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (!(this.props.suggestions === undefined)) return [3 /*break*/, 2];
|
|
89
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), (_a = this.props.sortField) !== null && _a !== void 0 ? _a : this.props.displayField)];
|
|
98
90
|
case 1:
|
|
99
|
-
suggestions =
|
|
100
|
-
// ak mame funkciu, zosortujeme tu
|
|
101
|
-
if (typeof this.props.displayField === 'function') {
|
|
102
|
-
suggestions = XUtils_1.XUtils.arraySort(suggestions, this.props.displayField);
|
|
103
|
-
}
|
|
91
|
+
suggestions = _b.sent();
|
|
104
92
|
this.setState({ suggestions: suggestions });
|
|
105
|
-
|
|
93
|
+
_b.label = 2;
|
|
94
|
+
case 2: return [2 /*return*/];
|
|
106
95
|
}
|
|
107
96
|
});
|
|
108
97
|
});
|
|
@@ -140,6 +129,8 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
140
129
|
return _super.prototype.validate.call(this);
|
|
141
130
|
};
|
|
142
131
|
XAutoComplete.prototype.render = function () {
|
|
132
|
+
var _this = this;
|
|
133
|
+
var _a;
|
|
143
134
|
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
144
135
|
//const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
145
136
|
// TODO - readOnly
|
|
@@ -148,7 +139,7 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
148
139
|
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
149
140
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
150
141
|
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 })));
|
|
142
|
+
react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.getValue(), suggestions: (_a = this.props.suggestions) !== null && _a !== void 0 ? _a : this.state.suggestions, onChange: this.onChangeAutoCompleteBase, field: this.props.displayField, searchBrowse: this.props.searchBrowse, valueForm: this.props.assocForm, idField: xEntityAssoc.idField, error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase, customFilterFunction: function () { return _this.getFilterBase(_this.props.filter); } })));
|
|
152
143
|
};
|
|
153
144
|
return XAutoComplete;
|
|
154
145
|
}(XFormComponent_1.XFormComponent));
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React, { Component } from "react";
|
|
2
2
|
import { AutoCompleteChangeEvent } from "primereact/autocomplete";
|
|
3
3
|
import { OperationType } from "./XUtils";
|
|
4
|
+
import { MenuItem } from "primereact/menuitem";
|
|
5
|
+
import { XSearchBrowseParams } from "./XSearchBrowseParams";
|
|
6
|
+
import { XCustomFilter } from "../serverApi/FindParam";
|
|
4
7
|
export interface XAutoCompleteBaseProps {
|
|
5
8
|
value: any;
|
|
6
9
|
suggestions: any[];
|
|
7
10
|
onChange: (object: any, objectChange: OperationType) => void;
|
|
8
|
-
field: string
|
|
9
|
-
|
|
11
|
+
field: string;
|
|
12
|
+
searchBrowse?: JSX.Element;
|
|
13
|
+
valueForm?: JSX.Element;
|
|
10
14
|
idField?: string;
|
|
11
15
|
maxLength?: number;
|
|
12
16
|
readOnly?: boolean;
|
|
13
17
|
error?: string;
|
|
14
18
|
onErrorChange: (error: string | undefined) => void;
|
|
15
19
|
setFocusOnCreate?: boolean;
|
|
20
|
+
customFilterFunction?: () => XCustomFilter | undefined;
|
|
16
21
|
}
|
|
17
22
|
export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps> {
|
|
18
23
|
autoCompleteRef: any;
|
|
@@ -22,12 +27,12 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
22
27
|
notValid: boolean;
|
|
23
28
|
filteredSuggestions: any[] | undefined;
|
|
24
29
|
formDialogOpened: boolean;
|
|
30
|
+
searchDialogOpened: boolean;
|
|
25
31
|
};
|
|
26
32
|
formDialogObjectId: number | undefined;
|
|
27
|
-
|
|
33
|
+
formDialogInitValuesForInsert: any | undefined;
|
|
28
34
|
constructor(props: XAutoCompleteBaseProps);
|
|
29
35
|
componentDidMount(): void;
|
|
30
|
-
getDisplayValue(suggestion: any): string;
|
|
31
36
|
completeMethod(event: {
|
|
32
37
|
query: string;
|
|
33
38
|
}): void;
|
|
@@ -39,7 +44,12 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
39
44
|
setObjectValue(object: any, objectChange: OperationType): void;
|
|
40
45
|
formDialogOnSaveOrCancel(object: any | null, objectChange: OperationType): void;
|
|
41
46
|
formDialogOnHide(): void;
|
|
47
|
+
searchDialogOnChoose(chosenRow: any): void;
|
|
48
|
+
searchDialogOnHide(): void;
|
|
49
|
+
createInsertUpdateItems(splitButtonItems: MenuItem[]): void;
|
|
50
|
+
createSearchItem(splitButtonItems: MenuItem[]): void;
|
|
51
|
+
createDropdownItem(splitButtonItems: MenuItem[]): void;
|
|
42
52
|
computeInputValue(): any;
|
|
43
|
-
|
|
53
|
+
createSearchBrowseParams(): XSearchBrowseParams;
|
|
44
54
|
render(): JSX.Element;
|
|
45
55
|
}
|
|
@@ -91,7 +91,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
91
91
|
inputValueState: undefined,
|
|
92
92
|
notValid: false,
|
|
93
93
|
filteredSuggestions: undefined,
|
|
94
|
-
formDialogOpened: false
|
|
94
|
+
formDialogOpened: false,
|
|
95
|
+
searchDialogOpened: false
|
|
95
96
|
};
|
|
96
97
|
_this.completeMethod = _this.completeMethod.bind(_this);
|
|
97
98
|
_this.onChange = _this.onChange.bind(_this);
|
|
@@ -99,7 +100,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
99
100
|
_this.onBlur = _this.onBlur.bind(_this);
|
|
100
101
|
_this.formDialogOnSaveOrCancel = _this.formDialogOnSaveOrCancel.bind(_this);
|
|
101
102
|
_this.formDialogOnHide = _this.formDialogOnHide.bind(_this);
|
|
102
|
-
_this.
|
|
103
|
+
_this.searchDialogOnChoose = _this.searchDialogOnChoose.bind(_this);
|
|
104
|
+
_this.searchDialogOnHide = _this.searchDialogOnHide.bind(_this);
|
|
103
105
|
return _this;
|
|
104
106
|
}
|
|
105
107
|
XAutoCompleteBase.prototype.componentDidMount = function () {
|
|
@@ -107,17 +109,6 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
107
109
|
this.setFocusToInput();
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
|
-
XAutoCompleteBase.prototype.getDisplayValue = function (suggestion) {
|
|
111
|
-
var displayValue;
|
|
112
|
-
if (typeof this.props.field === 'string') {
|
|
113
|
-
displayValue = suggestion[this.props.field];
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
// this.props.field is function returning string
|
|
117
|
-
displayValue = this.props.field(suggestion);
|
|
118
|
-
}
|
|
119
|
-
return displayValue;
|
|
120
|
-
};
|
|
121
112
|
XAutoCompleteBase.prototype.completeMethod = function (event) {
|
|
122
113
|
var _this = this;
|
|
123
114
|
var filteredSuggestions;
|
|
@@ -127,7 +118,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
127
118
|
else {
|
|
128
119
|
var queryNormalized_1 = XUtils_1.XUtils.normalizeString(event.query);
|
|
129
120
|
filteredSuggestions = this.props.suggestions.filter(function (suggestion) {
|
|
130
|
-
var fieldValue = _this.
|
|
121
|
+
var fieldValue = suggestion[_this.props.field];
|
|
131
122
|
// specialna null polozka (prazdny objekt) - test dame az za test fieldValue na undefined - koli performance
|
|
132
123
|
if (fieldValue === undefined && Object.keys(suggestion).length === 0) {
|
|
133
124
|
return false;
|
|
@@ -204,8 +195,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
204
195
|
this.formDialogObjectId = undefined;
|
|
205
196
|
// TODO - pridat ako novu prop metodu ktora bude vracat bude mat parameter this.state.inputValueState a vrati object
|
|
206
197
|
// ak bude tato metoda undefined, tak zostane tato povodna funkcionalita
|
|
207
|
-
this.
|
|
208
|
-
this.
|
|
198
|
+
this.formDialogInitValuesForInsert = {};
|
|
199
|
+
this.formDialogInitValuesForInsert[this.props.field] = this.state.inputValueState;
|
|
209
200
|
this.setState({formDialogOpened: true});
|
|
210
201
|
}
|
|
211
202
|
else {
|
|
@@ -245,91 +236,124 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
245
236
|
this.setFocusToInput();
|
|
246
237
|
}
|
|
247
238
|
};
|
|
239
|
+
XAutoCompleteBase.prototype.searchDialogOnChoose = function (chosenRow) {
|
|
240
|
+
this.setState({ searchDialogOpened: false });
|
|
241
|
+
// zapiseme vybraty row do objektu
|
|
242
|
+
this.setObjectValue(chosenRow, XUtils_1.OperationType.None);
|
|
243
|
+
};
|
|
244
|
+
XAutoCompleteBase.prototype.searchDialogOnHide = function () {
|
|
245
|
+
this.setState({ searchDialogOpened: false });
|
|
246
|
+
// ak mame v inpute neplatnu hodnotu, vratime kurzor na input
|
|
247
|
+
if (this.state.inputChanged) {
|
|
248
|
+
this.setFocusToInput();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
XAutoCompleteBase.prototype.createInsertUpdateItems = function (splitButtonItems) {
|
|
252
|
+
var _this = this;
|
|
253
|
+
splitButtonItems.push({
|
|
254
|
+
icon: 'pi pi-plus',
|
|
255
|
+
command: function (e) {
|
|
256
|
+
// otvorime dialog na insert
|
|
257
|
+
_this.formDialogObjectId = undefined;
|
|
258
|
+
_this.formDialogInitValuesForInsert = {};
|
|
259
|
+
// ak mame nevalidnu hodnotu, tak ju predplnime (snaha o user friendly)
|
|
260
|
+
if (_this.state.inputChanged) {
|
|
261
|
+
_this.formDialogInitValuesForInsert[_this.props.field] = _this.state.inputValueState;
|
|
262
|
+
}
|
|
263
|
+
_this.setState({ formDialogOpened: true });
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
splitButtonItems.push({
|
|
267
|
+
icon: 'pi pi-pencil',
|
|
268
|
+
command: function (e) {
|
|
269
|
+
if (_this.state.inputChanged) {
|
|
270
|
+
alert("Value \"".concat(_this.state.inputValueState, "\" was not found among valid values, please enter some valid value."));
|
|
271
|
+
_this.setFocusToInput();
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
if (_this.props.value === null) {
|
|
275
|
+
alert('Please select some row.');
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// otvorime dialog na update
|
|
279
|
+
if (_this.props.idField === undefined) {
|
|
280
|
+
throw "XAutoCompleteBase: property valueForm is defined but property idField is also needed for form editation.";
|
|
281
|
+
}
|
|
282
|
+
_this.formDialogObjectId = _this.props.value[_this.props.idField];
|
|
283
|
+
_this.formDialogInitValuesForInsert = undefined;
|
|
284
|
+
_this.setState({ formDialogOpened: true });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
// remove nebudeme podporovat, je technicky problematicky - nemozme vymazat zaznam z DB koli FK constraintu
|
|
290
|
+
// {
|
|
291
|
+
// icon: 'pi pi-times',
|
|
292
|
+
// command: (e: any) => {
|
|
293
|
+
// console.log('remove');
|
|
294
|
+
// }
|
|
295
|
+
// },
|
|
296
|
+
};
|
|
297
|
+
XAutoCompleteBase.prototype.createSearchItem = function (splitButtonItems) {
|
|
298
|
+
var _this = this;
|
|
299
|
+
splitButtonItems.push({
|
|
300
|
+
icon: 'pi pi-search',
|
|
301
|
+
command: function (e) {
|
|
302
|
+
_this.setState({ searchDialogOpened: true });
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
XAutoCompleteBase.prototype.createDropdownItem = function (splitButtonItems) {
|
|
307
|
+
var _this = this;
|
|
308
|
+
splitButtonItems.push({
|
|
309
|
+
icon: 'pi pi-chevron-down',
|
|
310
|
+
command: function (e) {
|
|
311
|
+
// zobrazi cely suggestions list, zide sa ak chceme vidiet vsetky moznosti
|
|
312
|
+
// neprakticke ak mame vela poloziek v suggestions list
|
|
313
|
+
// krasne zobrazi cely objekt!
|
|
314
|
+
// this.autoCompleteRef.current je element <AutoComplete .../>, ktory vytvarame v render metode
|
|
315
|
+
//console.log(this.autoCompleteRef.current);
|
|
316
|
+
// otvori dropdown (search je metoda popisana v API, volanie sme skopcili zo zdrojakov primereact)
|
|
317
|
+
_this.autoCompleteRef.current.search(e, '', 'dropdown');
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
};
|
|
248
321
|
// vracia objekt (ak inputChanged === false) alebo string (ak inputChanged === true)
|
|
249
322
|
XAutoCompleteBase.prototype.computeInputValue = function () {
|
|
250
|
-
var inputValue
|
|
323
|
+
var inputValue;
|
|
251
324
|
if (!this.state.inputChanged) {
|
|
252
325
|
// poznamka: ak object === null tak treba do inputu zapisovat prazdny retazec, ak by sme pouzili null, neprejavila by sa zmena v modeli na null
|
|
253
326
|
var object = this.props.value;
|
|
254
|
-
|
|
255
|
-
inputValue = (object !== null) ? object : ""; // TODO - je "" ok?
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
inputValue = (object !== null) ? this.props.field(object) : "";
|
|
259
|
-
}
|
|
327
|
+
inputValue = (object !== null) ? object : ""; // TODO - je "" ok?
|
|
260
328
|
}
|
|
261
329
|
else {
|
|
262
330
|
inputValue = this.state.inputValueState;
|
|
263
331
|
}
|
|
264
332
|
return inputValue;
|
|
265
333
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return
|
|
334
|
+
// takto cez metodku, mozno sa metodka vola len ked sa otvori dialog a usetrime nieco...
|
|
335
|
+
XAutoCompleteBase.prototype.createSearchBrowseParams = function () {
|
|
336
|
+
return {
|
|
337
|
+
onChoose: this.searchDialogOnChoose,
|
|
338
|
+
displayFieldFilter: (this.state.inputChanged ? { field: this.props.field, constraint: { value: this.state.inputValueState, matchMode: "startsWith" } } : undefined),
|
|
339
|
+
customFilterFunction: this.props.customFilterFunction
|
|
340
|
+
};
|
|
269
341
|
};
|
|
270
342
|
XAutoCompleteBase.prototype.render = function () {
|
|
271
343
|
var _this = this;
|
|
272
344
|
var _a;
|
|
273
345
|
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
274
346
|
var dropdownButton;
|
|
275
|
-
if (this.props.valueForm) {
|
|
276
|
-
// mame CRUD operacie, potrebujeme SplitButton
|
|
347
|
+
if ((this.props.searchBrowse && !readOnly) || this.props.valueForm) {
|
|
348
|
+
// mame searchBrowse alebo CRUD operacie, potrebujeme SplitButton
|
|
277
349
|
var splitButtonItems = [];
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (_this.state.inputChanged && typeof _this.props.field === 'string') {
|
|
286
|
-
_this.formDialogInitObjectForInsert[_this.props.field] = _this.state.inputValueState;
|
|
287
|
-
}
|
|
288
|
-
_this.setState({ formDialogOpened: true });
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
splitButtonItems.push({
|
|
292
|
-
icon: 'pi pi-pencil',
|
|
293
|
-
command: function (e) {
|
|
294
|
-
if (_this.state.inputChanged) {
|
|
295
|
-
alert("Value \"".concat(_this.state.inputValueState, "\" was not found among valid values, please enter some valid value."));
|
|
296
|
-
_this.setFocusToInput();
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
if (_this.props.value === null) {
|
|
300
|
-
alert('Please select some row.');
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
// otvorime dialog na update
|
|
304
|
-
if (_this.props.idField === undefined) {
|
|
305
|
-
throw "XAutoCompleteBase: property valueForm is defined but property idField is also needed for form editation.";
|
|
306
|
-
}
|
|
307
|
-
_this.formDialogObjectId = _this.props.value[_this.props.idField];
|
|
308
|
-
_this.formDialogInitObjectForInsert = undefined;
|
|
309
|
-
_this.setState({ formDialogOpened: true });
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
// remove nebudeme podporovat, je technicky problematicky - nemozme vymazat zaznam z DB koli FK constraintu
|
|
315
|
-
// {
|
|
316
|
-
// icon: 'pi pi-times',
|
|
317
|
-
// command: (e: any) => {
|
|
318
|
-
// console.log('remove');
|
|
319
|
-
// }
|
|
320
|
-
// },
|
|
321
|
-
splitButtonItems.push({
|
|
322
|
-
icon: 'pi pi-chevron-down',
|
|
323
|
-
command: function (e) {
|
|
324
|
-
// zobrazi cely suggestions list, zide sa ak chceme vidiet vsetky moznosti
|
|
325
|
-
// neprakticke ak mame vela poloziek v suggestions list
|
|
326
|
-
// krasne zobrazi cely objekt!
|
|
327
|
-
// this.autoCompleteRef.current je element <AutoComplete .../>, ktory vytvarame v render metode
|
|
328
|
-
//console.log(this.autoCompleteRef.current);
|
|
329
|
-
// otvori dropdown (search je metoda popisana v API, volanie sme skopcili zo zdrojakov primereact)
|
|
330
|
-
_this.autoCompleteRef.current.search(e, '', 'dropdown');
|
|
331
|
-
}
|
|
332
|
-
});
|
|
350
|
+
if (this.props.valueForm) {
|
|
351
|
+
this.createInsertUpdateItems(splitButtonItems);
|
|
352
|
+
}
|
|
353
|
+
if (this.props.searchBrowse && !readOnly) {
|
|
354
|
+
this.createSearchItem(splitButtonItems);
|
|
355
|
+
}
|
|
356
|
+
this.createDropdownItem(splitButtonItems);
|
|
333
357
|
dropdownButton = react_1.default.createElement(splitbutton_1.SplitButton, { model: splitButtonItems, className: 'x-splitbutton-only-dropdown' + XUtils_1.XUtils.mobileCssSuffix(), menuClassName: 'x-splitbutton-only-dropdown-menu' + XUtils_1.XUtils.mobileCssSuffix(), disabled: readOnly });
|
|
334
358
|
}
|
|
335
359
|
else {
|
|
@@ -338,14 +362,6 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
338
362
|
}
|
|
339
363
|
// vypocitame inputValue
|
|
340
364
|
var inputValue = this.computeInputValue();
|
|
341
|
-
// poznamka: asi by sa dalo pouzivat vzdy len itemTemplate (nepouzivat field)
|
|
342
|
-
var fieldOrItemTemplate;
|
|
343
|
-
if (typeof this.props.field === 'string') {
|
|
344
|
-
fieldOrItemTemplate = { field: this.props.field };
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
fieldOrItemTemplate = { itemTemplate: this.itemTemplate };
|
|
348
|
-
}
|
|
349
365
|
var error;
|
|
350
366
|
if (this.state.notValid) {
|
|
351
367
|
// ak je v nevalidnom stave, tak ma tato chybova hlaska prednost pred ostatnymi (ak nahodou su)
|
|
@@ -355,15 +371,18 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
355
371
|
error = this.props.error;
|
|
356
372
|
}
|
|
357
373
|
// Dialog pre konkretny form:
|
|
358
|
-
// <DobrovolnikForm id={this.formDialogObjectId} object={this.
|
|
374
|
+
// <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitValuesForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
|
|
359
375
|
// formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
|
|
360
376
|
return (react_1.default.createElement("div", { className: "x-auto-complete-base" },
|
|
361
|
-
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod
|
|
377
|
+
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, field: this.props.field, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, maxLength: this.props.maxLength, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createErrorProps(error))),
|
|
362
378
|
dropdownButton,
|
|
363
379
|
this.props.valueForm != undefined && !readOnly ?
|
|
364
|
-
react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New
|
|
365
|
-
id: this.formDialogObjectId,
|
|
366
|
-
}
|
|
380
|
+
react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New row' }, react_1.default.cloneElement(this.props.valueForm, {
|
|
381
|
+
id: this.formDialogObjectId, initValues: this.formDialogInitValuesForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
|
|
382
|
+
} /*, this.props.valueForm.children*/))
|
|
383
|
+
: undefined,
|
|
384
|
+
this.props.searchBrowse != undefined && !readOnly ?
|
|
385
|
+
react_1.default.createElement(dialog_1.Dialog, { visible: this.state.searchDialogOpened, onHide: this.searchDialogOnHide }, react_1.default.cloneElement(this.props.searchBrowse, { searchBrowseParams: this.createSearchBrowseParams() } /*, props.searchBrowse.children*/))
|
|
367
386
|
: undefined));
|
|
368
387
|
};
|
|
369
388
|
return XAutoCompleteBase;
|
|
@@ -6,10 +6,11 @@ import { XError } from "./XErrors";
|
|
|
6
6
|
import { XTableFieldFilterProp } from "./XFormDataTable2";
|
|
7
7
|
export interface XAutoCompleteDTProps extends XFormComponentDTProps {
|
|
8
8
|
assocField: string;
|
|
9
|
-
displayField: string
|
|
10
|
-
|
|
11
|
-
assocForm?:
|
|
9
|
+
displayField: string;
|
|
10
|
+
searchBrowse?: JSX.Element;
|
|
11
|
+
assocForm?: JSX.Element;
|
|
12
12
|
filter?: XTableFieldFilterProp;
|
|
13
|
+
suggestions?: any[];
|
|
13
14
|
}
|
|
14
15
|
export declare class XAutoCompleteDT extends XFormComponentDT<XAutoCompleteDTProps> {
|
|
15
16
|
protected xAssoc: XAssoc;
|
|
@@ -81,15 +81,14 @@ var XAutoCompleteDT = /** @class */ (function (_super) {
|
|
|
81
81
|
var suggestions;
|
|
82
82
|
return __generator(this, function (_a) {
|
|
83
83
|
switch (_a.label) {
|
|
84
|
-
case 0:
|
|
84
|
+
case 0:
|
|
85
|
+
if (!(this.props.suggestions === undefined)) return [3 /*break*/, 2];
|
|
86
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), this.props.displayField)];
|
|
85
87
|
case 1:
|
|
86
88
|
suggestions = _a.sent();
|
|
87
|
-
// ak mame funkciu, zosortujeme tu
|
|
88
|
-
if (typeof this.props.displayField === 'function') {
|
|
89
|
-
suggestions = XUtils_1.XUtils.arraySort(suggestions, this.props.displayField);
|
|
90
|
-
}
|
|
91
89
|
this.setState({ suggestions: suggestions });
|
|
92
|
-
|
|
90
|
+
_a.label = 2;
|
|
91
|
+
case 2: return [2 /*return*/];
|
|
93
92
|
}
|
|
94
93
|
});
|
|
95
94
|
});
|
|
@@ -128,12 +127,14 @@ var XAutoCompleteDT = /** @class */ (function (_super) {
|
|
|
128
127
|
return _super.prototype.validate.call(this);
|
|
129
128
|
};
|
|
130
129
|
XAutoCompleteDT.prototype.render = function () {
|
|
130
|
+
var _this = this;
|
|
131
|
+
var _a;
|
|
131
132
|
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
132
133
|
//const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
133
134
|
// TODO - size
|
|
134
135
|
//const size = this.props.size ?? xDisplayField.length;
|
|
135
136
|
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
136
|
-
return (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, readOnly: this.isReadOnly(), error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase }));
|
|
137
|
+
return (react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.getValue(), suggestions: (_a = this.props.suggestions) !== null && _a !== void 0 ? _a : this.state.suggestions, onChange: this.onChangeAutoCompleteBase, field: this.props.displayField, searchBrowse: this.props.searchBrowse, valueForm: this.props.assocForm, idField: xEntityAssoc.idField, readOnly: this.isReadOnly(), error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase, customFilterFunction: function () { return _this.getFilterBase(_this.props.filter); } }));
|
|
137
138
|
};
|
|
138
139
|
return XAutoCompleteDT;
|
|
139
140
|
}(XFormComponentDT_1.XFormComponentDT));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XFormBase } from "./XFormBase";
|
|
3
3
|
import { XField } from "../serverApi/XEntityMetadata";
|
|
4
|
+
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
4
5
|
export declare const XCheckboxDT: (props: {
|
|
5
6
|
form: XFormBase;
|
|
6
7
|
xField: XField;
|
|
7
8
|
field: string;
|
|
8
9
|
rowData: any;
|
|
9
|
-
readOnly?:
|
|
10
|
+
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
10
11
|
}) => JSX.Element;
|