@michalrakus/x-react-web-lib 1.13.0 → 1.14.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/XFormCol.d.ts +3 -0
- package/XFormCol.js +5 -0
- package/XFormInlineRow.d.ts +3 -0
- package/XFormInlineRow.js +5 -0
- package/XFormRow.d.ts +3 -0
- package/XFormRow.js +5 -0
- package/XFormRowCol.d.ts +3 -0
- package/XFormRowCol.js +5 -0
- package/gulpfile.js +5 -0
- package/lib/components/XAutoComplete.d.ts +1 -1
- package/lib/components/XAutoComplete.js +1 -5
- package/lib/components/XAutoCompleteBase.d.ts +1 -0
- package/lib/components/XAutoCompleteBase.js +1 -1
- package/lib/components/XDropdownDTFilter.d.ts +3 -0
- package/lib/components/XDropdownDTFilter.js +5 -4
- package/lib/components/XFormDataTable2.d.ts +15 -9
- package/lib/components/XFormDataTable2.js +30 -21
- package/lib/components/XFormRowCol/XFormCol.d.ts +8 -0
- package/lib/components/XFormRowCol/XFormCol.js +12 -0
- package/lib/components/XFormRowCol/XFormInlineRow.d.ts +8 -0
- package/lib/components/XFormRowCol/XFormInlineRow.js +12 -0
- package/lib/components/XFormRowCol/XFormRow.d.ts +8 -0
- package/lib/components/XFormRowCol/XFormRow.js +12 -0
- package/lib/components/XFormRowCol/XFormRowCol.d.ts +9 -0
- package/lib/components/XFormRowCol/XFormRowCol.js +30 -0
- package/lib/components/XLazyDataTable.d.ts +10 -1
- package/lib/components/XLazyDataTable.js +5 -2
- package/lib/components/XUtils.d.ts +8 -0
- package/lib/components/XUtils.js +23 -1
- package/package.json +1 -1
package/XFormCol.d.ts
ADDED
package/XFormCol.js
ADDED
package/XFormRow.d.ts
ADDED
package/XFormRow.js
ADDED
package/XFormRowCol.d.ts
ADDED
package/XFormRowCol.js
ADDED
package/gulpfile.js
CHANGED
|
@@ -18,6 +18,11 @@ function generateApi(cb) {
|
|
|
18
18
|
"./lib/administration/XBrowseMetaBrowse",
|
|
19
19
|
"./lib/administration/XBrowseMetaForm",
|
|
20
20
|
|
|
21
|
+
"./lib/components/XFormRowCol/XFormCol",
|
|
22
|
+
"./lib/components/XFormRowCol/XFormInlineRow",
|
|
23
|
+
"./lib/components/XFormRowCol/XFormRow",
|
|
24
|
+
"./lib/components/XFormRowCol/XFormRowCol",
|
|
25
|
+
|
|
21
26
|
"./lib/components/useXToken",
|
|
22
27
|
"./lib/components/XAutoComplete",
|
|
23
28
|
"./lib/components/XAutoCompleteBase",
|
|
@@ -14,7 +14,7 @@ export interface XAutoCompleteProps extends XFormComponentProps<XObject> {
|
|
|
14
14
|
sortField?: string | DataTableSortMeta[];
|
|
15
15
|
suggestions?: any[];
|
|
16
16
|
lazy?: boolean;
|
|
17
|
-
|
|
17
|
+
width?: string;
|
|
18
18
|
inputStyle?: React.CSSProperties;
|
|
19
19
|
}
|
|
20
20
|
export declare class XAutoComplete extends XFormComponent<XObject, XAutoCompleteProps> {
|
|
@@ -138,14 +138,10 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
138
138
|
var _this = this;
|
|
139
139
|
var _a;
|
|
140
140
|
var xEntityAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.xAssoc.entityName);
|
|
141
|
-
//const xDisplayField = XUtilsMetadataCommon.getXFieldByPath(xEntityAssoc, this.props.displayField);
|
|
142
|
-
// TODO - readOnly
|
|
143
|
-
// TODO - size
|
|
144
|
-
//const size = this.props.size ?? xDisplayField.length;
|
|
145
141
|
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
146
142
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
147
143
|
react_1.default.createElement("label", { htmlFor: this.props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
148
|
-
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); }, onSearchStart: this.props.lazy ? this.onSearchStart : undefined })));
|
|
144
|
+
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, width: this.props.width, customFilterFunction: function () { return _this.getFilterBase(_this.props.filter); }, onSearchStart: this.props.lazy ? this.onSearchStart : undefined })));
|
|
149
145
|
};
|
|
150
146
|
return XAutoComplete;
|
|
151
147
|
}(XFormComponent_1.XFormComponent));
|
|
@@ -405,7 +405,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
405
405
|
// <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitValuesForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
|
|
406
406
|
// formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
|
|
407
407
|
return (react_1.default.createElement("div", { className: "x-auto-complete-base" },
|
|
408
|
-
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))),
|
|
408
|
+
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), { style: { width: this.props.width } })),
|
|
409
409
|
dropdownButton,
|
|
410
410
|
this.props.valueForm != undefined && !readOnly ?
|
|
411
411
|
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, {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { XCustomFilter } from "../serverApi/FindParam";
|
|
2
3
|
export declare const XDropdownDTFilter: (props: {
|
|
3
4
|
entity: string;
|
|
4
5
|
path: string;
|
|
5
6
|
value: any;
|
|
6
7
|
onValueChange: (field: string, displayValue: any) => void;
|
|
8
|
+
filter?: XCustomFilter | undefined;
|
|
9
|
+
sortField?: string | undefined;
|
|
7
10
|
}) => JSX.Element;
|
|
@@ -98,13 +98,14 @@ var XDropdownDTFilter = function (props) {
|
|
|
98
98
|
};
|
|
99
99
|
var findOptions = function (entity, path, displayField) { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
100
|
var xAssoc, options, emptyOption;
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
var _a;
|
|
102
|
+
return __generator(this, function (_b) {
|
|
103
|
+
switch (_b.label) {
|
|
103
104
|
case 0:
|
|
104
105
|
xAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getLastXAssocByPath(XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(entity), path);
|
|
105
|
-
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(xAssoc.entityName,
|
|
106
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(xAssoc.entityName, props.filter, (_a = props.sortField) !== null && _a !== void 0 ? _a : displayField)];
|
|
106
107
|
case 1:
|
|
107
|
-
options =
|
|
108
|
+
options = _b.sent();
|
|
108
109
|
emptyOption = {};
|
|
109
110
|
emptyOption[displayField] = XUtils_1.XUtils.dropdownEmptyOptionValue;
|
|
110
111
|
options.splice(0, 0, emptyOption); // null polozka (nepridavat pre not null atributy)
|
|
@@ -2,6 +2,7 @@ import { XFormBase } from "./XFormBase";
|
|
|
2
2
|
import { Component, ReactChild } from "react";
|
|
3
3
|
import { DataTableFilterMeta } from "primereact/datatable";
|
|
4
4
|
import { XEntity, XField } from "../serverApi/XEntityMetadata";
|
|
5
|
+
import { XViewStatusOrBoolean } from "./XUtils";
|
|
5
6
|
import { FilterMatchMode } from "primereact/api";
|
|
6
7
|
import { XTableFieldChangeEvent } from "./XFieldChangeEvent";
|
|
7
8
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
@@ -65,8 +66,8 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
65
66
|
filters: DataTableFilterMeta;
|
|
66
67
|
};
|
|
67
68
|
constructor(props: XFormDataTableProps);
|
|
68
|
-
getPathForColumn(columnProps:
|
|
69
|
-
static getHeader(columnProps:
|
|
69
|
+
getPathForColumn(columnProps: XFormColumnBaseProps): string;
|
|
70
|
+
static getHeader(columnProps: XFormColumnBaseProps, xEntity: XEntity, field: string, xField: XField): string;
|
|
70
71
|
static isReadOnlyHeader(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined): boolean;
|
|
71
72
|
getEntity(): string;
|
|
72
73
|
createInitFilters(): DataTableFilterMeta;
|
|
@@ -78,7 +79,7 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
78
79
|
getCheckboxFilterValue(field: string): boolean | null;
|
|
79
80
|
onDropdownFilterChange(field: string, displayValue: any): void;
|
|
80
81
|
getDropdownFilterValue(field: string): any;
|
|
81
|
-
bodyTemplate(columnProps:
|
|
82
|
+
bodyTemplate(columnProps: XFormColumnBaseProps, tableReadOnly: boolean, rowData: any, xEntity: XEntity): any;
|
|
82
83
|
onClickAddRow(): void;
|
|
83
84
|
onClickRemoveRowBySelection(): void;
|
|
84
85
|
removeRow(row: any): void;
|
|
@@ -89,7 +90,7 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
89
90
|
export type XTableFieldOnChange = (e: XTableFieldChangeEvent<any, any>) => void;
|
|
90
91
|
export type XTableFieldReadOnlyProp = boolean | ((object: any, tableRow: any) => boolean);
|
|
91
92
|
export type XTableFieldFilterProp = XCustomFilter | ((object: any, rowData: any) => XCustomFilter | undefined);
|
|
92
|
-
export interface
|
|
93
|
+
export interface XFormColumnBaseProps {
|
|
93
94
|
type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton";
|
|
94
95
|
header?: any;
|
|
95
96
|
readOnly?: XTableFieldReadOnlyProp;
|
|
@@ -97,17 +98,18 @@ export interface XFormColumnProps {
|
|
|
97
98
|
showFilterMenu?: boolean;
|
|
98
99
|
width?: string;
|
|
99
100
|
onChange?: XTableFieldOnChange;
|
|
101
|
+
columnViewStatus: XViewStatusOrBoolean;
|
|
100
102
|
}
|
|
101
|
-
export interface
|
|
103
|
+
export interface XFormColumnProps extends XFormColumnBaseProps {
|
|
102
104
|
field: string;
|
|
103
105
|
}
|
|
104
|
-
export interface XFormDropdownColumnProps extends
|
|
106
|
+
export interface XFormDropdownColumnProps extends XFormColumnBaseProps {
|
|
105
107
|
assocField: string;
|
|
106
108
|
displayField: string;
|
|
107
109
|
sortField?: string;
|
|
108
110
|
filter?: XCustomFilter;
|
|
109
111
|
}
|
|
110
|
-
export interface XFormAutoCompleteColumnProps extends
|
|
112
|
+
export interface XFormAutoCompleteColumnProps extends XFormColumnBaseProps {
|
|
111
113
|
assocField: string;
|
|
112
114
|
displayField: string;
|
|
113
115
|
searchBrowse?: JSX.Element;
|
|
@@ -115,32 +117,36 @@ export interface XFormAutoCompleteColumnProps extends XFormColumnProps {
|
|
|
115
117
|
filter?: XTableFieldFilterProp;
|
|
116
118
|
suggestions?: any[];
|
|
117
119
|
}
|
|
118
|
-
export interface XFormSearchButtonColumnProps extends
|
|
120
|
+
export interface XFormSearchButtonColumnProps extends XFormColumnBaseProps {
|
|
119
121
|
assocField: string;
|
|
120
122
|
displayField: string;
|
|
121
123
|
searchBrowse: JSX.Element;
|
|
122
124
|
}
|
|
123
125
|
export declare const XFormColumn: {
|
|
124
|
-
(props:
|
|
126
|
+
(props: XFormColumnProps): null;
|
|
125
127
|
defaultProps: {
|
|
126
128
|
type: string;
|
|
129
|
+
columnViewStatus: boolean;
|
|
127
130
|
};
|
|
128
131
|
};
|
|
129
132
|
export declare const XFormDropdownColumn: {
|
|
130
133
|
(props: XFormDropdownColumnProps): null;
|
|
131
134
|
defaultProps: {
|
|
132
135
|
type: string;
|
|
136
|
+
columnViewStatus: boolean;
|
|
133
137
|
};
|
|
134
138
|
};
|
|
135
139
|
export declare const XFormAutoCompleteColumn: {
|
|
136
140
|
(props: XFormAutoCompleteColumnProps): null;
|
|
137
141
|
defaultProps: {
|
|
138
142
|
type: string;
|
|
143
|
+
columnViewStatus: boolean;
|
|
139
144
|
};
|
|
140
145
|
};
|
|
141
146
|
export declare const XFormSearchButtonColumn: {
|
|
142
147
|
(props: XFormSearchButtonColumnProps): null;
|
|
143
148
|
defaultProps: {
|
|
144
149
|
type: string;
|
|
150
|
+
columnViewStatus: boolean;
|
|
145
151
|
};
|
|
146
152
|
};
|
|
@@ -350,8 +350,19 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
350
350
|
// body={(rowData: any) => bodyTemplate(childColumn.props.field, rowData)}
|
|
351
351
|
XFormDataTable2.prototype.bodyTemplate = function (columnProps, tableReadOnly, rowData, xEntity) {
|
|
352
352
|
var body;
|
|
353
|
+
// columnProps.columnViewStatus "ReadOnly" has higher prio then tableReadOnly
|
|
353
354
|
// tableReadOnly has higher prio then property readOnly
|
|
354
|
-
|
|
355
|
+
// (viewStatus "Hidden" - column is not rendered (bodyTemplate not called), viewStatus "ReadWrite" (default) - tableReadOnly/columnProps.readOnly is applied)
|
|
356
|
+
var readOnly;
|
|
357
|
+
if (XUtils_1.XUtils.xViewStatus(columnProps.columnViewStatus) === XUtils_1.XViewStatus.ReadOnly) {
|
|
358
|
+
readOnly = true;
|
|
359
|
+
}
|
|
360
|
+
else if (tableReadOnly) {
|
|
361
|
+
readOnly = true;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
readOnly = columnProps.readOnly;
|
|
365
|
+
}
|
|
355
366
|
if (columnProps.type === "inputSimple") {
|
|
356
367
|
var columnPropsInputSimple = columnProps;
|
|
357
368
|
var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, columnPropsInputSimple.field);
|
|
@@ -497,7 +508,8 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
497
508
|
};
|
|
498
509
|
XFormDataTable2.prototype.render = function () {
|
|
499
510
|
var _this = this;
|
|
500
|
-
var _a, _b;
|
|
511
|
+
var _a, _b, _c;
|
|
512
|
+
var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.getEntity());
|
|
501
513
|
var paginator = this.props.paginator !== undefined ? this.props.paginator : false;
|
|
502
514
|
var rows = undefined;
|
|
503
515
|
if (paginator) {
|
|
@@ -509,13 +521,14 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
509
521
|
}
|
|
510
522
|
}
|
|
511
523
|
var filterDisplay = this.props.filterDisplay !== "none" ? this.props.filterDisplay : undefined;
|
|
524
|
+
// default sortovanie - ak mame insert tak nesortujeme (drzime poradie v akom user zaznam vytvoril), ak mame update tak podla id zosortujeme (nech je to zobrazene vzdy rovnako)
|
|
525
|
+
var sortField = ((_a = this.props.sortField) !== null && _a !== void 0 ? _a : this.props.form.isAddRow()) ? undefined : xEntity.idField;
|
|
512
526
|
var label = this.props.label !== undefined ? this.props.label : this.props.assocField;
|
|
513
527
|
var readOnly = this.isReadOnly();
|
|
514
528
|
// v bloku function (child) nejde pouzit priamo this, thisLocal uz ide pouzit
|
|
515
529
|
var thisLocal = this;
|
|
516
530
|
var object = this.props.form.state.object;
|
|
517
531
|
var valueList = object !== null ? object[this.props.assocField] : [];
|
|
518
|
-
var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.getEntity());
|
|
519
532
|
var scrollWidth = undefined; // vypnute horizontalne scrollovanie
|
|
520
533
|
var scrollHeight = undefined; // vypnute vertikalne scrollovanie
|
|
521
534
|
if (this.props.scrollable) {
|
|
@@ -543,7 +556,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
543
556
|
tableStyle = __assign(__assign({}, tableStyle), { width: width });
|
|
544
557
|
}
|
|
545
558
|
// pre lepsiu citatelnost vytvarame stlpce uz tu
|
|
546
|
-
var columnElemList = react_1.default.Children.map(this.props.children, function (child) {
|
|
559
|
+
var columnElemList = react_1.default.Children.map(this.props.children.filter(function (child) { return XUtils_1.XUtils.xViewStatus(child.props.columnViewStatus) !== XUtils_1.XViewStatus.Hidden; }), function (child) {
|
|
547
560
|
// ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
|
|
548
561
|
// priklad je na https://soshace.com/building-react-components-using-children-props-and-context-api/
|
|
549
562
|
// (vzdy musime robit manipulacie so stlpcom, lebo potrebujeme pridat filter={true} sortable={true}
|
|
@@ -624,14 +637,14 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
624
637
|
var removeRowLabel = undefined;
|
|
625
638
|
if (this.props.showAddRemoveButtons) {
|
|
626
639
|
// calling xLocaleOption does not work in standard default values initialisation place (public static defaultProps)
|
|
627
|
-
addRowLabel = (
|
|
628
|
-
removeRowLabel = (
|
|
640
|
+
addRowLabel = (_b = this.props.addRowLabel) !== null && _b !== void 0 ? _b : (0, XLocale_1.xLocaleOption)('addRow');
|
|
641
|
+
removeRowLabel = (_c = this.props.removeRowLabel) !== null && _c !== void 0 ? _c : (0, XLocale_1.xLocaleOption)('removeRow');
|
|
629
642
|
}
|
|
630
643
|
return (react_1.default.createElement("div", null,
|
|
631
644
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
632
645
|
react_1.default.createElement("label", null, label)),
|
|
633
646
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
634
|
-
react_1.default.createElement(datatable_1.DataTable, { ref: function (el) { return _this.dt = el; }, value: valueList, dataKey: this.dataKey, paginator: paginator, rows: rows, totalRecords: valueList.length, filterDisplay: filterDisplay, filters: this.state.filters, onFilter: this.onFilter, sortMode: "multiple", removableSort: true, multiSortMeta:
|
|
647
|
+
react_1.default.createElement(datatable_1.DataTable, { ref: function (el) { return _this.dt = el; }, value: valueList, dataKey: this.dataKey, paginator: paginator, rows: rows, totalRecords: valueList.length, filterDisplay: filterDisplay, filters: this.state.filters, onFilter: this.onFilter, sortMode: "multiple", removableSort: true, multiSortMeta: sortField !== undefined ? [{ field: sortField, order: 1 }] : undefined, selectionMode: "single", selection: this.state.selectedRow, onSelectionChange: this.onSelectionChange, className: "p-datatable-sm x-form-datatable", resizableColumns: true, columnResizeMode: "expand", tableStyle: tableStyle, scrollable: this.props.scrollable, scrollHeight: scrollHeight, style: style }, columnElemList)),
|
|
635
648
|
this.props.showAddRemoveButtons ?
|
|
636
649
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
637
650
|
react_1.default.createElement(XButton_1.XButton, { icon: this.props.addRowIcon, label: addRowLabel, onClick: this.onClickAddRow, disabled: readOnly }),
|
|
@@ -639,8 +652,8 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
639
652
|
: undefined));
|
|
640
653
|
};
|
|
641
654
|
XFormDataTable2.defaultProps = {
|
|
642
|
-
filterDisplay: "
|
|
643
|
-
sortable:
|
|
655
|
+
filterDisplay: "none",
|
|
656
|
+
sortable: false,
|
|
644
657
|
scrollable: true,
|
|
645
658
|
scrollWidth: '100%',
|
|
646
659
|
scrollHeight: '200vh',
|
|
@@ -654,35 +667,31 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
654
667
|
return XFormDataTable2;
|
|
655
668
|
}(react_1.Component));
|
|
656
669
|
exports.XFormDataTable2 = XFormDataTable2;
|
|
670
|
+
// default props for XFormColumnBaseProps
|
|
671
|
+
var XFormColumnBase_defaultProps = {
|
|
672
|
+
columnViewStatus: true
|
|
673
|
+
};
|
|
657
674
|
var XFormColumn = function (props) {
|
|
658
675
|
// nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
|
|
659
676
|
return (null);
|
|
660
677
|
};
|
|
661
678
|
exports.XFormColumn = XFormColumn;
|
|
662
|
-
exports.XFormColumn.defaultProps = {
|
|
663
|
-
type: "inputSimple"
|
|
664
|
-
};
|
|
679
|
+
exports.XFormColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "inputSimple" });
|
|
665
680
|
var XFormDropdownColumn = function (props) {
|
|
666
681
|
// nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
|
|
667
682
|
return (null);
|
|
668
683
|
};
|
|
669
684
|
exports.XFormDropdownColumn = XFormDropdownColumn;
|
|
670
|
-
exports.XFormDropdownColumn.defaultProps = {
|
|
671
|
-
type: "dropdown"
|
|
672
|
-
};
|
|
685
|
+
exports.XFormDropdownColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "dropdown" });
|
|
673
686
|
var XFormAutoCompleteColumn = function (props) {
|
|
674
687
|
// nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
|
|
675
688
|
return (null);
|
|
676
689
|
};
|
|
677
690
|
exports.XFormAutoCompleteColumn = XFormAutoCompleteColumn;
|
|
678
|
-
exports.XFormAutoCompleteColumn.defaultProps = {
|
|
679
|
-
type: "autoComplete"
|
|
680
|
-
};
|
|
691
|
+
exports.XFormAutoCompleteColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "autoComplete" });
|
|
681
692
|
var XFormSearchButtonColumn = function (props) {
|
|
682
693
|
// nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
|
|
683
694
|
return (null);
|
|
684
695
|
};
|
|
685
696
|
exports.XFormSearchButtonColumn = XFormSearchButtonColumn;
|
|
686
|
-
exports.XFormSearchButtonColumn.defaultProps = {
|
|
687
|
-
type: "searchButton"
|
|
688
|
-
};
|
|
697
|
+
exports.XFormSearchButtonColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "searchButton" });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { XFormBase } from "../XFormBase";
|
|
3
|
+
export interface XFormColProps {
|
|
4
|
+
form?: XFormBase;
|
|
5
|
+
labelStyle?: React.CSSProperties;
|
|
6
|
+
children: JSX.Element | JSX.Element[];
|
|
7
|
+
}
|
|
8
|
+
export declare const XFormCol: (props: XFormColProps) => JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.XFormCol = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var XFormRowCol_1 = require("./XFormRowCol");
|
|
9
|
+
var XFormCol = function (props) {
|
|
10
|
+
return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-col", form: props.form, labelStyle: props.labelStyle, children: props.children });
|
|
11
|
+
};
|
|
12
|
+
exports.XFormCol = XFormCol;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { XFormBase } from "../XFormBase";
|
|
3
|
+
export interface XFormInlineRowProps {
|
|
4
|
+
form?: XFormBase;
|
|
5
|
+
labelStyle?: React.CSSProperties;
|
|
6
|
+
children: JSX.Element | JSX.Element[];
|
|
7
|
+
}
|
|
8
|
+
export declare const XFormInlineRow: (props: XFormInlineRowProps) => JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.XFormInlineRow = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var XFormRowCol_1 = require("./XFormRowCol");
|
|
9
|
+
var XFormInlineRow = function (props) {
|
|
10
|
+
return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-inline-row", form: props.form, labelStyle: props.labelStyle, children: props.children });
|
|
11
|
+
};
|
|
12
|
+
exports.XFormInlineRow = XFormInlineRow;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { XFormBase } from "../XFormBase";
|
|
3
|
+
export interface XFormRowProps {
|
|
4
|
+
form?: XFormBase;
|
|
5
|
+
labelStyle?: React.CSSProperties;
|
|
6
|
+
children: JSX.Element | JSX.Element[];
|
|
7
|
+
}
|
|
8
|
+
export declare const XFormRow: (props: XFormRowProps) => JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.XFormRow = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var XFormRowCol_1 = require("./XFormRowCol");
|
|
9
|
+
var XFormRow = function (props) {
|
|
10
|
+
return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-row", form: props.form, labelStyle: props.labelStyle, children: props.children });
|
|
11
|
+
};
|
|
12
|
+
exports.XFormRow = XFormRow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { XFormBase } from "../XFormBase";
|
|
3
|
+
export interface XFormRowColProps {
|
|
4
|
+
className: "x-form-row" | "x-form-inline-row" | "x-form-col";
|
|
5
|
+
form?: XFormBase;
|
|
6
|
+
labelStyle?: React.CSSProperties;
|
|
7
|
+
children: JSX.Element | JSX.Element[];
|
|
8
|
+
}
|
|
9
|
+
export declare const XFormRowCol: (props: XFormRowColProps) => JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
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.XFormRowCol = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var XFormRowCol = function (props) {
|
|
9
|
+
var childElemList;
|
|
10
|
+
if (props.form || props.labelStyle) {
|
|
11
|
+
// ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
|
|
12
|
+
// priklad je na https://soshace.com/building-react-components-using-children-props-and-context-api/
|
|
13
|
+
childElemList = react_1.default.Children.map(props.children, function (child) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
// klonujeme len nase X* komponenty (napr. XInputText), child.type.name vracia nazov komponenty (napr. XInputText)
|
|
16
|
+
// ak vyklonujeme cudziu komponentu, funguje, ale prida do nej property labelstyle=[object Object]
|
|
17
|
+
if (child.type.name && child.type.name.startsWith("X")) {
|
|
18
|
+
return react_1.default.cloneElement(child, { form: (_a = child.props.form) !== null && _a !== void 0 ? _a : props.form, labelStyle: (_b = child.props.labelStyle) !== null && _b !== void 0 ? _b : props.labelStyle });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return child;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
childElemList = props.children; // netreba klonovat - viac menej koli performance
|
|
27
|
+
}
|
|
28
|
+
return react_1.default.createElement("div", { className: props.className }, childElemList);
|
|
29
|
+
};
|
|
30
|
+
exports.XFormRowCol = XFormRowCol;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactChild } from 'react';
|
|
2
2
|
import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMetaData } from 'primereact/datatable';
|
|
3
3
|
import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereact/column';
|
|
4
|
+
import { XViewStatusOrBoolean } from "./XUtils";
|
|
4
5
|
import { XSearchBrowseParams } from "./XSearchBrowseParams";
|
|
5
6
|
import { XAggregateType, XCustomFilter } from "../serverApi/FindParam";
|
|
6
7
|
import { XOnSaveOrCancelProp } from "./XFormBase";
|
|
@@ -86,11 +87,19 @@ export interface XLazyColumnProps {
|
|
|
86
87
|
header?: any;
|
|
87
88
|
align?: "left" | "center" | "right";
|
|
88
89
|
dropdownInFilter?: boolean;
|
|
90
|
+
dropdownFilter?: XCustomFilter;
|
|
91
|
+
dropdownSortField?: string;
|
|
89
92
|
showFilterMenu?: boolean;
|
|
90
93
|
betweenFilter?: XBetweenFilterProp | "noBetween";
|
|
91
94
|
width?: string;
|
|
92
95
|
aggregateType?: XAggregateType;
|
|
96
|
+
columnViewStatus: XViewStatusOrBoolean;
|
|
93
97
|
filterElement?: XFilterElementProp;
|
|
94
98
|
body?: React.ReactNode | ((data: any, options: ColumnBodyOptions) => React.ReactNode);
|
|
95
99
|
}
|
|
96
|
-
export declare const XLazyColumn:
|
|
100
|
+
export declare const XLazyColumn: {
|
|
101
|
+
(props: XLazyColumnProps): null;
|
|
102
|
+
defaultProps: {
|
|
103
|
+
columnViewStatus: boolean;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
@@ -720,7 +720,7 @@ var XLazyDataTable = function (props) {
|
|
|
720
720
|
// export pre search button-y zatial vypneme
|
|
721
721
|
var exportRows = (props.searchBrowseParams === undefined);
|
|
722
722
|
// pre lepsiu citatelnost vytvarame stlpce uz tu
|
|
723
|
-
var columnElemList = react_1.default.Children.map(props.children, function (child) {
|
|
723
|
+
var columnElemList = react_1.default.Children.map(props.children.filter(function (child) { return XUtils_1.XUtils.xViewStatus(child.props.columnViewStatus) !== XUtils_1.XViewStatus.Hidden; }), function (child) {
|
|
724
724
|
// ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
|
|
725
725
|
// priklad je na https://soshace.com/building-react-components-using-children-props-and-context-api/
|
|
726
726
|
// (vzdy musime robit manipulacie so stlpcom, lebo potrebujeme pridat filter={true} sortable={true}
|
|
@@ -759,7 +759,7 @@ var XLazyDataTable = function (props) {
|
|
|
759
759
|
}
|
|
760
760
|
else if (childColumn.props.dropdownInFilter) {
|
|
761
761
|
var dropdownValue = getDropdownFilterValue(childColumn.props.field);
|
|
762
|
-
filterElement = react_1.default.createElement(XDropdownDTFilter_1.XDropdownDTFilter, { entity: props.entity, path: childColumn.props.field, value: dropdownValue, onValueChange: onDropdownFilterChange });
|
|
762
|
+
filterElement = react_1.default.createElement(XDropdownDTFilter_1.XDropdownDTFilter, { entity: props.entity, path: childColumn.props.field, value: dropdownValue, onValueChange: onDropdownFilterChange, filter: childColumn.props.dropdownFilter, sortField: childColumn.props.dropdownSortField });
|
|
763
763
|
}
|
|
764
764
|
else if (xField.type === "date" || xField.type === "datetime") {
|
|
765
765
|
betweenFilter = getBetweenFilter(childColumn.props.betweenFilter, props.betweenFilter);
|
|
@@ -902,3 +902,6 @@ var XLazyColumn = function (props) {
|
|
|
902
902
|
return (null);
|
|
903
903
|
};
|
|
904
904
|
exports.XLazyColumn = XLazyColumn;
|
|
905
|
+
exports.XLazyColumn.defaultProps = {
|
|
906
|
+
columnViewStatus: true // XViewStatus.ReadWrite
|
|
907
|
+
};
|
|
@@ -13,6 +13,12 @@ export declare enum OperationType {
|
|
|
13
13
|
Update = 2,
|
|
14
14
|
Remove = 3
|
|
15
15
|
}
|
|
16
|
+
export declare enum XViewStatus {
|
|
17
|
+
ReadWrite = 0,
|
|
18
|
+
ReadOnly = 1,
|
|
19
|
+
Hidden = 2
|
|
20
|
+
}
|
|
21
|
+
export type XViewStatusOrBoolean = XViewStatus | boolean;
|
|
16
22
|
export interface IPostgresInterval {
|
|
17
23
|
years?: number;
|
|
18
24
|
months?: number;
|
|
@@ -103,5 +109,7 @@ export declare class XUtils {
|
|
|
103
109
|
static normalizeString(value: string): string;
|
|
104
110
|
static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
|
|
105
111
|
static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
|
|
112
|
+
static filterIdIn(idField: string, idList: number[]): XCustomFilter;
|
|
106
113
|
static isTableRowInserted(tableRow: any): boolean;
|
|
114
|
+
static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
|
|
107
115
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -83,7 +83,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
83
83
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
84
84
|
};
|
|
85
85
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
86
|
-
exports.XUtils = exports.OperationType = void 0;
|
|
86
|
+
exports.XUtils = exports.XViewStatus = exports.OperationType = void 0;
|
|
87
87
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
88
88
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
89
89
|
var ExportImportParam_1 = require("../serverApi/ExportImportParam");
|
|
@@ -97,6 +97,12 @@ var OperationType;
|
|
|
97
97
|
OperationType[OperationType["Update"] = 2] = "Update";
|
|
98
98
|
OperationType[OperationType["Remove"] = 3] = "Remove";
|
|
99
99
|
})(OperationType = exports.OperationType || (exports.OperationType = {}));
|
|
100
|
+
var XViewStatus;
|
|
101
|
+
(function (XViewStatus) {
|
|
102
|
+
XViewStatus[XViewStatus["ReadWrite"] = 0] = "ReadWrite";
|
|
103
|
+
XViewStatus[XViewStatus["ReadOnly"] = 1] = "ReadOnly";
|
|
104
|
+
XViewStatus[XViewStatus["Hidden"] = 2] = "Hidden";
|
|
105
|
+
})(XViewStatus = exports.XViewStatus || (exports.XViewStatus = {}));
|
|
100
106
|
var XUtils = /** @class */ (function () {
|
|
101
107
|
function XUtils() {
|
|
102
108
|
}
|
|
@@ -725,10 +731,26 @@ var XUtils = /** @class */ (function () {
|
|
|
725
731
|
return customFilterItemsResult;
|
|
726
732
|
};
|
|
727
733
|
// pomocna metodka
|
|
734
|
+
// ak je idList prazdny, vytvori podmienku id IN (0) a nevrati ziadne zaznamy
|
|
735
|
+
XUtils.filterIdIn = function (idField, idList) {
|
|
736
|
+
return { where: "[".concat(idField, "] IN (:...idList)"), params: { "idList": idList.length > 0 ? idList : [0] } };
|
|
737
|
+
};
|
|
738
|
+
// pomocna metodka
|
|
728
739
|
XUtils.isTableRowInserted = function (tableRow) {
|
|
729
740
|
var _a;
|
|
730
741
|
return (_a = tableRow.__x_generatedRowId) !== null && _a !== void 0 ? _a : false; // specialny priznak, ze sme vygenerovali id-cko
|
|
731
742
|
};
|
|
743
|
+
// pomocna metodka
|
|
744
|
+
XUtils.xViewStatus = function (xViewStatusOrBoolean) {
|
|
745
|
+
var xViewStatus;
|
|
746
|
+
if (typeof xViewStatusOrBoolean === "boolean") {
|
|
747
|
+
xViewStatus = xViewStatusOrBoolean ? XViewStatus.ReadWrite : XViewStatus.Hidden;
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
xViewStatus = xViewStatusOrBoolean;
|
|
751
|
+
}
|
|
752
|
+
return xViewStatus;
|
|
753
|
+
};
|
|
732
754
|
XUtils.dropdownEmptyOptionValue = " ";
|
|
733
755
|
XUtils.xBackendUrl = undefined;
|
|
734
756
|
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|