@olenbetong/appframe-ds 1.3.1 → 1.3.3
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/CHANGELOG.md +19 -0
- package/package.json +4 -4
- package/src/filter/FilterEditor.test.tsx +27 -1
- package/src/filter/FilterValueEditor.tsx +20 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @olenbetong/appframe-ds
|
|
2
2
|
|
|
3
|
+
## 1.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [04ff05a]
|
|
8
|
+
- @olenbetong/appframe-core@2.15.1
|
|
9
|
+
- @olenbetong/appframe-data@1.7.4
|
|
10
|
+
- @olenbetong/appframe-react@2.2.4
|
|
11
|
+
|
|
12
|
+
## 1.3.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 48e6ac8: The filter builder adds the seconds to datetime values, which the datetime input leaves out. SQL Server rejected the value without them with "Conversion failed when converting date and/or time from character string".
|
|
17
|
+
- Updated dependencies [a63831a]
|
|
18
|
+
- @olenbetong/appframe-core@2.15.0
|
|
19
|
+
- @olenbetong/appframe-react@2.2.3
|
|
20
|
+
- @olenbetong/appframe-data@1.7.3
|
|
21
|
+
|
|
3
22
|
## 1.3.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-ds",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Components that bind Designsystemet components to Appframe data objects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./es/index.d.ts",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"@atlaskit/pragmatic-drag-and-drop": "3.1.0",
|
|
64
64
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "2.2.2",
|
|
65
65
|
"@base-ui/react": "1.8.0",
|
|
66
|
-
"@olenbetong/appframe-core": "2.
|
|
67
|
-
"@olenbetong/appframe-data": "1.7.
|
|
68
|
-
"@olenbetong/appframe-react": "2.2.
|
|
66
|
+
"@olenbetong/appframe-core": "2.15.1",
|
|
67
|
+
"@olenbetong/appframe-data": "1.7.4",
|
|
68
|
+
"@olenbetong/appframe-react": "2.2.4",
|
|
69
69
|
"clsx": "^2.1.1",
|
|
70
70
|
"dockview-react": "8.3.1",
|
|
71
71
|
"localforage": "^1.10.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FieldMetadata, FilterExpression, FilterTree } from "@olenbetong/appframe-core";
|
|
2
|
-
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import { describe, expect, it, vi } from "vitest";
|
|
5
5
|
|
|
@@ -131,6 +131,32 @@ describe("FilterEditor", () => {
|
|
|
131
131
|
expect(firstExpression(onChange)).toMatchObject({ value: "Yesterday", valueType: "special" });
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
+
it("adds the seconds a datetime input leaves out", () => {
|
|
135
|
+
let onChange = vi.fn();
|
|
136
|
+
render(
|
|
137
|
+
<FilterEditor fields={FIELDS} value={filterWith("Created", "equals", "", "datetime")} onChange={onChange} />,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
fireEvent.change(screen.getByLabelText("Value"), { target: { value: "2026-09-25T00:00" } });
|
|
141
|
+
|
|
142
|
+
expect(firstExpression(onChange)).toMatchObject({ value: "2026-09-25T00:00:00" });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("adds the seconds to both ends of a datetime range", () => {
|
|
146
|
+
let onChange = vi.fn();
|
|
147
|
+
render(
|
|
148
|
+
<FilterEditor
|
|
149
|
+
fields={FIELDS}
|
|
150
|
+
value={filterWith("Created", "between", ["2026-09-01T00:00:00", ""], "datetime")}
|
|
151
|
+
onChange={onChange}
|
|
152
|
+
/>,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
fireEvent.change(screen.getByLabelText("To"), { target: { value: "2026-09-30T23:59" } });
|
|
156
|
+
|
|
157
|
+
expect(firstExpression(onChange)).toMatchObject({ value: ["2026-09-01T00:00:00", "2026-09-30T23:59:00"] });
|
|
158
|
+
});
|
|
159
|
+
|
|
134
160
|
it("does not offer relative values for numbers", () => {
|
|
135
161
|
render(<FilterEditor fields={FIELDS} value={filterWith("Age", "equals", "1", "number")} />);
|
|
136
162
|
|
|
@@ -47,6 +47,25 @@ function toStringValue(value: FilterExpression["value"]): string {
|
|
|
47
47
|
return String(value);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* A `datetime-local` input reports `2026-09-25T00:00`, leaving out the seconds
|
|
52
|
+
* when they are zero. The value reaches SQL Server as a string, and SQL Server
|
|
53
|
+
* only accepts the ISO 8601 form with a `T` when the seconds are present, so
|
|
54
|
+
* the filter fails with "Conversion failed when converting date and/or time
|
|
55
|
+
* from character string" unless they are added.
|
|
56
|
+
*/
|
|
57
|
+
function withSeconds(value: string): string {
|
|
58
|
+
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(value) ? `${value}:00` : value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function toFilterValue(value: FilterExpression["value"], inputType: string): FilterExpression["value"] {
|
|
62
|
+
if (inputType !== "datetime-local") return value;
|
|
63
|
+
if (typeof value === "string") return withSeconds(value);
|
|
64
|
+
if (Array.isArray(value)) return value.map((item) => (typeof item === "string" ? withSeconds(item) : item));
|
|
65
|
+
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
50
69
|
function toArrayValue(value: FilterExpression["value"], length?: number): string[] {
|
|
51
70
|
let array = Array.isArray(value) ? value.map(toStringValue) : [];
|
|
52
71
|
if (length === undefined) return array;
|
|
@@ -75,7 +94,7 @@ export function FilterValueEditor({
|
|
|
75
94
|
let inputType = getInputType(field);
|
|
76
95
|
|
|
77
96
|
function setValue(value: FilterExpression["value"]) {
|
|
78
|
-
onChange({ ...expression, value });
|
|
97
|
+
onChange({ ...expression, value: isDynamic ? value : toFilterValue(value, inputType) });
|
|
79
98
|
}
|
|
80
99
|
|
|
81
100
|
function setDynamic(enabled: boolean) {
|