@michalrakus/x-react-web-lib 1.8.0 → 1.10.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/README.md +3 -3
- package/XInputInterval.d.ts +3 -0
- package/XInputInterval.js +5 -0
- package/XInputIntervalBase.d.ts +3 -0
- package/XInputIntervalBase.js +5 -0
- package/gulpfile.js +84 -82
- package/lib/administration/XBrowseMetaBrowse.d.ts +2 -2
- package/lib/administration/XBrowseMetaBrowse.js +21 -21
- package/lib/administration/XBrowseMetaForm.d.ts +5 -5
- package/lib/administration/XBrowseMetaForm.js +63 -63
- package/lib/administration/XUserBrowse.d.ts +2 -2
- package/lib/administration/XUserBrowse.js +88 -87
- package/lib/administration/XUserForm.d.ts +9 -9
- package/lib/administration/XUserForm.js +195 -194
- package/lib/components/SearchTableParams.d.ts +11 -11
- package/lib/components/SearchTableParams.js +2 -2
- package/lib/components/SourceCodeLinkEntity.d.ts +4 -4
- package/lib/components/SourceCodeLinkEntity.js +14 -14
- package/lib/components/XAutoComplete.d.ts +36 -36
- package/lib/components/XAutoComplete.js +155 -155
- package/lib/components/XAutoCompleteBase.d.ts +45 -45
- package/lib/components/XAutoCompleteBase.js +371 -371
- package/lib/components/XAutoCompleteDT.d.ts +33 -33
- package/lib/components/XAutoCompleteDT.js +140 -140
- package/lib/components/XBrowse.d.ts +33 -33
- package/lib/components/XBrowse.js +360 -360
- package/lib/components/XButton.d.ts +9 -9
- package/lib/components/XButton.js +13 -13
- package/lib/components/XButtonIconMedium.d.ts +9 -9
- package/lib/components/XButtonIconMedium.js +13 -13
- package/lib/components/XButtonIconNarrow.d.ts +10 -10
- package/lib/components/XButtonIconNarrow.js +25 -25
- package/lib/components/XButtonIconSmall.d.ts +9 -9
- package/lib/components/XButtonIconSmall.js +13 -13
- package/lib/components/XCalendar.d.ts +9 -8
- package/lib/components/XCalendar.js +27 -27
- package/lib/components/XChangePasswordForm.d.ts +5 -5
- package/lib/components/XChangePasswordForm.js +160 -160
- package/lib/components/XCheckbox.d.ts +8 -8
- package/lib/components/XCheckbox.js +57 -57
- package/lib/components/XCheckboxDT.d.ts +10 -10
- package/lib/components/XCheckboxDT.js +46 -46
- package/lib/components/XDataTable.d.ts +11 -11
- package/lib/components/XDataTable.js +197 -197
- package/lib/components/XDropdown.d.ts +18 -18
- package/lib/components/XDropdown.js +57 -57
- package/lib/components/XDropdownDT.d.ts +16 -13
- package/lib/components/XDropdownDT.js +135 -128
- package/lib/components/XDropdownDTFilter.d.ts +7 -7
- package/lib/components/XDropdownDTFilter.js +121 -121
- package/lib/components/XDropdownForEntity.d.ts +26 -25
- package/lib/components/XDropdownForEntity.js +151 -149
- package/lib/components/XDropdownFormDTFilter.d.ts +7 -7
- package/lib/components/XDropdownFormDTFilter.js +121 -121
- package/lib/components/XEditColumnDialog.d.ts +13 -13
- package/lib/components/XEditColumnDialog.js +112 -112
- package/lib/components/XEnvVars.d.ts +15 -12
- package/lib/components/XEnvVars.js +23 -20
- package/lib/components/XErrors.d.ts +12 -12
- package/lib/components/XErrors.js +2 -2
- package/lib/components/XExportRowsDialog.d.ts +15 -15
- package/lib/components/XExportRowsDialog.js +184 -184
- package/lib/components/XFieldChangeEvent.d.ts +11 -11
- package/lib/components/XFieldChangeEvent.js +2 -2
- package/lib/components/XFieldSelector.d.ts +7 -7
- package/lib/components/XFieldSelector.js +113 -113
- package/lib/components/XFormBase.d.ts +68 -59
- package/lib/components/XFormBase.js +613 -526
- package/lib/components/XFormBaseModif.d.ts +5 -5
- package/lib/components/XFormBaseModif.js +33 -33
- package/lib/components/XFormBaseT.d.ts +4 -4
- package/lib/components/XFormBaseT.js +31 -31
- package/lib/components/XFormComponent.d.ts +40 -40
- package/lib/components/XFormComponent.js +177 -177
- package/lib/components/XFormComponentDT.d.ts +30 -30
- package/lib/components/XFormComponentDT.js +145 -145
- package/lib/components/XFormDataTable2.d.ts +144 -143
- package/lib/components/XFormDataTable2.js +679 -686
- package/lib/components/XFormFooter.d.ts +6 -6
- package/lib/components/XFormFooter.js +19 -19
- package/lib/components/XFormNavigator3.d.ts +12 -12
- package/lib/components/XFormNavigator3.js +130 -130
- package/lib/components/XHolders.d.ts +7 -7
- package/lib/components/XHolders.js +15 -15
- package/lib/components/XInput.d.ts +13 -13
- package/lib/components/XInput.js +38 -38
- package/lib/components/XInputDT.d.ts +11 -11
- package/lib/components/XInputDT.js +37 -37
- package/lib/components/XInputDate.d.ts +13 -13
- package/lib/components/XInputDate.js +63 -63
- package/lib/components/XInputDateDT.d.ts +10 -10
- package/lib/components/XInputDateDT.js +55 -55
- package/lib/components/XInputDecimal.d.ts +15 -15
- package/lib/components/XInputDecimal.js +78 -78
- package/lib/components/XInputDecimalBase.d.ts +12 -12
- package/lib/components/XInputDecimalBase.js +18 -18
- package/lib/components/XInputDecimalDT.d.ts +11 -11
- package/lib/components/XInputDecimalDT.js +74 -74
- package/lib/components/XInputFileList.d.ts +36 -36
- package/lib/components/XInputFileList.js +251 -251
- package/lib/components/XInputInterval.d.ts +14 -0
- package/lib/components/XInputInterval.js +56 -0
- package/lib/components/XInputIntervalBase.d.ts +10 -0
- package/lib/components/XInputIntervalBase.js +97 -0
- package/lib/components/XInputIntervalDT.d.ts +11 -0
- package/lib/components/XInputIntervalDT.js +43 -0
- package/lib/components/XInputText.d.ts +12 -12
- package/lib/components/XInputText.js +69 -69
- package/lib/components/XInputTextDT.d.ts +9 -9
- package/lib/components/XInputTextDT.js +42 -42
- package/lib/components/XInputTextarea.d.ts +18 -18
- package/lib/components/XInputTextarea.js +85 -85
- package/lib/components/XLazyDataTable.d.ts +78 -78
- package/lib/components/XLazyDataTable.js +899 -885
- package/lib/components/XLocale.d.ts +26 -26
- package/lib/components/XLocale.js +59 -59
- package/lib/components/XLoginDialog.d.ts +8 -8
- package/lib/components/XLoginDialog.js +21 -21
- package/lib/components/XLoginForm.d.ts +7 -7
- package/lib/components/XLoginForm.js +128 -128
- package/lib/components/XObject.d.ts +3 -3
- package/lib/components/XObject.js +2 -2
- package/lib/components/XResponseError.d.ts +11 -11
- package/lib/components/XResponseError.js +32 -32
- package/lib/components/XSearchButton.d.ts +26 -26
- package/lib/components/XSearchButton.js +225 -225
- package/lib/components/XSearchButtonDT.d.ts +12 -12
- package/lib/components/XSearchButtonDT.js +188 -188
- package/lib/components/XSearchButtonOld.d.ts +13 -13
- package/lib/components/XSearchButtonOld.js +212 -212
- package/lib/components/XToOneAssocButton.d.ts +8 -8
- package/lib/components/XToOneAssocButton.js +30 -30
- package/lib/components/XToken.d.ts +6 -6
- package/lib/components/XToken.js +2 -2
- package/lib/components/XUtils.d.ts +84 -74
- package/lib/components/XUtils.js +664 -627
- package/lib/components/XUtilsConversions.d.ts +15 -12
- package/lib/components/XUtilsConversions.js +177 -125
- package/lib/components/XUtilsMetadata.d.ts +39 -39
- package/lib/components/XUtilsMetadata.js +452 -452
- package/lib/components/locale/x-en.json +26 -26
- package/lib/components/useXToken.d.ts +2 -2
- package/lib/components/useXToken.js +44 -44
- package/lib/serverApi/ExportImportParam.d.ts +51 -51
- package/lib/serverApi/ExportImportParam.js +34 -34
- package/lib/serverApi/FindParam.d.ts +35 -34
- package/lib/serverApi/FindParam.js +30 -30
- package/lib/serverApi/FindResult.d.ts +8 -8
- package/lib/serverApi/FindResult.js +2 -2
- package/lib/serverApi/XBrowseMetadata.d.ts +19 -19
- package/lib/serverApi/XBrowseMetadata.js +2 -2
- package/lib/serverApi/XEntityMetadata.d.ts +35 -35
- package/lib/serverApi/XEntityMetadata.js +2 -2
- package/lib/serverApi/XFileJsonField.d.ts +6 -6
- package/lib/serverApi/XFileJsonField.js +2 -2
- package/lib/serverApi/XUser.d.ts +8 -7
- package/lib/serverApi/XUser.js +2 -2
- package/lib/serverApi/XUserAuthenticationIfc.d.ts +9 -9
- package/lib/serverApi/XUserAuthenticationIfc.js +2 -2
- package/lib/serverApi/XUtilsCommon.d.ts +14 -13
- package/lib/serverApi/XUtilsCommon.js +180 -110
- package/package.json +1 -1
|
@@ -1,155 +1,155 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
-
};
|
|
56
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.XAutoComplete = void 0;
|
|
58
|
-
var react_1 = __importDefault(require("react"));
|
|
59
|
-
var XFormComponent_1 = require("./XFormComponent");
|
|
60
|
-
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
61
|
-
var XUtils_1 = require("./XUtils");
|
|
62
|
-
var XAutoCompleteBase_1 = require("./XAutoCompleteBase");
|
|
63
|
-
var XAutoComplete = /** @class */ (function (_super) {
|
|
64
|
-
__extends(XAutoComplete, _super);
|
|
65
|
-
function XAutoComplete(props) {
|
|
66
|
-
var _this = _super.call(this, props) || this;
|
|
67
|
-
_this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity()), props.assocField);
|
|
68
|
-
_this.errorInBase = undefined;
|
|
69
|
-
_this.state = {
|
|
70
|
-
suggestions: []
|
|
71
|
-
};
|
|
72
|
-
_this.onChangeAutoCompleteBase = _this.onChangeAutoCompleteBase.bind(_this);
|
|
73
|
-
_this.onErrorChangeAutoCompleteBase = _this.onErrorChangeAutoCompleteBase.bind(_this);
|
|
74
|
-
props.form.addField(props.assocField + '.' + _this.getDisplayFieldOrId());
|
|
75
|
-
return _this;
|
|
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
|
-
XAutoComplete.prototype.componentDidMount = function () {
|
|
89
|
-
console.log("volany XAutoComplete.componentDidMount()");
|
|
90
|
-
this.readAndSetSuggestions();
|
|
91
|
-
};
|
|
92
|
-
XAutoComplete.prototype.readAndSetSuggestions = function () {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
var suggestions;
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
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)];
|
|
98
|
-
case 1:
|
|
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
|
-
}
|
|
104
|
-
this.setState({ suggestions: suggestions });
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
XAutoComplete.prototype.getField = function () {
|
|
111
|
-
return this.props.assocField;
|
|
112
|
-
};
|
|
113
|
-
XAutoComplete.prototype.isNotNull = function () {
|
|
114
|
-
return !this.xAssoc.isNullable;
|
|
115
|
-
};
|
|
116
|
-
XAutoComplete.prototype.getValue = function () {
|
|
117
|
-
var assocObject = this.getValueFromObject();
|
|
118
|
-
return assocObject;
|
|
119
|
-
};
|
|
120
|
-
XAutoComplete.prototype.onChangeAutoCompleteBase = function (object, objectChange) {
|
|
121
|
-
this.onValueChangeBase(object, this.props.onChange, objectChange);
|
|
122
|
-
if (objectChange !== XUtils_1.OperationType.None) {
|
|
123
|
-
// zmenil sa zaznam dobrovolnika v DB
|
|
124
|
-
// zatial len refreshneme z DB
|
|
125
|
-
// ak by bol reqest pomaly, mozme pri inserte (nove id) / update (existujuce id) upravit zoznam a usetrime tym request do DB
|
|
126
|
-
// ak bol delete (dobrovolnik === null), treba urobit refresh do DB (alebo si poslat id-cko zmazaneho zaznamu)
|
|
127
|
-
this.readAndSetSuggestions();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
XAutoComplete.prototype.onErrorChangeAutoCompleteBase = function (error) {
|
|
131
|
-
this.errorInBase = error; // odlozime si error
|
|
132
|
-
};
|
|
133
|
-
// overrides method in XFormComponent
|
|
134
|
-
XAutoComplete.prototype.validate = function () {
|
|
135
|
-
if (this.errorInBase) {
|
|
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() } };
|
|
138
|
-
}
|
|
139
|
-
// zavolame povodnu metodu
|
|
140
|
-
return _super.prototype.validate.call(this);
|
|
141
|
-
};
|
|
142
|
-
XAutoComplete.prototype.render = function () {
|
|
143
|
-
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
144
|
-
//const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
145
|
-
// TODO - readOnly
|
|
146
|
-
// TODO - size
|
|
147
|
-
//const size = this.props.size ?? xDisplayField.length;
|
|
148
|
-
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
149
|
-
return (react_1.default.createElement("div", { className: "field grid" },
|
|
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 })));
|
|
152
|
-
};
|
|
153
|
-
return XAutoComplete;
|
|
154
|
-
}(XFormComponent_1.XFormComponent));
|
|
155
|
-
exports.XAutoComplete = XAutoComplete;
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.XAutoComplete = void 0;
|
|
58
|
+
var react_1 = __importDefault(require("react"));
|
|
59
|
+
var XFormComponent_1 = require("./XFormComponent");
|
|
60
|
+
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
61
|
+
var XUtils_1 = require("./XUtils");
|
|
62
|
+
var XAutoCompleteBase_1 = require("./XAutoCompleteBase");
|
|
63
|
+
var XAutoComplete = /** @class */ (function (_super) {
|
|
64
|
+
__extends(XAutoComplete, _super);
|
|
65
|
+
function XAutoComplete(props) {
|
|
66
|
+
var _this = _super.call(this, props) || this;
|
|
67
|
+
_this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity()), props.assocField);
|
|
68
|
+
_this.errorInBase = undefined;
|
|
69
|
+
_this.state = {
|
|
70
|
+
suggestions: []
|
|
71
|
+
};
|
|
72
|
+
_this.onChangeAutoCompleteBase = _this.onChangeAutoCompleteBase.bind(_this);
|
|
73
|
+
_this.onErrorChangeAutoCompleteBase = _this.onErrorChangeAutoCompleteBase.bind(_this);
|
|
74
|
+
props.form.addField(props.assocField + '.' + _this.getDisplayFieldOrId());
|
|
75
|
+
return _this;
|
|
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
|
+
XAutoComplete.prototype.componentDidMount = function () {
|
|
89
|
+
//console.log("volany XAutoComplete.componentDidMount()");
|
|
90
|
+
this.readAndSetSuggestions();
|
|
91
|
+
};
|
|
92
|
+
XAutoComplete.prototype.readAndSetSuggestions = function () {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
var suggestions;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
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)];
|
|
98
|
+
case 1:
|
|
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
|
+
}
|
|
104
|
+
this.setState({ suggestions: suggestions });
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
XAutoComplete.prototype.getField = function () {
|
|
111
|
+
return this.props.assocField;
|
|
112
|
+
};
|
|
113
|
+
XAutoComplete.prototype.isNotNull = function () {
|
|
114
|
+
return !this.xAssoc.isNullable;
|
|
115
|
+
};
|
|
116
|
+
XAutoComplete.prototype.getValue = function () {
|
|
117
|
+
var assocObject = this.getValueFromObject();
|
|
118
|
+
return assocObject;
|
|
119
|
+
};
|
|
120
|
+
XAutoComplete.prototype.onChangeAutoCompleteBase = function (object, objectChange) {
|
|
121
|
+
this.onValueChangeBase(object, this.props.onChange, objectChange);
|
|
122
|
+
if (objectChange !== XUtils_1.OperationType.None) {
|
|
123
|
+
// zmenil sa zaznam dobrovolnika v DB
|
|
124
|
+
// zatial len refreshneme z DB
|
|
125
|
+
// ak by bol reqest pomaly, mozme pri inserte (nove id) / update (existujuce id) upravit zoznam a usetrime tym request do DB
|
|
126
|
+
// ak bol delete (dobrovolnik === null), treba urobit refresh do DB (alebo si poslat id-cko zmazaneho zaznamu)
|
|
127
|
+
this.readAndSetSuggestions();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
XAutoComplete.prototype.onErrorChangeAutoCompleteBase = function (error) {
|
|
131
|
+
this.errorInBase = error; // odlozime si error
|
|
132
|
+
};
|
|
133
|
+
// overrides method in XFormComponent
|
|
134
|
+
XAutoComplete.prototype.validate = function () {
|
|
135
|
+
if (this.errorInBase) {
|
|
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() } };
|
|
138
|
+
}
|
|
139
|
+
// zavolame povodnu metodu
|
|
140
|
+
return _super.prototype.validate.call(this);
|
|
141
|
+
};
|
|
142
|
+
XAutoComplete.prototype.render = function () {
|
|
143
|
+
var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
|
|
144
|
+
//const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
145
|
+
// TODO - readOnly
|
|
146
|
+
// TODO - size
|
|
147
|
+
//const size = this.props.size ?? xDisplayField.length;
|
|
148
|
+
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
149
|
+
return (react_1.default.createElement("div", { className: "field grid" },
|
|
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 })));
|
|
152
|
+
};
|
|
153
|
+
return XAutoComplete;
|
|
154
|
+
}(XFormComponent_1.XFormComponent));
|
|
155
|
+
exports.XAutoComplete = XAutoComplete;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import React, { Component } from "react";
|
|
2
|
-
import { AutoCompleteChangeEvent } from "primereact/autocomplete";
|
|
3
|
-
import { OperationType } from "./XUtils";
|
|
4
|
-
export interface XAutoCompleteBaseProps {
|
|
5
|
-
value: any;
|
|
6
|
-
suggestions: any[];
|
|
7
|
-
onChange: (object: any, objectChange: OperationType) => void;
|
|
8
|
-
field: string | ((suggestion: any) => string);
|
|
9
|
-
valueForm?: any;
|
|
10
|
-
idField?: string;
|
|
11
|
-
maxLength?: number;
|
|
12
|
-
readOnly?: boolean;
|
|
13
|
-
error?: string;
|
|
14
|
-
onErrorChange: (error: string | undefined) => void;
|
|
15
|
-
setFocusOnCreate?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps> {
|
|
18
|
-
autoCompleteRef: any;
|
|
19
|
-
state: {
|
|
20
|
-
inputChanged: boolean;
|
|
21
|
-
inputValueState: string | undefined;
|
|
22
|
-
notValid: boolean;
|
|
23
|
-
filteredSuggestions: any[] | undefined;
|
|
24
|
-
formDialogOpened: boolean;
|
|
25
|
-
};
|
|
26
|
-
formDialogObjectId: number | undefined;
|
|
27
|
-
formDialogInitObjectForInsert: any | undefined;
|
|
28
|
-
constructor(props: XAutoCompleteBaseProps);
|
|
29
|
-
componentDidMount(): void;
|
|
30
|
-
getDisplayValue(suggestion: any): string;
|
|
31
|
-
completeMethod(event: {
|
|
32
|
-
query: string;
|
|
33
|
-
}): void;
|
|
34
|
-
onChange(e: AutoCompleteChangeEvent): void;
|
|
35
|
-
onSelect(e: any): void;
|
|
36
|
-
onBlur(e: React.FocusEvent<HTMLInputElement>): void;
|
|
37
|
-
createErrorMessage(): string;
|
|
38
|
-
setFocusToInput(): void;
|
|
39
|
-
setObjectValue(object: any, objectChange: OperationType): void;
|
|
40
|
-
formDialogOnSaveOrCancel(object: any | null, objectChange: OperationType): void;
|
|
41
|
-
formDialogOnHide(): void;
|
|
42
|
-
computeInputValue(): any;
|
|
43
|
-
itemTemplate(suggestion: any, index: number): React.ReactNode;
|
|
44
|
-
render(): JSX.Element;
|
|
45
|
-
}
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import { AutoCompleteChangeEvent } from "primereact/autocomplete";
|
|
3
|
+
import { OperationType } from "./XUtils";
|
|
4
|
+
export interface XAutoCompleteBaseProps {
|
|
5
|
+
value: any;
|
|
6
|
+
suggestions: any[];
|
|
7
|
+
onChange: (object: any, objectChange: OperationType) => void;
|
|
8
|
+
field: string | ((suggestion: any) => string);
|
|
9
|
+
valueForm?: any;
|
|
10
|
+
idField?: string;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
onErrorChange: (error: string | undefined) => void;
|
|
15
|
+
setFocusOnCreate?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps> {
|
|
18
|
+
autoCompleteRef: any;
|
|
19
|
+
state: {
|
|
20
|
+
inputChanged: boolean;
|
|
21
|
+
inputValueState: string | undefined;
|
|
22
|
+
notValid: boolean;
|
|
23
|
+
filteredSuggestions: any[] | undefined;
|
|
24
|
+
formDialogOpened: boolean;
|
|
25
|
+
};
|
|
26
|
+
formDialogObjectId: number | undefined;
|
|
27
|
+
formDialogInitObjectForInsert: any | undefined;
|
|
28
|
+
constructor(props: XAutoCompleteBaseProps);
|
|
29
|
+
componentDidMount(): void;
|
|
30
|
+
getDisplayValue(suggestion: any): string;
|
|
31
|
+
completeMethod(event: {
|
|
32
|
+
query: string;
|
|
33
|
+
}): void;
|
|
34
|
+
onChange(e: AutoCompleteChangeEvent): void;
|
|
35
|
+
onSelect(e: any): void;
|
|
36
|
+
onBlur(e: React.FocusEvent<HTMLInputElement>): void;
|
|
37
|
+
createErrorMessage(): string;
|
|
38
|
+
setFocusToInput(): void;
|
|
39
|
+
setObjectValue(object: any, objectChange: OperationType): void;
|
|
40
|
+
formDialogOnSaveOrCancel(object: any | null, objectChange: OperationType): void;
|
|
41
|
+
formDialogOnHide(): void;
|
|
42
|
+
computeInputValue(): any;
|
|
43
|
+
itemTemplate(suggestion: any, index: number): React.ReactNode;
|
|
44
|
+
render(): JSX.Element;
|
|
45
|
+
}
|