@olenbetong/synergi-react 5.3.1 → 5.5.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/components/ColorCard/index.css +8 -8
- package/es/components/ImageEditor/ImageEditor.d.ts +6 -0
- package/es/components/ImageEditor/ImageEditor.js +6 -2
- package/es/components/ImageEditor/ResponsiveButton.d.ts +2 -1
- package/es/components/ImageEditor/ResponsiveButton.js +3 -3
- package/es/components/ImageEditor/plugins/cropPlugin/CropContext.d.ts +2 -1
- package/es/components/ImageEditor/plugins/cropPlugin/CropContext.js +2 -2
- package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +27 -7
- package/es/components/ImageEditor/types.d.ts +5 -0
- package/es/index.css +1 -1
- 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 +19 -10
- 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/components/ColorCard/index.css +8 -8
- package/src/components/ImageEditor/ImageEditor.test.tsx +103 -0
- package/src/components/ImageEditor/ImageEditor.tsx +18 -2
- package/src/components/ImageEditor/ResponsiveButton.tsx +4 -3
- package/src/components/ImageEditor/plugins/cropPlugin/CropContext.tsx +5 -2
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.test.tsx +118 -0
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +52 -18
- package/src/components/ImageEditor/types.ts +5 -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,164 @@
|
|
|
1
|
+
import { generateApiDataObject } from "@olenbetong/appframe-data";
|
|
2
|
+
export const dsVehicleInfo = generateApiDataObject({
|
|
3
|
+
resource: "aviw_Plant_CallOffs_Chart_VehicleInfo",
|
|
4
|
+
id: "dsVehicleInfo",
|
|
5
|
+
allowUpdate: false,
|
|
6
|
+
allowInsert: false,
|
|
7
|
+
allowDelete: false,
|
|
8
|
+
dynamicLoading: false,
|
|
9
|
+
fields: [
|
|
10
|
+
{
|
|
11
|
+
name: "PrimKey",
|
|
12
|
+
type: "string",
|
|
13
|
+
nullable: false,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "ObjectID",
|
|
17
|
+
type: "number",
|
|
18
|
+
nullable: false,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "ObjectNo",
|
|
22
|
+
type: "number",
|
|
23
|
+
nullable: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "LocationID",
|
|
27
|
+
type: "number",
|
|
28
|
+
nullable: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "LastStartLocationID",
|
|
32
|
+
type: "number",
|
|
33
|
+
nullable: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "RegistrationNo",
|
|
37
|
+
type: "string",
|
|
38
|
+
nullable: true,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "Model",
|
|
42
|
+
type: "string",
|
|
43
|
+
nullable: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Manufacturer",
|
|
47
|
+
type: "string",
|
|
48
|
+
nullable: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "ProductionYear",
|
|
52
|
+
type: "number",
|
|
53
|
+
nullable: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Type",
|
|
57
|
+
type: "string",
|
|
58
|
+
nullable: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "TypeName",
|
|
62
|
+
type: "string",
|
|
63
|
+
nullable: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "ParentType",
|
|
67
|
+
type: "string",
|
|
68
|
+
nullable: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "ParentTypeName",
|
|
72
|
+
type: "string",
|
|
73
|
+
nullable: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "Image",
|
|
77
|
+
type: "string",
|
|
78
|
+
nullable: true,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "GPSID",
|
|
82
|
+
type: "string",
|
|
83
|
+
nullable: true,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "BoomLength",
|
|
87
|
+
type: "number",
|
|
88
|
+
nullable: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "LastDeliveryTicketID",
|
|
92
|
+
type: "number",
|
|
93
|
+
nullable: true,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "Inoperable",
|
|
97
|
+
type: "boolean",
|
|
98
|
+
nullable: true,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "InoperableID",
|
|
102
|
+
type: "number",
|
|
103
|
+
nullable: true,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "InoperableComment",
|
|
107
|
+
type: "string",
|
|
108
|
+
nullable: true,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "PlannedInoperable",
|
|
112
|
+
type: "boolean",
|
|
113
|
+
nullable: true,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "PlannedInoperableID",
|
|
117
|
+
type: "number",
|
|
118
|
+
nullable: true,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "PlannedInoperableComment",
|
|
122
|
+
type: "string",
|
|
123
|
+
nullable: true,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "PlannedInoperableFromDateTime",
|
|
127
|
+
type: "datetime",
|
|
128
|
+
nullable: true,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "PlannedInoperableToDateTime",
|
|
132
|
+
type: "datetime",
|
|
133
|
+
nullable: true,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "PositionTimestamp",
|
|
137
|
+
type: "datetime",
|
|
138
|
+
nullable: true,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "PositionText",
|
|
142
|
+
type: "string",
|
|
143
|
+
nullable: true,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "Latitude",
|
|
147
|
+
type: "number",
|
|
148
|
+
nullable: true,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "Longitude",
|
|
152
|
+
type: "number",
|
|
153
|
+
nullable: true,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "PersonID",
|
|
157
|
+
type: "string",
|
|
158
|
+
nullable: true,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
parameters: {
|
|
162
|
+
maxRecords: 50,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type VehicleInfoLogRecord = {
|
|
2
|
+
PrimKey: string;
|
|
3
|
+
Created: Date;
|
|
4
|
+
CreatedBy: string;
|
|
5
|
+
Updated: Date;
|
|
6
|
+
UpdatedBy: string;
|
|
7
|
+
ID: number;
|
|
8
|
+
ObjectID: number;
|
|
9
|
+
FromDateTime: Date;
|
|
10
|
+
ToDateTime: Date;
|
|
11
|
+
OutOfService: boolean;
|
|
12
|
+
Comment: string;
|
|
13
|
+
IsPlanned: boolean | null;
|
|
14
|
+
};
|
|
15
|
+
export declare const dsVehicleInfoLog: import("@olenbetong/appframe-data").DataObject<VehicleInfoLogRecord>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { generateApiDataObject } from "@olenbetong/appframe-data";
|
|
2
|
+
import { dsVehicleInfo } from "./dsVehicleInfo.js";
|
|
3
|
+
export const dsVehicleInfoLog = generateApiDataObject({
|
|
4
|
+
resource: "aviw_Plant_CallOffs_Chart_VehicleInfoOOLog",
|
|
5
|
+
id: "dsVehicleInfoLog",
|
|
6
|
+
masterDataObject: dsVehicleInfo,
|
|
7
|
+
linkFields: {
|
|
8
|
+
ObjectID: "ObjectID",
|
|
9
|
+
},
|
|
10
|
+
allowUpdate: true,
|
|
11
|
+
allowInsert: true,
|
|
12
|
+
allowDelete: true,
|
|
13
|
+
dynamicLoading: false,
|
|
14
|
+
fields: [
|
|
15
|
+
{
|
|
16
|
+
name: "PrimKey",
|
|
17
|
+
type: "string",
|
|
18
|
+
nullable: false,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "Created",
|
|
22
|
+
type: "datetime",
|
|
23
|
+
nullable: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "CreatedBy",
|
|
27
|
+
type: "string",
|
|
28
|
+
nullable: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "Updated",
|
|
32
|
+
type: "datetime",
|
|
33
|
+
nullable: false,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "UpdatedBy",
|
|
37
|
+
type: "string",
|
|
38
|
+
nullable: false,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "ID",
|
|
42
|
+
type: "number",
|
|
43
|
+
nullable: false,
|
|
44
|
+
identity: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "ObjectID",
|
|
48
|
+
type: "number",
|
|
49
|
+
nullable: false,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "FromDateTime",
|
|
53
|
+
type: "datetime",
|
|
54
|
+
nullable: false,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "ToDateTime",
|
|
58
|
+
type: "datetime",
|
|
59
|
+
nullable: false,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "OutOfService",
|
|
63
|
+
type: "boolean",
|
|
64
|
+
nullable: false,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "Comment",
|
|
68
|
+
type: "string",
|
|
69
|
+
nullable: false,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "IsPlanned",
|
|
73
|
+
type: "boolean",
|
|
74
|
+
nullable: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
parameters: {
|
|
78
|
+
maxRecords: 50,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function toDateInput(value: Date): string;
|
|
2
|
+
export declare function toTimeInput(value: Date): string;
|
|
3
|
+
/** The new value for the date or time part, or null while the input is incomplete. */
|
|
4
|
+
export declare function fromInputs(date: string, time: string): Date | null;
|
|
5
|
+
export declare function formatDateTime(value: unknown): import("react").ReactNode;
|
|
6
|
+
/** "01.02.2026, 08:00 → 12:00", with the end date only when the period runs over midnight. */
|
|
7
|
+
export declare function formatPeriod(from: Date | null, to: Date | null): string;
|
|
8
|
+
export declare function formatMinutes(minutes: number): string;
|
|
9
|
+
/** A new inactive period: the working day of a future date, otherwise two hours from now. */
|
|
10
|
+
export declare function getNewPeriod(selectedDate: Date | undefined, now: Date): {
|
|
11
|
+
from: Date;
|
|
12
|
+
to: Date;
|
|
13
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
export function toDateInput(value) {
|
|
6
|
+
return value.toISOString().slice(0, 10);
|
|
7
|
+
}
|
|
8
|
+
export function toTimeInput(value) {
|
|
9
|
+
return value.toISOString().slice(11, 16);
|
|
10
|
+
}
|
|
11
|
+
/** The new value for the date or time part, or null while the input is incomplete. */
|
|
12
|
+
export function fromInputs(date, time) {
|
|
13
|
+
let value = new Date(`${date}T${time}:00Z`);
|
|
14
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
15
|
+
}
|
|
16
|
+
export function formatDateTime(value) {
|
|
17
|
+
if (!(value instanceof Date))
|
|
18
|
+
return value;
|
|
19
|
+
return new Intl.DateTimeFormat(globalThis.af?.userSession?.culture, {
|
|
20
|
+
year: "numeric",
|
|
21
|
+
month: "2-digit",
|
|
22
|
+
day: "2-digit",
|
|
23
|
+
hour: "2-digit",
|
|
24
|
+
minute: "2-digit",
|
|
25
|
+
timeZone: "UTC",
|
|
26
|
+
}).format(value);
|
|
27
|
+
}
|
|
28
|
+
/** "01.02.2026, 08:00 → 12:00", with the end date only when the period runs over midnight. */
|
|
29
|
+
export function formatPeriod(from, to) {
|
|
30
|
+
if (!from || !to)
|
|
31
|
+
return "";
|
|
32
|
+
let end = toDateInput(from) === toDateInput(to) ? toTimeInput(to) : formatDateTime(to);
|
|
33
|
+
return `${formatDateTime(from)} → ${end}`;
|
|
34
|
+
}
|
|
35
|
+
export function formatMinutes(minutes) {
|
|
36
|
+
let hours = Math.trunc(minutes / 60);
|
|
37
|
+
let remainder = minutes % 60;
|
|
38
|
+
return [hours > 0 && `${hours}t`, remainder > 0 && `${remainder}m`].filter(Boolean).join(" ");
|
|
39
|
+
}
|
|
40
|
+
/** A new inactive period: the working day of a future date, otherwise two hours from now. */
|
|
41
|
+
export function getNewPeriod(selectedDate, now) {
|
|
42
|
+
let current = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
|
|
43
|
+
if (selectedDate && selectedDate > current) {
|
|
44
|
+
let from = new Date(selectedDate.getTime() + 6 * 3600000);
|
|
45
|
+
return { from, to: new Date(from.getTime() + 10 * 3600000) };
|
|
46
|
+
}
|
|
47
|
+
return { from: current, to: new Date(current.getTime() + 2 * 3600000) };
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ObVehicleInfo-dialog{display:flex;flex-direction:column;overflow:hidden}@media(min-width: 900px){.ObVehicleInfo-dialog{--dsc-dialog-max-height: calc(100dvh - 2rem);height:min(46rem,100dvh - 2rem)}}.ObVehicleInfo-dialog>button[data-command=close],.ObVehicleInfo-dialog>button[command=close],.ObVehicleInfo-dialog>form[method=dialog]:first-child{position:absolute;inset-block-start:var(--ds-size-2);inset-inline-end:var(--ds-size-2);margin:0;z-index:1}.ObVehicleInfo-tabs{--dsc-tabs-content-padding: 0;--dsc-tabs-list-border-bottom-width: 0;display:flex;flex:1;flex-direction:column;min-height:0}.ObVehicleInfo-header{display:flex;flex:none;align-items:center;justify-content:space-between;gap:1rem;padding-block:var(--ds-size-2) 0;padding-inline-end:3.5rem}.ObVehicleInfo-content{flex:1;min-height:0;overflow-y:auto}.ObVehicleInfo-tab>:is(h3,h4){padding-inline:var(--ds-size-3)}.ObVehicleInfo-tab,.ObVehicleInfo-form{display:flex;flex-direction:column;gap:1rem}.ObVehicleInfo-columns{display:grid;grid-template-columns:7fr 5fr;gap:.5rem;align-items:start}.ObVehicleInfo-table{table-layout:fixed;width:100%}.ObVehicleInfo-table td:first-child{width:45%}.ObVehicleInfo-image{max-width:100%}.ObVehicleInfo-placeholder{font-size:10rem;opacity:.4}.ObVehicleInfo-periods{list-style:none;margin:0;padding:0}.ObVehicleInfo-periods button{display:flex;gap:.75rem;align-items:center;width:100%;padding:.5rem;border:0;border-block-end:1px solid var(--ds-color-neutral-border-subtle);background:none;color:inherit;font:inherit;text-align:start;cursor:pointer}.ObVehicleInfo-periods button:hover{background-color:var(--ds-color-neutral-surface-tinted)}.ObVehicleInfo-periods button svg{flex-shrink:0;font-size:1.75rem;color:var(--ds-color-danger-text-subtle)}.ObVehicleInfo-period{display:flex;gap:1rem}.ObVehicleInfo-actions{display:flex;flex:none;justify-content:flex-end;gap:.5rem}.ObVehicleInfo-actions-start{margin-inline-end:auto}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
export type VehicleInfoDialogProps = {
|
|
3
|
+
/** The vehicle to show. The dialog is closed while this is null. */
|
|
4
|
+
vehicleId: number | null;
|
|
5
|
+
/** The day being looked at, the default for a new inactive period when it is in the future. */
|
|
6
|
+
date?: Date;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onOutOfServiceChanged?: () => void;
|
|
9
|
+
};
|
|
10
|
+
/** A vehicle's details, last delivery ticket, driver and position, and its inactive periods. */
|
|
11
|
+
export declare function VehicleInfoDialog({ vehicleId, date, onClose, onOutOfServiceChanged }: VehicleInfoDialogProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Dialog, Tabs, Tag } from "@digdir/designsystemet-react";
|
|
3
|
+
import { PlusIcon, TruckIcon } from "@navikt/aksel-icons";
|
|
4
|
+
import { ResponsiveDialog } from "@olenbetong/appframe-ds";
|
|
5
|
+
import { useCurrentRow } from "@olenbetong/appframe-react";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
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
|
+
import "./index.css";
|
|
14
|
+
/** A vehicle's details, last delivery ticket, driver and position, and its inactive periods. */
|
|
15
|
+
export function VehicleInfoDialog({ vehicleId, date, onClose, onOutOfServiceChanged }) {
|
|
16
|
+
let [tab, setTab] = useState("vehicle");
|
|
17
|
+
let [formOpen, setFormOpen] = useState(false);
|
|
18
|
+
let row = useCurrentRow(dsVehicleInfo);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (vehicleId === null)
|
|
21
|
+
return;
|
|
22
|
+
dsVehicleInfo.recordSource.setWhereClause(`[ObjectNo] = ${vehicleId}`);
|
|
23
|
+
dsVehicleInfo.refreshDataSource();
|
|
24
|
+
}, [vehicleId]);
|
|
25
|
+
if (vehicleId === null)
|
|
26
|
+
return null;
|
|
27
|
+
function addPeriod() {
|
|
28
|
+
let { from, to } = getNewPeriod(date, new Date());
|
|
29
|
+
dsVehicleInfoLog.setCurrentIndex(-1);
|
|
30
|
+
dsVehicleInfoLog.currentRow("FromDateTime", from);
|
|
31
|
+
dsVehicleInfoLog.currentRow("ToDateTime", to);
|
|
32
|
+
dsVehicleInfoLog.currentRow("OutOfService", true);
|
|
33
|
+
setFormOpen(true);
|
|
34
|
+
}
|
|
35
|
+
function editPeriod(id) {
|
|
36
|
+
let index = dsVehicleInfoLog.getData().findIndex((period) => period.ID === id);
|
|
37
|
+
if (index >= 0) {
|
|
38
|
+
dsVehicleInfoLog.setCurrentIndex(index);
|
|
39
|
+
setFormOpen(true);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return (_jsxs(ResponsiveDialog, { open: true, onClose: onClose, maxWidth: "sm", className: "ObVehicleInfo-dialog", children: [_jsxs(Tabs, { value: tab, onChange: setTab, className: "ObVehicleInfo-tabs", children: [_jsxs(Dialog.Block, { className: "ObVehicleInfo-header", children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Tab, { value: "vehicle", children: getLocalizedString("Vehicle") }), _jsx(Tabs.Tab, { value: "ticket", children: getLocalizedString("Delivery ticket") }), _jsx(Tabs.Tab, { value: "driver", children: getLocalizedString("Driver") }), _jsx(Tabs.Tab, { value: "map", children: getLocalizedString("Map") })] }), _jsxs(Tag, { "data-color": "neutral", children: [_jsx(TruckIcon, { "aria-hidden": true }), " ", row.ObjectNo] })] }), _jsxs(Dialog.Block, { className: "ObVehicleInfo-content", children: [_jsx(Tabs.Panel, { value: "vehicle", children: _jsx(VehicleTab, { onEditPeriod: editPeriod }) }), _jsx(Tabs.Panel, { value: "ticket", children: _jsx(DeliveryTicketTab, {}) }), _jsx(Tabs.Panel, { value: "driver", children: _jsx(DriverTab, {}) }), _jsx(Tabs.Panel, { value: "map", children: _jsx(MapTab, {}) })] })] }), _jsxs(Dialog.Block, { className: "ObVehicleInfo-actions", children: [_jsxs(Button, { variant: "secondary", className: "ObVehicleInfo-actions-start", onClick: addPeriod, children: [_jsx(PlusIcon, { "aria-hidden": true }), " ", getLocalizedString("Add inactive period")] }), _jsx(Button, { variant: "tertiary", onClick: onClose, children: getLocalizedString("Close") })] }), formOpen && (_jsx(OutOfServiceForm, { onClose: () => setFormOpen(false), onSaved: () => {
|
|
43
|
+
setFormOpen(false);
|
|
44
|
+
onOutOfServiceChanged?.();
|
|
45
|
+
} }))] }));
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function VehicleTab({ onEditPeriod }: {
|
|
2
|
+
onEditPeriod: (id: number) => void;
|
|
3
|
+
}): import("react").JSX.Element;
|
|
4
|
+
export declare function DeliveryTicketTab(): import("react").JSX.Element;
|
|
5
|
+
export declare function DriverTab(): import("react").JSX.Element;
|
|
6
|
+
export declare function MapTab(): import("react").JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Heading, Paragraph, Table } from "@digdir/designsystemet-react";
|
|
3
|
+
import { CircleSlashIcon, TruckIcon } from "@navikt/aksel-icons";
|
|
4
|
+
import { getUserImage } from "@olenbetong/appframe-core";
|
|
5
|
+
import { useCurrentRow, useData } from "@olenbetong/appframe-react";
|
|
6
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
7
|
+
import { dsDeliveryTickets } from "./data/dsDeliveryTickets.js";
|
|
8
|
+
import { dsDriverStatus } from "./data/dsDriverStatus.js";
|
|
9
|
+
import { dsVehicleInfo } from "./data/dsVehicleInfo.js";
|
|
10
|
+
import { dsVehicleInfoLog } from "./data/dsVehicleInfoLog.js";
|
|
11
|
+
import { formatDateTime, formatMinutes, formatPeriod } from "./formatting.js";
|
|
12
|
+
const MAPS_KEY = "AIzaSyAe-z4UXfbPedkmuAeFtMIdOaeqqgVciQk";
|
|
13
|
+
function InfoTable({ rows }) {
|
|
14
|
+
return (_jsx(Table, { "data-size": "sm", "data-color": "neutral", zebra: true, className: "ObVehicleInfo-table", children: _jsx(Table.Body, { children: rows
|
|
15
|
+
.filter((row) => row !== false)
|
|
16
|
+
.map(([caption, value]) => (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { children: caption }), _jsx(Table.Cell, { children: formatDateTime(value) })] }, caption))) }) }));
|
|
17
|
+
}
|
|
18
|
+
export function VehicleTab({ onEditPeriod }) {
|
|
19
|
+
let row = useCurrentRow(dsVehicleInfo);
|
|
20
|
+
// A period being added is in the data too, without an ID until it is saved.
|
|
21
|
+
let periods = useData(dsVehicleInfoLog).filter((period) => period.ID);
|
|
22
|
+
return (_jsxs("div", { className: "ObVehicleInfo-tab", children: [_jsxs("div", { className: "ObVehicleInfo-columns", children: [_jsx(InfoTable, { rows: [
|
|
23
|
+
[getLocalizedString("Last activity"), row.PositionTimestamp],
|
|
24
|
+
[getLocalizedString("Home location"), row.LocationID],
|
|
25
|
+
[getLocalizedString("Last assignment for"), row.LastStartLocationID],
|
|
26
|
+
[getLocalizedString("Registration no."), row.RegistrationNo],
|
|
27
|
+
[getLocalizedString("Model"), row.Model],
|
|
28
|
+
[getLocalizedString("Manufacturer"), row.Manufacturer],
|
|
29
|
+
[getLocalizedString("Production year"), row.ProductionYear],
|
|
30
|
+
[getLocalizedString("Group"), `${row.ParentTypeName ?? ""} ${row.TypeName ?? ""}`],
|
|
31
|
+
[getLocalizedString("Boom length"), row.BoomLength],
|
|
32
|
+
] }), row.Image && row.PrimKey ? (_jsx("img", { alt: "", className: "ObVehicleInfo-image", src: `${dsVehicleInfo.getBlobURL(row.PrimKey, "Image", `${row.ObjectNo}.jpg`)}?mwidth=300` })) : (_jsx(TruckIcon, { "aria-hidden": true, className: "ObVehicleInfo-placeholder" }))] }), periods.length > 0 && (_jsx("ul", { className: "ObVehicleInfo-periods", children: periods.map((period) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => onEditPeriod(period.ID), children: [_jsx(CircleSlashIcon, { "aria-hidden": true }), _jsxs("span", { children: [_jsx("strong", { children: period.Comment }), _jsx("br", {}), period.IsPlanned ? `${getLocalizedString("Planned")}: ` : "", formatPeriod(period.FromDateTime, period.ToDateTime), " (", getLocalizedString("Created by"), " ", period.CreatedBy, ")"] })] }) }, period.ID))) }))] }));
|
|
33
|
+
}
|
|
34
|
+
export function DeliveryTicketTab() {
|
|
35
|
+
let record = useCurrentRow(dsDeliveryTickets);
|
|
36
|
+
return (_jsxs("div", { className: "ObVehicleInfo-tab", children: [_jsxs(Heading, { level: 3, "data-size": "xs", children: [getLocalizedString("Last delivery ticket"), ": ", record.DeliveryTicketID] }), _jsx(Heading, { level: 4, "data-size": "2xs", children: getLocalizedString("Customer") }), _jsx(InfoTable, { rows: [
|
|
37
|
+
[getLocalizedString("Customer nr"), record.CustomerNo],
|
|
38
|
+
[
|
|
39
|
+
getLocalizedString("Address"),
|
|
40
|
+
_jsxs(_Fragment, { children: [record.CustomerAdr1, _jsx("br", {}), record.CustomerAdr2, _jsx("br", {}), record.CustomerAdr3] }),
|
|
41
|
+
],
|
|
42
|
+
[getLocalizedString("Build site"), record.BuildSiteAdr1],
|
|
43
|
+
] }), _jsx(Heading, { level: 4, "data-size": "2xs", children: getLocalizedString("Concrete") }), _jsx(InfoTable, { rows: [
|
|
44
|
+
[getLocalizedString("Prod. time"), record.ProdTime],
|
|
45
|
+
[getLocalizedString("This load"), `${record.Qty} m³`],
|
|
46
|
+
[
|
|
47
|
+
getLocalizedString("Total delivered"),
|
|
48
|
+
`${record.QtyTotal} m³ ${getLocalizedString("of")} ${record.CallOffQty} m³`,
|
|
49
|
+
],
|
|
50
|
+
[getLocalizedString("Concrete"), record.ConcreteName],
|
|
51
|
+
] })] }));
|
|
52
|
+
}
|
|
53
|
+
export function DriverTab() {
|
|
54
|
+
let row = useCurrentRow(dsDriverStatus);
|
|
55
|
+
if (!row.PrimKey) {
|
|
56
|
+
return _jsx(Paragraph, { children: getLocalizedString("No driver data") });
|
|
57
|
+
}
|
|
58
|
+
let image = getUserImage(row.PrimKey, row.PersonID, row.ImageHash, "md");
|
|
59
|
+
return (_jsxs("div", { className: "ObVehicleInfo-columns", children: [_jsx(InfoTable, { rows: [
|
|
60
|
+
[getLocalizedString("Name"), row.FullName],
|
|
61
|
+
[getLocalizedString("Work location"), row.WorkLocation],
|
|
62
|
+
[getLocalizedString("Phone number"), row.PhoneMob],
|
|
63
|
+
row.RemainingDrivingTimeCurrent !== null && [
|
|
64
|
+
getLocalizedString("Remaining driving time (current)"),
|
|
65
|
+
formatMinutes(row.RemainingDrivingTimeCurrent),
|
|
66
|
+
],
|
|
67
|
+
row.RemainingDrivingTimeShift !== null && [
|
|
68
|
+
getLocalizedString("Remaining driving time (shift)"),
|
|
69
|
+
formatMinutes(row.RemainingDrivingTimeShift),
|
|
70
|
+
],
|
|
71
|
+
row.DurationOfNextBreak !== null && [
|
|
72
|
+
getLocalizedString("Duration of next break"),
|
|
73
|
+
formatMinutes(row.DurationOfNextBreak),
|
|
74
|
+
],
|
|
75
|
+
!!row.Timestamp && [getLocalizedString("Last updated"), row.Timestamp],
|
|
76
|
+
] }), image && _jsx("img", { alt: "", className: "ObVehicleInfo-image", src: image })] }));
|
|
77
|
+
}
|
|
78
|
+
export function MapTab() {
|
|
79
|
+
let row = useCurrentRow(dsVehicleInfo);
|
|
80
|
+
if (!row.PrimKey || !row.Latitude || !row.Longitude) {
|
|
81
|
+
return _jsx(Paragraph, { children: getLocalizedString("No position data") });
|
|
82
|
+
}
|
|
83
|
+
let position = `${row.Latitude},${row.Longitude}`;
|
|
84
|
+
return (_jsxs("div", { children: [_jsx("img", { alt: "", className: "ObVehicleInfo-image", src: `https://maps.googleapis.com/maps/api/staticmap?center=${position}&zoom=12&size=600x340&markers=color:green%7Clabel:${row.ObjectNo}%7C${position}&key=${MAPS_KEY}` }), _jsxs(Paragraph, { "data-size": "xs", children: [getLocalizedString("Last position saved"), ": ", formatDateTime(row.PositionTimestamp)] })] }));
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VehicleInfoDialog, type VehicleInfoDialogProps } from "./VehicleInfoDialog/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VehicleInfoDialog } from "./VehicleInfoDialog/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Standalone React component for SynergiWeb and Partner Portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
"types": "./es/index.d.ts",
|
|
9
9
|
"import": "./es/index.js"
|
|
10
10
|
},
|
|
11
|
+
"./charts": {
|
|
12
|
+
"types": "./es/charts/index.d.ts",
|
|
13
|
+
"import": "./es/charts/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./vehicles": {
|
|
16
|
+
"types": "./es/vehicles/index.d.ts",
|
|
17
|
+
"import": "./es/vehicles/index.js"
|
|
18
|
+
},
|
|
11
19
|
"./elements": {
|
|
12
20
|
"types": "./es/elements/index.d.ts",
|
|
13
21
|
"import": "./es/elements/index.js"
|
|
@@ -55,9 +63,9 @@
|
|
|
55
63
|
"@emotion/styled": "^11.14.1",
|
|
56
64
|
"@mui/icons-material": "9.5.0",
|
|
57
65
|
"@mui/material": "9.5.0",
|
|
58
|
-
"@olenbetong/appframe-core": "^2.
|
|
59
|
-
"@olenbetong/appframe-data": "^1.
|
|
60
|
-
"@olenbetong/appframe-ds": "^1.
|
|
66
|
+
"@olenbetong/appframe-core": "^2.16.0",
|
|
67
|
+
"@olenbetong/appframe-data": "^1.10.3",
|
|
68
|
+
"@olenbetong/appframe-ds": "^1.11.0",
|
|
61
69
|
"@olenbetong/appframe-mui": "^7.0.13",
|
|
62
70
|
"@olenbetong/appframe-react": "^2.2.8",
|
|
63
71
|
"clsx": "^2.1.1",
|
|
@@ -67,6 +75,7 @@
|
|
|
67
75
|
"filepond-plugin-image-preview": "^4.6.12",
|
|
68
76
|
"filepond-plugin-image-resize": "^2.0.10",
|
|
69
77
|
"filepond-plugin-image-transform": "^3.8.8",
|
|
78
|
+
"highcharts": "13.1.1",
|
|
70
79
|
"localforage": "^1.10.0",
|
|
71
80
|
"mitt": "^3.0.1",
|
|
72
81
|
"monaco-editor": "0.57.0",
|
|
@@ -92,21 +101,21 @@
|
|
|
92
101
|
"@digdir/designsystemet-css": "1.23.0",
|
|
93
102
|
"@digdir/designsystemet-react": "1.23.0",
|
|
94
103
|
"@digdir/designsystemet-web": "1.23.0",
|
|
95
|
-
"@navikt/aksel-icons": "8.
|
|
104
|
+
"@navikt/aksel-icons": "8.22.1",
|
|
96
105
|
"@testing-library/dom": "^10.4.2",
|
|
97
106
|
"@testing-library/jest-dom": "^7.0.1",
|
|
98
107
|
"@testing-library/react": "16.3.3",
|
|
99
108
|
"@testing-library/user-event": "^14.6.8",
|
|
100
|
-
"@vitest/browser": "5.0
|
|
101
|
-
"@vitest/browser-playwright": "5.0
|
|
102
|
-
"@vitest/coverage-v8": "5.0
|
|
109
|
+
"@vitest/browser": "5.1.0",
|
|
110
|
+
"@vitest/browser-playwright": "5.1.0",
|
|
111
|
+
"@vitest/coverage-v8": "5.1.0",
|
|
103
112
|
"dynamsoft-javascript-barcode": "6.5.4",
|
|
104
113
|
"happy-dom": "21.0.4",
|
|
105
114
|
"playwright": "^1.64.1",
|
|
106
115
|
"replace-in-files": "^3.0.0",
|
|
107
|
-
"sass": "1.
|
|
116
|
+
"sass": "1.107.1",
|
|
108
117
|
"typescript": "7.0.2",
|
|
109
|
-
"vitest": "5.0
|
|
118
|
+
"vitest": "5.1.0"
|
|
110
119
|
},
|
|
111
120
|
"optionalDependencies": {},
|
|
112
121
|
"scripts": {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Alert, Dialog, Paragraph, Spinner } from "@digdir/designsystemet-react";
|
|
2
|
+
import { ResponsiveDialog } from "@olenbetong/appframe-ds";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
6
|
+
import { dsTicketScan, type TicketScanRecord } from "./data.js";
|
|
7
|
+
|
|
8
|
+
const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "gif", "webp", "bmp", "avif", "svg"];
|
|
9
|
+
|
|
10
|
+
type ScanState =
|
|
11
|
+
| { status: "loading" }
|
|
12
|
+
| { status: "missing" }
|
|
13
|
+
| { status: "error"; message: string }
|
|
14
|
+
| { status: "loaded"; scan: TicketScanRecord };
|
|
15
|
+
|
|
16
|
+
export type TicketScanDialogProps = {
|
|
17
|
+
/** The ticket whose scan to show. The dialog is closed while this is null. */
|
|
18
|
+
deliveryTicketId: number | null;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** The newest scan of a delivery ticket, as an image or, for a PDF, in a frame. */
|
|
23
|
+
export function TicketScanDialog({ deliveryTicketId, onClose }: TicketScanDialogProps) {
|
|
24
|
+
let [loaded, setLoaded] = useState<{ ticketId: number; state: ScanState } | null>(null);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (deliveryTicketId === null) return;
|
|
28
|
+
|
|
29
|
+
let cancelled = false;
|
|
30
|
+
let done = (state: ScanState) => {
|
|
31
|
+
if (!cancelled) setLoaded({ ticketId: deliveryTicketId, state });
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
(async () => {
|
|
35
|
+
try {
|
|
36
|
+
dsTicketScan.recordSource.setWhereClause(`[DeliveryTicketID] = ${Number(deliveryTicketId)}`);
|
|
37
|
+
await dsTicketScan.refreshDataSource();
|
|
38
|
+
let scan = dsTicketScan.getData()[0] as TicketScanRecord | undefined;
|
|
39
|
+
done(scan ? { status: "loaded", scan } : { status: "missing" });
|
|
40
|
+
} catch (reason) {
|
|
41
|
+
done({ status: "error", message: reason instanceof Error ? reason.message : String(reason) });
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
cancelled = true;
|
|
47
|
+
};
|
|
48
|
+
}, [deliveryTicketId]);
|
|
49
|
+
|
|
50
|
+
if (deliveryTicketId === null) return null;
|
|
51
|
+
|
|
52
|
+
let state: ScanState = loaded?.ticketId === deliveryTicketId ? loaded.state : { status: "loading" };
|
|
53
|
+
|
|
54
|
+
let title = `${getLocalizedString("Delivery ticket")} ${deliveryTicketId}`;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<ResponsiveDialog open onClose={onClose} maxWidth="lg" title={title} className="ObCallOffDeliveries-scanDialog">
|
|
58
|
+
<Dialog.Block className="ObCallOffDeliveries-scan">
|
|
59
|
+
{state.status === "loading" && <Spinner aria-label={getLocalizedString("Loading")} />}
|
|
60
|
+
{state.status === "missing" && (
|
|
61
|
+
<Paragraph>{getLocalizedString("No scan found for this delivery ticket.")}</Paragraph>
|
|
62
|
+
)}
|
|
63
|
+
{state.status === "error" && <Alert data-color="danger">{state.message}</Alert>}
|
|
64
|
+
{state.status === "loaded" && <ScanView scan={state.scan} title={title} />}
|
|
65
|
+
</Dialog.Block>
|
|
66
|
+
</ResponsiveDialog>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function ScanView({ scan, title }: { scan: TicketScanRecord; title: string }) {
|
|
71
|
+
let url = `/api/data/file/view/atbv_Fleet_DeliveryTicketsScan/${scan.PrimKey}?t=${new Date(scan.Updated).getTime()}`;
|
|
72
|
+
let extension = (scan.Extension ?? "").toLowerCase();
|
|
73
|
+
|
|
74
|
+
if (IMAGE_EXTENSIONS.includes(extension)) {
|
|
75
|
+
return <img src={url} alt={title} />;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return <iframe src={url} title={title} />;
|
|
79
|
+
}
|