Skip to content

Commit baad1cf

Browse files
Samuel ShresthaSamuel Shrestha
authored andcommitted
#3880: Added Copy From Existing BOM Button
1 parent 669a815 commit baad1cf

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/frontend/src/components/NERFormModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const NERFormModal = ({
2525
children,
2626
showCloseButton,
2727
hideBackDrop = false,
28-
paperProps
28+
paperProps,
29+
copyFromExistingBomAction
2930
}: NERFormModalProps<any>) => {
3031
/**
3132
* Wrapper function for onSubmit so that form data is reset after submit
@@ -56,6 +57,7 @@ const NERFormModal = ({
5657
showCloseButton={showCloseButton}
5758
hideBackDrop={hideBackDrop}
5859
paperProps={paperProps}
60+
copyFromExistingBomAction={copyFromExistingBomAction}
5961
>
6062
<form id={formId} onSubmit={handleFormSubmit} noValidate>
6163
{children}

src/frontend/src/components/NERModal.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface NERModalProps {
2323
hideBackDrop?: boolean;
2424
icon?: JSX.Element | null;
2525
paperProps?: any;
26+
copyFromExistingBomAction?: ReactNode;
2627
}
2728

2829
const NERModal = ({
@@ -40,7 +41,8 @@ const NERModal = ({
4041
hideBackDrop = false,
4142
icon,
4243
paperProps,
43-
titleChildren
44+
titleChildren,
45+
copyFromExistingBomAction
4446
}: NERModalProps) => {
4547
return (
4648
<Dialog
@@ -111,13 +113,19 @@ const NERModal = ({
111113
</DialogContent>
112114
{!hideFormButtons && (
113115
<DialogActions>
116+
<Box sx={{ display: 'flex', alighItems: 'center', justifyContent: 'space-between', width: '100%' }}>
117+
<Box sx={{ ml: 1 }}>
118+
{copyFromExistingBomAction}
119+
</Box>
120+
114121
<Box sx={{ display: 'flex', flexDirection: 'row', mb: 1 }}>
115122
<NERFailButton sx={{ mx: 1 }} form={formId} onClick={onHide}>
116123
{cancelText || 'Cancel'}
117124
</NERFailButton>
118125
<NERSuccessButton sx={{ mx: 1 }} type="submit" form={formId} onClick={onSubmit} disabled={disabled}>
119126
{submitText || 'Submit'}
120127
</NERSuccessButton>
128+
</Box>
121129
</Box>
122130
</DialogActions>
123131
)}

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/BOM/MaterialForm/MaterialFormView.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
Button,
23
FormControl,
34
FormHelperText,
45
FormLabel,
@@ -39,6 +40,7 @@ export interface MaterialFormViewProps {
3940
watch: UseFormWatch<MaterialFormInput>;
4041
createManufacturer: (name: string) => void;
4142
setValue: UseFormSetValue<MaterialFormInput>;
43+
copyFromExistingBomAction?: React.ReactNode;
4244
}
4345

4446
const manufacturersToAutocomplete = (manufacturer: Manufacturer): { label: string; id: string } => {
@@ -80,6 +82,21 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
8082
onFormSubmit={onSubmit}
8183
formId={submitText + '-material-form'}
8284
showCloseButton
85+
copyFromExistingBomAction={
86+
<Button
87+
variant="contained"
88+
onClick={() => {}}
89+
sx={{
90+
mx: 1,
91+
textTransform: 'none',
92+
bgcolor: (t) => '#EF4345',
93+
color: (t) => t.palette.getContrastText('#EF4345'),
94+
'&:hover': { bgcolor: (t) => t.palette.error.dark }
95+
}}
96+
>
97+
COPY FROM EXISTING BOM
98+
</Button>
99+
}
83100
>
84101
<Grid container spacing={2}>
85102
<Grid item xs={7}>

0 commit comments

Comments
 (0)