@olenbetong/synergi-react 5.4.0 → 5.6.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/dist/styles/styles.css +1 -1
- package/dist/styles/styles.css.map +1 -1
- package/es/charts/CallOffDeliveries/TicketScanDialog.d.ts +7 -0
- package/es/charts/CallOffDeliveries/TicketScanDialog.js +47 -0
- package/es/charts/CallOffDeliveries/chartOptions.d.ts +8 -0
- package/es/charts/CallOffDeliveries/chartOptions.js +138 -0
- package/es/charts/CallOffDeliveries/data.d.ts +35 -0
- package/es/charts/CallOffDeliveries/data.js +30 -0
- package/es/charts/CallOffDeliveries/index.css +1 -0
- package/es/charts/CallOffDeliveries/index.d.ts +24 -0
- package/es/charts/CallOffDeliveries/index.js +115 -0
- package/es/charts/CallOffDeliveries/model.d.ts +37 -0
- package/es/charts/CallOffDeliveries/model.js +59 -0
- package/es/charts/ProductionPlan/PlanValueDialog.d.ts +14 -0
- package/es/charts/ProductionPlan/PlanValueDialog.js +47 -0
- package/es/charts/ProductionPlan/chartOptions.d.ts +20 -0
- package/es/charts/ProductionPlan/chartOptions.js +353 -0
- package/es/charts/ProductionPlan/data.d.ts +105 -0
- package/es/charts/ProductionPlan/data.js +61 -0
- package/es/charts/ProductionPlan/index.css +1 -0
- package/es/charts/ProductionPlan/index.d.ts +31 -0
- package/es/charts/ProductionPlan/index.js +203 -0
- package/es/charts/ProductionPlan/model.d.ts +29 -0
- package/es/charts/ProductionPlan/model.js +65 -0
- package/es/charts/Pumping/chartOptions.d.ts +12 -0
- package/es/charts/Pumping/chartOptions.js +197 -0
- package/es/charts/Pumping/data.d.ts +65 -0
- package/es/charts/Pumping/data.js +20 -0
- package/es/charts/Pumping/index.css +1 -0
- package/es/charts/Pumping/index.d.ts +27 -0
- package/es/charts/Pumping/index.js +124 -0
- package/es/charts/Pumping/model.d.ts +34 -0
- package/es/charts/Pumping/model.js +88 -0
- package/es/charts/UnboundPreview/chartOptions.d.ts +3 -0
- package/es/charts/UnboundPreview/chartOptions.js +126 -0
- package/es/charts/UnboundPreview/index.css +1 -0
- package/es/charts/UnboundPreview/index.d.ts +20 -0
- package/es/charts/UnboundPreview/index.js +55 -0
- package/es/charts/UnboundPreview/model.d.ts +49 -0
- package/es/charts/UnboundPreview/model.js +67 -0
- package/es/charts/VehicleDeliveries/chartOptions.d.ts +13 -0
- package/es/charts/VehicleDeliveries/chartOptions.js +270 -0
- package/es/charts/VehicleDeliveries/data.d.ts +71 -0
- package/es/charts/VehicleDeliveries/data.js +20 -0
- package/es/charts/VehicleDeliveries/deliveryXRange.d.ts +4 -0
- package/es/charts/VehicleDeliveries/deliveryXRange.js +62 -0
- package/es/charts/VehicleDeliveries/index.css +1 -0
- package/es/charts/VehicleDeliveries/index.d.ts +24 -0
- package/es/charts/VehicleDeliveries/index.js +129 -0
- package/es/charts/VehicleDeliveries/model.d.ts +24 -0
- package/es/charts/VehicleDeliveries/model.js +106 -0
- package/es/charts/format.d.ts +12 -0
- package/es/charts/format.js +34 -0
- package/es/charts/index.d.ts +5 -0
- package/es/charts/index.js +5 -0
- package/es/charts/storage.d.ts +5 -0
- package/es/charts/storage.js +35 -0
- package/es/chrome/assistant.d.ts +75 -0
- package/es/chrome/assistant.js +116 -0
- package/es/components/ColorCard/index.css +8 -8
- package/es/index.css +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.d.ts +4 -0
- package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.js +51 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.d.ts +99 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.js +499 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.d.ts +13 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.js +69 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.d.ts +33 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.js +164 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.d.ts +15 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.js +80 -0
- package/es/vehicles/VehicleInfoDialog/formatting.d.ts +13 -0
- package/es/vehicles/VehicleInfoDialog/formatting.js +48 -0
- package/es/vehicles/VehicleInfoDialog/index.css +1 -0
- package/es/vehicles/VehicleInfoDialog/index.d.ts +11 -0
- package/es/vehicles/VehicleInfoDialog/index.js +46 -0
- package/es/vehicles/VehicleInfoDialog/tabs.d.ts +6 -0
- package/es/vehicles/VehicleInfoDialog/tabs.js +85 -0
- package/es/vehicles/index.d.ts +1 -0
- package/es/vehicles/index.js +1 -0
- package/package.json +17 -8
- package/src/charts/CallOffDeliveries/TicketScanDialog.tsx +79 -0
- package/src/charts/CallOffDeliveries/chartOptions.ts +160 -0
- package/src/charts/CallOffDeliveries/data.ts +67 -0
- package/src/charts/CallOffDeliveries/index.scss +51 -0
- package/src/charts/CallOffDeliveries/index.tsx +217 -0
- package/src/charts/CallOffDeliveries/model.test.ts +90 -0
- package/src/charts/CallOffDeliveries/model.ts +87 -0
- package/src/charts/ProductionPlan/PlanValueDialog.tsx +107 -0
- package/src/charts/ProductionPlan/chartOptions.ts +406 -0
- package/src/charts/ProductionPlan/data.ts +170 -0
- package/src/charts/ProductionPlan/index.scss +148 -0
- package/src/charts/ProductionPlan/index.tsx +432 -0
- package/src/charts/ProductionPlan/model.test.ts +132 -0
- package/src/charts/ProductionPlan/model.ts +102 -0
- package/src/charts/Pumping/chartOptions.ts +224 -0
- package/src/charts/Pumping/data.ts +91 -0
- package/src/charts/Pumping/index.scss +42 -0
- package/src/charts/Pumping/index.tsx +222 -0
- package/src/charts/Pumping/model.test.ts +122 -0
- package/src/charts/Pumping/model.ts +104 -0
- package/src/charts/UnboundPreview/chartOptions.ts +137 -0
- package/src/charts/UnboundPreview/index.scss +17 -0
- package/src/charts/UnboundPreview/index.tsx +100 -0
- package/src/charts/UnboundPreview/model.test.ts +129 -0
- package/src/charts/UnboundPreview/model.ts +110 -0
- package/src/charts/VehicleDeliveries/chartOptions.ts +311 -0
- package/src/charts/VehicleDeliveries/data.ts +98 -0
- package/src/charts/VehicleDeliveries/deliveryXRange.ts +80 -0
- package/src/charts/VehicleDeliveries/index.scss +43 -0
- package/src/charts/VehicleDeliveries/index.tsx +262 -0
- package/src/charts/VehicleDeliveries/model.test.ts +117 -0
- package/src/charts/VehicleDeliveries/model.ts +139 -0
- package/src/charts/format.ts +38 -0
- package/src/charts/index.ts +20 -0
- package/src/charts/storage.ts +36 -0
- package/src/chrome/assistant.test.tsx +106 -0
- package/src/chrome/assistant.ts +178 -0
- package/src/components/ColorCard/index.css +8 -8
- package/src/index.ts +9 -0
- package/src/vehicles/VehicleInfoDialog/OutOfServiceForm.tsx +127 -0
- package/src/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.ts +600 -0
- package/src/vehicles/VehicleInfoDialog/data/dsDriverStatus.ts +84 -0
- package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfo.ts +198 -0
- package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.ts +97 -0
- package/src/vehicles/VehicleInfoDialog/formatting.test.ts +57 -0
- package/src/vehicles/VehicleInfoDialog/formatting.ts +58 -0
- package/src/vehicles/VehicleInfoDialog/index.scss +131 -0
- package/src/vehicles/VehicleInfoDialog/index.tsx +106 -0
- package/src/vehicles/VehicleInfoDialog/tabs.tsx +188 -0
- package/src/vehicles/index.ts +1 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { generateApiDataObject } from "@olenbetong/appframe-data";
|
|
2
|
+
|
|
3
|
+
export type VehicleInfoRecord = {
|
|
4
|
+
PrimKey: string;
|
|
5
|
+
ObjectID: number;
|
|
6
|
+
ObjectNo: number;
|
|
7
|
+
LocationID: number | null;
|
|
8
|
+
LastStartLocationID: number | null;
|
|
9
|
+
RegistrationNo: string | null;
|
|
10
|
+
Model: string | null;
|
|
11
|
+
Manufacturer: string | null;
|
|
12
|
+
ProductionYear: number | null;
|
|
13
|
+
Type: string | null;
|
|
14
|
+
TypeName: string | null;
|
|
15
|
+
ParentType: string | null;
|
|
16
|
+
ParentTypeName: string | null;
|
|
17
|
+
Image: string | null;
|
|
18
|
+
GPSID: string | null;
|
|
19
|
+
BoomLength: number | null;
|
|
20
|
+
LastDeliveryTicketID: number | null;
|
|
21
|
+
Inoperable: boolean | null;
|
|
22
|
+
InoperableID: number | null;
|
|
23
|
+
InoperableComment: string | null;
|
|
24
|
+
PlannedInoperable: boolean | null;
|
|
25
|
+
PlannedInoperableID: number | null;
|
|
26
|
+
PlannedInoperableComment: string | null;
|
|
27
|
+
PlannedInoperableFromDateTime: Date | null;
|
|
28
|
+
PlannedInoperableToDateTime: Date | null;
|
|
29
|
+
PositionTimestamp: Date | null;
|
|
30
|
+
PositionText: string | null;
|
|
31
|
+
Latitude: number | null;
|
|
32
|
+
Longitude: number | null;
|
|
33
|
+
PersonID: string | null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const dsVehicleInfo = generateApiDataObject<VehicleInfoRecord>({
|
|
37
|
+
resource: "aviw_Plant_CallOffs_Chart_VehicleInfo",
|
|
38
|
+
id: "dsVehicleInfo",
|
|
39
|
+
allowUpdate: false,
|
|
40
|
+
allowInsert: false,
|
|
41
|
+
allowDelete: false,
|
|
42
|
+
dynamicLoading: false,
|
|
43
|
+
fields: [
|
|
44
|
+
{
|
|
45
|
+
name: "PrimKey",
|
|
46
|
+
type: "string",
|
|
47
|
+
nullable: false,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "ObjectID",
|
|
51
|
+
type: "number",
|
|
52
|
+
nullable: false,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "ObjectNo",
|
|
56
|
+
type: "number",
|
|
57
|
+
nullable: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "LocationID",
|
|
61
|
+
type: "number",
|
|
62
|
+
nullable: true,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "LastStartLocationID",
|
|
66
|
+
type: "number",
|
|
67
|
+
nullable: true,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "RegistrationNo",
|
|
71
|
+
type: "string",
|
|
72
|
+
nullable: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "Model",
|
|
76
|
+
type: "string",
|
|
77
|
+
nullable: true,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "Manufacturer",
|
|
81
|
+
type: "string",
|
|
82
|
+
nullable: true,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "ProductionYear",
|
|
86
|
+
type: "number",
|
|
87
|
+
nullable: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "Type",
|
|
91
|
+
type: "string",
|
|
92
|
+
nullable: true,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "TypeName",
|
|
96
|
+
type: "string",
|
|
97
|
+
nullable: true,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "ParentType",
|
|
101
|
+
type: "string",
|
|
102
|
+
nullable: true,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "ParentTypeName",
|
|
106
|
+
type: "string",
|
|
107
|
+
nullable: true,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "Image",
|
|
111
|
+
type: "string",
|
|
112
|
+
nullable: true,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "GPSID",
|
|
116
|
+
type: "string",
|
|
117
|
+
nullable: true,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "BoomLength",
|
|
121
|
+
type: "number",
|
|
122
|
+
nullable: true,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "LastDeliveryTicketID",
|
|
126
|
+
type: "number",
|
|
127
|
+
nullable: true,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "Inoperable",
|
|
131
|
+
type: "boolean",
|
|
132
|
+
nullable: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "InoperableID",
|
|
136
|
+
type: "number",
|
|
137
|
+
nullable: true,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "InoperableComment",
|
|
141
|
+
type: "string",
|
|
142
|
+
nullable: true,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "PlannedInoperable",
|
|
146
|
+
type: "boolean",
|
|
147
|
+
nullable: true,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "PlannedInoperableID",
|
|
151
|
+
type: "number",
|
|
152
|
+
nullable: true,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "PlannedInoperableComment",
|
|
156
|
+
type: "string",
|
|
157
|
+
nullable: true,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "PlannedInoperableFromDateTime",
|
|
161
|
+
type: "datetime",
|
|
162
|
+
nullable: true,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "PlannedInoperableToDateTime",
|
|
166
|
+
type: "datetime",
|
|
167
|
+
nullable: true,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "PositionTimestamp",
|
|
171
|
+
type: "datetime",
|
|
172
|
+
nullable: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "PositionText",
|
|
176
|
+
type: "string",
|
|
177
|
+
nullable: true,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "Latitude",
|
|
181
|
+
type: "number",
|
|
182
|
+
nullable: true,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "Longitude",
|
|
186
|
+
type: "number",
|
|
187
|
+
nullable: true,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "PersonID",
|
|
191
|
+
type: "string",
|
|
192
|
+
nullable: true,
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
parameters: {
|
|
196
|
+
maxRecords: 50,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { generateApiDataObject } from "@olenbetong/appframe-data";
|
|
2
|
+
|
|
3
|
+
import { dsVehicleInfo } from "./dsVehicleInfo.js";
|
|
4
|
+
|
|
5
|
+
export type VehicleInfoLogRecord = {
|
|
6
|
+
PrimKey: string;
|
|
7
|
+
Created: Date;
|
|
8
|
+
CreatedBy: string;
|
|
9
|
+
Updated: Date;
|
|
10
|
+
UpdatedBy: string;
|
|
11
|
+
ID: number;
|
|
12
|
+
ObjectID: number;
|
|
13
|
+
FromDateTime: Date;
|
|
14
|
+
ToDateTime: Date;
|
|
15
|
+
OutOfService: boolean;
|
|
16
|
+
Comment: string;
|
|
17
|
+
IsPlanned: boolean | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const dsVehicleInfoLog = generateApiDataObject<VehicleInfoLogRecord>({
|
|
21
|
+
resource: "aviw_Plant_CallOffs_Chart_VehicleInfoOOLog",
|
|
22
|
+
id: "dsVehicleInfoLog",
|
|
23
|
+
masterDataObject: dsVehicleInfo as any,
|
|
24
|
+
linkFields: {
|
|
25
|
+
ObjectID: "ObjectID",
|
|
26
|
+
},
|
|
27
|
+
allowUpdate: true,
|
|
28
|
+
allowInsert: true,
|
|
29
|
+
allowDelete: true,
|
|
30
|
+
dynamicLoading: false,
|
|
31
|
+
fields: [
|
|
32
|
+
{
|
|
33
|
+
name: "PrimKey",
|
|
34
|
+
type: "string",
|
|
35
|
+
nullable: false,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "Created",
|
|
39
|
+
type: "datetime",
|
|
40
|
+
nullable: false,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "CreatedBy",
|
|
44
|
+
type: "string",
|
|
45
|
+
nullable: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "Updated",
|
|
49
|
+
type: "datetime",
|
|
50
|
+
nullable: false,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "UpdatedBy",
|
|
54
|
+
type: "string",
|
|
55
|
+
nullable: false,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "ID",
|
|
59
|
+
type: "number",
|
|
60
|
+
nullable: false,
|
|
61
|
+
identity: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "ObjectID",
|
|
65
|
+
type: "number",
|
|
66
|
+
nullable: false,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "FromDateTime",
|
|
70
|
+
type: "datetime",
|
|
71
|
+
nullable: false,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "ToDateTime",
|
|
75
|
+
type: "datetime",
|
|
76
|
+
nullable: false,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "OutOfService",
|
|
80
|
+
type: "boolean",
|
|
81
|
+
nullable: false,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "Comment",
|
|
85
|
+
type: "string",
|
|
86
|
+
nullable: false,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "IsPlanned",
|
|
90
|
+
type: "boolean",
|
|
91
|
+
nullable: true,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
parameters: {
|
|
95
|
+
maxRecords: 50,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { formatMinutes, formatPeriod, fromInputs, getNewPeriod, toDateInput, toTimeInput } from "./formatting.js";
|
|
4
|
+
|
|
5
|
+
describe("inputs", () => {
|
|
6
|
+
it("round-trips the wall clock time", () => {
|
|
7
|
+
let value = new Date("2026-11-09T08:15:00.000Z");
|
|
8
|
+
|
|
9
|
+
expect(toDateInput(value)).toBe("2026-11-09");
|
|
10
|
+
expect(toTimeInput(value)).toBe("08:15");
|
|
11
|
+
expect(fromInputs("2026-11-09", "08:15")).toEqual(value);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("gives null for an incomplete input", () => {
|
|
15
|
+
expect(fromInputs("", "08:15")).toBeNull();
|
|
16
|
+
expect(fromInputs("2026-11-09", "")).toBeNull();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("formatMinutes", () => {
|
|
21
|
+
it("leaves out empty parts", () => {
|
|
22
|
+
expect(formatMinutes(125)).toBe("2t 5m");
|
|
23
|
+
expect(formatMinutes(120)).toBe("2t");
|
|
24
|
+
expect(formatMinutes(5)).toBe("5m");
|
|
25
|
+
expect(formatMinutes(0)).toBe("");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("formatPeriod", () => {
|
|
30
|
+
it("is empty without both ends of the period", () => {
|
|
31
|
+
expect(formatPeriod(null, new Date())).toBe("");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("repeats the date only when the period runs over midnight", () => {
|
|
35
|
+
let from = new Date("2026-11-09T08:00:00Z");
|
|
36
|
+
|
|
37
|
+
expect(formatPeriod(from, new Date("2026-11-09T12:00:00Z"))).toMatch(/→ 12:00$/);
|
|
38
|
+
expect(formatPeriod(from, new Date("2026-11-10T12:00:00Z"))).toMatch(/→ .*2026.*12:00$/);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("getNewPeriod", () => {
|
|
43
|
+
let now = new Date("2026-11-09T10:00:00Z");
|
|
44
|
+
|
|
45
|
+
it("uses the working day of a future date", () => {
|
|
46
|
+
let { from, to } = getNewPeriod(new Date("2026-11-12T00:00:00Z"), now);
|
|
47
|
+
|
|
48
|
+
expect(from.toISOString()).toBe("2026-11-12T06:00:00.000Z");
|
|
49
|
+
expect(to.toISOString()).toBe("2026-11-12T16:00:00.000Z");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("uses the next two hours otherwise", () => {
|
|
53
|
+
let { from, to } = getNewPeriod(new Date("2026-11-01T00:00:00Z"), now);
|
|
54
|
+
|
|
55
|
+
expect(to.getTime() - from.getTime()).toBe(2 * 3600000);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Times in these views are wall clock times carried as UTC, so everything here reads and writes
|
|
3
|
+
* the UTC fields and never involves the browser's own time zone.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function toDateInput(value: Date) {
|
|
7
|
+
return value.toISOString().slice(0, 10);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function toTimeInput(value: Date) {
|
|
11
|
+
return value.toISOString().slice(11, 16);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The new value for the date or time part, or null while the input is incomplete. */
|
|
15
|
+
export function fromInputs(date: string, time: string) {
|
|
16
|
+
let value = new Date(`${date}T${time}:00Z`);
|
|
17
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function formatDateTime(value: unknown) {
|
|
21
|
+
if (!(value instanceof Date)) return value as React.ReactNode;
|
|
22
|
+
|
|
23
|
+
return new Intl.DateTimeFormat(globalThis.af?.userSession?.culture, {
|
|
24
|
+
year: "numeric",
|
|
25
|
+
month: "2-digit",
|
|
26
|
+
day: "2-digit",
|
|
27
|
+
hour: "2-digit",
|
|
28
|
+
minute: "2-digit",
|
|
29
|
+
timeZone: "UTC",
|
|
30
|
+
}).format(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** "01.02.2026, 08:00 → 12:00", with the end date only when the period runs over midnight. */
|
|
34
|
+
export function formatPeriod(from: Date | null, to: Date | null) {
|
|
35
|
+
if (!from || !to) return "";
|
|
36
|
+
|
|
37
|
+
let end = toDateInput(from) === toDateInput(to) ? toTimeInput(to) : formatDateTime(to);
|
|
38
|
+
return `${formatDateTime(from)} → ${end}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function formatMinutes(minutes: number) {
|
|
42
|
+
let hours = Math.trunc(minutes / 60);
|
|
43
|
+
let remainder = minutes % 60;
|
|
44
|
+
|
|
45
|
+
return [hours > 0 && `${hours}t`, remainder > 0 && `${remainder}m`].filter(Boolean).join(" ");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A new inactive period: the working day of a future date, otherwise two hours from now. */
|
|
49
|
+
export function getNewPeriod(selectedDate: Date | undefined, now: Date) {
|
|
50
|
+
let current = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
|
|
51
|
+
|
|
52
|
+
if (selectedDate && selectedDate > current) {
|
|
53
|
+
let from = new Date(selectedDate.getTime() + 6 * 3600000);
|
|
54
|
+
return { from, to: new Date(from.getTime() + 10 * 3600000) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { from: current, to: new Date(current.getTime() + 2 * 3600000) };
|
|
58
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
.ObVehicleInfo-dialog {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
|
|
6
|
+
// Tall enough for the vehicle tab with a few inactive periods. Below this width the dialog is full screen.
|
|
7
|
+
@media (min-width: 900px) {
|
|
8
|
+
--dsc-dialog-max-height: calc(100dvh - 2rem);
|
|
9
|
+
height: min(46rem, calc(100dvh - 2rem));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
> button[data-command="close"],
|
|
13
|
+
> button[command="close"],
|
|
14
|
+
> form[method="dialog"]:first-child {
|
|
15
|
+
position: absolute;
|
|
16
|
+
inset-block-start: var(--ds-size-2);
|
|
17
|
+
inset-inline-end: var(--ds-size-2);
|
|
18
|
+
margin: 0;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ObVehicleInfo-tabs {
|
|
24
|
+
--dsc-tabs-content-padding: 0;
|
|
25
|
+
--dsc-tabs-list-border-bottom-width: 0;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex: 1;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
min-height: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ObVehicleInfo-header {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex: none;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
gap: 1rem;
|
|
38
|
+
padding-block: var(--ds-size-2) 0;
|
|
39
|
+
padding-inline-end: 3.5rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ObVehicleInfo-content {
|
|
43
|
+
flex: 1;
|
|
44
|
+
min-height: 0;
|
|
45
|
+
overflow-y: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Lines the headings up with the text in the tables, which have padding for the striped rows.
|
|
49
|
+
.ObVehicleInfo-tab > :is(h3, h4) {
|
|
50
|
+
padding-inline: var(--ds-size-3);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.ObVehicleInfo-tab,
|
|
54
|
+
.ObVehicleInfo-form {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: 1rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ObVehicleInfo-columns {
|
|
61
|
+
display: grid;
|
|
62
|
+
grid-template-columns: 7fr 5fr;
|
|
63
|
+
gap: 0.5rem;
|
|
64
|
+
align-items: start;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ObVehicleInfo-table {
|
|
68
|
+
table-layout: fixed;
|
|
69
|
+
width: 100%;
|
|
70
|
+
|
|
71
|
+
// The same column width in every table, whatever the values in it.
|
|
72
|
+
td:first-child {
|
|
73
|
+
width: 45%;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ObVehicleInfo-image {
|
|
78
|
+
max-width: 100%;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ObVehicleInfo-placeholder {
|
|
82
|
+
font-size: 10rem;
|
|
83
|
+
opacity: 0.4;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ObVehicleInfo-periods {
|
|
87
|
+
list-style: none;
|
|
88
|
+
margin: 0;
|
|
89
|
+
padding: 0;
|
|
90
|
+
|
|
91
|
+
button {
|
|
92
|
+
display: flex;
|
|
93
|
+
gap: 0.75rem;
|
|
94
|
+
align-items: center;
|
|
95
|
+
width: 100%;
|
|
96
|
+
padding: 0.5rem;
|
|
97
|
+
border: 0;
|
|
98
|
+
border-block-end: 1px solid var(--ds-color-neutral-border-subtle);
|
|
99
|
+
background: none;
|
|
100
|
+
color: inherit;
|
|
101
|
+
font: inherit;
|
|
102
|
+
text-align: start;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
|
|
105
|
+
&:hover {
|
|
106
|
+
background-color: var(--ds-color-neutral-surface-tinted);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
svg {
|
|
110
|
+
flex-shrink: 0;
|
|
111
|
+
font-size: 1.75rem;
|
|
112
|
+
color: var(--ds-color-danger-text-subtle);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.ObVehicleInfo-period {
|
|
118
|
+
display: flex;
|
|
119
|
+
gap: 1rem;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.ObVehicleInfo-actions {
|
|
123
|
+
display: flex;
|
|
124
|
+
flex: none;
|
|
125
|
+
justify-content: flex-end;
|
|
126
|
+
gap: 0.5rem;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.ObVehicleInfo-actions-start {
|
|
130
|
+
margin-inline-end: auto;
|
|
131
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Button, Dialog, Tabs, Tag } from "@digdir/designsystemet-react";
|
|
2
|
+
import { PlusIcon, TruckIcon } from "@navikt/aksel-icons";
|
|
3
|
+
import { ResponsiveDialog } from "@olenbetong/appframe-ds";
|
|
4
|
+
import { useCurrentRow } from "@olenbetong/appframe-react";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
|
|
7
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
8
|
+
import { dsVehicleInfo } from "./data/dsVehicleInfo.js";
|
|
9
|
+
import { dsVehicleInfoLog } from "./data/dsVehicleInfoLog.js";
|
|
10
|
+
import { getNewPeriod } from "./formatting.js";
|
|
11
|
+
import { OutOfServiceForm } from "./OutOfServiceForm.js";
|
|
12
|
+
import { DeliveryTicketTab, DriverTab, MapTab, VehicleTab } from "./tabs.js";
|
|
13
|
+
|
|
14
|
+
import "./index.scss";
|
|
15
|
+
|
|
16
|
+
export type VehicleInfoDialogProps = {
|
|
17
|
+
/** The vehicle to show. The dialog is closed while this is null. */
|
|
18
|
+
vehicleId: number | null;
|
|
19
|
+
/** The day being looked at, the default for a new inactive period when it is in the future. */
|
|
20
|
+
date?: Date;
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
onOutOfServiceChanged?: () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** A vehicle's details, last delivery ticket, driver and position, and its inactive periods. */
|
|
26
|
+
export function VehicleInfoDialog({ vehicleId, date, onClose, onOutOfServiceChanged }: VehicleInfoDialogProps) {
|
|
27
|
+
let [tab, setTab] = useState("vehicle");
|
|
28
|
+
let [formOpen, setFormOpen] = useState(false);
|
|
29
|
+
let row = useCurrentRow(dsVehicleInfo);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (vehicleId === null) return;
|
|
33
|
+
|
|
34
|
+
dsVehicleInfo.recordSource.setWhereClause(`[ObjectNo] = ${vehicleId}`);
|
|
35
|
+
dsVehicleInfo.refreshDataSource();
|
|
36
|
+
}, [vehicleId]);
|
|
37
|
+
|
|
38
|
+
if (vehicleId === null) return null;
|
|
39
|
+
|
|
40
|
+
function addPeriod() {
|
|
41
|
+
let { from, to } = getNewPeriod(date, new Date());
|
|
42
|
+
|
|
43
|
+
dsVehicleInfoLog.setCurrentIndex(-1);
|
|
44
|
+
dsVehicleInfoLog.currentRow("FromDateTime", from);
|
|
45
|
+
dsVehicleInfoLog.currentRow("ToDateTime", to);
|
|
46
|
+
dsVehicleInfoLog.currentRow("OutOfService", true);
|
|
47
|
+
setFormOpen(true);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function editPeriod(id: number) {
|
|
51
|
+
let index = dsVehicleInfoLog.getData().findIndex((period) => period.ID === id);
|
|
52
|
+
if (index >= 0) {
|
|
53
|
+
dsVehicleInfoLog.setCurrentIndex(index);
|
|
54
|
+
setFormOpen(true);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<ResponsiveDialog open onClose={onClose} maxWidth="sm" className="ObVehicleInfo-dialog">
|
|
60
|
+
<Tabs value={tab} onChange={setTab} className="ObVehicleInfo-tabs">
|
|
61
|
+
<Dialog.Block className="ObVehicleInfo-header">
|
|
62
|
+
<Tabs.List>
|
|
63
|
+
<Tabs.Tab value="vehicle">{getLocalizedString("Vehicle")}</Tabs.Tab>
|
|
64
|
+
<Tabs.Tab value="ticket">{getLocalizedString("Delivery ticket")}</Tabs.Tab>
|
|
65
|
+
<Tabs.Tab value="driver">{getLocalizedString("Driver")}</Tabs.Tab>
|
|
66
|
+
<Tabs.Tab value="map">{getLocalizedString("Map")}</Tabs.Tab>
|
|
67
|
+
</Tabs.List>
|
|
68
|
+
<Tag data-color="neutral">
|
|
69
|
+
<TruckIcon aria-hidden /> {row.ObjectNo}
|
|
70
|
+
</Tag>
|
|
71
|
+
</Dialog.Block>
|
|
72
|
+
<Dialog.Block className="ObVehicleInfo-content">
|
|
73
|
+
<Tabs.Panel value="vehicle">
|
|
74
|
+
<VehicleTab onEditPeriod={editPeriod} />
|
|
75
|
+
</Tabs.Panel>
|
|
76
|
+
<Tabs.Panel value="ticket">
|
|
77
|
+
<DeliveryTicketTab />
|
|
78
|
+
</Tabs.Panel>
|
|
79
|
+
<Tabs.Panel value="driver">
|
|
80
|
+
<DriverTab />
|
|
81
|
+
</Tabs.Panel>
|
|
82
|
+
<Tabs.Panel value="map">
|
|
83
|
+
<MapTab />
|
|
84
|
+
</Tabs.Panel>
|
|
85
|
+
</Dialog.Block>
|
|
86
|
+
</Tabs>
|
|
87
|
+
<Dialog.Block className="ObVehicleInfo-actions">
|
|
88
|
+
<Button variant="secondary" className="ObVehicleInfo-actions-start" onClick={addPeriod}>
|
|
89
|
+
<PlusIcon aria-hidden /> {getLocalizedString("Add inactive period")}
|
|
90
|
+
</Button>
|
|
91
|
+
<Button variant="tertiary" onClick={onClose}>
|
|
92
|
+
{getLocalizedString("Close")}
|
|
93
|
+
</Button>
|
|
94
|
+
</Dialog.Block>
|
|
95
|
+
{formOpen && (
|
|
96
|
+
<OutOfServiceForm
|
|
97
|
+
onClose={() => setFormOpen(false)}
|
|
98
|
+
onSaved={() => {
|
|
99
|
+
setFormOpen(false);
|
|
100
|
+
onOutOfServiceChanged?.();
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
)}
|
|
104
|
+
</ResponsiveDialog>
|
|
105
|
+
);
|
|
106
|
+
}
|