@michalrakus/x-react-web-lib 1.2.0 → 1.4.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/XCalendar.d.ts +3 -0
- package/XCalendar.js +5 -0
- package/XDropdownForEntity.d.ts +3 -0
- package/XDropdownForEntity.js +5 -0
- package/XInputDecimalBase.d.ts +3 -0
- package/XInputDecimalBase.js +5 -0
- package/gulpfile.js +4 -1
- package/lib/components/XAutoCompleteBase.d.ts +1 -0
- package/lib/components/XAutoCompleteBase.js +6 -4
- package/lib/components/XAutoCompleteDT.js +1 -2
- package/lib/components/XCalendar.d.ts +8 -0
- package/lib/components/XCalendar.js +27 -0
- package/lib/components/XDropdown.d.ts +2 -7
- package/lib/components/XDropdown.js +8 -88
- package/lib/components/XDropdownDTFilter.js +8 -7
- package/lib/components/XDropdownForEntity.d.ts +24 -0
- package/lib/components/XDropdownForEntity.js +148 -0
- package/lib/components/XExportRowsDialog.js +2 -2
- package/lib/components/XFieldSelector.js +4 -3
- package/lib/components/XFormBase.d.ts +2 -0
- package/lib/components/XFormBase.js +10 -0
- package/lib/components/XFormComponent.d.ts +5 -1
- package/lib/components/XFormComponent.js +31 -3
- package/lib/components/XFormComponentDT.js +28 -2
- package/lib/components/XFormDataTable2.d.ts +2 -1
- package/lib/components/XFormDataTable2.js +45 -12
- package/lib/components/XInputDate.d.ts +12 -8
- package/lib/components/XInputDate.js +49 -44
- package/lib/components/XInputDecimalBase.d.ts +12 -0
- package/lib/components/XInputDecimalBase.js +18 -0
- package/lib/components/XLazyDataTable.d.ts +10 -1
- package/lib/components/XLazyDataTable.js +136 -52
- package/lib/components/XUtilsMetadata.d.ts +6 -2
- package/lib/components/XUtilsMetadata.js +79 -18
- package/lib/serverApi/ExportImportParam.d.ts +2 -0
- package/lib/serverApi/XEntityMetadata.d.ts +3 -2
- package/lib/serverApi/XUtilsCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +9 -0
- package/package.json +1 -1
package/XCalendar.d.ts
ADDED
package/XCalendar.js
ADDED
package/gulpfile.js
CHANGED
|
@@ -16,13 +16,15 @@ function generateApi(cb) {
|
|
|
16
16
|
"./lib/components/useXToken",
|
|
17
17
|
"./lib/components/XAutoComplete",
|
|
18
18
|
"./lib/components/XAutoCompleteBase",
|
|
19
|
+
"./lib/components/XBrowse",
|
|
19
20
|
"./lib/components/XButton",
|
|
20
21
|
"./lib/components/XButtonIconNarrow",
|
|
21
22
|
"./lib/components/XButtonIconSmall",
|
|
22
|
-
"./lib/components/
|
|
23
|
+
"./lib/components/XCalendar",
|
|
23
24
|
"./lib/components/XChangePasswordForm",
|
|
24
25
|
"./lib/components/XCheckbox",
|
|
25
26
|
"./lib/components/XDropdown",
|
|
27
|
+
"./lib/components/XDropdownForEntity",
|
|
26
28
|
"./lib/components/XEnvVars",
|
|
27
29
|
"./lib/components/XErrors",
|
|
28
30
|
"./lib/components/XFieldChangeEvent",
|
|
@@ -34,6 +36,7 @@ function generateApi(cb) {
|
|
|
34
36
|
"./lib/components/XHolders",
|
|
35
37
|
"./lib/components/XInputDate",
|
|
36
38
|
"./lib/components/XInputDecimal",
|
|
39
|
+
"./lib/components/XInputDecimalBase",
|
|
37
40
|
"./lib/components/XInputText",
|
|
38
41
|
"./lib/components/XInputTextarea",
|
|
39
42
|
"./lib/components/XLazyDataTable",
|
|
@@ -265,6 +265,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
265
265
|
};
|
|
266
266
|
XAutoCompleteBase.prototype.render = function () {
|
|
267
267
|
var _this = this;
|
|
268
|
+
var _a;
|
|
269
|
+
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
268
270
|
var dropdownButton;
|
|
269
271
|
if (this.props.valueForm) {
|
|
270
272
|
// mame CRUD operacie, potrebujeme SplitButton
|
|
@@ -324,11 +326,11 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
324
326
|
_this.autoCompleteRef.current.search(e, '', 'dropdown');
|
|
325
327
|
}
|
|
326
328
|
});
|
|
327
|
-
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() });
|
|
329
|
+
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 });
|
|
328
330
|
}
|
|
329
331
|
else {
|
|
330
332
|
// mame len 1 operaciu - dame jednoduchy button
|
|
331
|
-
dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", onClick: function (e) { return _this.autoCompleteRef.current.search(e, '', 'dropdown'); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() });
|
|
333
|
+
dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", onClick: function (e) { return _this.autoCompleteRef.current.search(e, '', 'dropdown'); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix(), disabled: readOnly });
|
|
332
334
|
}
|
|
333
335
|
// vypocitame inputValue
|
|
334
336
|
var inputValue = this.computeInputValue();
|
|
@@ -352,9 +354,9 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
352
354
|
// <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitObjectForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
|
|
353
355
|
// formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
|
|
354
356
|
return (react_1.default.createElement("div", { className: "x-auto-complete-base" },
|
|
355
|
-
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod }, fieldOrItemTemplate, { onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, maxLength: this.props.maxLength, ref: this.autoCompleteRef }, XUtils_1.XUtils.createErrorProps(error))),
|
|
357
|
+
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod }, fieldOrItemTemplate, { 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))),
|
|
356
358
|
dropdownButton,
|
|
357
|
-
this.props.valueForm != undefined ?
|
|
359
|
+
this.props.valueForm != undefined && !readOnly ?
|
|
358
360
|
react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New record' }, react_1.default.cloneElement(this.props.valueForm, {
|
|
359
361
|
id: this.formDialogObjectId, object: this.formDialogInitObjectForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
|
|
360
362
|
}, this.props.valueForm.children))
|
|
@@ -130,11 +130,10 @@ var XAutoCompleteDT = /** @class */ (function (_super) {
|
|
|
130
130
|
XAutoCompleteDT.prototype.render = function () {
|
|
131
131
|
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
132
132
|
//const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
133
|
-
// TODO - readOnly
|
|
134
133
|
// TODO - size
|
|
135
134
|
//const size = this.props.size ?? xDisplayField.length;
|
|
136
135
|
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
137
|
-
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, error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase }));
|
|
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 }));
|
|
138
137
|
};
|
|
139
138
|
return XAutoCompleteDT;
|
|
140
139
|
}(XFormComponentDT_1.XFormComponentDT));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.XCalendar = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var calendar_1 = require("primereact/calendar");
|
|
9
|
+
var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
10
|
+
// wrapper for Calendar component, maybe better name would be XInputDateBase
|
|
11
|
+
var XCalendar = function (props) {
|
|
12
|
+
var _a;
|
|
13
|
+
var onChange = function (e) {
|
|
14
|
+
// z Calendar prichadza e.value - typ Date alebo null
|
|
15
|
+
// typ Date prichadza ak uzivatel vyplnil validny datum, null (typeof e.value vracia "object") prichadza ak uzivatel vymazal datum
|
|
16
|
+
// alebo je este datum nekompletny (uzivatel prave zadava datum)
|
|
17
|
+
// ak nastavime keepInvalid={true}, tak bude chodit nevalidny string (typeof e.value vracia "string")
|
|
18
|
+
//console.log(typeof e.value);
|
|
19
|
+
//console.log(e.value instanceof Date);
|
|
20
|
+
if (e.value instanceof Date || e.value === null) {
|
|
21
|
+
props.onChange(e.value);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var datetime = (_a = props.datetime) !== null && _a !== void 0 ? _a : false;
|
|
25
|
+
return (react_1.default.createElement(calendar_1.Calendar, { id: props.id, value: props.value, onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date' }));
|
|
26
|
+
};
|
|
27
|
+
exports.XCalendar = XCalendar;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { XFormComponent, XFormComponentProps } from "./XFormComponent";
|
|
2
|
+
import { XFilterProp, XFormComponent, XFormComponentProps } from "./XFormComponent";
|
|
3
3
|
import { XAssoc } from "../serverApi/XEntityMetadata";
|
|
4
4
|
import { XObject } from "./XObject";
|
|
5
5
|
export interface XDropdownProps extends XFormComponentProps<XObject> {
|
|
6
6
|
assocField: string;
|
|
7
7
|
displayField: string;
|
|
8
|
+
filter?: XFilterProp;
|
|
8
9
|
}
|
|
9
10
|
export declare class XDropdown extends XFormComponent<XObject, XDropdownProps> {
|
|
10
11
|
protected xAssoc: XAssoc;
|
|
11
|
-
state: {
|
|
12
|
-
options: any[];
|
|
13
|
-
};
|
|
14
12
|
constructor(props: XDropdownProps);
|
|
15
13
|
getField(): string;
|
|
16
14
|
isNotNull(): boolean;
|
|
17
15
|
getValue(): any | null;
|
|
18
|
-
onValueChange(e: any): void;
|
|
19
|
-
componentDidMount(): void;
|
|
20
|
-
private findOptions;
|
|
21
16
|
render(): JSX.Element;
|
|
22
17
|
}
|
|
@@ -14,73 +14,21 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
-
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;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
19
|
};
|
|
67
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
21
|
exports.XDropdown = void 0;
|
|
69
22
|
var react_1 = __importDefault(require("react"));
|
|
70
|
-
var dropdown_1 = require("primereact/dropdown");
|
|
71
|
-
var XUtils_1 = require("./XUtils");
|
|
72
23
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
73
24
|
var XFormComponent_1 = require("./XFormComponent");
|
|
25
|
+
var XDropdownForEntity_1 = require("./XDropdownForEntity");
|
|
74
26
|
var XDropdown = /** @class */ (function (_super) {
|
|
75
27
|
__extends(XDropdown, _super);
|
|
76
28
|
function XDropdown(props) {
|
|
77
29
|
var _this = _super.call(this, props) || this;
|
|
78
30
|
_this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity()), props.assocField);
|
|
79
|
-
_this.state = {
|
|
80
|
-
options: []
|
|
81
|
-
};
|
|
82
31
|
props.form.addField(props.assocField + '.' + props.displayField);
|
|
83
|
-
_this.onValueChange = _this.onValueChange.bind(_this);
|
|
84
32
|
return _this;
|
|
85
33
|
}
|
|
86
34
|
XDropdown.prototype.getField = function () {
|
|
@@ -93,44 +41,16 @@ var XDropdown = /** @class */ (function (_super) {
|
|
|
93
41
|
var assocObject = this.getValueFromObject();
|
|
94
42
|
return assocObject;
|
|
95
43
|
};
|
|
96
|
-
XDropdown.prototype.onValueChange = function (e) {
|
|
97
|
-
var newValueOrNull;
|
|
98
|
-
// specialna null polozka nema ziadne atributy
|
|
99
|
-
if (Object.keys(e.target.value).length === 0) {
|
|
100
|
-
newValueOrNull = null;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
newValueOrNull = e.target.value;
|
|
104
|
-
}
|
|
105
|
-
this.onValueChangeBase(newValueOrNull, this.props.onChange);
|
|
106
|
-
};
|
|
107
|
-
XDropdown.prototype.componentDidMount = function () {
|
|
108
|
-
this.findOptions(this.props.form.getEntity(), this.props.assocField);
|
|
109
|
-
};
|
|
110
|
-
XDropdown.prototype.findOptions = function (entity, assocField) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
-
var options;
|
|
113
|
-
return __generator(this, function (_a) {
|
|
114
|
-
switch (_a.label) {
|
|
115
|
-
case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchMany('findRowsForAssoc', { entity: entity, assocField: assocField })];
|
|
116
|
-
case 1:
|
|
117
|
-
options = _a.sent();
|
|
118
|
-
options.splice(0, 0, {}); // null polozka (nepridavat pre not null atributy)
|
|
119
|
-
this.setState({ options: options });
|
|
120
|
-
return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
44
|
XDropdown.prototype.render = function () {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
45
|
+
var _this = this;
|
|
46
|
+
// POZOR!
|
|
47
|
+
// this.getFilterBase(this.props.filter) - nefunguje dynamicky filter, lebo objekt potrebny vo funkcii this.props.filter sa nacitava az v XFormBase.componentDidMount()
|
|
48
|
+
// a funkcia this.props.filter sa vola skor (pri vypocitavani atributu filter)
|
|
49
|
+
// ani keby bola funkcia volana vo componentDidMount() tohto XDropdown, nepomohlo by to, tento componentDidMount() sa vola skor ako componentDidMount() parenta XFormBase
|
|
50
|
+
// planuje sa to riesit bud zavedenim cache pre options alebo vytiahnutim options na uroven XFormBase
|
|
131
51
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
132
52
|
react_1.default.createElement("label", { htmlFor: this.props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
133
|
-
react_1.default.createElement(
|
|
53
|
+
react_1.default.createElement(XDropdownForEntity_1.XDropdownForEntity, { id: this.props.assocField, entity: this.xAssoc.entityName, displayField: this.props.displayField, value: this.getValue(), onChange: function (value) { return _this.onValueChangeBase(value, _this.props.onChange); }, readOnly: this.isReadOnly(), isNotNull: this.isNotNull(), error: this.getError(), filter: this.getFilterBase(this.props.filter) })));
|
|
134
54
|
};
|
|
135
55
|
return XDropdown;
|
|
136
56
|
}(XFormComponent_1.XFormComponent));
|
|
@@ -80,28 +80,29 @@ var react_1 = __importStar(require("react"));
|
|
|
80
80
|
var XUtils_1 = require("./XUtils");
|
|
81
81
|
var dropdown_1 = require("primereact/dropdown");
|
|
82
82
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
83
|
+
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
83
84
|
// pouzivany vo filtri v XLazyDataTable aj v XFormDataTable2
|
|
84
85
|
var XDropdownDTFilter = function (props) {
|
|
85
86
|
var _a = __read((0, react_1.useState)([]), 2), options = _a[0], setOptions = _a[1];
|
|
86
|
-
// TODO - upravit tak aby zvladol aj path dlzky 3 a viac
|
|
87
87
|
var fieldList = XUtilsCommon_1.XUtilsCommon.getFieldListForPath(props.path);
|
|
88
88
|
if (fieldList.length < 2) {
|
|
89
|
-
throw "XDropdownDTFilter: prop path (".concat(props.path, ") must have at least 2
|
|
89
|
+
throw "XDropdownDTFilter: prop path (".concat(props.path, ") must have at least 2 items");
|
|
90
90
|
}
|
|
91
|
-
var assocField = fieldList[0];
|
|
92
91
|
var displayField = fieldList[fieldList.length - 1];
|
|
93
92
|
// parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
|
|
94
93
|
(0, react_1.useEffect)(function () {
|
|
95
|
-
findOptions(props.entity,
|
|
94
|
+
findOptions(props.entity, props.path, displayField);
|
|
96
95
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
97
96
|
var onValueChange = function (e) {
|
|
98
97
|
props.onValueChange(props.path, e.target.value);
|
|
99
98
|
};
|
|
100
|
-
var findOptions = function (entity,
|
|
101
|
-
var options, emptyOption;
|
|
99
|
+
var findOptions = function (entity, path, displayField) { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
var xAssoc, options, emptyOption;
|
|
102
101
|
return __generator(this, function (_a) {
|
|
103
102
|
switch (_a.label) {
|
|
104
|
-
case 0:
|
|
103
|
+
case 0:
|
|
104
|
+
xAssoc = XUtilsMetadata_1.XUtilsMetadata.getLastXAssocByPath(XUtilsMetadata_1.XUtilsMetadata.getXEntity(entity), path);
|
|
105
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(xAssoc.entityName, undefined, displayField)];
|
|
105
106
|
case 1:
|
|
106
107
|
options = _a.sent();
|
|
107
108
|
emptyOption = {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component } from "react";
|
|
2
|
+
import { DropdownChangeEvent } from "primereact/dropdown";
|
|
3
|
+
import { XCustomFilter } from "../serverApi/FindParam";
|
|
4
|
+
export interface XDropdownForEntityProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
entity: string;
|
|
7
|
+
displayField: string;
|
|
8
|
+
value: any | null;
|
|
9
|
+
onChange: (value: any | null) => void;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
isNotNull?: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
filter?: XCustomFilter;
|
|
14
|
+
}
|
|
15
|
+
export declare class XDropdownForEntity extends Component<XDropdownForEntityProps> {
|
|
16
|
+
state: {
|
|
17
|
+
options: any[];
|
|
18
|
+
};
|
|
19
|
+
constructor(props: XDropdownForEntityProps);
|
|
20
|
+
componentDidMount(): void;
|
|
21
|
+
loadOptions(): Promise<void>;
|
|
22
|
+
onChange(e: DropdownChangeEvent): void;
|
|
23
|
+
render(): JSX.Element;
|
|
24
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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.XDropdownForEntity = void 0;
|
|
89
|
+
var react_1 = __importStar(require("react"));
|
|
90
|
+
var dropdown_1 = require("primereact/dropdown");
|
|
91
|
+
var XUtils_1 = require("./XUtils");
|
|
92
|
+
// vseobecny Dropdown ktoreho parametrom je entity, zobrazuje zaznamy danej entity, po selectnuti vracia zaznam danej entity
|
|
93
|
+
// ambicia je pouzivat ho vsade - vo formulari, vo filtroch, vo form tabulke, priamo aplikacnym programmerom
|
|
94
|
+
// dalo by sa vyclenit este XDropdownBase, ktory by dostaval ako parameter options (bol by nezavisly od DB), zatial ho nerobime,
|
|
95
|
+
// pravdepodobnost potreby XDropdownBase je nizka
|
|
96
|
+
// do buducna sa planuje pouzit cache pre options (plnila by sa pri otvoreni XFormBase*) - dolezite je to hlavne pre dropdowny vo form tabulke (a tiez pre dynamicky filter vo formulari - objekt sa nacita neskor ako options)
|
|
97
|
+
// tiez by bolo fajn podporovat dynamicky filter (vo formulari) - to by ale trebalo vytiahnut options do state formulara
|
|
98
|
+
// otazka je ci nepouzivat vsade len XAutoComplete a upustit od XDropdown
|
|
99
|
+
var XDropdownForEntity = /** @class */ (function (_super) {
|
|
100
|
+
__extends(XDropdownForEntity, _super);
|
|
101
|
+
function XDropdownForEntity(props) {
|
|
102
|
+
var _this = _super.call(this, props) || this;
|
|
103
|
+
_this.state = {
|
|
104
|
+
options: []
|
|
105
|
+
};
|
|
106
|
+
_this.onChange = _this.onChange.bind(_this);
|
|
107
|
+
return _this;
|
|
108
|
+
}
|
|
109
|
+
XDropdownForEntity.prototype.componentDidMount = function () {
|
|
110
|
+
this.loadOptions();
|
|
111
|
+
};
|
|
112
|
+
XDropdownForEntity.prototype.loadOptions = function () {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var options;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.props.entity, this.props.filter, this.props.displayField)];
|
|
118
|
+
case 1:
|
|
119
|
+
options = _a.sent();
|
|
120
|
+
if (this.props.isNotNull === undefined || !this.props.isNotNull) {
|
|
121
|
+
// pridame prazdnu polozku
|
|
122
|
+
options.splice(0, 0, {}); // null polozka
|
|
123
|
+
}
|
|
124
|
+
this.setState({ options: options });
|
|
125
|
+
return [2 /*return*/];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
XDropdownForEntity.prototype.onChange = function (e) {
|
|
131
|
+
var value;
|
|
132
|
+
// specialna null polozka nema ziadne atributy
|
|
133
|
+
if (Object.keys(e.value).length === 0) {
|
|
134
|
+
value = null;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
value = e.value;
|
|
138
|
+
}
|
|
139
|
+
this.props.onChange(value);
|
|
140
|
+
};
|
|
141
|
+
XDropdownForEntity.prototype.render = function () {
|
|
142
|
+
// TODO - mozno by nebolo od veci pouzivat InputText ak readOnly === true (chybala by len sipka (rozbalovac)) a dalo by sa copy-paste-ovat
|
|
143
|
+
// propertiesy na Dropdown-e: readOnly vyseduje, disabled znemoznuje vyber polozky
|
|
144
|
+
return (react_1.default.createElement(dropdown_1.Dropdown, __assign({ id: this.props.id, options: this.state.options, optionLabel: this.props.displayField, value: this.props.value, onChange: this.onChange, readOnly: this.props.readOnly, disabled: this.props.readOnly }, XUtils_1.XUtils.createErrorProps(this.props.error))));
|
|
145
|
+
};
|
|
146
|
+
return XDropdownForEntity;
|
|
147
|
+
}(react_1.Component));
|
|
148
|
+
exports.XDropdownForEntity = XDropdownForEntity;
|
|
@@ -52,13 +52,13 @@ var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
|
52
52
|
var XExportRowsDialog = function (props) {
|
|
53
53
|
var _a;
|
|
54
54
|
var _b = __read((0, react_1.useState)(ExportImportParam_1.ExportType.Csv), 2), exportType = _b[0], setExportType = _b[1];
|
|
55
|
-
var _c = __read((0, react_1.useState)(
|
|
55
|
+
var _c = __read((0, react_1.useState)(true), 2), createHeaderLine = _c[0], setCreateHeaderLine = _c[1];
|
|
56
56
|
var _d = __read((0, react_1.useState)(ExportImportParam_1.CsvSeparator.Semicolon), 2), csvSeparator = _d[0], setCsvSeparator = _d[1];
|
|
57
57
|
var _e = __read((0, react_1.useState)(ExportImportParam_1.CsvDecimalFormat.Comma), 2), decimalFormat = _e[0], setDecimalFormat = _e[1];
|
|
58
58
|
// bez tejto metody by pri opetovnom otvoreni dialogu ponechal povodne hodnoty
|
|
59
59
|
var onShow = function () {
|
|
60
60
|
setExportType(ExportImportParam_1.ExportType.Csv);
|
|
61
|
-
setCreateHeaderLine(
|
|
61
|
+
setCreateHeaderLine(true); // excel hadze hlasky koli prvemu riadku header-ov
|
|
62
62
|
setCsvSeparator(ExportImportParam_1.CsvSeparator.Semicolon);
|
|
63
63
|
setDecimalFormat(ExportImportParam_1.CsvDecimalFormat.Comma);
|
|
64
64
|
};
|
|
@@ -84,9 +84,10 @@ var XFieldSelector = function (props) {
|
|
|
84
84
|
}
|
|
85
85
|
finally { if (e_1) throw e_1.error; }
|
|
86
86
|
}
|
|
87
|
+
var assocToOneList = XUtilsMetadata_1.XUtilsMetadata.getXAssocList(xEntity, ["many-to-one", "one-to-one"]);
|
|
87
88
|
try {
|
|
88
|
-
for (var
|
|
89
|
-
var
|
|
89
|
+
for (var assocToOneList_1 = __values(assocToOneList), assocToOneList_1_1 = assocToOneList_1.next(); !assocToOneList_1_1.done; assocToOneList_1_1 = assocToOneList_1.next()) {
|
|
90
|
+
var xAssoc = assocToOneList_1_1.value;
|
|
90
91
|
var itemKey = keyPrefix + xAssoc.name;
|
|
91
92
|
treeNodeList.push({
|
|
92
93
|
key: itemKey,
|
|
@@ -99,7 +100,7 @@ var XFieldSelector = function (props) {
|
|
|
99
100
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
100
101
|
finally {
|
|
101
102
|
try {
|
|
102
|
-
if (
|
|
103
|
+
if (assocToOneList_1_1 && !assocToOneList_1_1.done && (_b = assocToOneList_1.return)) _b.call(assocToOneList_1);
|
|
103
104
|
}
|
|
104
105
|
finally { if (e_2) throw e_2.error; }
|
|
105
106
|
}
|
|
@@ -45,11 +45,13 @@ export declare abstract class XFormBase extends Component<FormProps> {
|
|
|
45
45
|
addXFormComponent(xFormComponent: XFormComponent<any, any>): void;
|
|
46
46
|
findXFormComponent(field: string): XFormComponent<any, any> | undefined;
|
|
47
47
|
addXFormDataTable(xFormDataTable: XFormDataTable2): void;
|
|
48
|
+
formReadOnlyBase(field: string): boolean;
|
|
48
49
|
onClickSave(): Promise<void>;
|
|
49
50
|
onClickCancel(): void;
|
|
50
51
|
validateSave(): boolean;
|
|
51
52
|
validateForm(): XErrorMap;
|
|
52
53
|
fieldValidation(): XErrorMap;
|
|
54
|
+
formReadOnly(object: XObject, field: string): boolean;
|
|
53
55
|
preInitForm(object: XObject, operationType: OperationType.Insert | OperationType.Update): void;
|
|
54
56
|
validate(object: XObject): XErrors;
|
|
55
57
|
preSave(object: XObject): void;
|
|
@@ -345,6 +345,10 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
345
345
|
XFormBase.prototype.addXFormDataTable = function (xFormDataTable) {
|
|
346
346
|
this.xFormDataTableList.push(xFormDataTable);
|
|
347
347
|
};
|
|
348
|
+
XFormBase.prototype.formReadOnlyBase = function (field) {
|
|
349
|
+
// TODO - bude this.state.object vzdycky !== undefined?
|
|
350
|
+
return this.formReadOnly(this.state.object, field);
|
|
351
|
+
};
|
|
348
352
|
XFormBase.prototype.onClickSave = function () {
|
|
349
353
|
return __awaiter(this, void 0, void 0, function () {
|
|
350
354
|
var isAddRow, object, e_3;
|
|
@@ -493,6 +497,12 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
493
497
|
}
|
|
494
498
|
return xErrorMap;
|
|
495
499
|
};
|
|
500
|
+
// this method can be overriden in subclass if needed
|
|
501
|
+
// (the purpose is to put the whole form to read only mode (maybe with exception a few fields))
|
|
502
|
+
// if returns true for the param "field", then the field is read only, otherwise the property readOnly of the XInput* is processed
|
|
503
|
+
XFormBase.prototype.formReadOnly = function (object, field) {
|
|
504
|
+
return false;
|
|
505
|
+
};
|
|
496
506
|
// this method can be overriden in subclass if needed (to modify/save object after read from DB and before set into the form)
|
|
497
507
|
XFormBase.prototype.preInitForm = function (object, operationType) {
|
|
498
508
|
};
|
|
@@ -5,11 +5,12 @@ import { OperationType } from "./XUtils";
|
|
|
5
5
|
import { XFieldChangeEvent } from "./XFieldChangeEvent";
|
|
6
6
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
7
7
|
export type FieldOnChange = (e: XFieldChangeEvent<any>) => void;
|
|
8
|
+
export type XReadOnlyProp = boolean | ((object: any) => boolean);
|
|
8
9
|
export type XFilterProp = XCustomFilter | ((object: any) => XCustomFilter | undefined);
|
|
9
10
|
export interface XFormComponentProps<T> {
|
|
10
11
|
form: XFormBase;
|
|
11
12
|
label?: string;
|
|
12
|
-
readOnly?:
|
|
13
|
+
readOnly?: XReadOnlyProp;
|
|
13
14
|
labelStyle?: React.CSSProperties;
|
|
14
15
|
inline?: boolean;
|
|
15
16
|
onChange?: FieldOnChange;
|
|
@@ -29,6 +30,9 @@ export declare abstract class XFormComponent<T, P extends XFormComponentProps<T>
|
|
|
29
30
|
} | undefined;
|
|
30
31
|
validateOnChange(value: any): string | undefined;
|
|
31
32
|
validateNotNull(value: any): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated - nie je to pekne riesenie - do komponentu treba posielat error message (string) a nie props (asi ako v XAutoComplete)
|
|
35
|
+
*/
|
|
32
36
|
getClassNameTooltip(): {};
|
|
33
37
|
getError(): string | undefined;
|
|
34
38
|
callOnChangeFromOnBlur(): void;
|