@olenbetong/synergi-react 2.2.3 → 2.3.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/FilePond.d.ts +8 -5
- package/es/components/FilePond.js +47 -20
- package/es/elements/ElementDamage/DamageFormButtons.d.ts +9 -0
- package/es/elements/ElementDamage/DamageFormButtons.js +7 -0
- package/es/elements/ElementDamage/DescriptionInput.d.ts +14 -0
- package/es/elements/ElementDamage/DescriptionInput.js +44 -0
- package/es/elements/{ElementDamageForm/DuplicateDamage/DuplicateElementDamageDialog.d.ts → ElementDamage/DuplicateDamage/DublicateElementDamageDialog.d.ts} +4 -3
- package/es/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.js +12 -0
- package/es/elements/ElementDamage/DuplicateDamage/index.d.ts +36 -0
- package/es/elements/ElementDamage/DuplicateDamage/index.js +40 -0
- package/es/elements/ElementDamage/ElementNumberTextField.d.ts +10 -0
- package/es/elements/ElementDamage/ElementNumberTextField.js +18 -0
- package/es/elements/ElementDamage/HiddenDamageFields.d.ts +6 -0
- package/es/elements/ElementDamage/HiddenDamageFields.js +4 -0
- package/es/elements/ElementDamage/RegisterFix.d.ts +14 -0
- package/es/elements/ElementDamage/RegisterFix.js +45 -0
- package/es/elements/ElementDamage/SubmitButtons.d.ts +20 -0
- package/es/elements/ElementDamage/SubmitButtons.js +7 -0
- package/es/elements/ElementDamage/TransportElementSelect.d.ts +7 -0
- package/es/elements/ElementDamage/TransportElementSelect.js +16 -0
- package/es/elements/ElementLookup.d.ts +20 -0
- package/es/elements/ElementLookup.js +30 -0
- package/es/elements/{AddElementDialog → ElementLookupDialog}/Manual/ManualForm.js +4 -2
- package/es/elements/{AddElementDialog → ElementLookupDialog}/getElement.d.ts +1 -0
- package/es/elements/{AddElementDialog → ElementLookupDialog}/getElement.js +1 -0
- package/es/elements/{AddElementDialog → ElementLookupDialog}/index.d.ts +5 -5
- package/es/elements/{AddElementDialog → ElementLookupDialog}/index.js +4 -1
- package/es/elements/ProjectSelect.js +9 -2
- package/es/elements/data/dsDamages.d.ts +1 -1
- package/es/elements/data/dsDamages.js +2 -2
- package/es/elements/data/dsElements.d.ts +2 -0
- package/es/elements/data/dsElements.js +11 -1
- package/es/elements/data/dsTransportElements.d.ts +10 -0
- package/es/elements/data/dsTransportElements.js +57 -0
- package/es/elements/data/index.d.ts +5 -1
- package/es/elements/data/index.js +5 -1
- package/es/elements/data/procDeleteAttachment.d.ts +2 -0
- package/es/elements/data/procDeleteAttachment.js +18 -0
- package/es/elements/data/procDeleteDamage.d.ts +2 -0
- package/es/elements/data/procDeleteDamage.js +18 -0
- package/es/elements/data/procRemoveDamageFix.d.ts +2 -0
- package/es/elements/data/procRemoveDamageFix.js +18 -0
- package/es/elements/data/procRestoreAttachments.d.ts +2 -0
- package/es/elements/data/procRestoreAttachments.js +18 -0
- package/es/elements/index.d.ts +8 -2
- package/es/elements/index.js +8 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/package.json +1 -1
- package/src/components/FilePond.tsx +73 -26
- package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -0
- package/src/elements/ElementDamage/DescriptionInput.tsx +111 -0
- package/src/elements/{ElementDamageForm/DuplicateDamage/DuplicateElementDamageDialog.tsx → ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx} +24 -9
- package/src/elements/ElementDamage/DuplicateDamage/index.tsx +105 -0
- package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -0
- package/src/elements/ElementDamage/HiddenDamageFields.tsx +13 -0
- package/src/elements/ElementDamage/RegisterFix.tsx +100 -0
- package/src/elements/ElementDamage/SubmitButtons.tsx +40 -0
- package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -0
- package/src/elements/ElementLookup.tsx +90 -0
- package/src/elements/{AddElementDialog → ElementLookupDialog}/Manual/ManualForm.tsx +5 -2
- package/src/elements/{AddElementDialog → ElementLookupDialog}/getElement.ts +2 -0
- package/src/elements/{AddElementDialog → ElementLookupDialog}/index.tsx +9 -5
- package/src/elements/ProjectSelect.tsx +13 -3
- package/src/elements/data/dsDamages.ts +3 -3
- package/src/elements/data/dsElements.ts +13 -1
- package/src/elements/data/dsTransportElements.ts +68 -0
- package/src/elements/data/index.ts +5 -1
- package/src/elements/data/procDeleteAttachment.ts +19 -0
- package/src/elements/data/procDeleteDamage.ts +19 -0
- package/src/elements/data/procRemoveDamageFix.ts +19 -0
- package/src/elements/data/procRestoreAttachments.ts +19 -0
- package/src/elements/index.ts +8 -3
- package/src/index.ts +1 -1
- package/es/elements/ElementDamageForm/DamageFormFields.d.ts +0 -12
- package/es/elements/ElementDamageForm/DamageFormFields.js +0 -39
- package/es/elements/ElementDamageForm/DuplicateDamage/DuplicateElementDamageDialog.js +0 -11
- package/es/elements/ElementDamageForm/index.d.ts +0 -13
- package/es/elements/ElementDamageForm/index.js +0 -219
- package/src/elements/ElementDamageForm/DamageFormFields.tsx +0 -149
- package/src/elements/ElementDamageForm/index.tsx +0 -397
- /package/es/elements/{ElementDamageForm → ElementDamage}/DuplicateDamage/DesktopView.d.ts +0 -0
- /package/es/elements/{ElementDamageForm → ElementDamage}/DuplicateDamage/DesktopView.js +0 -0
- /package/es/elements/{ElementDamageForm → ElementDamage}/DuplicateDamage/PhoneView.d.ts +0 -0
- /package/es/elements/{ElementDamageForm → ElementDamage}/DuplicateDamage/PhoneView.js +0 -0
- /package/es/elements/{ElementDamageForm → ElementDamage}/index.css +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/DeadIcon.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/DeadIcon.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/Error.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/Error.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/index.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/index.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/useScanner.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/useScanner.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/index.css +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/index.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/index.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/useHIDScanner.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/useHIDScanner.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/Manual/ManualForm.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/utils/Giai.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/utils/Giai.js +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/utils/beep.d.ts +0 -0
- /package/es/elements/{AddElementDialog → ElementLookupDialog}/utils/beep.js +0 -0
- /package/src/elements/{ElementDamageForm → ElementDamage}/DuplicateDamage/DesktopView.tsx +0 -0
- /package/src/elements/{ElementDamageForm → ElementDamage}/DuplicateDamage/PhoneView.tsx +0 -0
- /package/src/elements/{ElementDamageForm → ElementDamage}/index.css +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/DeadIcon.tsx +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/Error.tsx +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/index.tsx +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/BarcodeScanner/useScanner.ts +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/index.css +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/index.tsx +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/HIDScanner/useHIDScanner.ts +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/utils/Giai.ts +0 -0
- /package/src/elements/{AddElementDialog → ElementLookupDialog}/utils/beep.ts +0 -0
|
@@ -5,20 +5,20 @@ export type AddElement = {
|
|
|
5
5
|
scanTime?: number;
|
|
6
6
|
};
|
|
7
7
|
type InitialTabProps = "camera" | "scanner" | "manual";
|
|
8
|
-
export type
|
|
8
|
+
export type ElementLookupDialogSharedProps = {
|
|
9
9
|
open: boolean;
|
|
10
10
|
onClose: () => void;
|
|
11
11
|
initialTab?: InitialTabProps | null;
|
|
12
12
|
useSearch?: boolean;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
14
|
+
export type ElementLookupDialogSingleModeProps = ElementLookupDialogSharedProps & {
|
|
15
15
|
mode: "single" | "search";
|
|
16
16
|
onAdd: (element: AddElement) => Promise<void>;
|
|
17
17
|
};
|
|
18
|
-
export type
|
|
18
|
+
export type ElementLookupDialogMultiModeProps = ElementLookupDialogSharedProps & {
|
|
19
19
|
mode: "multi";
|
|
20
20
|
onAdd: (element: AddElement[]) => Promise<void>;
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
23
|
-
export declare function
|
|
22
|
+
export type ElementLookupDialogProps = ElementLookupDialogSingleModeProps | ElementLookupDialogMultiModeProps;
|
|
23
|
+
export declare function ElementLookupDialog(props: ElementLookupDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
export {};
|
|
@@ -15,7 +15,7 @@ import { AddElementHIDScanner } from "./HIDScanner";
|
|
|
15
15
|
import { AddElementManualForm } from "./Manual/ManualForm";
|
|
16
16
|
import { useBeeper } from "./utils/beep";
|
|
17
17
|
import Giai from "./utils/Giai";
|
|
18
|
-
export function
|
|
18
|
+
export function ElementLookupDialog(props) {
|
|
19
19
|
let { open, onClose, initialTab } = props;
|
|
20
20
|
let [tab, setTab] = useState("camera");
|
|
21
21
|
let [elements, setElements] = useState([]);
|
|
@@ -67,6 +67,9 @@ export function AddElementDialog(props) {
|
|
|
67
67
|
alert(error.message);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
if (tab === "manual" && props.mode === "search") {
|
|
71
|
+
tab = "camera";
|
|
72
|
+
}
|
|
70
73
|
return (_jsx(ResponsiveDialog, { open: open, onClose: onClose, slotProps: {
|
|
71
74
|
paper: { sx: { overflow: "hidden" } },
|
|
72
75
|
}, children: _jsxs(Box, { display: "flex", flexDirection: "column", maxHeight: "100%", overflow: "hidden", flexGrow: 1, children: [_jsxs(Tabs, { value: tab, onChange: (_, newTab) => setTab(newTab), variant: "fullWidth", sx: { flexShrink: 0 }, children: [props.mode !== "search" && _jsx(Tab, { icon: _jsx(Edit, {}), label: getLocalizedString("Manual"), value: "manual" }), _jsx(Tab, { icon: _jsx(TapAndPlay, {}), label: getLocalizedString("Scanner"), value: "scanner" }), _jsx(Tab, { icon: _jsx(QrCodeScanner, {}), label: getLocalizedString("Camera"), value: "camera" })] }), tab === "camera" && (_jsx(Box, { flexBasis: "12rem", flexGrow: 1, flexShrink: 2, children: _jsx(BarcodeScanner, { onRead: (element) => handleElementAdd(element, "camera-barcode") }) })), tab === "manual" && (_jsx(Box, { p: 2, children: _jsx(AddElementManualForm, { onAdd: (element) => handleElementAdd(element, "manual") }) })), tab === "scanner" && (_jsx(Box, { flexBasis: "12rem", flexGrow: 1, flexShrink: 2, children: _jsx(AddElementHIDScanner, { onScan: (element) => handleElementAdd(element, element.startsWith(Giai.BARCODE_PREFIX) ? "hid-barcode" : "hid-rfid") }) })), _jsxs(Box, { flex: "3 1 14rem", overflow: "auto", children: [props.mode === "multi" && (_jsx(Alert, { icon: false, severity: "info", sx: { justifyContent: "center", py: 0, position: "sticky", top: 0, zIndex: 1 }, slotProps: {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Autocomplete, ListItem, ListItemText, TextField } from "@mui/material";
|
|
3
3
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
4
|
import { useDataWithFilter, useDebounce } from "@olenbetong/appframe-react";
|
|
5
|
-
import { useMemo, useState } from "react";
|
|
5
|
+
import { useMemo, useRef, useState } from "react";
|
|
6
6
|
import { dsProjects } from "./data/dsProjects";
|
|
7
7
|
import { dsReportProjects } from "./data/dsReportProjects";
|
|
8
8
|
export function ProjectSelect({ className, disabled, id, names, onChange, readOnly, required, defaultValue, value, label, sx, report, }) {
|
|
@@ -10,7 +10,9 @@ export function ProjectSelect({ className, disabled, id, names, onChange, readOn
|
|
|
10
10
|
let [query, setQuery] = useState("");
|
|
11
11
|
let search = useDebounce(query);
|
|
12
12
|
let projects = useDataWithFilter(report ? dsReportProjects : dsProjects, search ? `[SearchColumn] LIKE '%${search}%'` : "");
|
|
13
|
+
let highlightRef = useRef(null);
|
|
13
14
|
function handleSelect(value) {
|
|
15
|
+
highlightRef.current = null;
|
|
14
16
|
if (!disabled && !readOnly) {
|
|
15
17
|
if (onChange) {
|
|
16
18
|
onChange(value);
|
|
@@ -28,7 +30,12 @@ export function ProjectSelect({ className, disabled, id, names, onChange, readOn
|
|
|
28
30
|
});
|
|
29
31
|
return new Set([...nameCount.entries()].filter(([, count]) => count > 1).map(([name]) => name));
|
|
30
32
|
}, [projects]);
|
|
31
|
-
return (_jsxs(_Fragment, { children: [_jsx(Autocomplete, { sx: sx, autoHighlight: true, className: className, options: projects, disabled: disabled, getOptionLabel: (option) => option?.ProjectID !== undefined ? `${option.ProjectID}: ${option.ProjectName}` : "", isOptionEqualToValue: (option, value) => option.Domain === value.Domain && option.ProjectID === value.ProjectID,
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx(Autocomplete, { sx: sx, autoHighlight: true, autoSelect: true, clearOnEscape: true, className: className, options: projects, disabled: disabled, getOptionLabel: (option) => option?.ProjectID !== undefined ? `${option.ProjectID}: ${option.ProjectName}` : "", isOptionEqualToValue: (option, value) => option.Domain === value.Domain && option.ProjectID === value.ProjectID, onChange: (_, value) => handleSelect(value), onClose: () => setQuery(""), value: value !== undefined ? value : selected, renderInput: (params) => (_jsx(TextField, { ...params, label: label ? label : getLocalizedString("Project ID"), id: id ?? "ProjectLookup", fullWidth: true, slotProps: {
|
|
34
|
+
htmlInput: {
|
|
35
|
+
readOnly,
|
|
36
|
+
...params.inputProps,
|
|
37
|
+
},
|
|
38
|
+
}, autoComplete: "off", variant: "filled", required: required, onChange: (evt) => setQuery(evt.target.value), value: query })), renderOption: (props, option) => {
|
|
32
39
|
let isDuplicated = option.ProjectName && duplicatedNames.has(option.ProjectName);
|
|
33
40
|
return (_jsx(ListItem, { ...props, children: _jsx(ListItemText, { primary: isDuplicated ? `${option.ProjectName} (${option.Domain})` : option.ProjectName, secondary: option.ProjectID }) }));
|
|
34
41
|
} }), _jsx("input", { name: names?.domain ?? "Domain", type: "hidden", value: current?.Domain ?? "" }), _jsx("input", { name: names?.name ?? "ProjectName", type: "hidden", value: current?.ProjectName ?? "" }), _jsx("input", { name: names?.projectId ?? "ProjectID", type: "hidden", value: current?.ProjectID ?? "" })] }));
|
|
@@ -17,8 +17,8 @@ export type DamagesRecord = {
|
|
|
17
17
|
Action: string | null;
|
|
18
18
|
RegisteredFix: Date | null;
|
|
19
19
|
RegisteredFixBy: string | null;
|
|
20
|
+
RegisteredFixFullName: string | null;
|
|
20
21
|
Cause: string | null;
|
|
21
|
-
FullName: string | null;
|
|
22
22
|
SearchColumn: string;
|
|
23
23
|
ElementRef: string | null;
|
|
24
24
|
};
|
|
@@ -100,12 +100,12 @@ export const dsDamages = generateApiDataObject({
|
|
|
100
100
|
nullable: true,
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
|
-
name: "
|
|
103
|
+
name: "RegisteredFixFullName",
|
|
104
104
|
type: "string",
|
|
105
105
|
nullable: true,
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
|
-
name: "
|
|
108
|
+
name: "Cause",
|
|
109
109
|
type: "string",
|
|
110
110
|
nullable: true,
|
|
111
111
|
},
|
|
@@ -4,7 +4,7 @@ af resources generate aviw_Production_Elements_All \
|
|
|
4
4
|
--id dsElements \
|
|
5
5
|
--types \
|
|
6
6
|
--max-records 100 \
|
|
7
|
-
--fields PrimKey,ProjectID,ElementID
|
|
7
|
+
--fields PrimKey,ProjectID,ElementID,ProjectName,Name
|
|
8
8
|
*/
|
|
9
9
|
import { generateApiDataObject } from "@olenbetong/appframe-data";
|
|
10
10
|
export const dsElements = generateApiDataObject({
|
|
@@ -25,11 +25,21 @@ export const dsElements = generateApiDataObject({
|
|
|
25
25
|
type: "string",
|
|
26
26
|
nullable: false,
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
name: "ProjectName",
|
|
30
|
+
type: "string",
|
|
31
|
+
nullable: false,
|
|
32
|
+
},
|
|
28
33
|
{
|
|
29
34
|
name: "ElementID",
|
|
30
35
|
type: "string",
|
|
31
36
|
nullable: true,
|
|
32
37
|
},
|
|
38
|
+
{
|
|
39
|
+
name: "Name",
|
|
40
|
+
type: "string",
|
|
41
|
+
nullable: true,
|
|
42
|
+
},
|
|
33
43
|
],
|
|
34
44
|
parameters: {
|
|
35
45
|
maxRecords: 100,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type TransportElementsRecord = {
|
|
2
|
+
PrimKey: string;
|
|
3
|
+
DeliveryTicketID: number;
|
|
4
|
+
Domain: string;
|
|
5
|
+
ProjectID: string;
|
|
6
|
+
ProjectName: string;
|
|
7
|
+
ElementID: string | null;
|
|
8
|
+
Name: string | null;
|
|
9
|
+
};
|
|
10
|
+
export declare const dsTransportElements: import("@olenbetong/appframe-data").DataObject<TransportElementsRecord>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
auto-generated by CLI:
|
|
3
|
+
af resources generate aviw_Fleet_DeliveryTickets_Elements \
|
|
4
|
+
--id dsTransportElements \
|
|
5
|
+
--types \
|
|
6
|
+
--max-records 100 \
|
|
7
|
+
--fields PrimKey,DeliveryTicketID,ProjectID,ProjectName,ElementID,Name,Domain
|
|
8
|
+
*/
|
|
9
|
+
import { generateApiDataObject } from "@olenbetong/appframe-data";
|
|
10
|
+
export const dsTransportElements = generateApiDataObject({
|
|
11
|
+
resource: "aviw_Fleet_DeliveryTickets_Elements",
|
|
12
|
+
id: "dsTransportElements",
|
|
13
|
+
allowUpdate: false,
|
|
14
|
+
allowInsert: false,
|
|
15
|
+
allowDelete: false,
|
|
16
|
+
dynamicLoading: false,
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
name: "PrimKey",
|
|
20
|
+
type: "string",
|
|
21
|
+
nullable: false,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "DeliveryTicketID",
|
|
25
|
+
type: "number",
|
|
26
|
+
nullable: false,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "Domain",
|
|
30
|
+
type: "string",
|
|
31
|
+
nullable: false,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "ProjectID",
|
|
35
|
+
type: "string",
|
|
36
|
+
nullable: false,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "ProjectName",
|
|
40
|
+
type: "string",
|
|
41
|
+
nullable: false,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "ElementID",
|
|
45
|
+
type: "string",
|
|
46
|
+
nullable: true,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "Name",
|
|
50
|
+
type: "string",
|
|
51
|
+
nullable: true,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
parameters: {
|
|
55
|
+
maxRecords: 100,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -3,5 +3,9 @@ export * from "./dsCurrentAttachment.js";
|
|
|
3
3
|
export * from "./dsDamages.js";
|
|
4
4
|
export * from "./dsDamagesDuplicateCheck.js";
|
|
5
5
|
export * from "./dsElements.js";
|
|
6
|
-
export * from "./procApproveDamage.js";
|
|
7
6
|
export * from "./dsProjects.js";
|
|
7
|
+
export * from "./procApproveDamage.js";
|
|
8
|
+
export * from "./procDeleteAttachment.js";
|
|
9
|
+
export * from "./procDeleteDamage.js";
|
|
10
|
+
export * from "./procRemoveDamageFix.js";
|
|
11
|
+
export * from "./procRestoreAttachments.js";
|
|
@@ -3,5 +3,9 @@ export * from "./dsCurrentAttachment.js";
|
|
|
3
3
|
export * from "./dsDamages.js";
|
|
4
4
|
export * from "./dsDamagesDuplicateCheck.js";
|
|
5
5
|
export * from "./dsElements.js";
|
|
6
|
-
export * from "./procApproveDamage.js";
|
|
7
6
|
export * from "./dsProjects.js";
|
|
7
|
+
export * from "./procApproveDamage.js";
|
|
8
|
+
export * from "./procDeleteAttachment.js";
|
|
9
|
+
export * from "./procDeleteDamage.js";
|
|
10
|
+
export * from "./procRemoveDamageFix.js";
|
|
11
|
+
export * from "./procRestoreAttachments.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
auto-generated by CLI:
|
|
3
|
+
af resources generate astp_Production_ElementsDamages_DeleteAttachments \
|
|
4
|
+
--id procDeleteAttachment
|
|
5
|
+
*/
|
|
6
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
7
|
+
export const procDeleteAttachment = new ProcedureAPI({
|
|
8
|
+
procedureId: "astp_Production_ElementsDamages_DeleteAttachments",
|
|
9
|
+
parameters: [
|
|
10
|
+
{
|
|
11
|
+
name: "PrimKeyList",
|
|
12
|
+
type: "string",
|
|
13
|
+
hasDefault: false,
|
|
14
|
+
required: false,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
timeout: 30000,
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
auto-generated by CLI:
|
|
3
|
+
af resources generate astp_Production_ElementsDamages_Delete \
|
|
4
|
+
--id procDeleteDamage
|
|
5
|
+
*/
|
|
6
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
7
|
+
export const procDeleteDamage = new ProcedureAPI({
|
|
8
|
+
procedureId: "astp_Production_ElementsDamages_Delete",
|
|
9
|
+
parameters: [
|
|
10
|
+
{
|
|
11
|
+
name: "ID",
|
|
12
|
+
type: "number",
|
|
13
|
+
hasDefault: false,
|
|
14
|
+
required: false,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
timeout: 30000,
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
auto-generated by CLI:
|
|
3
|
+
af resources generate astp_Production_ElementsDamages_RemoveFix \
|
|
4
|
+
--id procRemoveDamageFix
|
|
5
|
+
*/
|
|
6
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
7
|
+
export const procRemoveDamageFix = new ProcedureAPI({
|
|
8
|
+
procedureId: "astp_Production_ElementsDamages_RemoveFix",
|
|
9
|
+
parameters: [
|
|
10
|
+
{
|
|
11
|
+
name: "ID",
|
|
12
|
+
type: "number",
|
|
13
|
+
hasDefault: false,
|
|
14
|
+
required: false,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
timeout: 30000,
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
auto-generated by CLI:
|
|
3
|
+
af resources generate astp_Production_ElementsDamages_RestoreAttachments \
|
|
4
|
+
--id procRestoreAttachments
|
|
5
|
+
*/
|
|
6
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
7
|
+
export const procRestoreAttachments = new ProcedureAPI({
|
|
8
|
+
procedureId: "astp_Production_ElementsDamages_RestoreAttachments",
|
|
9
|
+
parameters: [
|
|
10
|
+
{
|
|
11
|
+
name: "PrimKeyList",
|
|
12
|
+
type: "string",
|
|
13
|
+
hasDefault: false,
|
|
14
|
+
required: false,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
timeout: 30000,
|
|
18
|
+
});
|
package/es/elements/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export * from "./data/index.js";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
2
|
+
export * from "./ElementDamage/DescriptionInput.js";
|
|
3
|
+
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
4
|
+
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
5
|
+
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
6
|
+
export * from "./ElementDamage/RegisterFix.js";
|
|
7
|
+
export * from "./ElementDamage/SubmitButtons.js";
|
|
8
|
+
export * from "./ElementLookup.js";
|
|
9
|
+
export * from "./ElementLookupDialog/index.js";
|
package/es/elements/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export * from "./data/index.js";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
2
|
+
export * from "./ElementDamage/DescriptionInput.js";
|
|
3
|
+
export * from "./ElementDamage/DuplicateDamage/index.js";
|
|
4
|
+
export * from "./ElementDamage/ElementNumberTextField.js";
|
|
5
|
+
export * from "./ElementDamage/HiddenDamageFields.js";
|
|
6
|
+
export * from "./ElementDamage/RegisterFix.js";
|
|
7
|
+
export * from "./ElementDamage/SubmitButtons.js";
|
|
8
|
+
export * from "./ElementLookup.js";
|
|
9
|
+
export * from "./ElementLookupDialog/index.js";
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Checkbox, type CheckboxProps } from "./components/Checkbox/index.js";
|
|
2
2
|
export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
|
|
3
3
|
export { DateNavigator } from "./components/DateNavigator/index.js";
|
|
4
|
+
export * from "./components/FilePond.js";
|
|
4
5
|
export { Card, LinkedList, LinkedListItem } from "./components/LinkedCardList/index.js";
|
|
5
6
|
export { BannerImage as PageBannerImage, type BannerImageProps, PageBanner, type PageBannerProps, Tab as PageBannerTab, TabList as PageBannerTabList, type TabListProps as PageBannerTabListProps, type TabProps as PageBannerTabProps, Title as PageBannerTitle, type TitleProps as PageBannerTitleProps, } from "./components/PageBanner/index.js";
|
|
6
7
|
export { Portal } from "./components/Portal/index.js";
|
|
@@ -9,5 +10,4 @@ export { Sidebar, type SidebarProps } from "./components/Sidebar/index.js";
|
|
|
9
10
|
export { Spinner, type SpinnerProps } from "./components/Spinner/index.js";
|
|
10
11
|
export { SplitContainer, type SplitContainerProps } from "./components/SplitContainer/index.js";
|
|
11
12
|
export { ValueToggleGroup, type ValueToggleGroupProps } from "./components/ValueToggleGroup/index.js";
|
|
12
|
-
export { ElementDamageForm } from "./elements/ElementDamageForm/index.js";
|
|
13
13
|
export { useTranslation } from "./useTranslation/index.js";
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Checkbox } from "./components/Checkbox/index.js";
|
|
2
2
|
export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
|
|
3
3
|
export { DateNavigator } from "./components/DateNavigator/index.js";
|
|
4
|
+
export * from "./components/FilePond.js";
|
|
4
5
|
export { Card, LinkedList, LinkedListItem } from "./components/LinkedCardList/index.js";
|
|
5
6
|
export { BannerImage as PageBannerImage, PageBanner, Tab as PageBannerTab, TabList as PageBannerTabList, Title as PageBannerTitle, } from "./components/PageBanner/index.js";
|
|
6
7
|
export { Portal } from "./components/Portal/index.js";
|
|
@@ -9,5 +10,4 @@ export { Sidebar } from "./components/Sidebar/index.js";
|
|
|
9
10
|
export { Spinner } from "./components/Spinner/index.js";
|
|
10
11
|
export { SplitContainer } from "./components/SplitContainer/index.js";
|
|
11
12
|
export { ValueToggleGroup } from "./components/ValueToggleGroup/index.js";
|
|
12
|
-
export { ElementDamageForm } from "./elements/ElementDamageForm/index.js";
|
|
13
13
|
export { useTranslation } from "./useTranslation/index.js";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import "filepond/dist/filepond.css";
|
|
|
4
4
|
|
|
5
5
|
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
6
6
|
import type { DataObject } from "@olenbetong/appframe-data";
|
|
7
|
-
import { useData } from "@olenbetong/appframe-react";
|
|
7
|
+
import { useData, useFetchData } from "@olenbetong/appframe-react";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
create,
|
|
@@ -20,7 +20,7 @@ import FilePondPluginImageExifOrientation from "filepond-plugin-image-exif-orien
|
|
|
20
20
|
import FilePondPluginImagePreview from "filepond-plugin-image-preview";
|
|
21
21
|
import FilePondPluginImageResize from "filepond-plugin-image-resize";
|
|
22
22
|
import FilePondPluginImageTransform from "filepond-plugin-image-transform";
|
|
23
|
-
import { type RefObject, useEffect, useRef } from "react";
|
|
23
|
+
import { type RefObject, useEffect, useMemo, useRef } from "react";
|
|
24
24
|
|
|
25
25
|
export { registerPlugin, FileStatus };
|
|
26
26
|
|
|
@@ -82,10 +82,11 @@ const labels = {
|
|
|
82
82
|
type FilePondProps<T extends Record<string, unknown>> = React.HTMLProps<HTMLInputElement> & {
|
|
83
83
|
dataObject: DataObject<T>;
|
|
84
84
|
fields: Partial<T>;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
onError: () => void;
|
|
85
|
+
onUploadStart: () => void;
|
|
86
|
+
onFileUploaded: (error: FilePondErrorDescription | null, file: FilePondFile) => void;
|
|
87
|
+
onFinishedUploads: () => void;
|
|
88
|
+
onError: (error: string) => void;
|
|
89
|
+
onFileRemoved?: (primKey: string) => void;
|
|
89
90
|
/**
|
|
90
91
|
* If the file should be uploaded to a blob field, set the field name here
|
|
91
92
|
*/
|
|
@@ -102,8 +103,28 @@ type FilePondProps<T extends Record<string, unknown>> = React.HTMLProps<HTMLInpu
|
|
|
102
103
|
* Options to pass to FilePond
|
|
103
104
|
*/
|
|
104
105
|
filePondOptions?: Partial<FilePondOptions>;
|
|
106
|
+
attachmentPrimKeys?: string[];
|
|
107
|
+
whereClause?: string;
|
|
105
108
|
};
|
|
106
109
|
|
|
110
|
+
function getFileUrl<T extends Record<string, unknown>>(
|
|
111
|
+
dataObject: DataObject<T>,
|
|
112
|
+
fieldName?: string,
|
|
113
|
+
primKey?: string,
|
|
114
|
+
action = "upload",
|
|
115
|
+
) {
|
|
116
|
+
let url =
|
|
117
|
+
action === "upload"
|
|
118
|
+
? dataObject.dataHandler.getUploadUrl()
|
|
119
|
+
: dataObject.dataHandler.getFileStoreURL(primKey ?? "", fieldName ?? "");
|
|
120
|
+
|
|
121
|
+
if (action === "upload") {
|
|
122
|
+
url += "/";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return url?.replaceAll("//", "/") ?? "";
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
type FileStoreDataObjectRecord = {
|
|
108
129
|
PrimKey: string;
|
|
109
130
|
FileName: string | null;
|
|
@@ -117,19 +138,29 @@ type FileStoreDataObjectRecord = {
|
|
|
117
138
|
export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
118
139
|
dataObject,
|
|
119
140
|
fields,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
141
|
+
onUploadStart,
|
|
142
|
+
onFileUploaded,
|
|
143
|
+
onFinishedUploads,
|
|
144
|
+
onFileRemoved,
|
|
123
145
|
onError,
|
|
124
146
|
fieldName,
|
|
125
147
|
filePondOptions,
|
|
126
148
|
primKey,
|
|
149
|
+
attachmentPrimKeys,
|
|
150
|
+
whereClause,
|
|
127
151
|
inputRef: inputRefProp,
|
|
128
152
|
...props
|
|
129
153
|
}: FilePondProps<T>) {
|
|
130
154
|
let inputRef = useRef<HTMLInputElement>(null);
|
|
131
155
|
let pondRef = useRef<FilePondInstance | null>(null);
|
|
132
|
-
let
|
|
156
|
+
let filesData = useData(dataObject);
|
|
157
|
+
let { data: filesFetched } = useFetchData(dataObject, whereClause ?? "1=2");
|
|
158
|
+
let files = useMemo(() => {
|
|
159
|
+
if (whereClause) {
|
|
160
|
+
return filesFetched;
|
|
161
|
+
}
|
|
162
|
+
return filesData;
|
|
163
|
+
}, [whereClause, filesFetched, filesData]);
|
|
133
164
|
let clearFilesRef = useRef(false);
|
|
134
165
|
|
|
135
166
|
useEffect(() => {
|
|
@@ -154,6 +185,7 @@ export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
|
154
185
|
} as Partial<T>);
|
|
155
186
|
|
|
156
187
|
if (result) {
|
|
188
|
+
onFileRemoved?.(source);
|
|
157
189
|
load();
|
|
158
190
|
} else {
|
|
159
191
|
error("Failed to delete file on server. Delete request returned false");
|
|
@@ -168,12 +200,6 @@ export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
|
168
200
|
}
|
|
169
201
|
}
|
|
170
202
|
|
|
171
|
-
let uploadUrl = dataObject.dataHandler.getUploadUrl({ fieldName, primKey });
|
|
172
|
-
|
|
173
|
-
if (!uploadUrl) {
|
|
174
|
-
throw new Error("DataHandler does not support file uploads.");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
203
|
let options: FilePondOptions = {
|
|
178
204
|
allowMultiple: Boolean(props.multiple),
|
|
179
205
|
allowImageResize: true,
|
|
@@ -182,11 +208,26 @@ export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
|
182
208
|
imageResizeTargetHeight: 2400,
|
|
183
209
|
imageResizeUpscale: false,
|
|
184
210
|
...labels,
|
|
185
|
-
onaddfilestart: () =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
211
|
+
onaddfilestart: (file) => {
|
|
212
|
+
if (file.status !== 5 && file.status !== 6 && file.status !== 10) {
|
|
213
|
+
onUploadStart();
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
onprocessfile: (error, file) => {
|
|
217
|
+
onFileUploaded(error, file);
|
|
218
|
+
|
|
219
|
+
let refFiles = pondRef.current?.getFiles();
|
|
220
|
+
let found = refFiles?.find(
|
|
221
|
+
(file) => file.status !== 2 && file.status !== 5 && file.status !== 6 && file.status !== 10,
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
if (found === undefined) {
|
|
225
|
+
onFinishedUploads();
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
onprocessfiles: () => onFinishedUploads(),
|
|
229
|
+
onerror: (error) => onError(error.body),
|
|
230
|
+
beforeRemoveFile: () => {
|
|
190
231
|
if (confirm(getLocalizedString("Are you sure you want to remove this file?"))) {
|
|
191
232
|
return true;
|
|
192
233
|
}
|
|
@@ -194,11 +235,14 @@ export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
|
194
235
|
return false;
|
|
195
236
|
},
|
|
196
237
|
server: {
|
|
238
|
+
load: getFileUrl(dataObject, fieldName, primKey, "view"),
|
|
239
|
+
restore: getFileUrl(dataObject, fieldName, primKey, "view"),
|
|
240
|
+
|
|
197
241
|
revert: removeUploadedFile,
|
|
198
242
|
remove: removeUploadedFile,
|
|
199
243
|
|
|
200
244
|
process: {
|
|
201
|
-
url:
|
|
245
|
+
url: getFileUrl(dataObject, fieldName),
|
|
202
246
|
ondata: (formData) => {
|
|
203
247
|
let masterChildCriteria = dataObject.getParameter("masterChildCriteria");
|
|
204
248
|
let allFields = { ...masterChildCriteria, ...fields };
|
|
@@ -227,13 +271,14 @@ export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
|
227
271
|
props.multiple,
|
|
228
272
|
fields,
|
|
229
273
|
fieldName,
|
|
274
|
+
primKey,
|
|
230
275
|
inputRefProp,
|
|
231
276
|
filePondOptions,
|
|
232
277
|
onError,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
278
|
+
onFileUploaded,
|
|
279
|
+
onUploadStart,
|
|
280
|
+
onFinishedUploads,
|
|
281
|
+
onFileRemoved,
|
|
237
282
|
]);
|
|
238
283
|
|
|
239
284
|
useEffect(() => {
|
|
@@ -259,6 +304,8 @@ export function FilePond<T extends FileStoreDataObjectRecord>({
|
|
|
259
304
|
|
|
260
305
|
return (
|
|
261
306
|
<div className="filepond--wrapper">
|
|
307
|
+
{attachmentPrimKeys && <input type="hidden" name="AttachmentPrimkeys" value={attachmentPrimKeys} />}
|
|
308
|
+
|
|
262
309
|
<input type="file" {...props} name="File" ref={inputRefProp ?? inputRef} />
|
|
263
310
|
</div>
|
|
264
311
|
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Add from "@mui/icons-material/Add";
|
|
2
|
+
import { Button } from "@mui/material";
|
|
3
|
+
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
|
+
|
|
5
|
+
type DamageFormButtonsProps = {
|
|
6
|
+
isEdit: boolean;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
uploadingFile: boolean;
|
|
9
|
+
handleDelete: () => void;
|
|
10
|
+
handleCancel: () => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function DamageFormButtonsProps({
|
|
14
|
+
isEdit,
|
|
15
|
+
loading,
|
|
16
|
+
uploadingFile,
|
|
17
|
+
handleDelete,
|
|
18
|
+
handleCancel,
|
|
19
|
+
}: DamageFormButtonsProps) {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
{isEdit && <Button onClick={handleDelete}>{getLocalizedString("Delete")}</Button>}
|
|
23
|
+
<Button onClick={handleCancel}>{getLocalizedString("Cancel")}</Button>
|
|
24
|
+
<Button
|
|
25
|
+
loading={loading || uploadingFile}
|
|
26
|
+
loadingPosition="start"
|
|
27
|
+
startIcon={<Add />}
|
|
28
|
+
type="submit"
|
|
29
|
+
variant="contained"
|
|
30
|
+
>
|
|
31
|
+
{isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
|
|
32
|
+
</Button>
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|