@michalrakus/x-react-web-lib 1.36.1 → 1.37.1
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 +1 -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/XFormDataTable2.js +1 -1
- package/lib/components/XInput.d.ts +1 -0
- package/lib/components/XInputTextarea.js +1 -1
- package/lib/components/XInputTextareaBase.d.ts +1 -0
- package/lib/components/XInputTextareaBase.js +1 -1
- package/lib/components/XUtils.d.ts +1 -1
- package/lib/components/XUtils.js +7 -5
- package/lib/serverApi/XUtilsCommon.d.ts +4 -0
- package/lib/serverApi/XUtilsCommon.js +31 -1
- package/package.json +1 -1
package/XCheckboxBase.js
ADDED
package/gulpfile.js
CHANGED
|
@@ -43,6 +43,7 @@ function generateApi(cb) {
|
|
|
43
43
|
"./lib/components/XCalendar",
|
|
44
44
|
"./lib/components/XChangePasswordForm",
|
|
45
45
|
"./lib/components/XCheckbox",
|
|
46
|
+
"./lib/components/XCheckboxBase",
|
|
46
47
|
"./lib/components/XDropdown",
|
|
47
48
|
"./lib/components/XDropdownForEntity",
|
|
48
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;
|
|
@@ -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
|
|
@@ -4,6 +4,7 @@ import { XField } from "../serverApi/XEntityMetadata";
|
|
|
4
4
|
export interface XInputProps<T> extends XFormComponentProps<T> {
|
|
5
5
|
field: string;
|
|
6
6
|
inputStyle?: React.CSSProperties;
|
|
7
|
+
inputClassName?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare abstract class XInput<T, P extends XInputProps<T>> extends XFormComponent<T, P> {
|
|
9
10
|
protected xField: XField;
|
|
@@ -99,7 +99,7 @@ var XInputTextarea = exports.XInputTextarea = /** @class */ (function (_super) {
|
|
|
99
99
|
react_1.default.createElement("label", { id: labelElemId, htmlFor: this.props.field, className: !this.labelOnTop ? 'col-fixed' : undefined, style: labelStyle }, this.getLabel()),
|
|
100
100
|
labelTooltip ? react_1.default.createElement(tooltip_1.Tooltip, { target: "#".concat(labelElemId), content: labelTooltip }) : null,
|
|
101
101
|
this.props.form.state.object ?
|
|
102
|
-
react_1.default.createElement(XInputTextareaBase_1.XInputTextareaBase, { ref: this.xInputTextareaBaseRef, id: this.props.field, value: value, onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, style: inputStyle, rows: this.props.rows, cols: cols, autoResize: this.props.autoResize, error: this.getError(), tooltip: this.props.tooltip, placeholder: (_b = this.props.placeholder) !== null && _b !== void 0 ? _b : this.props.desc })
|
|
102
|
+
react_1.default.createElement(XInputTextareaBase_1.XInputTextareaBase, { ref: this.xInputTextareaBaseRef, id: this.props.field, value: value, onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, style: inputStyle, className: this.props.inputClassName, rows: this.props.rows, cols: cols, autoResize: this.props.autoResize, error: this.getError(), tooltip: this.props.tooltip, placeholder: (_b = this.props.placeholder) !== null && _b !== void 0 ? _b : this.props.desc })
|
|
103
103
|
: null));
|
|
104
104
|
};
|
|
105
105
|
XInputTextarea.defaultProps = {
|
|
@@ -99,7 +99,7 @@ var XInputTextareaBase = /** @class */ (function (_super) {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
XInputTextareaBase.prototype.render = function () {
|
|
102
|
-
return (react_1.default.createElement(inputtextarea_1.InputTextarea, __assign({ ref: this.inputTextareaRef, id: this.props.id, value: this.getInputValue(), onChange: this.onChange, onBlur: this.onBlur, readOnly: this.props.readOnly, maxLength: this.props.maxLength, style: this.props.style, rows: this.props.rows, cols: this.props.cols, autoResize: this.props.autoResize }, XUtils_1.XUtils.createTooltipOrErrorProps(this.props.error, this.props.tooltip), { placeholder: this.props.placeholder })));
|
|
102
|
+
return (react_1.default.createElement(inputtextarea_1.InputTextarea, __assign({ ref: this.inputTextareaRef, id: this.props.id, value: this.getInputValue(), onChange: this.onChange, onBlur: this.onBlur, readOnly: this.props.readOnly, maxLength: this.props.maxLength, style: this.props.style, rows: this.props.rows, cols: this.props.cols, autoResize: this.props.autoResize }, XUtils_1.XUtils.addClassName(XUtils_1.XUtils.createTooltipOrErrorProps(this.props.error, this.props.tooltip), this.props.className), { placeholder: this.props.placeholder })));
|
|
103
103
|
};
|
|
104
104
|
return XInputTextareaBase;
|
|
105
105
|
}(react_1.Component));
|
|
@@ -101,7 +101,7 @@ export declare class XUtils {
|
|
|
101
101
|
static createTooltipOrErrorProps(error: string | undefined, tooltip?: string | undefined): object;
|
|
102
102
|
static addClassName(props: {
|
|
103
103
|
[key: string]: any;
|
|
104
|
-
}, className: string): {
|
|
104
|
+
}, className: string | undefined): {
|
|
105
105
|
[key: string]: any;
|
|
106
106
|
};
|
|
107
107
|
static getErrorMessages(xErrorMap: XErrorMap): string;
|
package/lib/components/XUtils.js
CHANGED
|
@@ -617,11 +617,13 @@ var XUtils = exports.XUtils = /** @class */ (function () {
|
|
|
617
617
|
// pouzivame ju, lebo XUtils.createErrorProps nam prebijal className
|
|
618
618
|
XUtils.addClassName = function (props, className) {
|
|
619
619
|
var propsClassName = props.className;
|
|
620
|
-
if (
|
|
621
|
-
propsClassName
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
620
|
+
if (className !== undefined) {
|
|
621
|
+
if (propsClassName !== undefined) {
|
|
622
|
+
propsClassName += " " + className;
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
propsClassName = className;
|
|
626
|
+
}
|
|
625
627
|
}
|
|
626
628
|
props.className = propsClassName;
|
|
627
629
|
return props;
|
|
@@ -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);
|