@michalrakus/x-react-web-lib 1.11.0 → 1.12.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/lib/components/XAutoComplete.d.ts +2 -0
- package/lib/components/XAutoComplete.js +6 -5
- package/lib/components/XAutoCompleteBase.js +1 -1
- package/lib/components/XCheckboxDT.d.ts +2 -1
- package/lib/components/XCheckboxDT.js +2 -9
- package/lib/components/XDropdownDT.d.ts +2 -2
- package/lib/components/XDropdownDT.js +2 -3
- package/lib/components/XFormBase.d.ts +5 -5
- package/lib/components/XFormComponent.d.ts +3 -3
- package/lib/components/XFormComponentDT.d.ts +4 -4
- package/lib/components/XFormComponentDT.js +10 -11
- package/lib/components/XFormDataTable2.d.ts +5 -3
- package/lib/components/XFormDataTable2.js +33 -12
- package/lib/components/XFtsInput.d.ts +9 -0
- package/lib/components/XFtsInput.js +30 -0
- package/lib/components/XInputDateDT.d.ts +2 -1
- package/lib/components/XInputDateDT.js +2 -9
- package/lib/components/XInputTextDT.d.ts +2 -1
- package/lib/components/XInputTextDT.js +2 -9
- package/lib/components/XLazyDataTable.d.ts +2 -0
- package/lib/components/XLazyDataTable.js +37 -12
- package/lib/components/XSearchButtonDT.d.ts +2 -1
- package/lib/components/XSearchButtonDT.js +1 -1
- package/lib/components/XUtils.d.ts +6 -1
- package/lib/components/XUtils.js +45 -2
- package/lib/serverApi/ExportImportParam.d.ts +2 -1
- package/lib/serverApi/FindParam.d.ts +6 -0
- package/package.json +1 -1
|
@@ -4,12 +4,14 @@ import { XAssoc } from "../serverApi/XEntityMetadata";
|
|
|
4
4
|
import { OperationType } from "./XUtils";
|
|
5
5
|
import { XError } from "./XErrors";
|
|
6
6
|
import { XObject } from "./XObject";
|
|
7
|
+
import { DataTableSortMeta } from "primereact/datatable";
|
|
7
8
|
export interface XAutoCompleteProps extends XFormComponentProps<XObject> {
|
|
8
9
|
assocField: string;
|
|
9
10
|
displayField: string;
|
|
10
11
|
searchBrowse?: JSX.Element;
|
|
11
12
|
assocForm?: JSX.Element;
|
|
12
13
|
filter?: XFilterProp;
|
|
14
|
+
sortField?: string | DataTableSortMeta[];
|
|
13
15
|
suggestions?: any[];
|
|
14
16
|
size?: number;
|
|
15
17
|
inputStyle?: React.CSSProperties;
|
|
@@ -79,17 +79,18 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
79
79
|
this.readAndSetSuggestions();
|
|
80
80
|
};
|
|
81
81
|
XAutoComplete.prototype.readAndSetSuggestions = function () {
|
|
82
|
+
var _a;
|
|
82
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
84
|
var suggestions;
|
|
84
|
-
return __generator(this, function (
|
|
85
|
-
switch (
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
86
87
|
case 0:
|
|
87
88
|
if (!(this.props.suggestions === undefined)) return [3 /*break*/, 2];
|
|
88
|
-
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), this.props.displayField)];
|
|
89
|
+
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), (_a = this.props.sortField) !== null && _a !== void 0 ? _a : this.props.displayField)];
|
|
89
90
|
case 1:
|
|
90
|
-
suggestions =
|
|
91
|
+
suggestions = _b.sent();
|
|
91
92
|
this.setState({ suggestions: suggestions });
|
|
92
|
-
|
|
93
|
+
_b.label = 2;
|
|
93
94
|
case 2: return [2 /*return*/];
|
|
94
95
|
}
|
|
95
96
|
});
|
|
@@ -377,7 +377,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
377
377
|
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, field: this.props.field, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, maxLength: this.props.maxLength, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createErrorProps(error))),
|
|
378
378
|
dropdownButton,
|
|
379
379
|
this.props.valueForm != undefined && !readOnly ?
|
|
380
|
-
react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New
|
|
380
|
+
react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New row' }, react_1.default.cloneElement(this.props.valueForm, {
|
|
381
381
|
id: this.formDialogObjectId, initValues: this.formDialogInitValuesForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
|
|
382
382
|
} /*, this.props.valueForm.children*/))
|
|
383
383
|
: undefined,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XFormBase } from "./XFormBase";
|
|
3
3
|
import { XField } from "../serverApi/XEntityMetadata";
|
|
4
|
+
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
4
5
|
export declare const XCheckboxDT: (props: {
|
|
5
6
|
form: XFormBase;
|
|
6
7
|
xField: XField;
|
|
7
8
|
field: string;
|
|
8
9
|
rowData: any;
|
|
9
|
-
readOnly?:
|
|
10
|
+
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
10
11
|
}) => JSX.Element;
|
|
@@ -7,16 +7,8 @@ exports.XCheckboxDT = void 0;
|
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var tristatecheckbox_1 = require("primereact/tristatecheckbox");
|
|
9
9
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
10
|
+
var XUtils_1 = require("./XUtils");
|
|
10
11
|
var XCheckboxDT = function (props) {
|
|
11
|
-
// ak mame path, field je vzdy readOnly
|
|
12
|
-
var readOnly;
|
|
13
|
-
var posDot = props.field.indexOf(".");
|
|
14
|
-
if (posDot !== -1) {
|
|
15
|
-
readOnly = true;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
readOnly = props.readOnly !== undefined ? props.readOnly : false;
|
|
19
|
-
}
|
|
20
12
|
var onValueChange = function (field, rowData, newValue) {
|
|
21
13
|
// pri klikani na TriStateCheckbox prichadza v newValue cyklicky: true -> false -> null
|
|
22
14
|
// ak mame not null atribut, tak pri null hodnote skocime rovno na true
|
|
@@ -41,6 +33,7 @@ var XCheckboxDT = function (props) {
|
|
|
41
33
|
// konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli (a tiez aby korektne pridal novy riadok)
|
|
42
34
|
fieldValue = rowDataValue;
|
|
43
35
|
}
|
|
36
|
+
var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
|
|
44
37
|
return (react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { id: props.field, value: fieldValue, onChange: function (e) { return onValueChange(props.field, props.rowData, e.value); }, disabled: readOnly }));
|
|
45
38
|
};
|
|
46
39
|
exports.XCheckboxDT = XCheckboxDT;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XFormBase } from "./XFormBase";
|
|
3
|
-
import { XDropdownOptionsMap } from "./XFormDataTable2";
|
|
3
|
+
import { XDropdownOptionsMap, XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
4
4
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
5
5
|
export declare const XDropdownDT: (props: {
|
|
6
6
|
form: XFormBase;
|
|
@@ -12,5 +12,5 @@ export declare const XDropdownDT: (props: {
|
|
|
12
12
|
dropdownOptionsMap: XDropdownOptionsMap;
|
|
13
13
|
onDropdownOptionsMapChange: (dropdownOptionsMap: XDropdownOptionsMap) => void;
|
|
14
14
|
rowData: any;
|
|
15
|
-
readOnly?:
|
|
15
|
+
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
16
16
|
}) => JSX.Element;
|
|
@@ -103,7 +103,6 @@ var XDropdownDT = function (props) {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
}); };
|
|
106
|
-
var readOnly = props.readOnly !== undefined ? props.readOnly : false;
|
|
107
106
|
var onValueChange = function (assocField, rowData, newValue) {
|
|
108
107
|
// zmenime hodnotu v modeli (odtial sa hodnota cita)
|
|
109
108
|
var newValueOrNull;
|
|
@@ -118,7 +117,6 @@ var XDropdownDT = function (props) {
|
|
|
118
117
|
// kedze "rowData" je sucastou "props.form.state.object", tak nam staci zavolat setState({object: object}), aby sa zmena prejavila
|
|
119
118
|
props.form.onObjectDataChange();
|
|
120
119
|
};
|
|
121
|
-
// TODO - readOnly implementovat
|
|
122
120
|
// Dropdown setuje do atributu object.assocField asociovany objekt zo zoznamu objektov ktore ziskame podla asociacie
|
|
123
121
|
var assocObject = null;
|
|
124
122
|
if (props.rowData !== null) {
|
|
@@ -129,7 +127,8 @@ var XDropdownDT = function (props) {
|
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
var options = props.dropdownOptionsMap[props.assocField] !== undefined ? props.dropdownOptionsMap[props.assocField] : []; // mozno mozme do options prasknut rovno undefined...
|
|
130
|
+
var readOnly = XUtils_1.XUtils.isReadOnlyTableField(undefined, props.readOnly, props.form.state.object, props.rowData);
|
|
132
131
|
// appendTo={document.body} appenduje overlay panel na element body - eliminuje problem s overflow (pozri poznamku v XDropdownDTFilter)
|
|
133
|
-
return (react_1.default.createElement(dropdown_1.Dropdown, { appendTo: document.body, id: props.assocField, optionLabel: props.displayField, value: assocObject, options: options, dataKey: idField, onChange: function (e) { return onValueChange(props.assocField, props.rowData, e.target.value); } }));
|
|
132
|
+
return (react_1.default.createElement(dropdown_1.Dropdown, { appendTo: document.body, id: props.assocField, optionLabel: props.displayField, value: assocObject, options: options, dataKey: idField, onChange: function (e) { return onValueChange(props.assocField, props.rowData, e.target.value); }, readOnly: readOnly, disabled: readOnly }));
|
|
134
133
|
};
|
|
135
134
|
exports.XDropdownDT = XDropdownDT;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Component } from "react";
|
|
2
2
|
import { XObject } from "./XObject";
|
|
3
3
|
import { OperationType } from "./XUtils";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { XFieldOnChange, XFormComponent } from "./XFormComponent";
|
|
5
|
+
import { XTableFieldOnChange, XFormDataTable2, XRowTechData } from "./XFormDataTable2";
|
|
6
6
|
import { XErrorMap, XErrors } from "./XErrors";
|
|
7
7
|
export type XOnSaveOrCancelProp = (object: XObject | null, objectChange: OperationType) => void;
|
|
8
8
|
export interface XFormProps {
|
|
@@ -35,12 +35,12 @@ export declare abstract class XFormBase extends Component<XFormProps> {
|
|
|
35
35
|
getXObject(): XObject;
|
|
36
36
|
getObject(): any;
|
|
37
37
|
isAddRow(): any;
|
|
38
|
-
onFieldChange(field: string, value: any, error?: string | undefined, onChange?:
|
|
39
|
-
onTableFieldChange(rowData: any, field: string, value: any, error?: string | undefined, onChange?:
|
|
38
|
+
onFieldChange(field: string, value: any, error?: string | undefined, onChange?: XFieldOnChange, assocObjectChange?: OperationType): void;
|
|
39
|
+
onTableFieldChange(rowData: any, field: string, value: any, error?: string | undefined, onChange?: XTableFieldOnChange, assocObjectChange?: OperationType): void;
|
|
40
40
|
/**
|
|
41
41
|
* @deprecated - mal by sa pouzivat onTableFieldChange
|
|
42
42
|
*/
|
|
43
|
-
onObjectDataChange(row?: any, onChange?:
|
|
43
|
+
onObjectDataChange(row?: any, onChange?: XTableFieldOnChange): void;
|
|
44
44
|
setStateXForm(): void;
|
|
45
45
|
onTableAddRow(assocField: string, newRow: any, dataKey?: string, selectedRow?: {}): void;
|
|
46
46
|
static getNextRowId(rowList: any[], dataKey: string): number;
|
|
@@ -4,7 +4,7 @@ import { XError } from "./XErrors";
|
|
|
4
4
|
import { OperationType } from "./XUtils";
|
|
5
5
|
import { XFieldChangeEvent } from "./XFieldChangeEvent";
|
|
6
6
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
7
|
-
export type
|
|
7
|
+
export type XFieldOnChange = (e: XFieldChangeEvent<any>) => void;
|
|
8
8
|
export type XReadOnlyProp = boolean | ((object: any) => boolean);
|
|
9
9
|
export type XFilterProp = XCustomFilter | ((object: any) => XCustomFilter | undefined);
|
|
10
10
|
export interface XFormComponentProps<T> {
|
|
@@ -13,13 +13,13 @@ export interface XFormComponentProps<T> {
|
|
|
13
13
|
readOnly?: XReadOnlyProp;
|
|
14
14
|
labelStyle?: React.CSSProperties;
|
|
15
15
|
inline?: boolean;
|
|
16
|
-
onChange?:
|
|
16
|
+
onChange?: XFieldOnChange;
|
|
17
17
|
}
|
|
18
18
|
export declare abstract class XFormComponent<T, P extends XFormComponentProps<T>> extends Component<P> {
|
|
19
19
|
protected constructor(props: P);
|
|
20
20
|
abstract getField(): string;
|
|
21
21
|
getValueFromObject(): any;
|
|
22
|
-
onValueChangeBase(value: any, onChange?:
|
|
22
|
+
onValueChangeBase(value: any, onChange?: XFieldOnChange, assocObjectChange?: OperationType): void;
|
|
23
23
|
abstract isNotNull(): boolean;
|
|
24
24
|
isReadOnly(): boolean;
|
|
25
25
|
getLabel(): string;
|
|
@@ -3,19 +3,19 @@ import { Component } from "react";
|
|
|
3
3
|
import { OperationType } from "./XUtils";
|
|
4
4
|
import { XError } from "./XErrors";
|
|
5
5
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
6
|
-
import { XTableFieldFilterProp,
|
|
6
|
+
import { XTableFieldFilterProp, XTableFieldOnChange, XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
7
7
|
export interface XFormComponentDTProps {
|
|
8
8
|
form: XFormBase;
|
|
9
9
|
entity: string;
|
|
10
10
|
rowData: any;
|
|
11
|
-
readOnly?:
|
|
12
|
-
onChange?:
|
|
11
|
+
readOnly?: XTableFieldReadOnlyProp;
|
|
12
|
+
onChange?: XTableFieldOnChange;
|
|
13
13
|
}
|
|
14
14
|
export declare abstract class XFormComponentDT<P extends XFormComponentDTProps> extends Component<P> {
|
|
15
15
|
protected constructor(props: P);
|
|
16
16
|
abstract getField(): string;
|
|
17
17
|
getValueFromRowData(): any;
|
|
18
|
-
onValueChangeBase(value: any, onChange?:
|
|
18
|
+
onValueChangeBase(value: any, onChange?: XTableFieldOnChange, assocObjectChange?: OperationType): void;
|
|
19
19
|
abstract isNotNull(): boolean;
|
|
20
20
|
isReadOnly(): boolean;
|
|
21
21
|
validate(): {
|
|
@@ -60,17 +60,16 @@ var XFormComponentDT = /** @class */ (function (_super) {
|
|
|
60
60
|
else if (typeof this.props.readOnly === 'boolean') {
|
|
61
61
|
readOnly = this.props.readOnly;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// }
|
|
63
|
+
else if (typeof this.props.readOnly === 'function') {
|
|
64
|
+
// TODO - tazko povedat ci niekedy bude object === null (asi ano vid metodu getFilterBase)
|
|
65
|
+
var object = this.props.form.state.object;
|
|
66
|
+
if (object) {
|
|
67
|
+
readOnly = this.props.readOnly(this.props.form.getXObject(), this.props.rowData);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
readOnly = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
74
73
|
else {
|
|
75
74
|
// readOnly is undefined
|
|
76
75
|
readOnly = false;
|
|
@@ -67,6 +67,7 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
67
67
|
constructor(props: XFormDataTableProps);
|
|
68
68
|
getPathForColumn(columnProps: XFormColumnProps): string;
|
|
69
69
|
static getHeader(columnProps: XFormColumnProps, xEntity: XEntity, field: string, xField: XField): string;
|
|
70
|
+
static isReadOnlyHeader(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined): boolean;
|
|
70
71
|
getEntity(): string;
|
|
71
72
|
createInitFilters(): DataTableFilterMeta;
|
|
72
73
|
getFilterMatchMode(xField: XField): FilterMatchMode;
|
|
@@ -85,16 +86,17 @@ export declare class XFormDataTable2 extends Component<XFormDataTableProps> {
|
|
|
85
86
|
isReadOnly(): boolean;
|
|
86
87
|
render(): JSX.Element;
|
|
87
88
|
}
|
|
88
|
-
export type
|
|
89
|
+
export type XTableFieldOnChange = (e: XTableFieldChangeEvent<any, any>) => void;
|
|
90
|
+
export type XTableFieldReadOnlyProp = boolean | ((object: any, tableRow: any) => boolean);
|
|
89
91
|
export type XTableFieldFilterProp = XCustomFilter | ((object: any, rowData: any) => XCustomFilter | undefined);
|
|
90
92
|
export interface XFormColumnProps {
|
|
91
93
|
type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton";
|
|
92
94
|
header?: any;
|
|
93
|
-
readOnly?:
|
|
95
|
+
readOnly?: XTableFieldReadOnlyProp;
|
|
94
96
|
dropdownInFilter?: boolean;
|
|
95
97
|
showFilterMenu?: boolean;
|
|
96
98
|
width?: string;
|
|
97
|
-
onChange?:
|
|
99
|
+
onChange?: XTableFieldOnChange;
|
|
98
100
|
}
|
|
99
101
|
export interface XFormInputSimpleColumnProps extends XFormColumnProps {
|
|
100
102
|
field: string;
|
|
@@ -79,6 +79,7 @@ var tristatecheckbox_1 = require("primereact/tristatecheckbox");
|
|
|
79
79
|
var api_1 = require("primereact/api");
|
|
80
80
|
var XAutoCompleteDT_1 = require("./XAutoCompleteDT");
|
|
81
81
|
var XButtonIconNarrow_1 = require("./XButtonIconNarrow");
|
|
82
|
+
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
82
83
|
var XLocale_1 = require("./XLocale");
|
|
83
84
|
var XInputIntervalDT_1 = require("./XInputIntervalDT");
|
|
84
85
|
var XFormDataTable2 = /** @class */ (function (_super) {
|
|
@@ -151,7 +152,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
154
|
XFormDataTable2.getHeader = function (columnProps, xEntity, field, xField) {
|
|
154
|
-
var _a
|
|
155
|
+
var _a;
|
|
155
156
|
// poznamky - parametre field a xField by sme mohli vyratavat na zaklade columnProps ale kedze ich uz mame, setrime performance a neduplikujeme vypocet
|
|
156
157
|
// nie je to tu uplne idealne nakodene, ale je to pomerne prehladne
|
|
157
158
|
var isNullable = true;
|
|
@@ -159,35 +160,58 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
159
160
|
if (columnProps.type === "inputSimple") {
|
|
160
161
|
var columnPropsInputSimple = columnProps;
|
|
161
162
|
isNullable = xField.isNullable;
|
|
162
|
-
readOnly =
|
|
163
|
+
readOnly = XFormDataTable2.isReadOnlyHeader(columnPropsInputSimple.field, columnProps.readOnly);
|
|
163
164
|
}
|
|
164
165
|
else if (columnProps.type === "dropdown") {
|
|
165
166
|
var columnPropsDropdown = columnProps;
|
|
166
167
|
var xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(xEntity, columnPropsDropdown.assocField);
|
|
167
168
|
isNullable = xAssoc.isNullable;
|
|
168
|
-
readOnly = (
|
|
169
|
+
readOnly = XFormDataTable2.isReadOnlyHeader(undefined, columnProps.readOnly);
|
|
169
170
|
}
|
|
170
171
|
else if (columnProps.type === "autoComplete") {
|
|
171
172
|
var columnPropsAutoComplete = columnProps;
|
|
172
173
|
var xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(xEntity, columnPropsAutoComplete.assocField);
|
|
173
174
|
isNullable = xAssoc.isNullable;
|
|
174
|
-
readOnly = (
|
|
175
|
+
readOnly = XFormDataTable2.isReadOnlyHeader(undefined, columnProps.readOnly);
|
|
175
176
|
}
|
|
176
177
|
else if (columnProps.type === "searchButton") {
|
|
177
178
|
var columnPropsSearchButton = columnProps;
|
|
178
179
|
var xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(xEntity, columnPropsSearchButton.assocField);
|
|
179
180
|
isNullable = xAssoc.isNullable;
|
|
180
|
-
readOnly = (
|
|
181
|
+
readOnly = XFormDataTable2.isReadOnlyHeader(undefined, columnProps.readOnly);
|
|
181
182
|
}
|
|
182
183
|
else {
|
|
183
184
|
throw "Unknown prop type = " + columnProps.type;
|
|
184
185
|
}
|
|
185
|
-
var header = (
|
|
186
|
+
var header = (_a = columnProps.header) !== null && _a !== void 0 ? _a : field;
|
|
186
187
|
if (!isNullable && !readOnly) {
|
|
187
188
|
header = XUtils_1.XUtils.markNotNull(header);
|
|
188
189
|
}
|
|
189
190
|
return header;
|
|
190
191
|
};
|
|
192
|
+
// helper
|
|
193
|
+
XFormDataTable2.isReadOnlyHeader = function (path, readOnly) {
|
|
194
|
+
var isReadOnly;
|
|
195
|
+
if (path && !XUtilsCommon_1.XUtilsCommon.isSingleField(path)) {
|
|
196
|
+
// if the length of field is 2 or more, then readOnly
|
|
197
|
+
isReadOnly = true;
|
|
198
|
+
}
|
|
199
|
+
// formReadOnlyBase is called on the level XFormDataTable2
|
|
200
|
+
// else if (this.props.form.formReadOnlyBase("xxx")) {
|
|
201
|
+
// isReadOnly = true;
|
|
202
|
+
// }
|
|
203
|
+
else if (typeof readOnly === 'boolean') {
|
|
204
|
+
isReadOnly = readOnly;
|
|
205
|
+
}
|
|
206
|
+
else if (typeof readOnly === 'function') {
|
|
207
|
+
isReadOnly = false;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// readOnly is undefined
|
|
211
|
+
isReadOnly = false;
|
|
212
|
+
}
|
|
213
|
+
return isReadOnly;
|
|
214
|
+
};
|
|
191
215
|
XFormDataTable2.prototype.getEntity = function () {
|
|
192
216
|
if (this.entity === undefined) {
|
|
193
217
|
throw "Unexpected error: this.entity is undefined";
|
|
@@ -324,12 +348,11 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
324
348
|
*/
|
|
325
349
|
// body={(rowData: any) => bodyTemplate(childColumn.props.field, rowData)}
|
|
326
350
|
XFormDataTable2.prototype.bodyTemplate = function (columnProps, tableReadOnly, rowData, xEntity) {
|
|
327
|
-
var _a, _b;
|
|
328
351
|
var body;
|
|
352
|
+
// tableReadOnly has higher prio then property readOnly
|
|
353
|
+
var readOnly = tableReadOnly ? true : columnProps.readOnly;
|
|
329
354
|
if (columnProps.type === "inputSimple") {
|
|
330
355
|
var columnPropsInputSimple = columnProps;
|
|
331
|
-
// tableReadOnly has higher prio then property readOnly
|
|
332
|
-
var readOnly = tableReadOnly || ((_a = columnPropsInputSimple.readOnly) !== null && _a !== void 0 ? _a : false);
|
|
333
356
|
var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntity, columnPropsInputSimple.field);
|
|
334
357
|
if (xField.type === "decimal" || xField.type === "number") {
|
|
335
358
|
body = react_1.default.createElement(XInputDecimalDT_1.XInputDecimalDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly, onChange: columnPropsInputSimple.onChange });
|
|
@@ -350,12 +373,10 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
350
373
|
}
|
|
351
374
|
else if (columnProps.type === "dropdown") {
|
|
352
375
|
var columnPropsDropdown = columnProps;
|
|
353
|
-
body = react_1.default.createElement(XDropdownDT_1.XDropdownDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsDropdown.assocField, displayField: columnPropsDropdown.displayField, sortField: columnPropsDropdown.sortField, filter: columnPropsDropdown.filter, dropdownOptionsMap: this.state.dropdownOptionsMap, onDropdownOptionsMapChange: this.onDropdownOptionsMapChange, rowData: rowData });
|
|
376
|
+
body = react_1.default.createElement(XDropdownDT_1.XDropdownDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsDropdown.assocField, displayField: columnPropsDropdown.displayField, sortField: columnPropsDropdown.sortField, filter: columnPropsDropdown.filter, dropdownOptionsMap: this.state.dropdownOptionsMap, onDropdownOptionsMapChange: this.onDropdownOptionsMapChange, rowData: rowData, readOnly: readOnly });
|
|
354
377
|
}
|
|
355
378
|
else if (columnProps.type === "autoComplete") {
|
|
356
379
|
var columnPropsAutoComplete = columnProps;
|
|
357
|
-
// tableReadOnly has higher prio then property readOnly
|
|
358
|
-
var readOnly = tableReadOnly || ((_b = columnPropsAutoComplete.readOnly) !== null && _b !== void 0 ? _b : false);
|
|
359
380
|
body = react_1.default.createElement(XAutoCompleteDT_1.XAutoCompleteDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsAutoComplete.assocField, displayField: columnPropsAutoComplete.displayField, searchBrowse: columnPropsAutoComplete.searchBrowse, assocForm: columnPropsAutoComplete.assocForm, filter: columnPropsAutoComplete.filter, suggestions: columnPropsAutoComplete.suggestions, rowData: rowData, readOnly: readOnly });
|
|
360
381
|
}
|
|
361
382
|
else if (columnProps.type === "searchButton") {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface XFtsInputValue {
|
|
3
|
+
value: string | null;
|
|
4
|
+
matchMode: 'startsWith' | 'contains' | 'endsWith' | 'equals';
|
|
5
|
+
}
|
|
6
|
+
export declare const XFtsInput: (props: {
|
|
7
|
+
value: XFtsInputValue;
|
|
8
|
+
onChange: (value: XFtsInputValue) => void;
|
|
9
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.XFtsInput = void 0;
|
|
18
|
+
var inputtext_1 = require("primereact/inputtext");
|
|
19
|
+
var react_1 = __importDefault(require("react"));
|
|
20
|
+
var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
21
|
+
var XFtsInput = function (props) {
|
|
22
|
+
var onChange = function (e) {
|
|
23
|
+
var value = (0, XUtilsConversions_1.stringFromUI)(e.target.value);
|
|
24
|
+
props.value.value = value;
|
|
25
|
+
props.onChange(__assign({}, props.value)); // vyklonujeme aby react zaregistroval, ze sme urobili zmenu
|
|
26
|
+
};
|
|
27
|
+
// TODO - pridat input na zmenu matchMode
|
|
28
|
+
return (react_1.default.createElement(inputtext_1.InputText, { value: (0, XUtilsConversions_1.stringAsUI)(props.value.value), onChange: onChange, style: { height: '2.5rem', width: '17rem' }, className: "m-1" }));
|
|
29
|
+
};
|
|
30
|
+
exports.XFtsInput = XFtsInput;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XFormBase } from "./XFormBase";
|
|
3
3
|
import { XField } from "../serverApi/XEntityMetadata";
|
|
4
|
+
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
4
5
|
export declare const XInputDateDT: (props: {
|
|
5
6
|
form: XFormBase;
|
|
6
7
|
xField: XField;
|
|
7
8
|
field: string;
|
|
8
9
|
rowData: any;
|
|
9
|
-
readOnly?:
|
|
10
|
+
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
10
11
|
}) => JSX.Element;
|
|
@@ -8,18 +8,10 @@ var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
|
8
8
|
var calendar_1 = require("primereact/calendar");
|
|
9
9
|
var react_1 = __importDefault(require("react"));
|
|
10
10
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
11
|
+
var XUtils_1 = require("./XUtils");
|
|
11
12
|
var XInputDateDT = function (props) {
|
|
12
13
|
var showTime = (props.xField.type === 'datetime');
|
|
13
14
|
var cssClassName = showTime ? 'x-input-datetime' : 'x-input-date';
|
|
14
|
-
// ak mame path, field je vzdy readOnly
|
|
15
|
-
var readOnly;
|
|
16
|
-
var posDot = props.field.indexOf(".");
|
|
17
|
-
if (posDot !== -1) {
|
|
18
|
-
readOnly = true;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
readOnly = props.readOnly !== undefined ? props.readOnly : false;
|
|
22
|
-
}
|
|
23
15
|
var onValueChange = function (field, rowData, newValue) {
|
|
24
16
|
// z Calendar prichadza e.value - typ Date alebo null
|
|
25
17
|
// zmenime hodnotu v modeli (odtial sa hodnota cita)
|
|
@@ -47,6 +39,7 @@ var XInputDateDT = function (props) {
|
|
|
47
39
|
}
|
|
48
40
|
// fieldValue zostalo undefined (konvertujeme null -> undefined) - Calendar pozaduje undefined, nechce null
|
|
49
41
|
}
|
|
42
|
+
var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
|
|
50
43
|
// TODO - nefunguje dobre pridavanie noveho riadku - su tam stare neupdatnute hodnoty - este to asi neopravili https://github.com/primefaces/primereact/issues/1277
|
|
51
44
|
// test mame na TestovaciForm
|
|
52
45
|
// appendTo={document.body} appenduje overlay panel na element body - eliminuje problem s overflow (pozri poznamku v XDropdownDTFilter)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XFormBase } from "./XFormBase";
|
|
3
|
+
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
3
4
|
export declare const XInputTextDT: (props: {
|
|
4
5
|
form: XFormBase;
|
|
5
6
|
entity: string;
|
|
6
7
|
field: string;
|
|
7
8
|
rowData: any;
|
|
8
|
-
readOnly?:
|
|
9
|
+
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
9
10
|
}) => JSX.Element;
|
|
@@ -9,17 +9,9 @@ var inputtext_1 = require("primereact/inputtext");
|
|
|
9
9
|
var XUtilsConversions_1 = require("./XUtilsConversions");
|
|
10
10
|
var XUtilsMetadata_1 = require("./XUtilsMetadata");
|
|
11
11
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
12
|
+
var XUtils_1 = require("./XUtils");
|
|
12
13
|
var XInputTextDT = function (props) {
|
|
13
14
|
var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPathStr(props.entity, props.field);
|
|
14
|
-
// ak mame path, field je vzdy readOnly
|
|
15
|
-
var readOnly;
|
|
16
|
-
var posDot = props.field.indexOf(".");
|
|
17
|
-
if (posDot !== -1) {
|
|
18
|
-
readOnly = true;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
readOnly = props.readOnly !== undefined ? props.readOnly : false;
|
|
22
|
-
}
|
|
23
15
|
var onValueChange = function (field, rowData, newValue) {
|
|
24
16
|
// zmenime hodnotu v modeli (odtial sa hodnota cita)
|
|
25
17
|
rowData[field] = (0, XUtilsConversions_1.stringFromUI)(newValue);
|
|
@@ -37,6 +29,7 @@ var XInputTextDT = function (props) {
|
|
|
37
29
|
// konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli (a tiez aby korektne pridal novy riadok)
|
|
38
30
|
fieldValue = (0, XUtilsConversions_1.stringAsUI)(rowDataValue);
|
|
39
31
|
}
|
|
32
|
+
var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
|
|
40
33
|
return (react_1.default.createElement(inputtext_1.InputText, { id: props.field, value: fieldValue, onChange: function (e) { return onValueChange(props.field, props.rowData, e.target.value); }, readOnly: readOnly, maxLength: xField.length, className: "x-input-to-resize" }));
|
|
41
34
|
};
|
|
42
35
|
exports.XInputTextDT = XInputTextDT;
|
|
@@ -42,6 +42,7 @@ export interface XLazyDataTableProps {
|
|
|
42
42
|
filters?: DataTableFilterMeta;
|
|
43
43
|
customFilter?: XCustomFilter;
|
|
44
44
|
sortField?: string;
|
|
45
|
+
fullTextSearch: boolean | string[];
|
|
45
46
|
searchBrowseParams?: XSearchBrowseParams;
|
|
46
47
|
width?: string;
|
|
47
48
|
dataLoadedState?: [boolean, React.Dispatch<React.SetStateAction<boolean>>];
|
|
@@ -56,6 +57,7 @@ export declare const XLazyDataTable: {
|
|
|
56
57
|
paginator: boolean;
|
|
57
58
|
rows: number;
|
|
58
59
|
filterDisplay: string;
|
|
60
|
+
fullTextSearch: boolean;
|
|
59
61
|
scrollable: boolean;
|
|
60
62
|
scrollWidth: string;
|
|
61
63
|
scrollHeight: string;
|
|
@@ -115,6 +115,7 @@ var api_1 = require("primereact/api");
|
|
|
115
115
|
var XCalendar_1 = require("./XCalendar");
|
|
116
116
|
var XInputDecimalBase_1 = require("./XInputDecimalBase");
|
|
117
117
|
var XLocale_1 = require("./XLocale");
|
|
118
|
+
var XFtsInput_1 = require("./XFtsInput");
|
|
118
119
|
var XLazyDataTable = function (props) {
|
|
119
120
|
var _a;
|
|
120
121
|
// must be here, is used in createInitFilters()
|
|
@@ -196,6 +197,9 @@ var XLazyDataTable = function (props) {
|
|
|
196
197
|
}
|
|
197
198
|
return filterItem;
|
|
198
199
|
};
|
|
200
|
+
var createInitFtsInputValue = function () {
|
|
201
|
+
return { value: null, matchMode: "contains" };
|
|
202
|
+
};
|
|
199
203
|
// premenne platne pre cely component (obdoba member premennych v class-e)
|
|
200
204
|
var dataTableEl = (0, react_1.useRef)(null);
|
|
201
205
|
var customFilterItems = XUtils_1.XUtils.createCustomFilterItems(props.customFilter);
|
|
@@ -219,12 +223,15 @@ var XLazyDataTable = function (props) {
|
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
225
|
var _f = __read((0, react_1.useState)(filtersInit), 2), filters = _f[0], setFilters = _f[1]; // filtrovanie na "controlled manner" (moze sa sem nainicializovat nejaka hodnota)
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
226
|
+
var initFtsInputValue = props.fullTextSearch ? createInitFtsInputValue() : undefined;
|
|
227
|
+
var _g = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValue = _g[0], setFtsInputValue = _g[1];
|
|
228
|
+
var _h = __read((0, react_1.useState)(props.sortField ? [{ field: props.sortField, order: 1 }] : []), 2), multiSortMeta = _h[0], setMultiSortMeta = _h[1];
|
|
229
|
+
var _j = __read((0, react_1.useState)(null), 2), selectedRow = _j[0], setSelectedRow = _j[1];
|
|
230
|
+
var _k = __read((_a = props.dataLoadedState) !== null && _a !== void 0 ? _a : (0, react_1.useState)(false), 2), dataLoaded = _k[0], setDataLoaded = _k[1]; // priznak kde si zapiseme, ci uz sme nacitali data
|
|
231
|
+
var _l = __read((0, react_1.useState)(false), 2), exportRowsDialogOpened = _l[0], setExportRowsDialogOpened = _l[1];
|
|
232
|
+
var _m = __read((0, react_1.useState)(), 2), exportRowsDialogRowCount = _m[0], setExportRowsDialogRowCount = _m[1]; // param pre dialog
|
|
233
|
+
var _o = __read((0, react_1.useState)(filtersInit), 2), filtersAfterFiltering = _o[0], setFiltersAfterFiltering = _o[1]; // sem si odkladame stav filtra po kliknuti na button Filter (chceme exportovat presne to co vidno vyfiltrovane)
|
|
234
|
+
var _p = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValueAfterFiltering = _p[0], setFtsInputValueAfterFiltering = _p[1]; // tak isto ako filtersAfterFiltering
|
|
228
235
|
// parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
|
|
229
236
|
(0, react_1.useEffect)(function () {
|
|
230
237
|
// jednoduchy sposob - nepouzivame parameter props.displayed a priznak dataLoaded
|
|
@@ -257,7 +264,7 @@ var XLazyDataTable = function (props) {
|
|
|
257
264
|
return __generator(this, function (_a) {
|
|
258
265
|
//console.log("zavolany onPage");
|
|
259
266
|
setFirst(event.first);
|
|
260
|
-
loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: event.first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
|
|
267
|
+
loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: event.first, rows: rows, filters: filters, fullTextSearch: createXFullTextSearch(ftsInputValue), customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
|
|
261
268
|
return [2 /*return*/];
|
|
262
269
|
});
|
|
263
270
|
}); };
|
|
@@ -271,7 +278,7 @@ var XLazyDataTable = function (props) {
|
|
|
271
278
|
//console.log("zavolany onSort - this.state.multiSortMeta = " + JSON.stringify(multiSortMeta));
|
|
272
279
|
//console.log("zavolany onSort - event.multiSortMeta = " + JSON.stringify(event.multiSortMeta));
|
|
273
280
|
setMultiSortMeta(event.multiSortMeta);
|
|
274
|
-
loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: event.multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
|
|
281
|
+
loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, fullTextSearch: createXFullTextSearch(ftsInputValue), customFilterItems: customFilterItems, multiSortMeta: event.multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
|
|
275
282
|
};
|
|
276
283
|
var onClickFilter = function () {
|
|
277
284
|
//console.log("zavolany onClickFilter");
|
|
@@ -281,9 +288,12 @@ var XLazyDataTable = function (props) {
|
|
|
281
288
|
// najjednoduchsi sposob - pomeni aj pripadne nastavene matchMode hodnoty
|
|
282
289
|
var filtersInit = createInitFilters();
|
|
283
290
|
setFilters(filtersInit);
|
|
291
|
+
if (ftsInputValue) {
|
|
292
|
+
setFtsInputValue(createInitFtsInputValue());
|
|
293
|
+
}
|
|
284
294
|
};
|
|
285
295
|
var loadData = function () {
|
|
286
|
-
loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
|
|
296
|
+
loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, fullTextSearch: createXFullTextSearch(ftsInputValue), customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems });
|
|
287
297
|
};
|
|
288
298
|
var loadDataBase = function (findParam) { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
299
|
var findResult;
|
|
@@ -299,6 +309,7 @@ var XLazyDataTable = function (props) {
|
|
|
299
309
|
setLoading(false);
|
|
300
310
|
// odlozime si filter hodnoty pre pripadny export - deep cloning vyzera ze netreba
|
|
301
311
|
setFiltersAfterFiltering(filters);
|
|
312
|
+
setFtsInputValueAfterFiltering(ftsInputValue ? __assign({}, ftsInputValue) : undefined);
|
|
302
313
|
return [2 /*return*/];
|
|
303
314
|
}
|
|
304
315
|
});
|
|
@@ -315,6 +326,17 @@ var XLazyDataTable = function (props) {
|
|
|
315
326
|
}
|
|
316
327
|
});
|
|
317
328
|
}); };
|
|
329
|
+
var createXFullTextSearch = function (ftsInputValue) {
|
|
330
|
+
var xFullTextSearch = undefined; // default
|
|
331
|
+
if (ftsInputValue && ftsInputValue.value !== null) {
|
|
332
|
+
xFullTextSearch = {
|
|
333
|
+
fields: Array.isArray(props.fullTextSearch) ? props.fullTextSearch : undefined,
|
|
334
|
+
value: ftsInputValue.value,
|
|
335
|
+
matchMode: ftsInputValue.matchMode
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
return xFullTextSearch;
|
|
339
|
+
};
|
|
318
340
|
var getFields = function () {
|
|
319
341
|
// krasne zobrazi cely objekt!
|
|
320
342
|
//console.log(dataTableEl.current);
|
|
@@ -451,7 +473,7 @@ var XLazyDataTable = function (props) {
|
|
|
451
473
|
return __generator(this, function (_a) {
|
|
452
474
|
switch (_a.label) {
|
|
453
475
|
case 0:
|
|
454
|
-
findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems };
|
|
476
|
+
findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, fullTextSearch: createXFullTextSearch(ftsInputValueAfterFiltering), customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields(), aggregateItems: aggregateItems };
|
|
455
477
|
return [4 /*yield*/, findByFilter(findParam)];
|
|
456
478
|
case 1:
|
|
457
479
|
findResult = _a.sent();
|
|
@@ -463,7 +485,7 @@ var XLazyDataTable = function (props) {
|
|
|
463
485
|
});
|
|
464
486
|
}); };
|
|
465
487
|
var createExportParams = function () {
|
|
466
|
-
var queryParam = { filters: filtersAfterFiltering, customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
|
|
488
|
+
var queryParam = { filters: filtersAfterFiltering, fullTextSearch: createXFullTextSearch(ftsInputValueAfterFiltering), customFilterItems: customFilterItems, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
|
|
467
489
|
return {
|
|
468
490
|
path: "x-lazy-data-table-export",
|
|
469
491
|
queryParam: queryParam,
|
|
@@ -868,8 +890,10 @@ var XLazyDataTable = function (props) {
|
|
|
868
890
|
}
|
|
869
891
|
return react_1.default.createElement(column_1.Column, { field: childColumn.props.field, header: header, footer: footer, filter: true, sortable: true, filterElement: filterElement, dataType: dataType, showFilterMenu: showFilterMenu, showClearButton: showClearButton, body: body, headerStyle: headerStyle, align: align });
|
|
870
892
|
});
|
|
893
|
+
// align-items-center centruje vertikalne (posuva smerom doulu do stredu)
|
|
871
894
|
return (react_1.default.createElement("div", null,
|
|
872
|
-
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
895
|
+
react_1.default.createElement("div", { className: "flex justify-content-center align-items-center" },
|
|
896
|
+
ftsInputValue ? react_1.default.createElement(XFtsInput_1.XFtsInput, { value: ftsInputValue, onChange: function (value) { return setFtsInputValue(value); } }) : null,
|
|
873
897
|
react_1.default.createElement(XButton_1.XButton, { key: "filter", label: (0, XLocale_1.xLocaleOption)('filter'), onClick: onClickFilter }),
|
|
874
898
|
react_1.default.createElement(XButton_1.XButton, { key: "clearFilter", label: (0, XLocale_1.xLocaleOption)('clearFilter'), onClick: onClickClearFilter })),
|
|
875
899
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
@@ -888,6 +912,7 @@ exports.XLazyDataTable.defaultProps = {
|
|
|
888
912
|
paginator: true,
|
|
889
913
|
rows: 10,
|
|
890
914
|
filterDisplay: "row",
|
|
915
|
+
fullTextSearch: true,
|
|
891
916
|
scrollable: true,
|
|
892
917
|
scrollWidth: 'viewport',
|
|
893
918
|
scrollHeight: 'viewport',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XFormBase } from "./XFormBase";
|
|
3
|
+
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
3
4
|
export declare const XSearchButtonDT: (props: {
|
|
4
5
|
form: XFormBase;
|
|
5
6
|
entity: string;
|
|
@@ -8,5 +9,5 @@ export declare const XSearchButtonDT: (props: {
|
|
|
8
9
|
searchBrowse: JSX.Element;
|
|
9
10
|
assocForm?: JSX.Element | undefined;
|
|
10
11
|
rowData: any;
|
|
11
|
-
readOnly?:
|
|
12
|
+
readOnly?: XTableFieldReadOnlyProp | undefined;
|
|
12
13
|
}) => JSX.Element;
|
|
@@ -102,7 +102,6 @@ var XSearchButtonDT = function (props) {
|
|
|
102
102
|
}
|
|
103
103
|
return inputValue;
|
|
104
104
|
};
|
|
105
|
-
var readOnly = props.readOnly !== undefined ? props.readOnly : false;
|
|
106
105
|
var onInputValueChange = function (e) {
|
|
107
106
|
setInputChanged(true);
|
|
108
107
|
setInputValueState(e.target.value);
|
|
@@ -177,6 +176,7 @@ var XSearchButtonDT = function (props) {
|
|
|
177
176
|
};
|
|
178
177
|
// vypocitame inputValue
|
|
179
178
|
var inputValue = computeInputValue();
|
|
179
|
+
var readOnly = XUtils_1.XUtils.isReadOnlyTableField(undefined, props.readOnly, props.form.state.object, props.rowData);
|
|
180
180
|
return (react_1.default.createElement("div", null,
|
|
181
181
|
react_1.default.createElement("div", { className: "x-search-button-base" },
|
|
182
182
|
react_1.default.createElement(inputtext_1.InputText, { id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: readOnly, ref: inputTextRef }),
|
|
@@ -4,6 +4,9 @@ import React from "react";
|
|
|
4
4
|
import { XEnvVar } from "./XEnvVars";
|
|
5
5
|
import { XError, XErrorMap } from "./XErrors";
|
|
6
6
|
import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
|
|
7
|
+
import { DataTableSortMeta } from "primereact/datatable";
|
|
8
|
+
import { XObject } from "./XObject";
|
|
9
|
+
import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
|
|
7
10
|
export declare enum OperationType {
|
|
8
11
|
None = 0,
|
|
9
12
|
Insert = 1,
|
|
@@ -44,7 +47,7 @@ export declare class XUtils {
|
|
|
44
47
|
static registerAppForm(elem: any, entity: string, formId?: string): void;
|
|
45
48
|
static getAppForm(entity: string, formId?: string): any;
|
|
46
49
|
static fetchMany(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any[]>;
|
|
47
|
-
static fetchRows(entity: string, customFilter?: XCustomFilter | undefined, sortField?: string, fields?: string[]): Promise<any[]>;
|
|
50
|
+
static fetchRows(entity: string, customFilter?: XCustomFilter | undefined, sortField?: string | DataTableSortMeta[] | undefined, fields?: string[]): Promise<any[]>;
|
|
48
51
|
static fetchOne(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
|
|
49
52
|
static fetchString(path: string, value: any): Promise<string>;
|
|
50
53
|
static fetch(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
|
|
@@ -86,6 +89,7 @@ export declare class XUtils {
|
|
|
86
89
|
*/
|
|
87
90
|
static arrayIntersect<T>(array1: T[], array2: T[], idField: string): T[];
|
|
88
91
|
static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
|
|
92
|
+
static isReadOnlyTableField(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined, object: XObject | null, tableRow: any): boolean;
|
|
89
93
|
static markNotNull(label: string): string;
|
|
90
94
|
static showErrorMessage(message: string, e: unknown): void;
|
|
91
95
|
static createErrorProps(error: string | undefined): {};
|
|
@@ -99,4 +103,5 @@ export declare class XUtils {
|
|
|
99
103
|
static normalizeString(value: string): string;
|
|
100
104
|
static createCustomFilterItems(customFilter: XCustomFilter | undefined): XCustomFilterItem[] | undefined;
|
|
101
105
|
static filterAnd(...filters: (XCustomFilter | undefined)[]): XCustomFilterItem[] | undefined;
|
|
106
|
+
static isTableRowInserted(tableRow: any): boolean;
|
|
102
107
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -265,11 +265,20 @@ var XUtils = /** @class */ (function () {
|
|
|
265
265
|
// pomocna metodka pouzivajuca lazyDataTable service
|
|
266
266
|
XUtils.fetchRows = function (entity, customFilter, sortField, fields) {
|
|
267
267
|
return __awaiter(this, void 0, void 0, function () {
|
|
268
|
-
var findParam, rowList;
|
|
268
|
+
var multiSortMeta, findParam, rowList;
|
|
269
269
|
return __generator(this, function (_a) {
|
|
270
270
|
switch (_a.label) {
|
|
271
271
|
case 0:
|
|
272
|
-
|
|
272
|
+
multiSortMeta = undefined;
|
|
273
|
+
if (sortField) {
|
|
274
|
+
if (Array.isArray(sortField)) {
|
|
275
|
+
multiSortMeta = sortField;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
multiSortMeta = [{ field: sortField, order: 1 }];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
findParam = { resultType: FindParam_1.ResultType.AllRows, entity: entity, customFilterItems: XUtils.createCustomFilterItems(customFilter), multiSortMeta: multiSortMeta, fields: fields };
|
|
273
282
|
return [4 /*yield*/, XUtils.fetchOne('lazyDataTableFindRows', findParam)];
|
|
274
283
|
case 1:
|
|
275
284
|
rowList = (_a.sent()).rowList;
|
|
@@ -546,6 +555,35 @@ var XUtils = /** @class */ (function () {
|
|
|
546
555
|
}
|
|
547
556
|
return readOnly;
|
|
548
557
|
};
|
|
558
|
+
// docasna funkcia, kym sa vsade nebude pouzivat XFormComponentDT a jej isReadOnly()
|
|
559
|
+
XUtils.isReadOnlyTableField = function (path, readOnly, object, tableRow) {
|
|
560
|
+
var isReadOnly;
|
|
561
|
+
if (path && !XUtilsCommon_1.XUtilsCommon.isSingleField(path)) {
|
|
562
|
+
// if the length of field is 2 or more, then readOnly
|
|
563
|
+
isReadOnly = true;
|
|
564
|
+
}
|
|
565
|
+
// formReadOnlyBase is called on the level XFormDataTable2
|
|
566
|
+
// else if (this.props.form.formReadOnlyBase("xxx")) {
|
|
567
|
+
// isReadOnly = true;
|
|
568
|
+
// }
|
|
569
|
+
else if (typeof readOnly === 'boolean') {
|
|
570
|
+
isReadOnly = readOnly;
|
|
571
|
+
}
|
|
572
|
+
else if (typeof readOnly === 'function') {
|
|
573
|
+
// TODO - tazko povedat ci niekedy bude object === null (asi ano vid metodu getFilterBase)
|
|
574
|
+
if (object) {
|
|
575
|
+
isReadOnly = readOnly(object, tableRow);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
isReadOnly = true;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
// readOnly is undefined
|
|
583
|
+
isReadOnly = false;
|
|
584
|
+
}
|
|
585
|
+
return isReadOnly;
|
|
586
|
+
};
|
|
549
587
|
XUtils.markNotNull = function (label) {
|
|
550
588
|
return label + ' *';
|
|
551
589
|
};
|
|
@@ -685,6 +723,11 @@ var XUtils = /** @class */ (function () {
|
|
|
685
723
|
}
|
|
686
724
|
return customFilterItemsResult;
|
|
687
725
|
};
|
|
726
|
+
// pomocna metodka
|
|
727
|
+
XUtils.isTableRowInserted = function (tableRow) {
|
|
728
|
+
var _a;
|
|
729
|
+
return (_a = tableRow.__x_generatedRowId) !== null && _a !== void 0 ? _a : false; // specialny priznak, ze sme vygenerovali id-cko
|
|
730
|
+
};
|
|
688
731
|
XUtils.dropdownEmptyOptionValue = " ";
|
|
689
732
|
XUtils.xBackendUrl = undefined;
|
|
690
733
|
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataTableFilterMeta, DataTableSortMeta } from "primereact/datatable";
|
|
2
|
-
import { XCustomFilterItem } from "./FindParam";
|
|
2
|
+
import { XCustomFilterItem, XFullTextSearch } from "./FindParam";
|
|
3
3
|
export declare enum ExportType {
|
|
4
4
|
Csv = "csv",
|
|
5
5
|
Json = "json"
|
|
@@ -11,6 +11,7 @@ export interface ExportParam {
|
|
|
11
11
|
}
|
|
12
12
|
export interface LazyDataTableQueryParam {
|
|
13
13
|
filters: DataTableFilterMeta;
|
|
14
|
+
fullTextSearch?: XFullTextSearch;
|
|
14
15
|
customFilterItems?: XCustomFilterItem[];
|
|
15
16
|
multiSortMeta?: DataTableSortMeta[];
|
|
16
17
|
entity: string;
|
|
@@ -12,6 +12,11 @@ export interface XCustomFilterItem {
|
|
|
12
12
|
params: XParams;
|
|
13
13
|
}
|
|
14
14
|
export type XCustomFilter = XCustomFilterItem | XCustomFilterItem[];
|
|
15
|
+
export interface XFullTextSearch {
|
|
16
|
+
fields?: string[];
|
|
17
|
+
value: string;
|
|
18
|
+
matchMode: 'startsWith' | 'contains' | 'endsWith' | 'equals';
|
|
19
|
+
}
|
|
15
20
|
export declare enum XAggregateType {
|
|
16
21
|
Min = "MIN",
|
|
17
22
|
Max = "MAX",
|
|
@@ -27,6 +32,7 @@ export interface FindParam {
|
|
|
27
32
|
first?: number;
|
|
28
33
|
rows?: number;
|
|
29
34
|
filters?: DataTableFilterMeta;
|
|
35
|
+
fullTextSearch?: XFullTextSearch;
|
|
30
36
|
customFilterItems?: XCustomFilterItem[];
|
|
31
37
|
multiSortMeta?: DataTableSortMeta[];
|
|
32
38
|
entity: string;
|