@olenbetong/synergi-react 5.0.0 → 5.1.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/es/components/Checkbox/index.js +1 -9
- package/es/components/CodeEditor/CodeEditor.css +6 -6
- package/es/components/FilePond.js +3 -12
- package/es/components/ImageEditor/plugins/redactPlugin/useRedactTool.js +18 -14
- package/es/components/ImageEditor/useImageHistory.js +13 -1
- package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +1 -1
- package/es/components/MergeProgressDialog/useMergeJob.js +5 -4
- package/es/components/Portal/index.js +20 -20
- package/es/components/SplitContainer/index.js +3 -1
- package/es/components/Toolbar/Toolbar.css +137 -137
- package/es/components/Toolbar/index.js +6 -1
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.js +8 -0
- package/es/elements/ElementLookupDialog/HIDScanner/useHIDScanner.js +3 -1
- package/es/elements-ds/DescriptionInput.d.ts +16 -0
- package/es/elements-ds/DescriptionInput.js +41 -0
- package/es/elements-ds/DuplicateElementDamage.d.ts +40 -0
- package/es/elements-ds/DuplicateElementDamage.js +57 -0
- package/es/elements-ds/ElementLookup.d.ts +23 -0
- package/es/elements-ds/ElementLookup.js +35 -0
- package/es/elements-ds/ElementLookupDialog.d.ts +7 -0
- package/es/elements-ds/ElementLookupDialog.js +84 -0
- package/es/elements-ds/FormFields.d.ts +43 -0
- package/es/elements-ds/FormFields.js +67 -0
- package/es/elements-ds/HIDScanner.d.ts +7 -0
- package/es/elements-ds/HIDScanner.js +36 -0
- package/es/elements-ds/ManualForm.d.ts +7 -0
- package/es/elements-ds/ManualForm.js +70 -0
- package/es/elements-ds/ProjectSelect.d.ts +28 -0
- package/es/elements-ds/ProjectSelect.js +45 -0
- package/es/elements-ds/elements-ds.css +157 -0
- package/es/elements-ds/index.d.ts +12 -0
- package/es/elements-ds/index.js +14 -0
- package/es/useTranslation/index.js +5 -3
- package/package.json +15 -3
- package/src/chrome/AppShell/AppShell.test.tsx +48 -0
- package/src/chrome/AppShell/index.tsx +29 -29
- package/src/chrome/openReport.test.ts +50 -0
- package/src/chrome/openReport.ts +34 -34
- package/src/colorScheme.test.ts +188 -0
- package/src/colorScheme.ts +125 -125
- package/src/components/Checkbox/Checkbox.browser.test.tsx +116 -0
- package/src/components/Checkbox/index.tsx +1 -10
- package/src/components/CodeEditor/CodeEditor.css +6 -6
- package/src/components/CodeEditor/CodeEditor.tsx +173 -173
- package/src/components/CodeEditor/index.ts +1 -1
- package/src/components/ColorCard/ColorCard.test.tsx +34 -0
- package/src/components/DateNavigator/DateNavigator.test.tsx +175 -0
- package/src/components/DateNavigator/index.tsx +186 -186
- package/src/components/FilePond.browser.test.tsx +389 -0
- package/src/components/FilePond.tsx +303 -312
- package/src/components/ImageEditor/ImageEditor.browser.test.tsx +286 -0
- package/src/components/ImageEditor/ImageEditor.test.tsx +299 -0
- package/src/components/ImageEditor/ImageEditor.tsx +348 -348
- package/src/components/ImageEditor/index.ts +9 -9
- package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
- package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.test.ts +225 -0
- package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
- package/src/components/ImageEditor/plugins/plugins.browser.test.ts +252 -0
- package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
- package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.test.ts +89 -0
- package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.ts +16 -13
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
- package/src/components/ImageEditor/plugins/zoomPlugin/useZoomPan.test.ts +154 -0
- package/src/components/ImageEditor/useActiveTool.ts +21 -21
- package/src/components/ImageEditor/useEdgeDetection.test.ts +96 -0
- package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
- package/src/components/ImageEditor/useImageHistory.test.ts +409 -0
- package/src/components/ImageEditor/useImageHistory.ts +206 -197
- package/src/components/ImageEditor/useOpenCV.test.ts +208 -0
- package/src/components/ImageEditor/useOpenCV.ts +184 -184
- package/src/components/LinkedCardList/index.scss +95 -95
- package/src/components/MergeProgressDialog/MergeProgressDialogDs.browser.test.tsx +156 -0
- package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +1 -0
- package/src/components/MergeProgressDialog/useMergeJob.test.ts +326 -0
- package/src/components/MergeProgressDialog/useMergeJob.ts +4 -3
- package/src/components/PageBanner/index.tsx +80 -80
- package/src/components/PdfViewer/PdfViewer.browser.test.tsx +78 -0
- package/src/components/PdfViewer/PdfViewer.tsx +158 -158
- package/src/components/Portal/Portal.test.tsx +106 -0
- package/src/components/Portal/index.tsx +22 -25
- package/src/components/Sidebar/Sidebar.browser.test.tsx +57 -0
- package/src/components/Sidebar/Sidebar.test.tsx +123 -0
- package/src/components/SplitContainer/SplitContainer.browser.test.tsx +304 -0
- package/src/components/SplitContainer/index.tsx +335 -333
- package/src/components/Toolbar/Toolbar.css +137 -137
- package/src/components/Toolbar/Toolbar.test.tsx +216 -0
- package/src/components/Toolbar/ToolbarBreadcrumbs.browser.test.tsx +137 -0
- package/src/components/Toolbar/index.tsx +270 -265
- package/src/components/ValueToggleGroup/ValueToggleGroup.test.tsx +112 -0
- package/src/designsystemet-web-types.d.ts +24 -24
- package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
- package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
- package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
- package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
- package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
- package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
- package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
- package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
- package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
- package/src/elements/ElementLookup.tsx +123 -123
- package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.browser.test.tsx +175 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +8 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/engines.browser.test.ts +225 -0
- package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
- package/src/elements/ElementLookupDialog/HIDScanner/useHIDScanner.test.ts +124 -0
- package/src/elements/ElementLookupDialog/HIDScanner/useHIDScanner.ts +2 -1
- package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
- package/src/elements/ElementLookupDialog/getElement.test.ts +133 -0
- package/src/elements/ElementLookupDialog/index.tsx +226 -226
- package/src/elements/ElementLookupDialog/utils/Giai.test.ts +53 -0
- package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
- package/src/elements/ProjectSelect.tsx +130 -130
- package/src/elements/index.ts +15 -15
- package/src/elements-ds/DamageForm.browser.test.tsx +530 -0
- package/src/elements-ds/DescriptionInput.tsx +114 -0
- package/src/elements-ds/DuplicateElementDamage.tsx +185 -0
- package/src/elements-ds/ElementLookup.tsx +114 -0
- package/src/elements-ds/ElementLookupDialog.browser.test.tsx +207 -0
- package/src/elements-ds/ElementLookupDialog.tsx +196 -0
- package/src/elements-ds/FormFields.tsx +176 -0
- package/src/elements-ds/HIDScanner.tsx +53 -0
- package/src/elements-ds/ManualForm.tsx +129 -0
- package/src/elements-ds/ProjectSelect.tsx +120 -0
- package/src/elements-ds/elements-ds.css +157 -0
- package/src/elements-ds/index.ts +16 -0
- package/src/filter/index.ts +34 -34
- package/src/i18n.test.ts +31 -0
- package/src/i18n.ts +13 -13
- package/src/mui/MuiThemeProvider.tsx +135 -135
- package/src/test/fakeCamera.ts +98 -0
- package/src/test/fakeDataApi.ts +90 -0
- package/src/test/setup.browser.ts +21 -0
- package/src/test/setup.ts +23 -23
- package/src/useTranslation/index.ts +5 -3
- package/src/useTranslation/useTranslation.test.ts +128 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.d.ts +0 -1
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.js +0 -103
- package/es/test/setup.d.ts +0 -6
- package/es/test/setup.js +0 -6
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Card, CardContent, Typography } from "@mui/material";
|
|
2
|
-
import type { DamagesRecord } from "../../data";
|
|
3
|
-
import { getLocalizedString } from "../../../i18n.js";
|
|
4
|
-
|
|
5
|
-
type DuplicatePhoneViewItemProps = {
|
|
6
|
-
record: DamagesRecord;
|
|
7
|
-
linkToDamage: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function DuplicatePhoneViewItem({ record, linkToDamage }: DuplicatePhoneViewItemProps) {
|
|
11
|
-
return (
|
|
12
|
-
<Card
|
|
13
|
-
variant="outlined"
|
|
14
|
-
onClick={() => {
|
|
15
|
-
if (linkToDamage) {
|
|
16
|
-
window.location.href = `${record.ID}`;
|
|
17
|
-
}
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
<CardContent>
|
|
21
|
-
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>
|
|
22
|
-
{record.Date.toLocaleDateString()}
|
|
23
|
-
</Typography>
|
|
24
|
-
<Typography variant="h5" sx={{ mb: 1.5 }}>
|
|
25
|
-
{record.ElementID} - {record.DisplayName}
|
|
26
|
-
</Typography>
|
|
27
|
-
|
|
28
|
-
<Typography>{getLocalizedString("Description")}:</Typography>
|
|
29
|
-
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
30
|
-
{record.Description}
|
|
31
|
-
</Typography>
|
|
32
|
-
|
|
33
|
-
<Typography>{getLocalizedString("Cause")}: </Typography>
|
|
34
|
-
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
35
|
-
{record.Cause}
|
|
36
|
-
</Typography>
|
|
37
|
-
|
|
38
|
-
<Typography>{getLocalizedString("Action")}: </Typography>
|
|
39
|
-
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
40
|
-
{record.Action}
|
|
41
|
-
</Typography>
|
|
42
|
-
</CardContent>
|
|
43
|
-
</Card>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
1
|
+
import { Card, CardContent, Typography } from "@mui/material";
|
|
2
|
+
import type { DamagesRecord } from "../../data";
|
|
3
|
+
import { getLocalizedString } from "../../../i18n.js";
|
|
4
|
+
|
|
5
|
+
type DuplicatePhoneViewItemProps = {
|
|
6
|
+
record: DamagesRecord;
|
|
7
|
+
linkToDamage: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function DuplicatePhoneViewItem({ record, linkToDamage }: DuplicatePhoneViewItemProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Card
|
|
13
|
+
variant="outlined"
|
|
14
|
+
onClick={() => {
|
|
15
|
+
if (linkToDamage) {
|
|
16
|
+
window.location.href = `${record.ID}`;
|
|
17
|
+
}
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
<CardContent>
|
|
21
|
+
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>
|
|
22
|
+
{record.Date.toLocaleDateString()}
|
|
23
|
+
</Typography>
|
|
24
|
+
<Typography variant="h5" sx={{ mb: 1.5 }}>
|
|
25
|
+
{record.ElementID} - {record.DisplayName}
|
|
26
|
+
</Typography>
|
|
27
|
+
|
|
28
|
+
<Typography>{getLocalizedString("Description")}:</Typography>
|
|
29
|
+
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
30
|
+
{record.Description}
|
|
31
|
+
</Typography>
|
|
32
|
+
|
|
33
|
+
<Typography>{getLocalizedString("Cause")}: </Typography>
|
|
34
|
+
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
35
|
+
{record.Cause}
|
|
36
|
+
</Typography>
|
|
37
|
+
|
|
38
|
+
<Typography>{getLocalizedString("Action")}: </Typography>
|
|
39
|
+
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
40
|
+
{record.Action}
|
|
41
|
+
</Typography>
|
|
42
|
+
</CardContent>
|
|
43
|
+
</Card>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { type SxProps, TextField, type Theme } from "@mui/material";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { getLocalizedString } from "../../i18n.js";
|
|
4
|
-
|
|
5
|
-
type ElementNumberTextFieldProps = {
|
|
6
|
-
value?: string | null;
|
|
7
|
-
defaultValue?: string | null;
|
|
8
|
-
onChange?: (value: string) => void;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
sx?: SxProps<Theme>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function ElementNumberTextField({ value, defaultValue, onChange, disabled, sx }: ElementNumberTextFieldProps) {
|
|
14
|
-
let [elementNumber, setElementNumber] = useState<string>(defaultValue ?? "");
|
|
15
|
-
let elementNumberValue = value === undefined ? elementNumber : value;
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (value === undefined && defaultValue) {
|
|
19
|
-
setElementNumber(defaultValue);
|
|
20
|
-
}
|
|
21
|
-
}, [defaultValue, value]);
|
|
22
|
-
|
|
23
|
-
function handleChange(value: string) {
|
|
24
|
-
onChange?.(value);
|
|
25
|
-
setElementNumber(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<TextField
|
|
30
|
-
name="ElementNumber"
|
|
31
|
-
id="NewElementDamage_ElementNr"
|
|
32
|
-
value={elementNumberValue}
|
|
33
|
-
onChange={(event) => handleChange(event.currentTarget.value)}
|
|
34
|
-
label={getLocalizedString("Element number")}
|
|
35
|
-
fullWidth
|
|
36
|
-
autoComplete="off"
|
|
37
|
-
disabled={disabled ?? false}
|
|
38
|
-
sx={{ ...sx }}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
1
|
+
import { type SxProps, TextField, type Theme } from "@mui/material";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
4
|
+
|
|
5
|
+
type ElementNumberTextFieldProps = {
|
|
6
|
+
value?: string | null;
|
|
7
|
+
defaultValue?: string | null;
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
sx?: SxProps<Theme>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function ElementNumberTextField({ value, defaultValue, onChange, disabled, sx }: ElementNumberTextFieldProps) {
|
|
14
|
+
let [elementNumber, setElementNumber] = useState<string>(defaultValue ?? "");
|
|
15
|
+
let elementNumberValue = value === undefined ? elementNumber : value;
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (value === undefined && defaultValue) {
|
|
19
|
+
setElementNumber(defaultValue);
|
|
20
|
+
}
|
|
21
|
+
}, [defaultValue, value]);
|
|
22
|
+
|
|
23
|
+
function handleChange(value: string) {
|
|
24
|
+
onChange?.(value);
|
|
25
|
+
setElementNumber(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<TextField
|
|
30
|
+
name="ElementNumber"
|
|
31
|
+
id="NewElementDamage_ElementNr"
|
|
32
|
+
value={elementNumberValue}
|
|
33
|
+
onChange={(event) => handleChange(event.currentTarget.value)}
|
|
34
|
+
label={getLocalizedString("Element number")}
|
|
35
|
+
fullWidth
|
|
36
|
+
autoComplete="off"
|
|
37
|
+
disabled={disabled ?? false}
|
|
38
|
+
sx={{ ...sx }}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import CheckIcon from "@mui/icons-material/Check";
|
|
2
|
-
import { Button, Checkbox, FormControlLabel, Typography } from "@mui/material";
|
|
3
|
-
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
|
|
6
|
-
import { procApproveDamage } from "../data";
|
|
7
|
-
import { getLocalizedString, localize } from "../../i18n.js";
|
|
8
|
-
|
|
9
|
-
const formatter = new Intl.DateTimeFormat(af.userSession.culture, {
|
|
10
|
-
day: "numeric",
|
|
11
|
-
month: "long",
|
|
12
|
-
year: "numeric",
|
|
13
|
-
hour: "2-digit",
|
|
14
|
-
minute: "2-digit",
|
|
15
|
-
timeZone: "UTC",
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
type RegisterFixType = {
|
|
19
|
-
ID: number;
|
|
20
|
-
RegisteredFixFullName: string | null;
|
|
21
|
-
RegisteredFix: Date | null;
|
|
22
|
-
RegisteredFixBy: string | null;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type ApproveDamageProcedureRecord = {
|
|
26
|
-
Table: Array<Required<RegisterFixType>>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type RegisterFixProps = {
|
|
30
|
-
value?: RegisterFixType | null;
|
|
31
|
-
defaultValue?: RegisterFixType | null;
|
|
32
|
-
onFix?: (ID: number) => void;
|
|
33
|
-
edit?: boolean;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export function RegisterFix({ value, defaultValue, onFix, edit }: RegisterFixProps) {
|
|
37
|
-
let [loading, setLoading] = useState<boolean>(false);
|
|
38
|
-
let initializedRef = useRef<boolean>(false);
|
|
39
|
-
|
|
40
|
-
let [fix, setFix] = useState<RegisterFixType | null>(defaultValue ?? null);
|
|
41
|
-
let fixValue = value === undefined ? fix : value;
|
|
42
|
-
|
|
43
|
-
// biome-ignore lint: intentionally skipping "value" dependency as this should never run when "value" changes
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (initializedRef.current) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (value === undefined && defaultValue) {
|
|
50
|
-
setFix(defaultValue);
|
|
51
|
-
initializedRef.current = true;
|
|
52
|
-
}
|
|
53
|
-
}, [defaultValue]);
|
|
54
|
-
|
|
55
|
-
async function handleRegisterFix() {
|
|
56
|
-
try {
|
|
57
|
-
if (confirm(getLocalizedString("Are you sure you want to register a fix for this damage?"))) {
|
|
58
|
-
setLoading(true);
|
|
59
|
-
let record = (await procApproveDamage.execute({ ID: fixValue?.ID })) as ApproveDamageProcedureRecord;
|
|
60
|
-
|
|
61
|
-
setFix({ ...record.Table[0] });
|
|
62
|
-
|
|
63
|
-
setLoading(false);
|
|
64
|
-
onFix?.(fixValue?.ID ?? -1);
|
|
65
|
-
}
|
|
66
|
-
} catch (error) {
|
|
67
|
-
alert((error as Error).message);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<>
|
|
73
|
-
{edit ? (
|
|
74
|
-
<Button
|
|
75
|
-
loading={loading}
|
|
76
|
-
loadingPosition="end"
|
|
77
|
-
endIcon={<CheckIcon />}
|
|
78
|
-
onClick={handleRegisterFix}
|
|
79
|
-
disabled={!!fixValue?.RegisteredFix}
|
|
80
|
-
variant="contained"
|
|
81
|
-
>
|
|
82
|
-
{getLocalizedString("Register fix")}
|
|
83
|
-
</Button>
|
|
84
|
-
) : (
|
|
85
|
-
<FormControlLabel
|
|
86
|
-
control={<Checkbox />}
|
|
87
|
-
label={getLocalizedString("Register fixed")}
|
|
88
|
-
name="RegisteredFix"
|
|
89
|
-
id="NewElementDamage_RegisteredFix"
|
|
90
|
-
/>
|
|
91
|
-
)}
|
|
92
|
-
|
|
93
|
-
{fixValue?.RegisteredFix && (
|
|
94
|
-
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
95
|
-
{localize`Registered fix by ${fixValue.RegisteredFixFullName ?? fixValue.RegisteredFixBy} on the ${formatter.format(fixValue.RegisteredFix)}`}
|
|
96
|
-
</Typography>
|
|
97
|
-
)}
|
|
98
|
-
</>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
1
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
2
|
+
import { Button, Checkbox, FormControlLabel, Typography } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
|
|
6
|
+
import { procApproveDamage } from "../data";
|
|
7
|
+
import { getLocalizedString, localize } from "../../i18n.js";
|
|
8
|
+
|
|
9
|
+
const formatter = new Intl.DateTimeFormat(af.userSession.culture, {
|
|
10
|
+
day: "numeric",
|
|
11
|
+
month: "long",
|
|
12
|
+
year: "numeric",
|
|
13
|
+
hour: "2-digit",
|
|
14
|
+
minute: "2-digit",
|
|
15
|
+
timeZone: "UTC",
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
type RegisterFixType = {
|
|
19
|
+
ID: number;
|
|
20
|
+
RegisteredFixFullName: string | null;
|
|
21
|
+
RegisteredFix: Date | null;
|
|
22
|
+
RegisteredFixBy: string | null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type ApproveDamageProcedureRecord = {
|
|
26
|
+
Table: Array<Required<RegisterFixType>>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type RegisterFixProps = {
|
|
30
|
+
value?: RegisterFixType | null;
|
|
31
|
+
defaultValue?: RegisterFixType | null;
|
|
32
|
+
onFix?: (ID: number) => void;
|
|
33
|
+
edit?: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function RegisterFix({ value, defaultValue, onFix, edit }: RegisterFixProps) {
|
|
37
|
+
let [loading, setLoading] = useState<boolean>(false);
|
|
38
|
+
let initializedRef = useRef<boolean>(false);
|
|
39
|
+
|
|
40
|
+
let [fix, setFix] = useState<RegisterFixType | null>(defaultValue ?? null);
|
|
41
|
+
let fixValue = value === undefined ? fix : value;
|
|
42
|
+
|
|
43
|
+
// biome-ignore lint: intentionally skipping "value" dependency as this should never run when "value" changes
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (initializedRef.current) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (value === undefined && defaultValue) {
|
|
50
|
+
setFix(defaultValue);
|
|
51
|
+
initializedRef.current = true;
|
|
52
|
+
}
|
|
53
|
+
}, [defaultValue]);
|
|
54
|
+
|
|
55
|
+
async function handleRegisterFix() {
|
|
56
|
+
try {
|
|
57
|
+
if (confirm(getLocalizedString("Are you sure you want to register a fix for this damage?"))) {
|
|
58
|
+
setLoading(true);
|
|
59
|
+
let record = (await procApproveDamage.execute({ ID: fixValue?.ID })) as ApproveDamageProcedureRecord;
|
|
60
|
+
|
|
61
|
+
setFix({ ...record.Table[0] });
|
|
62
|
+
|
|
63
|
+
setLoading(false);
|
|
64
|
+
onFix?.(fixValue?.ID ?? -1);
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
alert((error as Error).message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
{edit ? (
|
|
74
|
+
<Button
|
|
75
|
+
loading={loading}
|
|
76
|
+
loadingPosition="end"
|
|
77
|
+
endIcon={<CheckIcon />}
|
|
78
|
+
onClick={handleRegisterFix}
|
|
79
|
+
disabled={!!fixValue?.RegisteredFix}
|
|
80
|
+
variant="contained"
|
|
81
|
+
>
|
|
82
|
+
{getLocalizedString("Register fix")}
|
|
83
|
+
</Button>
|
|
84
|
+
) : (
|
|
85
|
+
<FormControlLabel
|
|
86
|
+
control={<Checkbox />}
|
|
87
|
+
label={getLocalizedString("Register fixed")}
|
|
88
|
+
name="RegisteredFix"
|
|
89
|
+
id="NewElementDamage_RegisteredFix"
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
|
|
93
|
+
{fixValue?.RegisteredFix && (
|
|
94
|
+
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
|
95
|
+
{localize`Registered fix by ${fixValue.RegisteredFixFullName ?? fixValue.RegisteredFixBy} on the ${formatter.format(fixValue.RegisteredFix)}`}
|
|
96
|
+
</Typography>
|
|
97
|
+
)}
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import Add from "@mui/icons-material/Add";
|
|
2
|
-
import { Box, Button, type SxProps, type Theme } from "@mui/material";
|
|
3
|
-
import { getLocalizedString } from "../../i18n.js";
|
|
4
|
-
|
|
5
|
-
type SubmitButtonsProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Whether the form is in edit mode. If true, delete button is visible and submit button's text changes.
|
|
8
|
-
*/
|
|
9
|
-
edit?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Set loading state for submit button
|
|
12
|
-
*/
|
|
13
|
-
loading?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Custom styles for Box wrapper around buttons
|
|
16
|
-
*/
|
|
17
|
-
sx?: SxProps<Theme>;
|
|
18
|
-
onDelete?: () => void;
|
|
19
|
-
onCancel?: () => void;
|
|
20
|
-
onSubmit?: () => void;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export function SubmitButtons({ edit, loading, onDelete, onCancel, onSubmit, sx }: SubmitButtonsProps) {
|
|
24
|
-
return (
|
|
25
|
-
<Box sx={{ display: "flex", flexWrap: "wrap", gap: 2, justifyContent: "flex-end", ...sx }}>
|
|
26
|
-
{edit && <Button onClick={onDelete}>{getLocalizedString("Delete")}</Button>}
|
|
27
|
-
<Button onClick={onCancel}>{getLocalizedString("Cancel")}</Button>
|
|
28
|
-
<Button
|
|
29
|
-
loading={loading}
|
|
30
|
-
loadingPosition="start"
|
|
31
|
-
startIcon={<Add />}
|
|
32
|
-
type="submit"
|
|
33
|
-
variant="contained"
|
|
34
|
-
onClick={onSubmit}
|
|
35
|
-
>
|
|
36
|
-
{edit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
|
|
37
|
-
</Button>
|
|
38
|
-
</Box>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
1
|
+
import Add from "@mui/icons-material/Add";
|
|
2
|
+
import { Box, Button, type SxProps, type Theme } from "@mui/material";
|
|
3
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
4
|
+
|
|
5
|
+
type SubmitButtonsProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the form is in edit mode. If true, delete button is visible and submit button's text changes.
|
|
8
|
+
*/
|
|
9
|
+
edit?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Set loading state for submit button
|
|
12
|
+
*/
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Custom styles for Box wrapper around buttons
|
|
16
|
+
*/
|
|
17
|
+
sx?: SxProps<Theme>;
|
|
18
|
+
onDelete?: () => void;
|
|
19
|
+
onCancel?: () => void;
|
|
20
|
+
onSubmit?: () => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function SubmitButtons({ edit, loading, onDelete, onCancel, onSubmit, sx }: SubmitButtonsProps) {
|
|
24
|
+
return (
|
|
25
|
+
<Box sx={{ display: "flex", flexWrap: "wrap", gap: 2, justifyContent: "flex-end", ...sx }}>
|
|
26
|
+
{edit && <Button onClick={onDelete}>{getLocalizedString("Delete")}</Button>}
|
|
27
|
+
<Button onClick={onCancel}>{getLocalizedString("Cancel")}</Button>
|
|
28
|
+
<Button
|
|
29
|
+
loading={loading}
|
|
30
|
+
loadingPosition="start"
|
|
31
|
+
startIcon={<Add />}
|
|
32
|
+
type="submit"
|
|
33
|
+
variant="contained"
|
|
34
|
+
onClick={onSubmit}
|
|
35
|
+
>
|
|
36
|
+
{edit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
|
|
37
|
+
</Button>
|
|
38
|
+
</Box>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import DropDownArrowIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
2
|
-
import { Button, ListItemText, Menu, MenuItem } from "@mui/material";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import type { TransportElementsRecord } from "../data/dsTransportElements.js";
|
|
5
|
-
import { getLocalizedString } from "../../i18n.js";
|
|
6
|
-
|
|
7
|
-
export type TransportElementSelectProps = {
|
|
8
|
-
elements: TransportElementsRecord[];
|
|
9
|
-
onSelect: (element: TransportElementsRecord) => void;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function TransportElementSelect({ elements, onSelect }: TransportElementSelectProps) {
|
|
13
|
-
let [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
|
14
|
-
let open = !!anchorEl;
|
|
15
|
-
let [selected, setSelected] = useState<TransportElementsRecord | null>(null);
|
|
16
|
-
|
|
17
|
-
function handleChange(element: TransportElementsRecord) {
|
|
18
|
-
setAnchorEl(null);
|
|
19
|
-
onSelect(element);
|
|
20
|
-
setSelected(element);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<>
|
|
25
|
-
<Button
|
|
26
|
-
id="select_element"
|
|
27
|
-
variant="contained"
|
|
28
|
-
endIcon={
|
|
29
|
-
<DropDownArrowIcon
|
|
30
|
-
style={{ transform: open ? "rotate(180deg)" : "rotate(0deg)", transition: "transform 0.2s" }}
|
|
31
|
-
/>
|
|
32
|
-
}
|
|
33
|
-
sx={{ width: "165px" }}
|
|
34
|
-
aria-controls={open ? "basic-menu" : undefined}
|
|
35
|
-
aria-haspopup="true"
|
|
36
|
-
aria-expanded={open ? "true" : undefined}
|
|
37
|
-
onClick={(event) => setAnchorEl(event.currentTarget)}
|
|
38
|
-
>
|
|
39
|
-
{selected ? `${selected.ElementID} - ${selected.Name}` : getLocalizedString("Select element")}
|
|
40
|
-
</Button>
|
|
41
|
-
<Menu id="menu_element" anchorEl={anchorEl} open={open} onClose={() => setAnchorEl(null)}>
|
|
42
|
-
{elements.map((element) => (
|
|
43
|
-
<MenuItem key={element.PrimKey} onClick={() => handleChange(element)}>
|
|
44
|
-
<ListItemText>
|
|
45
|
-
{element.ElementID} - {element.Name}
|
|
46
|
-
</ListItemText>
|
|
47
|
-
</MenuItem>
|
|
48
|
-
))}
|
|
49
|
-
</Menu>
|
|
50
|
-
</>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
1
|
+
import DropDownArrowIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
2
|
+
import { Button, ListItemText, Menu, MenuItem } from "@mui/material";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import type { TransportElementsRecord } from "../data/dsTransportElements.js";
|
|
5
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
6
|
+
|
|
7
|
+
export type TransportElementSelectProps = {
|
|
8
|
+
elements: TransportElementsRecord[];
|
|
9
|
+
onSelect: (element: TransportElementsRecord) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function TransportElementSelect({ elements, onSelect }: TransportElementSelectProps) {
|
|
13
|
+
let [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
|
14
|
+
let open = !!anchorEl;
|
|
15
|
+
let [selected, setSelected] = useState<TransportElementsRecord | null>(null);
|
|
16
|
+
|
|
17
|
+
function handleChange(element: TransportElementsRecord) {
|
|
18
|
+
setAnchorEl(null);
|
|
19
|
+
onSelect(element);
|
|
20
|
+
setSelected(element);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<Button
|
|
26
|
+
id="select_element"
|
|
27
|
+
variant="contained"
|
|
28
|
+
endIcon={
|
|
29
|
+
<DropDownArrowIcon
|
|
30
|
+
style={{ transform: open ? "rotate(180deg)" : "rotate(0deg)", transition: "transform 0.2s" }}
|
|
31
|
+
/>
|
|
32
|
+
}
|
|
33
|
+
sx={{ width: "165px" }}
|
|
34
|
+
aria-controls={open ? "basic-menu" : undefined}
|
|
35
|
+
aria-haspopup="true"
|
|
36
|
+
aria-expanded={open ? "true" : undefined}
|
|
37
|
+
onClick={(event) => setAnchorEl(event.currentTarget)}
|
|
38
|
+
>
|
|
39
|
+
{selected ? `${selected.ElementID} - ${selected.Name}` : getLocalizedString("Select element")}
|
|
40
|
+
</Button>
|
|
41
|
+
<Menu id="menu_element" anchorEl={anchorEl} open={open} onClose={() => setAnchorEl(null)}>
|
|
42
|
+
{elements.map((element) => (
|
|
43
|
+
<MenuItem key={element.PrimKey} onClick={() => handleChange(element)}>
|
|
44
|
+
<ListItemText>
|
|
45
|
+
{element.ElementID} - {element.Name}
|
|
46
|
+
</ListItemText>
|
|
47
|
+
</MenuItem>
|
|
48
|
+
))}
|
|
49
|
+
</Menu>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
}
|