@michalrakus/x-react-web-lib 1.25.0 → 1.26.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.
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React, { Component } from "react";
|
|
2
2
|
import { AutoCompleteChangeEvent } from "primereact/autocomplete";
|
|
3
3
|
import { OperationType, XQuery } from "./XUtils";
|
|
4
|
-
import {
|
|
4
|
+
import { MenuItemCommandEvent } from "primereact/menuitem";
|
|
5
5
|
import { XSearchBrowseParams } from "./XSearchBrowseParams";
|
|
6
6
|
import { DataTableSortMeta } from "primereact/datatable";
|
|
7
|
+
import { XEntity } from "../serverApi/XEntityMetadata";
|
|
8
|
+
interface XButtonItem {
|
|
9
|
+
icon: any | undefined;
|
|
10
|
+
tooltip?: string;
|
|
11
|
+
command(event: MenuItemCommandEvent): void;
|
|
12
|
+
}
|
|
7
13
|
export type XSuggestionsLoadProp = "eager" | "onSearchStart" | "lazy";
|
|
8
14
|
export type XSuggestionsLoadType = "suggestions" | XSuggestionsLoadProp;
|
|
9
15
|
export interface XAutoCompleteBaseProps {
|
|
10
16
|
value: any;
|
|
11
17
|
onChange: (object: any, objectChange: OperationType) => void;
|
|
12
18
|
suggestions?: any[];
|
|
19
|
+
suggestionsEntity?: string;
|
|
13
20
|
suggestionsLoad?: XSuggestionsLoadProp;
|
|
14
21
|
suggestionsQuery?: XQuery;
|
|
15
22
|
lazyLoadMaxRows: number;
|
|
@@ -20,7 +27,11 @@ export interface XAutoCompleteBaseProps {
|
|
|
20
27
|
valueForm?: JSX.Element;
|
|
21
28
|
idField?: string;
|
|
22
29
|
onAddRow?: (inputValue: string) => void;
|
|
30
|
+
insertButtonTooltip?: string;
|
|
31
|
+
updateButtonTooltip?: string;
|
|
32
|
+
searchButtonTooltip?: string;
|
|
23
33
|
minLength?: number;
|
|
34
|
+
buttonsLayout: "splitButton" | "buttons";
|
|
24
35
|
width?: string;
|
|
25
36
|
scrollHeight?: string;
|
|
26
37
|
inputClassName?: string;
|
|
@@ -35,6 +46,7 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
35
46
|
lazyLoadMaxRows: number;
|
|
36
47
|
splitQueryValue: boolean;
|
|
37
48
|
minLength: number;
|
|
49
|
+
buttonsLayout: string;
|
|
38
50
|
scrollHeight: string;
|
|
39
51
|
};
|
|
40
52
|
autoCompleteRef: any;
|
|
@@ -49,6 +61,7 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
49
61
|
};
|
|
50
62
|
suggestionsLoadedForOSS: boolean;
|
|
51
63
|
wasOnChangeCalled: boolean;
|
|
64
|
+
xEntity: XEntity | undefined;
|
|
52
65
|
formDialogObjectId: number | undefined;
|
|
53
66
|
formDialogInitValuesForInsert: any | undefined;
|
|
54
67
|
constructor(props: XAutoCompleteBaseProps);
|
|
@@ -72,10 +85,10 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
72
85
|
formDialogOnHide(): void;
|
|
73
86
|
searchDialogOnChoose(chosenRow: any): void;
|
|
74
87
|
searchDialogOnHide(): void;
|
|
75
|
-
createInsertItem(
|
|
76
|
-
createUpdateItem(
|
|
77
|
-
createSearchItem(
|
|
78
|
-
createDropdownItem(
|
|
88
|
+
createInsertItem(buttonItems: XButtonItem[]): void;
|
|
89
|
+
createUpdateItem(buttonItems: XButtonItem[]): void;
|
|
90
|
+
createSearchItem(buttonItems: XButtonItem[]): void;
|
|
91
|
+
createDropdownItem(buttonItems: XButtonItem[]): void;
|
|
79
92
|
onOpenDropdown(e: any): void;
|
|
80
93
|
openDropdown(e: any): void;
|
|
81
94
|
onEditAssocValue(): void;
|
|
@@ -88,3 +101,4 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
88
101
|
createSearchBrowseParams(): XSearchBrowseParams;
|
|
89
102
|
render(): React.JSX.Element;
|
|
90
103
|
}
|
|
104
|
+
export {};
|
|
@@ -129,6 +129,7 @@ var dialog_1 = require("primereact/dialog");
|
|
|
129
129
|
var XUtils_1 = require("./XUtils");
|
|
130
130
|
var button_1 = require("primereact/button");
|
|
131
131
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
132
|
+
var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
|
|
132
133
|
var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
133
134
|
__extends(XAutoCompleteBase, _super);
|
|
134
135
|
function XAutoCompleteBase(props) {
|
|
@@ -145,6 +146,20 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
145
146
|
};
|
|
146
147
|
_this.suggestionsLoadedForOSS = false;
|
|
147
148
|
_this.wasOnChangeCalled = false;
|
|
149
|
+
var entity;
|
|
150
|
+
if (_this.getXSuggestionsLoadType() === "suggestions") {
|
|
151
|
+
// if (this.props.suggestionsEntity === undefined) {
|
|
152
|
+
// throw "If prop suggestions is used, then also prop suggestionsEntity must be defined.";
|
|
153
|
+
// }
|
|
154
|
+
entity = _this.props.suggestionsEntity;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
if (_this.props.suggestionsQuery === undefined) {
|
|
158
|
+
throw "prop suggestionsQuery must be defined. (prop suggestions is not used)";
|
|
159
|
+
}
|
|
160
|
+
entity = _this.props.suggestionsQuery.entity;
|
|
161
|
+
}
|
|
162
|
+
_this.xEntity = entity ? XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(entity) : undefined;
|
|
148
163
|
_this.completeMethod = _this.completeMethod.bind(_this);
|
|
149
164
|
_this.onChange = _this.onChange.bind(_this);
|
|
150
165
|
_this.onSelect = _this.onSelect.bind(_this);
|
|
@@ -487,10 +502,11 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
487
502
|
this.setFocusToInput();
|
|
488
503
|
}
|
|
489
504
|
};
|
|
490
|
-
XAutoCompleteBase.prototype.createInsertItem = function (
|
|
505
|
+
XAutoCompleteBase.prototype.createInsertItem = function (buttonItems) {
|
|
491
506
|
var _this = this;
|
|
492
|
-
|
|
507
|
+
buttonItems.push({
|
|
493
508
|
icon: 'pi pi-plus',
|
|
509
|
+
tooltip: this.props.insertButtonTooltip,
|
|
494
510
|
command: function (e) {
|
|
495
511
|
if (_this.props.onAddRow) {
|
|
496
512
|
// mame custom handler pre "plus" button
|
|
@@ -514,10 +530,11 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
514
530
|
}
|
|
515
531
|
});
|
|
516
532
|
};
|
|
517
|
-
XAutoCompleteBase.prototype.createUpdateItem = function (
|
|
533
|
+
XAutoCompleteBase.prototype.createUpdateItem = function (buttonItems) {
|
|
518
534
|
var _this = this;
|
|
519
|
-
|
|
535
|
+
buttonItems.push({
|
|
520
536
|
icon: 'pi pi-pencil',
|
|
537
|
+
tooltip: this.props.updateButtonTooltip,
|
|
521
538
|
command: function (e) {
|
|
522
539
|
if (_this.state.inputChanged) {
|
|
523
540
|
alert("Value \"".concat(_this.state.inputValueState, "\" was not found among valid values, please enter some valid value."));
|
|
@@ -541,18 +558,19 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
541
558
|
// }
|
|
542
559
|
// },
|
|
543
560
|
};
|
|
544
|
-
XAutoCompleteBase.prototype.createSearchItem = function (
|
|
561
|
+
XAutoCompleteBase.prototype.createSearchItem = function (buttonItems) {
|
|
545
562
|
var _this = this;
|
|
546
|
-
|
|
563
|
+
buttonItems.push({
|
|
547
564
|
icon: 'pi pi-search',
|
|
565
|
+
tooltip: this.props.searchButtonTooltip,
|
|
548
566
|
command: function (e) {
|
|
549
567
|
_this.setState({ searchDialogOpened: true });
|
|
550
568
|
}
|
|
551
569
|
});
|
|
552
570
|
};
|
|
553
|
-
XAutoCompleteBase.prototype.createDropdownItem = function (
|
|
571
|
+
XAutoCompleteBase.prototype.createDropdownItem = function (buttonItems) {
|
|
554
572
|
var _this = this;
|
|
555
|
-
|
|
573
|
+
buttonItems.push({
|
|
556
574
|
icon: 'pi pi-chevron-down',
|
|
557
575
|
command: function (e) {
|
|
558
576
|
// zobrazi cely suggestions list, zide sa ak chceme vidiet vsetky moznosti
|
|
@@ -633,7 +651,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
633
651
|
displayValue = suggestion;
|
|
634
652
|
}
|
|
635
653
|
else {
|
|
636
|
-
displayValue = XUtilsCommon_1.XUtilsCommon.createDisplayValue(suggestion, this.getFields());
|
|
654
|
+
displayValue = XUtilsCommon_1.XUtilsCommon.createDisplayValue(suggestion, this.xEntity, this.getFields());
|
|
637
655
|
}
|
|
638
656
|
return displayValue;
|
|
639
657
|
};
|
|
@@ -654,37 +672,45 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
654
672
|
var _this = this;
|
|
655
673
|
var _a;
|
|
656
674
|
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
657
|
-
var
|
|
675
|
+
var buttons;
|
|
658
676
|
if (!readOnly) {
|
|
659
677
|
if (this.props.searchBrowse || this.props.valueForm || this.props.onAddRow) {
|
|
660
|
-
// mame searchBrowse alebo CRUD operacie, potrebujeme SplitButton
|
|
661
|
-
var
|
|
678
|
+
// mame searchBrowse alebo CRUD operacie, potrebujeme viac buttonov alebo SplitButton
|
|
679
|
+
var buttonItems = [];
|
|
662
680
|
if (this.props.valueForm || this.props.onAddRow) {
|
|
663
|
-
this.createInsertItem(
|
|
681
|
+
this.createInsertItem(buttonItems);
|
|
664
682
|
}
|
|
665
683
|
if (this.props.valueForm) {
|
|
666
|
-
this.createUpdateItem(
|
|
684
|
+
this.createUpdateItem(buttonItems);
|
|
667
685
|
}
|
|
668
686
|
if (this.props.searchBrowse && !readOnly) {
|
|
669
|
-
this.createSearchItem(
|
|
687
|
+
this.createSearchItem(buttonItems);
|
|
688
|
+
}
|
|
689
|
+
this.createDropdownItem(buttonItems);
|
|
690
|
+
if (this.props.buttonsLayout === "buttons") {
|
|
691
|
+
buttons = buttonItems.map(function (value) { return react_1.default.createElement(button_1.Button, { icon: value.icon, tooltip: value.tooltip, tooltipOptions: { position: 'top' }, onClick: function (e) { return value.command(e); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() }); });
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
// buttonsLayout === "splitButton"
|
|
695
|
+
// tooltip-y by trebalo pridat...
|
|
696
|
+
var splitButtonItems = buttonItems.map(function (value) { return { icon: value.icon, command: value.command }; });
|
|
697
|
+
buttons = [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 })];
|
|
670
698
|
}
|
|
671
|
-
this.createDropdownItem(splitButtonItems);
|
|
672
|
-
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 });
|
|
673
699
|
}
|
|
674
700
|
else {
|
|
675
701
|
// mame len 1 operaciu - dame jednoduchy button
|
|
676
|
-
|
|
702
|
+
buttons = [react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", onClick: function (e) { return _this.onOpenDropdown(e); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() })];
|
|
677
703
|
}
|
|
678
704
|
}
|
|
679
705
|
else {
|
|
680
706
|
// readOnly
|
|
681
707
|
// ak mame valueForm a mame asociovany objekt, umoznime editovat asociovany objekt
|
|
682
708
|
if (this.props.valueForm && this.props.value !== null) {
|
|
683
|
-
|
|
709
|
+
buttons = [react_1.default.createElement(button_1.Button, { icon: "pi pi-pencil", tooltip: this.props.updateButtonTooltip, tooltipOptions: { position: 'top' }, onClick: function (e) { return _this.onEditAssocValue(); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() })];
|
|
684
710
|
}
|
|
685
711
|
else {
|
|
686
712
|
// dame disablovany button (z estetickych dovodov, zachovame sirku)
|
|
687
|
-
|
|
713
|
+
buttons = [react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix(), disabled: true })];
|
|
688
714
|
}
|
|
689
715
|
}
|
|
690
716
|
// vypocitame inputValue
|
|
@@ -701,8 +727,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
701
727
|
// <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitValuesForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
|
|
702
728
|
// formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
|
|
703
729
|
return (react_1.default.createElement("div", { className: "x-auto-complete-base", style: { width: this.props.width } },
|
|
704
|
-
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, itemTemplate: this.itemTemplate, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, minLength: this.props.minLength, scrollHeight: this.props.scrollHeight, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(error), { inputClassName: this.props.inputClassName })),
|
|
705
|
-
|
|
730
|
+
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, itemTemplate: this.itemTemplate, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, minLength: this.props.minLength, scrollHeight: this.props.scrollHeight, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(error), { inputClassName: this.props.inputClassName, showEmptyMessage: true })),
|
|
731
|
+
buttons,
|
|
706
732
|
this.props.valueForm != undefined ?
|
|
707
733
|
react_1.default.createElement(dialog_1.Dialog, { className: "x-dialog-without-header", visible: this.state.formDialogOpened, onHide: this.formDialogOnHide }, react_1.default.cloneElement(this.props.valueForm, {
|
|
708
734
|
id: this.formDialogObjectId, initValues: this.formDialogInitValuesForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
|
|
@@ -717,6 +743,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
717
743
|
lazyLoadMaxRows: 10,
|
|
718
744
|
splitQueryValue: true,
|
|
719
745
|
minLength: 1,
|
|
746
|
+
buttonsLayout: "buttons",
|
|
720
747
|
scrollHeight: '15rem' // primereact has 200px
|
|
721
748
|
};
|
|
722
749
|
return XAutoCompleteBase;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XEntity, XField } from "./XEntityMetadata";
|
|
1
2
|
export declare class XUtilsCommon {
|
|
2
3
|
static newLine: string;
|
|
3
4
|
static getValueByPath(object: any, path: string): any;
|
|
@@ -9,7 +10,9 @@ export declare class XUtilsCommon {
|
|
|
9
10
|
static getPathToAssocAndField(path: string): [string | null, string];
|
|
10
11
|
static isSingleField(path: string): boolean;
|
|
11
12
|
static getPrefixAndField(path: string): [string | null, string];
|
|
12
|
-
static createDisplayValue(object: any, fields: string[]): string;
|
|
13
|
+
static createDisplayValue(object: any, xEntity: XEntity | undefined, fields: string[]): string;
|
|
14
|
+
static createDisplayValueForField(object: any, xEntity: XEntity | undefined, field: string): string;
|
|
15
|
+
static displayValueAsUI(prefix: string | null, value: any, xField: XField | undefined): string;
|
|
13
16
|
static objectAsJSON(value: any): string;
|
|
14
17
|
static arrayCreateMap<ID, T>(array: T[], idField: string): Map<ID, T>;
|
|
15
18
|
static getDayName(date: Date | null | undefined): string | undefined;
|
|
@@ -37,6 +37,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.dateFormat = exports.XUtilsCommon = void 0;
|
|
40
|
+
var XUtilsMetadataCommon_1 = require("./XUtilsMetadataCommon");
|
|
41
|
+
var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
40
42
|
// funkcie spolocne pre Web i pre Server
|
|
41
43
|
var XUtilsCommon = /** @class */ (function () {
|
|
42
44
|
function XUtilsCommon() {
|
|
@@ -168,26 +170,18 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
168
170
|
return [prefix, pathOnly];
|
|
169
171
|
}
|
|
170
172
|
};
|
|
171
|
-
XUtilsCommon.createDisplayValue = function (object, fields) {
|
|
173
|
+
XUtilsCommon.createDisplayValue = function (object, xEntity, fields) {
|
|
172
174
|
var e_2, _a;
|
|
173
175
|
var displayValue = "";
|
|
174
176
|
try {
|
|
175
177
|
for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
|
|
176
178
|
var field = fields_1_1.value;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var valueStr = value.toString(); // TODO - spravnu konverziu
|
|
182
|
-
if (valueStr !== "") {
|
|
183
|
-
if (displayValue !== "") {
|
|
184
|
-
displayValue += " ";
|
|
185
|
-
}
|
|
186
|
-
if (prefix) {
|
|
187
|
-
displayValue += prefix;
|
|
188
|
-
}
|
|
189
|
-
displayValue += valueStr;
|
|
179
|
+
var valueStr = XUtilsCommon.createDisplayValueForField(object, xEntity, field);
|
|
180
|
+
if (valueStr !== "") {
|
|
181
|
+
if (displayValue !== "") {
|
|
182
|
+
displayValue += " ";
|
|
190
183
|
}
|
|
184
|
+
displayValue += valueStr;
|
|
191
185
|
}
|
|
192
186
|
}
|
|
193
187
|
}
|
|
@@ -200,6 +194,62 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
200
194
|
}
|
|
201
195
|
return displayValue;
|
|
202
196
|
};
|
|
197
|
+
XUtilsCommon.createDisplayValueForField = function (object, xEntity, field) {
|
|
198
|
+
var e_3, _a;
|
|
199
|
+
// pouziva sa podobny algoritmus ako v XLazyDataTable - metoda bodyTemplate
|
|
200
|
+
// (ale nie je to take komplexne ako v XLazyDataTable - nevie renderovat napr. html (rich text))
|
|
201
|
+
var _b = __read(XUtilsCommon.getPrefixAndField(field), 2), prefix = _b[0], fieldOnly = _b[1];
|
|
202
|
+
var xField = undefined;
|
|
203
|
+
if (xEntity) {
|
|
204
|
+
xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, fieldOnly);
|
|
205
|
+
}
|
|
206
|
+
var displayValue;
|
|
207
|
+
var valueOrValueList = XUtilsCommon.getValueOrValueListByPath(object, fieldOnly);
|
|
208
|
+
if (Array.isArray(valueOrValueList)) {
|
|
209
|
+
// zatial je zoznam hodnot OneToMany asociacie oddeleny " ", nedat zoznam napr. do zatvoriek [<zoznam>] ?
|
|
210
|
+
displayValue = "";
|
|
211
|
+
try {
|
|
212
|
+
for (var valueOrValueList_1 = __values(valueOrValueList), valueOrValueList_1_1 = valueOrValueList_1.next(); !valueOrValueList_1_1.done; valueOrValueList_1_1 = valueOrValueList_1.next()) {
|
|
213
|
+
var value = valueOrValueList_1_1.value;
|
|
214
|
+
var valueAsUI = XUtilsCommon.displayValueAsUI(prefix, value, xField);
|
|
215
|
+
if (valueAsUI !== "") {
|
|
216
|
+
if (displayValue !== "") {
|
|
217
|
+
displayValue += " ";
|
|
218
|
+
}
|
|
219
|
+
displayValue += valueAsUI;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
224
|
+
finally {
|
|
225
|
+
try {
|
|
226
|
+
if (valueOrValueList_1_1 && !valueOrValueList_1_1.done && (_a = valueOrValueList_1.return)) _a.call(valueOrValueList_1);
|
|
227
|
+
}
|
|
228
|
+
finally { if (e_3) throw e_3.error; }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
displayValue = XUtilsCommon.displayValueAsUI(prefix, valueOrValueList, xField);
|
|
233
|
+
}
|
|
234
|
+
return displayValue;
|
|
235
|
+
};
|
|
236
|
+
XUtilsCommon.displayValueAsUI = function (prefix, value, xField) {
|
|
237
|
+
var displayValue;
|
|
238
|
+
if (xField) {
|
|
239
|
+
// null hodnoty konvertuje na ""
|
|
240
|
+
displayValue = (0, XUtilsConversions_1.convertValue)(xField, value, true, XUtilsConversions_1.AsUIType.Text); // Text - boolean sa konvertuje na ano/nie
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
// nemame entity, nevieme spravne konvertovat (ale casto nam staci aj takato jednoducha konverzia)
|
|
244
|
+
displayValue = (value !== null && value !== undefined) ? value.toString() : "";
|
|
245
|
+
}
|
|
246
|
+
if (displayValue !== "") {
|
|
247
|
+
if (prefix) {
|
|
248
|
+
displayValue = prefix + displayValue;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return displayValue;
|
|
252
|
+
};
|
|
203
253
|
XUtilsCommon.objectAsJSON = function (value) {
|
|
204
254
|
// sem treba dat nejaku pre nas vhodnu serializaciu
|
|
205
255
|
// zatial provizorne robene cez antipatern - modifikaciu prototype funcii primitivnych typov
|
|
@@ -223,7 +273,7 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
223
273
|
return json;
|
|
224
274
|
};
|
|
225
275
|
XUtilsCommon.arrayCreateMap = function (array, idField) {
|
|
226
|
-
var
|
|
276
|
+
var e_4, _a;
|
|
227
277
|
var idRowMap = new Map();
|
|
228
278
|
try {
|
|
229
279
|
for (var array_1 = __values(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
|
|
@@ -233,12 +283,12 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
233
283
|
}
|
|
234
284
|
}
|
|
235
285
|
}
|
|
236
|
-
catch (
|
|
286
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
237
287
|
finally {
|
|
238
288
|
try {
|
|
239
289
|
if (array_1_1 && !array_1_1.done && (_a = array_1.return)) _a.call(array_1);
|
|
240
290
|
}
|
|
241
|
-
finally { if (
|
|
291
|
+
finally { if (e_4) throw e_4.error; }
|
|
242
292
|
}
|
|
243
293
|
return idRowMap;
|
|
244
294
|
};
|