@michalrakus/x-react-web-lib 1.36.0 → 1.37.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/XCheckboxBase.d.ts +3 -0
- package/XCheckboxBase.js +5 -0
- package/gulpfile.js +3 -0
- package/lib/components/XCheckbox.d.ts +1 -3
- package/lib/components/XCheckbox.js +6 -27
- package/lib/components/XCheckboxBase.d.ts +11 -0
- package/lib/components/XCheckboxBase.js +52 -0
- package/lib/components/XCheckboxDT.d.ts +9 -10
- package/lib/components/XCheckboxDT.js +34 -30
- package/lib/components/XFormBase.d.ts +1 -0
- package/lib/components/XFormBase.js +2 -1
- package/lib/components/XFormDataTable2.js +1 -1
- package/lib/components/XFormDialog.js +1 -1
- package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +2 -1
- package/lib/components/XLazyDataTable/XLazyDataTable.js +29 -29
- package/lib/components/XUtils.d.ts +5 -4
- package/lib/components/XUtils.js +32 -10
- package/lib/components/useXStateLocal.d.ts +2 -0
- package/lib/components/useXStateLocal.js +9 -0
- package/lib/components/useXStateSession.js +2 -3
- package/lib/components/useXStateStorage.d.ts +3 -0
- package/lib/components/useXStateStorage.js +10 -0
- package/lib/components/useXStateStorageBase.d.ts +3 -0
- package/lib/components/{useXStateSessionBase.js → useXStateStorageBase.js} +5 -5
- package/lib/serverApi/XUtilsCommon.d.ts +4 -0
- package/lib/serverApi/XUtilsCommon.js +31 -1
- package/package.json +1 -1
- package/useXStateLocal.d.ts +3 -0
- package/useXStateLocal.js +5 -0
- package/useXStateStorage.d.ts +3 -0
- package/useXStateStorage.js +5 -0
- package/lib/components/useXStateSessionBase.d.ts +0 -2
package/XCheckboxBase.js
ADDED
package/gulpfile.js
CHANGED
|
@@ -30,7 +30,9 @@ function generateApi(cb) {
|
|
|
30
30
|
"./lib/components/XLazyDataTable/XLazyDataTable",
|
|
31
31
|
"./lib/components/XLazyDataTable/XMultilineRenderer",
|
|
32
32
|
|
|
33
|
+
"./lib/components/useXStateLocal",
|
|
33
34
|
"./lib/components/useXStateSession",
|
|
35
|
+
"./lib/components/useXStateStorage",
|
|
34
36
|
"./lib/components/useXToken",
|
|
35
37
|
"./lib/components/XAutoComplete",
|
|
36
38
|
"./lib/components/XAutoCompleteBase",
|
|
@@ -41,6 +43,7 @@ function generateApi(cb) {
|
|
|
41
43
|
"./lib/components/XCalendar",
|
|
42
44
|
"./lib/components/XChangePasswordForm",
|
|
43
45
|
"./lib/components/XCheckbox",
|
|
46
|
+
"./lib/components/XCheckboxBase",
|
|
44
47
|
"./lib/components/XDropdown",
|
|
45
48
|
"./lib/components/XDropdownForEntity",
|
|
46
49
|
"./lib/components/XEditBrowse",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { XInput, XInputProps } from "./XInput";
|
|
3
|
-
import { CheckboxChangeEvent } from "primereact/checkbox";
|
|
4
3
|
export interface XCheckboxProps extends XInputProps<boolean> {
|
|
5
4
|
isNotNull?: boolean;
|
|
6
5
|
}
|
|
@@ -8,7 +7,6 @@ export declare class XCheckbox extends XInput<boolean, XCheckboxProps> {
|
|
|
8
7
|
constructor(props: XCheckboxProps);
|
|
9
8
|
isNotNull(): boolean;
|
|
10
9
|
getValue(): boolean | null;
|
|
11
|
-
|
|
12
|
-
triStateCheckboxOnValueChange(e: any): void;
|
|
10
|
+
onValueChange(value: boolean | null): void;
|
|
13
11
|
render(): JSX.Element;
|
|
14
12
|
}
|
|
@@ -20,47 +20,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.XCheckbox = void 0;
|
|
22
22
|
var react_1 = __importDefault(require("react"));
|
|
23
|
-
var tristatecheckbox_1 = require("primereact/tristatecheckbox");
|
|
24
23
|
var XInput_1 = require("./XInput");
|
|
25
|
-
var
|
|
24
|
+
var XCheckboxBase_1 = require("./XCheckboxBase");
|
|
26
25
|
var XCheckbox = /** @class */ (function (_super) {
|
|
27
26
|
__extends(XCheckbox, _super);
|
|
28
27
|
function XCheckbox(props) {
|
|
29
28
|
var _this = _super.call(this, props) || this;
|
|
30
|
-
_this.
|
|
31
|
-
_this.triStateCheckboxOnValueChange = _this.triStateCheckboxOnValueChange.bind(_this);
|
|
29
|
+
_this.onValueChange = _this.onValueChange.bind(_this);
|
|
32
30
|
return _this;
|
|
33
31
|
}
|
|
34
32
|
XCheckbox.prototype.isNotNull = function () {
|
|
35
33
|
return this.props.isNotNull || _super.prototype.isNotNull.call(this);
|
|
36
34
|
};
|
|
37
35
|
XCheckbox.prototype.getValue = function () {
|
|
38
|
-
|
|
39
|
-
var value = this.getValueFromObject();
|
|
40
|
-
return value;
|
|
36
|
+
return this.getValueFromObject();
|
|
41
37
|
};
|
|
42
|
-
XCheckbox.prototype.
|
|
43
|
-
this.onValueChangeBase(
|
|
44
|
-
};
|
|
45
|
-
XCheckbox.prototype.triStateCheckboxOnValueChange = function (e) {
|
|
46
|
-
var newValue = e.value;
|
|
47
|
-
// pri klikani na TriStateCheckbox prichadza v newValue cyklicky: true -> false -> null
|
|
48
|
-
// ak mame not null atribut, tak pri null hodnote skocime rovno na true
|
|
49
|
-
if (this.isNotNull()) {
|
|
50
|
-
if (newValue === null) {
|
|
51
|
-
newValue = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// zmenime hodnotu v modeli (odtial sa hodnota cita)
|
|
55
|
-
this.onValueChangeBase(newValue, this.props.onChange);
|
|
38
|
+
XCheckbox.prototype.onValueChange = function (value) {
|
|
39
|
+
this.onValueChangeBase(value, this.props.onChange);
|
|
56
40
|
};
|
|
57
41
|
XCheckbox.prototype.render = function () {
|
|
58
|
-
var
|
|
59
|
-
// note: style overrides size (width of the input according to character count)
|
|
60
|
-
// pre not null atributy pouzijeme standardny checkbox aby sme pre false mali prazdny biely checkbox - TODO - pomenit ikonky na TriStateCheckbox aby to pekne sedelo
|
|
61
|
-
var element = this.isNotNull()
|
|
62
|
-
? react_1.default.createElement(checkbox_1.Checkbox, { id: this.props.field, checked: (_a = this.getValue()) !== null && _a !== void 0 ? _a : false, onChange: this.checkboxOnValueChange, disabled: this.isReadOnly(), style: this.props.inputStyle, tooltip: this.props.tooltip })
|
|
63
|
-
: react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { id: this.props.field, value: this.getValue(), onChange: this.triStateCheckboxOnValueChange, disabled: this.isReadOnly(), style: this.props.inputStyle, tooltip: this.props.tooltip });
|
|
42
|
+
var element = react_1.default.createElement(XCheckboxBase_1.XCheckboxBase, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), isNotNull: this.isNotNull(), tooltip: this.props.tooltip, error: this.getError(), style: this.props.inputStyle });
|
|
64
43
|
if (!this.props.onlyInput) {
|
|
65
44
|
var label = this.props.label; // nepridavame * ani ak je atribut not null (kedze sa pouziva jednoduchy checkbox, nie je mozne zadat null hodnotu)
|
|
66
45
|
element = react_1.default.createElement("div", { className: "field grid" },
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { CSSProperties } from "react";
|
|
2
|
+
export declare const XCheckboxBase: (props: {
|
|
3
|
+
id?: string | undefined;
|
|
4
|
+
value: boolean | null;
|
|
5
|
+
onChange: (value: boolean | null) => void;
|
|
6
|
+
readOnly?: boolean | undefined;
|
|
7
|
+
isNotNull?: boolean | undefined;
|
|
8
|
+
tooltip?: string | undefined;
|
|
9
|
+
error?: string | undefined;
|
|
10
|
+
style?: CSSProperties | undefined;
|
|
11
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
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.XCheckboxBase = void 0;
|
|
18
|
+
var react_1 = __importDefault(require("react"));
|
|
19
|
+
var tristatecheckbox_1 = require("primereact/tristatecheckbox");
|
|
20
|
+
var checkbox_1 = require("primereact/checkbox");
|
|
21
|
+
var XUtils_1 = require("./XUtils");
|
|
22
|
+
var XCheckboxBase = function (props) {
|
|
23
|
+
var _a;
|
|
24
|
+
var checkboxOnChange = function (e) {
|
|
25
|
+
var _a;
|
|
26
|
+
props.onChange((_a = e.checked) !== null && _a !== void 0 ? _a : false);
|
|
27
|
+
};
|
|
28
|
+
var triStateCheckboxChange = function (e) {
|
|
29
|
+
var _a;
|
|
30
|
+
// for blank value comes empty string "" (bug in primereact?)
|
|
31
|
+
var newValue = null;
|
|
32
|
+
if (typeof e.value !== 'string') {
|
|
33
|
+
newValue = (_a = e.value) !== null && _a !== void 0 ? _a : null;
|
|
34
|
+
}
|
|
35
|
+
// pri klikani na TriStateCheckbox prichadza v newValue cyklicky: true -> false -> null
|
|
36
|
+
// ak mame not null atribut, tak pri null hodnote skocime rovno na true
|
|
37
|
+
// TODO - pouzijeme, ked zrusime Checkbox a nechame len TriStateCheckbox
|
|
38
|
+
// if (props.isNotNull) {
|
|
39
|
+
// if (newValue === null) {
|
|
40
|
+
// newValue = true;
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
props.onChange(newValue);
|
|
44
|
+
};
|
|
45
|
+
return (
|
|
46
|
+
// pre not null atributy pouzijeme standardny checkbox aby sme pre false mali prazdny biely checkbox
|
|
47
|
+
// TODO - pomenit ikonky na TriStateCheckbox aby to pekne sedelo, potom mozme zrusit Checkbox
|
|
48
|
+
props.isNotNull ?
|
|
49
|
+
react_1.default.createElement(checkbox_1.Checkbox, __assign({ id: props.id, checked: (_a = props.value) !== null && _a !== void 0 ? _a : false, onChange: checkboxOnChange, disabled: props.readOnly, style: props.style }, XUtils_1.XUtils.createTooltipOrErrorProps(props.error, props.tooltip)))
|
|
50
|
+
: react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, __assign({ id: props.id, value: props.value, onChange: triStateCheckboxChange, disabled: props.readOnly, style: props.style }, XUtils_1.XUtils.createTooltipOrErrorProps(props.error, props.tooltip))));
|
|
51
|
+
};
|
|
52
|
+
exports.XCheckboxBase = XCheckboxBase;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { XFormBase } from "./XFormBase";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
2
|
+
import { XInputDT, XInputDTProps } from "./XInputDT";
|
|
3
|
+
export interface XCheckboxDTProps extends XInputDTProps {
|
|
4
|
+
}
|
|
5
|
+
export declare class XCheckboxDT extends XInputDT<XCheckboxDTProps> {
|
|
6
|
+
constructor(props: XCheckboxDTProps);
|
|
7
|
+
getValue(): boolean | null;
|
|
8
|
+
onValueChange(value: boolean | null): void;
|
|
9
|
+
render(): React.JSX.Element;
|
|
10
|
+
}
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
19
|
};
|
|
5
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
21
|
exports.XCheckboxDT = void 0;
|
|
7
22
|
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (newValue === null) {
|
|
17
|
-
newValue = true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// zmenime hodnotu v modeli (odtial sa hodnota cita)
|
|
21
|
-
rowData[field] = newValue;
|
|
22
|
-
// kedze "rowData" je sucastou "props.form.state.object", tak nam staci zavolat setState({object: object}), aby sa zmena prejavila
|
|
23
|
-
props.form.onObjectDataChange();
|
|
24
|
-
};
|
|
25
|
-
var fieldValue = null;
|
|
26
|
-
// test na undefined je tu koli insertu noveho riadku
|
|
27
|
-
if (props.rowData !== undefined && props.rowData !== null) {
|
|
28
|
-
var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(props.rowData, props.field);
|
|
29
|
-
// pri inserte noveho riadku su (zatial) vsetky fieldy undefined, dame na null, null je standard
|
|
30
|
-
if (rowDataValue === undefined) {
|
|
31
|
-
rowDataValue = null;
|
|
32
|
-
}
|
|
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)
|
|
34
|
-
fieldValue = rowDataValue;
|
|
23
|
+
var XInputDT_1 = require("./XInputDT");
|
|
24
|
+
var XCheckboxBase_1 = require("./XCheckboxBase");
|
|
25
|
+
var XCheckboxDT = /** @class */ (function (_super) {
|
|
26
|
+
__extends(XCheckboxDT, _super);
|
|
27
|
+
function XCheckboxDT(props) {
|
|
28
|
+
var _this = _super.call(this, props) || this;
|
|
29
|
+
_this.onValueChange = _this.onValueChange.bind(_this);
|
|
30
|
+
return _this;
|
|
35
31
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
32
|
+
XCheckboxDT.prototype.getValue = function () {
|
|
33
|
+
return this.getValueFromRowData();
|
|
34
|
+
};
|
|
35
|
+
XCheckboxDT.prototype.onValueChange = function (value) {
|
|
36
|
+
this.onValueChangeBase(value, this.props.onChange);
|
|
37
|
+
};
|
|
38
|
+
XCheckboxDT.prototype.render = function () {
|
|
39
|
+
return (react_1.default.createElement(XCheckboxBase_1.XCheckboxBase, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), isNotNull: this.isNotNull(), error: this.getError(), style: this.props.inputStyle }));
|
|
40
|
+
};
|
|
41
|
+
return XCheckboxDT;
|
|
42
|
+
}(XInputDT_1.XInputDT));
|
|
39
43
|
exports.XCheckboxDT = XCheckboxDT;
|
|
@@ -10,6 +10,7 @@ export interface XFormProps {
|
|
|
10
10
|
id?: number;
|
|
11
11
|
initValues?: object;
|
|
12
12
|
onSaveOrCancel?: XOnSaveOrCancelProp;
|
|
13
|
+
isInDialog?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export declare function Form(entity: string): <T extends new (...args: any[]) => {}>(constructor: T) => {
|
|
15
16
|
new (...args: any[]): {
|
|
@@ -235,7 +235,8 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
235
235
|
};
|
|
236
236
|
// helper method
|
|
237
237
|
XFormBase.prototype.isInDialog = function () {
|
|
238
|
-
|
|
238
|
+
var _a;
|
|
239
|
+
return (_a = this.props.isInDialog) !== null && _a !== void 0 ? _a : false;
|
|
239
240
|
};
|
|
240
241
|
// helper method
|
|
241
242
|
XFormBase.prototype.isTabViewUsed = function () {
|
|
@@ -394,7 +394,7 @@ var XFormDataTable2 = exports.XFormDataTable2 = /** @class */ (function (_super)
|
|
|
394
394
|
body = react_1.default.createElement(XInputIntervalDT_1.XInputIntervalDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly, onChange: columnPropsInputSimple.onChange });
|
|
395
395
|
}
|
|
396
396
|
else if (xField.type === "boolean") {
|
|
397
|
-
body = react_1.default.createElement(XCheckboxDT_1.XCheckboxDT, { form: this.props.form,
|
|
397
|
+
body = react_1.default.createElement(XCheckboxDT_1.XCheckboxDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly, onChange: columnPropsInputSimple.onChange });
|
|
398
398
|
}
|
|
399
399
|
else {
|
|
400
400
|
// xField.type === "string", pripadne ine jednoduche typy
|
|
@@ -16,7 +16,7 @@ var XFormDialog = function (props) {
|
|
|
16
16
|
};
|
|
17
17
|
var form = (_a = props.dialogState.form) !== null && _a !== void 0 ? _a : props.form;
|
|
18
18
|
return (react_1.default.createElement(dialog_1.Dialog, { key: "dialog-form", className: "x-dialog-without-header", visible: props.dialogState.opened, onHide: onHide }, form ? react_1.default.cloneElement(form, {
|
|
19
|
-
id: props.dialogState.id, initValues: props.dialogState.initValues, onSaveOrCancel: props.dialogState.onSaveOrCancel
|
|
19
|
+
id: props.dialogState.id, initValues: props.dialogState.initValues, onSaveOrCancel: props.dialogState.onSaveOrCancel, isInDialog: true
|
|
20
20
|
} /*, props.form.children*/) : null));
|
|
21
21
|
};
|
|
22
22
|
exports.XFormDialog = XFormDialog;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactChild } from 'react';
|
|
2
2
|
import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMetaData, DataTableRowExpansionTemplate, DataTableSortMeta } from 'primereact/datatable';
|
|
3
3
|
import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereact/column';
|
|
4
|
-
import { XViewStatusOrBoolean } from "../XUtils";
|
|
4
|
+
import { XStorageType, XViewStatusOrBoolean } from "../XUtils";
|
|
5
5
|
import { XSearchBrowseParams } from "../XSearchBrowseParams";
|
|
6
6
|
import { XAggregateFunction, XCustomFilter } from "../../serverApi/FindParam";
|
|
7
7
|
import { XOnSaveOrCancelProp } from "../XFormBase";
|
|
@@ -58,6 +58,7 @@ export interface XLazyDataTableRef {
|
|
|
58
58
|
}
|
|
59
59
|
export interface XLazyDataTableProps {
|
|
60
60
|
entity: string;
|
|
61
|
+
stateStorage?: XStorageType;
|
|
61
62
|
stateKey?: string;
|
|
62
63
|
label?: string;
|
|
63
64
|
labelStyle?: React.CSSProperties;
|
|
@@ -145,8 +145,8 @@ var XOcfDropdown_1 = require("./XOcfDropdown");
|
|
|
145
145
|
var XFieldSetBase_1 = require("../XFieldSet/XFieldSetBase");
|
|
146
146
|
var XAutoCompleteBase_1 = require("../XAutoCompleteBase");
|
|
147
147
|
var XInputTextBase_1 = require("../XInputTextBase");
|
|
148
|
-
var
|
|
149
|
-
var
|
|
148
|
+
var useXStateStorage_1 = require("../useXStateStorage");
|
|
149
|
+
var useXStateStorageBase_1 = require("../useXStateStorageBase");
|
|
150
150
|
var _ = __importStar(require("lodash"));
|
|
151
151
|
var XDocTemplateButton_1 = require("../../modules/docTemplates/XDocTemplateButton");
|
|
152
152
|
var XFormDialog_1 = require("../XFormDialog");
|
|
@@ -162,12 +162,12 @@ var XStateKeySuffix;
|
|
|
162
162
|
})(XStateKeySuffix || (exports.XStateKeySuffix = XStateKeySuffix = {}));
|
|
163
163
|
exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
164
164
|
var _b;
|
|
165
|
-
var _c = _a.
|
|
166
|
-
|
|
167
|
-
scrollHeight =
|
|
168
|
-
|
|
169
|
-
shrinkWidth =
|
|
170
|
-
var props = __assign({ paginator: paginator, rows: rows, filterDisplay: filterDisplay, autoFilter: autoFilter, showFilterButtons: showFilterButtons, fullTextSearch: fullTextSearch, multilineSwitch: multilineSwitch, multilineSwitchInitValue: multilineSwitchInitValue, multilineSwitchFewLinesCount: multilineSwitchFewLinesCount, scrollable: scrollable, scrollWidth: scrollWidth, scrollHeight: scrollHeight, shrinkWidth: shrinkWidth }, propsRest);
|
|
165
|
+
var _c = _a.stateStorage, stateStorage = _c === void 0 ? "session" : _c, _d = _a.paginator, paginator = _d === void 0 ? true : _d, _e = _a.rows, rows = _e === void 0 ? 30 : _e, _f = _a.filterDisplay, filterDisplay = _f === void 0 ? "row" : _f, _g = _a.autoFilter, autoFilter = _g === void 0 ? false : _g, _h = _a.showFilterButtons, showFilterButtons = _h === void 0 ? true : _h, _j = _a.fullTextSearch, fullTextSearch = _j === void 0 ? true : _j, _k = _a.multilineSwitch, multilineSwitch = _k === void 0 ? false : _k, _l = _a.multilineSwitchInitValue, multilineSwitchInitValue = _l === void 0 ? "allLines" : _l, _m = _a.multilineSwitchFewLinesCount, multilineSwitchFewLinesCount = _m === void 0 ? 2 : _m, _o = _a.scrollable, scrollable = _o === void 0 ? true : _o, _p = _a.scrollWidth, scrollWidth = _p === void 0 ? 'viewport' : _p, // nastavi sirku tabulky na (100vw - nieco) (ak bude obsah sirsi, zapne horizontalny scrollbar)
|
|
166
|
+
_q = _a.scrollHeight, // nastavi sirku tabulky na (100vw - nieco) (ak bude obsah sirsi, zapne horizontalny scrollbar)
|
|
167
|
+
scrollHeight = _q === void 0 ? 'viewport' : _q, // nastavi vysku tabulky na (100vh - nieco) (ak bude obsah vecsi, zapne vertikalny scrollbar)
|
|
168
|
+
_r = _a.shrinkWidth, // nastavi vysku tabulky na (100vh - nieco) (ak bude obsah vecsi, zapne vertikalny scrollbar)
|
|
169
|
+
shrinkWidth = _r === void 0 ? true : _r, propsRest = __rest(_a, ["stateStorage", "paginator", "rows", "filterDisplay", "autoFilter", "showFilterButtons", "fullTextSearch", "multilineSwitch", "multilineSwitchInitValue", "multilineSwitchFewLinesCount", "scrollable", "scrollWidth", "scrollHeight", "shrinkWidth"]);
|
|
170
|
+
var props = __assign({ stateStorage: stateStorage, paginator: paginator, rows: rows, filterDisplay: filterDisplay, autoFilter: autoFilter, showFilterButtons: showFilterButtons, fullTextSearch: fullTextSearch, multilineSwitch: multilineSwitch, multilineSwitchInitValue: multilineSwitchInitValue, multilineSwitchFewLinesCount: multilineSwitchFewLinesCount, scrollable: scrollable, scrollWidth: scrollWidth, scrollHeight: scrollHeight, shrinkWidth: shrinkWidth }, propsRest);
|
|
171
171
|
// must be here, is used in createFiltersInit()
|
|
172
172
|
var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.entity);
|
|
173
173
|
var createAggregateItems = function () {
|
|
@@ -320,7 +320,7 @@ exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
320
320
|
return "x-ldt-state-".concat((_a = props.stateKey) !== null && _a !== void 0 ? _a : props.entity, "-").concat(stateKeySuffix);
|
|
321
321
|
};
|
|
322
322
|
var removePagingFromStorage = function () {
|
|
323
|
-
XUtils_1.XUtils.removeValueFromStorage(getStateKey(XStateKeySuffix.pagingFirst));
|
|
323
|
+
XUtils_1.XUtils.removeValueFromStorage(props.stateStorage, getStateKey(XStateKeySuffix.pagingFirst));
|
|
324
324
|
};
|
|
325
325
|
// premenne platne pre cely component (obdoba member premennych v class-e)
|
|
326
326
|
var primeReactContext = react_1.default.useContext(api_1.PrimeReactContext); // probably does not work and deprecated PrimeReact.filterMatchModeOptions is used
|
|
@@ -338,15 +338,15 @@ exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
338
338
|
// ak mame fieldSet stlpce (stlpce ktore maju zadany fieldSetId a zobrazuju hodnoty podla fieldSet-u),
|
|
339
339
|
// tak sem nacitame mapy umoznujuce ziskanie labelov zakliknutych field-ov
|
|
340
340
|
// poznamka: uz by sa zislo mat vytvorene objekty (instancie) pre stlpce a do nich zapisovat pripadny XFieldSetMap, filter (teraz je vo "filters")
|
|
341
|
-
var
|
|
342
|
-
var
|
|
343
|
-
var
|
|
344
|
-
var
|
|
345
|
-
var
|
|
346
|
-
var
|
|
341
|
+
var _s = __read((0, react_1.useState)({}), 2), xFieldSetMaps = _s[0], setXFieldSetMaps = _s[1];
|
|
342
|
+
var _t = __read((0, react_1.useState)({ rowList: [], totalRecords: 0, aggregateValues: [] }), 2), value = _t[0], setValue = _t[1];
|
|
343
|
+
var _u = __read((0, react_1.useState)(undefined), 2), expandedRows = _u[0], setExpandedRows = _u[1];
|
|
344
|
+
var _v = __read((0, react_1.useState)(false), 2), loading = _v[0], setLoading = _v[1];
|
|
345
|
+
var _w = __read((0, useXStateStorage_1.useXStateStorage)(props.stateStorage, getStateKey(XStateKeySuffix.pagingFirst), 0), 2), first = _w[0], setFirst = _w[1];
|
|
346
|
+
var _x = __read((0, react_1.useState)(props.paginator ? props.rows : undefined), 2), rowsLocal = _x[0], setRowsLocal = _x[1];
|
|
347
347
|
// "filters" have special initialState function different from that used in useXStateSession
|
|
348
348
|
var filtersInitialStateFunction = function () {
|
|
349
|
-
var filtersInit = XUtils_1.XUtils.getValueFromStorage(getStateKey(XStateKeySuffix.filters), null);
|
|
349
|
+
var filtersInit = XUtils_1.XUtils.getValueFromStorage(props.stateStorage, getStateKey(XStateKeySuffix.filters), null);
|
|
350
350
|
if (filtersInit != null) {
|
|
351
351
|
// we have filters from session - if we have props.filters, we always override the values from session (values from props.filters have higher priority)
|
|
352
352
|
filtersInit = overrideFilters(filtersInit, props.filters);
|
|
@@ -357,23 +357,23 @@ exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
357
357
|
}
|
|
358
358
|
return filtersInit;
|
|
359
359
|
};
|
|
360
|
-
var
|
|
360
|
+
var _y = __read((0, useXStateStorageBase_1.useXStateStorageBase)(props.stateStorage, getStateKey(XStateKeySuffix.filters), filtersInitialStateFunction), 2), filters = _y[0], setFilters = _y[1]; // filtrovanie na "controlled manner" (moze sa sem nainicializovat nejaka hodnota)
|
|
361
361
|
var initFtsInputValue = props.fullTextSearch ? createInitFtsInputValue() : undefined;
|
|
362
|
-
var
|
|
363
|
-
var
|
|
364
|
-
var
|
|
365
|
-
var
|
|
366
|
-
var
|
|
362
|
+
var _z = __read((0, useXStateStorage_1.useXStateStorage)(props.stateStorage, getStateKey(XStateKeySuffix.ftsInputValue), initFtsInputValue), 2), ftsInputValue = _z[0], setFtsInputValue = _z[1];
|
|
363
|
+
var _0 = __read((0, useXStateStorage_1.useXStateStorage)(props.stateStorage, getStateKey(XStateKeySuffix.optionalCustomFilter), undefined), 2), optionalCustomFilter = _0[0], setOptionalCustomFilter = _0[1];
|
|
364
|
+
var _1 = __read((_b = props.multilineSwitchValue) !== null && _b !== void 0 ? _b : (0, useXStateStorage_1.useXStateStorage)(props.stateStorage, getStateKey(XStateKeySuffix.multilineSwitchValue), props.multilineSwitchInitValue), 2), multilineSwitchValue = _1[0], setMultilineSwitchValue = _1[1];
|
|
365
|
+
var _2 = __read((0, useXStateStorage_1.useXStateStorage)(props.stateStorage, getStateKey(XStateKeySuffix.multiSortMeta), XUtilsCommon_1.XUtilsCommon.createMultiSortMeta(props.sortField)), 2), multiSortMeta = _2[0], setMultiSortMeta = _2[1];
|
|
366
|
+
var _3 = __read((0, useXStateStorage_1.useXStateStorage)(props.stateStorage, getStateKey(XStateKeySuffix.selectedRow), null), 2), selectedRow = _3[0], setSelectedRow = _3[1];
|
|
367
367
|
/**
|
|
368
368
|
* @deprecated was used to reread data after save/cancel of the form when using XFormNavigator (deprecated)
|
|
369
369
|
*/
|
|
370
|
-
var
|
|
371
|
-
var
|
|
370
|
+
var _4 = __read((0, react_1.useState)(false), 2), dataLoaded = _4[0], setDataLoaded = _4[1]; // priznak kde si zapiseme, ci uz sme nacitali data
|
|
371
|
+
var _5 = __read((0, react_1.useState)({ dialogOpened: false }), 2), exportRowsDialogState = _5[0], setExportRowsDialogState = _5[1];
|
|
372
372
|
//const [exportRowsDialogRowCount, setExportRowsDialogRowCount] = useState<number>(); // param pre dialog
|
|
373
|
-
var
|
|
374
|
-
var
|
|
375
|
-
var
|
|
376
|
-
var
|
|
373
|
+
var _6 = __read((0, react_1.useState)(filters), 2), filtersAfterFiltering = _6[0], setFiltersAfterFiltering = _6[1]; // sem si odkladame stav filtra po kliknuti na button Filter (chceme exportovat presne to co vidno vyfiltrovane)
|
|
374
|
+
var _7 = __read((0, react_1.useState)(ftsInputValue), 2), ftsInputValueAfterFiltering = _7[0], setFtsInputValueAfterFiltering = _7[1]; // tak isto ako filtersAfterFiltering
|
|
375
|
+
var _8 = __read((0, react_1.useState)(optionalCustomFilter), 2), optionalCustomFilterAfterFiltering = _8[0], setOptionalCustomFilterAfterFiltering = _8[1]; // tak isto ako filtersAfterFiltering
|
|
376
|
+
var _9 = __read((0, react_1.useState)({ opened: false }), 2), formDialogState = _9[0], setFormDialogState = _9[1];
|
|
377
377
|
// parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
|
|
378
378
|
(0, react_1.useEffect)(function () {
|
|
379
379
|
// jednoduchy sposob - nepouzivame parameter props.displayed a priznak dataLoaded
|
|
@@ -1470,7 +1470,7 @@ exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
1470
1470
|
exportRows ? react_1.default.createElement(XButton_1.XButton, { key: "exportRows", icon: "pi pi-file-export", label: (0, XLocale_1.xLocaleOption)('exportRows'), onClick: onClickExport }) : null,
|
|
1471
1471
|
props.docTemplates && !isMobile && props.searchBrowseParams === undefined ? react_1.default.createElement(XDocTemplateButton_1.XDocTemplateButton, { key: "docTemplates", entity: props.entity, rowId: selectedRow ? selectedRow[dataKey] : undefined, docTemplates: typeof props.docTemplates === 'function' ? props.docTemplates : undefined }) : null,
|
|
1472
1472
|
props.appButtonsForRow && props.searchBrowseParams === undefined ? props.appButtonsForRow.map(function (xAppButton) { return react_1.default.createElement(XButton_1.XButton, { key: xAppButton.key, icon: xAppButton.icon, label: xAppButton.label, onClick: function () { return onClickAppButtonForRow(xAppButton.onClick); }, style: xAppButton.style }); }) : null,
|
|
1473
|
-
props.
|
|
1473
|
+
props.searchBrowseParams === undefined ? props.appButtons : null,
|
|
1474
1474
|
props.searchBrowseParams !== undefined ? react_1.default.createElement(XButton_1.XButton, { key: "choose", label: (0, XLocale_1.xLocaleOption)('chooseRow'), onClick: onClickChoose }) : null,
|
|
1475
1475
|
props.editForm != undefined ? react_1.default.createElement(XFormDialog_1.XFormDialog, { key: "formDialog", dialogState: formDialogState }) : null,
|
|
1476
1476
|
exportRows ? react_1.default.createElement(XExportRowsDialog_1.XExportRowsDialog, { key: "exportRowsDialog", dialogState: exportRowsDialogState, hideDialog: function () { return setExportRowsDialogState({ dialogOpened: false }); } }) : null),
|
|
@@ -22,6 +22,7 @@ export declare enum XViewStatus {
|
|
|
22
22
|
Hidden = "hidden"
|
|
23
23
|
}
|
|
24
24
|
export type XViewStatusOrBoolean = XViewStatus | boolean;
|
|
25
|
+
export type XStorageType = "none" | "session" | "local";
|
|
25
26
|
export interface IPostgresInterval {
|
|
26
27
|
years?: number;
|
|
27
28
|
months?: number;
|
|
@@ -110,10 +111,10 @@ export declare class XUtils {
|
|
|
110
111
|
static isTableRowInserted(tableRow: any): boolean;
|
|
111
112
|
static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
|
|
112
113
|
static options(valueStringList: string[]): SelectItem[];
|
|
113
|
-
static saveValueIntoStorage(key: string, value: any): void;
|
|
114
|
-
static getValueFromStorage(key: string, initValue: any): any;
|
|
115
|
-
static removeValueFromStorage(key: string): void;
|
|
116
|
-
static clearStorage(): void;
|
|
114
|
+
static saveValueIntoStorage(xStorageType: XStorageType, key: string, value: any): void;
|
|
115
|
+
static getValueFromStorage(xStorageType: XStorageType, key: string, initValue: any): any;
|
|
116
|
+
static removeValueFromStorage(xStorageType: XStorageType, key: string): void;
|
|
117
|
+
static clearStorage(xStorageType: XStorageType): void;
|
|
117
118
|
static reloadIfNewVersion(): void;
|
|
118
119
|
static reloadIfNewVersionNow(): Promise<void>;
|
|
119
120
|
static isLocalhost(): boolean;
|
package/lib/components/XUtils.js
CHANGED
|
@@ -713,7 +713,7 @@ var XUtils = exports.XUtils = /** @class */ (function () {
|
|
|
713
713
|
XUtils.options = function (valueStringList) {
|
|
714
714
|
return valueStringList.map(function (valueString) { return { value: valueString, label: valueString }; });
|
|
715
715
|
};
|
|
716
|
-
XUtils.saveValueIntoStorage = function (key, value) {
|
|
716
|
+
XUtils.saveValueIntoStorage = function (xStorageType, key, value) {
|
|
717
717
|
// value can be also string or null or undefined
|
|
718
718
|
// if we don't have object that can be serialised to json, we create special object
|
|
719
719
|
var valueObject;
|
|
@@ -727,12 +727,23 @@ var XUtils = exports.XUtils = /** @class */ (function () {
|
|
|
727
727
|
// value is null or string or boolean or number or Date...
|
|
728
728
|
valueObject = { _xValue: value };
|
|
729
729
|
}
|
|
730
|
-
|
|
730
|
+
if (xStorageType === "session") {
|
|
731
|
+
sessionStorage.setItem(key, XUtilsCommon_1.XUtilsCommon.objectAsJSON(valueObject));
|
|
732
|
+
}
|
|
733
|
+
else if (xStorageType === "local") {
|
|
734
|
+
localStorage.setItem(key, XUtilsCommon_1.XUtilsCommon.objectAsJSON(valueObject));
|
|
735
|
+
}
|
|
731
736
|
};
|
|
732
|
-
XUtils.getValueFromStorage = function (key, initValue) {
|
|
737
|
+
XUtils.getValueFromStorage = function (xStorageType, key, initValue) {
|
|
733
738
|
// if the value is not found in storage, initValue is returned
|
|
734
739
|
var value;
|
|
735
|
-
var item =
|
|
740
|
+
var item = null;
|
|
741
|
+
if (xStorageType === "session") {
|
|
742
|
+
item = sessionStorage.getItem(key);
|
|
743
|
+
}
|
|
744
|
+
else if (xStorageType === "local") {
|
|
745
|
+
item = localStorage.getItem(key);
|
|
746
|
+
}
|
|
736
747
|
if (item !== null) {
|
|
737
748
|
try {
|
|
738
749
|
var valueObject = JSON.parse(item);
|
|
@@ -750,7 +761,7 @@ var XUtils = exports.XUtils = /** @class */ (function () {
|
|
|
750
761
|
}
|
|
751
762
|
catch (e) {
|
|
752
763
|
// exception should not happen
|
|
753
|
-
console.log("XUtils.getValueFromStorage: Could not parse/process item from
|
|
764
|
+
console.log("XUtils.getValueFromStorage: Could not parse/process item from storage \"".concat(xStorageType, "\". key = ").concat(key, ", item = ").concat(item, ". Error: ").concat(e));
|
|
754
765
|
value = initValue;
|
|
755
766
|
}
|
|
756
767
|
}
|
|
@@ -759,11 +770,21 @@ var XUtils = exports.XUtils = /** @class */ (function () {
|
|
|
759
770
|
}
|
|
760
771
|
return value;
|
|
761
772
|
};
|
|
762
|
-
XUtils.removeValueFromStorage = function (key) {
|
|
763
|
-
|
|
773
|
+
XUtils.removeValueFromStorage = function (xStorageType, key) {
|
|
774
|
+
if (xStorageType === "session") {
|
|
775
|
+
sessionStorage.removeItem(key);
|
|
776
|
+
}
|
|
777
|
+
else if (xStorageType === "local") {
|
|
778
|
+
localStorage.removeItem(key);
|
|
779
|
+
}
|
|
764
780
|
};
|
|
765
|
-
XUtils.clearStorage = function () {
|
|
766
|
-
|
|
781
|
+
XUtils.clearStorage = function (xStorageType) {
|
|
782
|
+
if (xStorageType === "session") {
|
|
783
|
+
sessionStorage.clear();
|
|
784
|
+
}
|
|
785
|
+
else if (xStorageType === "local") {
|
|
786
|
+
localStorage.clear();
|
|
787
|
+
}
|
|
767
788
|
};
|
|
768
789
|
// hleper method used for items of XLazyDataTable (shortcut ldt)
|
|
769
790
|
// static getValueFromStorageLdt(entity: string, stateKeySuffix: XStateKeySuffix, initValue: any): any {
|
|
@@ -863,7 +884,8 @@ var XUtils = exports.XUtils = /** @class */ (function () {
|
|
|
863
884
|
// data in session may not correspond with new structures in new version
|
|
864
885
|
// e.g. if we add new column to XLazyDataTable, filter operator/value for this column new column is missing in data from session and application will crash
|
|
865
886
|
// simple solution is to clear session
|
|
866
|
-
XUtils.clearStorage();
|
|
887
|
+
XUtils.clearStorage("session");
|
|
888
|
+
XUtils.clearStorage("local");
|
|
867
889
|
// page reload (like pressing F5 or Enter on url bar)
|
|
868
890
|
// warning - if user has typed some data in form, the data will be lost
|
|
869
891
|
window.location.reload();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useXStateLocal = void 0;
|
|
4
|
+
var useXStateStorage_1 = require("./useXStateStorage");
|
|
5
|
+
// TODO - initialState sholud be value | function returning T, and the function should be called in function "initialStateFunction"
|
|
6
|
+
function useXStateLocal(key, initialState) {
|
|
7
|
+
return (0, useXStateStorage_1.useXStateStorage)("local", key, initialState);
|
|
8
|
+
}
|
|
9
|
+
exports.useXStateLocal = useXStateLocal;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useXStateSession = void 0;
|
|
4
|
-
var
|
|
5
|
-
var useXStateSessionBase_1 = require("./useXStateSessionBase");
|
|
4
|
+
var useXStateStorage_1 = require("./useXStateStorage");
|
|
6
5
|
// TODO - initialState sholud be value | function returning T, and the function should be called in function "initialStateFunction"
|
|
7
6
|
function useXStateSession(key, initialState) {
|
|
8
|
-
return (0,
|
|
7
|
+
return (0, useXStateStorage_1.useXStateStorage)("session", key, initialState);
|
|
9
8
|
}
|
|
10
9
|
exports.useXStateSession = useXStateSession;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useXStateStorage = void 0;
|
|
4
|
+
var XUtils_1 = require("./XUtils");
|
|
5
|
+
var useXStateStorageBase_1 = require("./useXStateStorageBase");
|
|
6
|
+
// TODO - initialState sholud be value | function returning T, and the function should be called in function "initialStateFunction"
|
|
7
|
+
function useXStateStorage(xStorageType, key, initialState) {
|
|
8
|
+
return (0, useXStateStorageBase_1.useXStateStorageBase)(xStorageType, key, function () { return XUtils_1.XUtils.getValueFromStorage(xStorageType, key, initialState); });
|
|
9
|
+
}
|
|
10
|
+
exports.useXStateStorage = useXStateStorage;
|
|
@@ -16,17 +16,17 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.useXStateStorageBase = void 0;
|
|
20
20
|
var react_1 = require("react");
|
|
21
21
|
var XUtils_1 = require("./XUtils");
|
|
22
22
|
// this base version enables to use custom version of function that computes initialState
|
|
23
|
-
// (in usual case
|
|
24
|
-
function
|
|
23
|
+
// (in usual case useXStateStorage shoud be used)
|
|
24
|
+
function useXStateStorageBase(xStorageType, key, initialStateFunction) {
|
|
25
25
|
var _a = __read((0, react_1.useState)(initialStateFunction), 2), value = _a[0], setValue = _a[1];
|
|
26
26
|
var setValueIntoSession = function (value) {
|
|
27
27
|
setValue(value);
|
|
28
|
-
XUtils_1.XUtils.saveValueIntoStorage(key, value);
|
|
28
|
+
XUtils_1.XUtils.saveValueIntoStorage(xStorageType, key, value);
|
|
29
29
|
};
|
|
30
30
|
return [value, setValueIntoSession];
|
|
31
31
|
}
|
|
32
|
-
exports.
|
|
32
|
+
exports.useXStateStorageBase = useXStateStorageBase;
|
|
@@ -48,10 +48,14 @@ export declare class XUtilsCommon {
|
|
|
48
48
|
static dateAddDays(date: Date | null, days: number): Date | null;
|
|
49
49
|
static dateAddMonths(date: Date | null, months: number): Date | null;
|
|
50
50
|
static dateEquals(date1: Date | null, date2: Date | null): boolean;
|
|
51
|
+
static dateIntersect(date1From: Date, date1To: Date, date2From: Date, date2To: Date): boolean;
|
|
52
|
+
static dateCompare(date1: Date, date2: Date): number;
|
|
51
53
|
static dateDiffInYears(dateOld: Date | null, dateNew: Date | null): number | null;
|
|
52
54
|
static monthDiff(monthOld: Date | null, monthNew: Date | null): number | null;
|
|
53
55
|
static findFirstMatch(pattern: RegExp, value: string): string | null;
|
|
54
56
|
static sqlMaxDateIfNull(sqlExp: string): string;
|
|
55
57
|
static today(): Date;
|
|
58
|
+
static currentMonth(): Date;
|
|
59
|
+
static dateAsMonth(date: Date | null): Date | null;
|
|
56
60
|
static isInt(stringValue: string): boolean;
|
|
57
61
|
}
|
|
@@ -486,7 +486,8 @@ var XUtilsCommon = exports.XUtilsCommon = /** @class */ (function () {
|
|
|
486
486
|
result = true;
|
|
487
487
|
}
|
|
488
488
|
else if (date1 !== null && date2 !== null) {
|
|
489
|
-
|
|
489
|
+
// to avoid problems with time part, we use dateCompare
|
|
490
|
+
result = (XUtilsCommon.dateCompare(date1, date2) === 0);
|
|
490
491
|
// mali sme problem - funkcia dateFromModel() konvertovala string "2025-02-04" na Tue Feb 04 2025 01:00:00 GMT+0100 (Central European Standard Time)
|
|
491
492
|
// a XCalendar pri vykliknuti datumu vracal Tue Feb 04 2025 00:00:00 GMT+0100 (Central European Standard Time) -> opravili sme XCalendar
|
|
492
493
|
//result = date1.getFullYear() === date2.getFullYear()
|
|
@@ -495,6 +496,24 @@ var XUtilsCommon = exports.XUtilsCommon = /** @class */ (function () {
|
|
|
495
496
|
}
|
|
496
497
|
return result;
|
|
497
498
|
};
|
|
499
|
+
XUtilsCommon.dateIntersect = function (date1From, date1To, date2From, date2To) {
|
|
500
|
+
return XUtilsCommon.dateCompare(date1From, date2To) <= 0 && XUtilsCommon.dateCompare(date2From, date1To) <= 0;
|
|
501
|
+
};
|
|
502
|
+
// because of time part, the usual compare (using <=) sometimes does not work correct
|
|
503
|
+
XUtilsCommon.dateCompare = function (date1, date2) {
|
|
504
|
+
var dateOnly1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
|
|
505
|
+
var dateOnly2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
|
506
|
+
if (dateOnly1.getTime() < dateOnly2.getTime()) {
|
|
507
|
+
return -1;
|
|
508
|
+
}
|
|
509
|
+
else if (dateOnly1.getTime() === dateOnly2.getTime()) {
|
|
510
|
+
return 0;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
// dateOnly1 > dateOnly2
|
|
514
|
+
return 1;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
498
517
|
// solution from internet
|
|
499
518
|
XUtilsCommon.dateDiffInYears = function (dateOld, dateNew) {
|
|
500
519
|
var diff = null;
|
|
@@ -553,6 +572,17 @@ var XUtilsCommon = exports.XUtilsCommon = /** @class */ (function () {
|
|
|
553
572
|
XUtilsCommon.today = function () {
|
|
554
573
|
return new Date((0, XUtilsConversions_1.dateAsYYYY_MM_DD)(new Date()));
|
|
555
574
|
};
|
|
575
|
+
XUtilsCommon.currentMonth = function () {
|
|
576
|
+
return XUtilsCommon.dateAsMonth(XUtilsCommon.today());
|
|
577
|
+
};
|
|
578
|
+
XUtilsCommon.dateAsMonth = function (date) {
|
|
579
|
+
var month = null;
|
|
580
|
+
if (date !== null) {
|
|
581
|
+
month = new Date(date); // create copy not to change "date"
|
|
582
|
+
month.setUTCDate(1); // first day of month
|
|
583
|
+
}
|
|
584
|
+
return month;
|
|
585
|
+
};
|
|
556
586
|
// vrati true ak sa string sklada iba z cislic, moze mat + alebo - na zaciatku
|
|
557
587
|
XUtilsCommon.isInt = function (stringValue) {
|
|
558
588
|
return /^[-+]?\d+$/.test(stringValue);
|
package/package.json
CHANGED