Skip to content

Commit 95c2263

Browse files
authored
Merge pull request #1707 from Northeastern-Electric-Racing/#1329-wp-form-refactor
#1329 WP Form Refactor
2 parents fc92838 + 1d1545a commit 95c2263

19 files changed

Lines changed: 479 additions & 354 deletions

File tree

src/backend/src/controllers/work-packages.controllers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export default class WorkPackagesController {
7171
blockedBy,
7272
expectedActivities,
7373
deliverables,
74-
projectLead,
75-
projectManager
74+
projectLeadId,
75+
projectManagerId
7676
} = req.body;
7777

7878
let { stage } = req.body;
@@ -93,8 +93,8 @@ export default class WorkPackagesController {
9393
blockedBy,
9494
expectedActivities,
9595
deliverables,
96-
projectLead,
97-
projectManager
96+
projectLeadId,
97+
projectManagerId
9898
);
9999
return res.status(200).json({ message: 'Work package updated successfully' });
100100
} catch (error: unknown) {

src/backend/src/routes/work-packages.routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ workPackagesRouter.post(
4242
body('deliverables').isArray(),
4343
body('deliverables.*.id').isInt({ min: -1 }).not().isString(),
4444
nonEmptyString(body('deliverables.*.detail')),
45-
intMinZero(body('projectLead').optional()),
46-
intMinZero(body('projectManager').optional()),
45+
intMinZero(body('projectLeadId').optional()),
46+
intMinZero(body('projectManagerId').optional()),
4747
validateInputs,
4848
WorkPackagesController.editWorkPackage
4949
);

src/frontend/src/components/ChangeRequestDropdown.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const ChangeRequestDropdown = ({ control, name, errors, changeHeight = 1 }: Chan
4949
value: cr.crId
5050
}));
5151

52+
const renderValues = new Map<number, string>();
53+
54+
changeRequests.forEach((cr) => renderValues.set(cr.crId, `${cr.crId} - ${wbsPipe(cr.wbsNum)}`));
55+
5256
return (
5357
<Box>
5458
<FormControl fullWidth>
@@ -60,7 +64,7 @@ const ChangeRequestDropdown = ({ control, name, errors, changeHeight = 1 }: Chan
6064
<Select
6165
id="cr-autocomplete"
6266
displayEmpty
63-
renderValue={(value) => value}
67+
renderValue={(value) => renderValues.get(Number(value))}
6468
value={value}
6569
onChange={(event: SelectChangeEvent<number>) => onChange(event.target.value)}
6670
size={'small'}

src/frontend/src/components/PageLayout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface PageLayoutProps {
1515
previousPages?: LinkItem[];
1616
headerRight?: ReactNode;
1717
tabs?: ReactElement;
18+
stickyHeader?: boolean;
1819
}
1920

2021
const PageLayout: React.FC<PageLayoutProps> = ({
@@ -23,15 +24,16 @@ const PageLayout: React.FC<PageLayoutProps> = ({
2324
hidePageTitle = false,
2425
previousPages = [],
2526
headerRight,
26-
tabs
27+
tabs,
28+
stickyHeader
2729
}) => {
2830
return (
2931
<Box>
3032
<Helmet>
3133
<title>{`FinishLine ${title && `| ${title}`}`}</title>
3234
<meta name="description" content="FinishLine Project Management Dashboard" />
3335
</Helmet>
34-
{!hidePageTitle && title && <PageTitle {...{ title, previousPages, headerRight, tabs }} />}
36+
{!hidePageTitle && title && <PageTitle sticky={stickyHeader} {...{ title, previousPages, headerRight, tabs }} />}
3537
{children}
3638
</Box>
3739
);

src/frontend/src/hooks/work-packages.hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const useEditWorkPackage = (wbsNum: WbsNumber) => {
8080
},
8181
{
8282
onSuccess: () => {
83-
queryClient.invalidateQueries(['work packages', wbsNum]);
83+
queryClient.invalidateQueries(['work packages']);
8484
}
8585
}
8686
);

src/frontend/src/layouts/PageTitle/PageTitle.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* See the LICENSE file in the repository root folder for details.
44
*/
55

6-
import { Typography, Box, Grid } from '@mui/material';
6+
import { Typography, Box, Grid, useTheme } from '@mui/material';
77
import { ReactElement, ReactNode } from 'react';
88
import { LinkItem } from '../../utils/types';
99
import PageBreadcrumbs from './PageBreadcrumbs';
@@ -13,6 +13,7 @@ interface PageTitleProps {
1313
previousPages: LinkItem[];
1414
headerRight?: ReactNode;
1515
tabs?: ReactElement;
16+
sticky?: boolean;
1617
}
1718

1819
/**
@@ -22,11 +23,22 @@ interface PageTitleProps {
2223
* @param headerRight The button to display on the right side of the page title
2324
* @param tabs The tabs on the page to display.
2425
*/
25-
const PageTitle: React.FC<PageTitleProps> = ({ title, previousPages, headerRight, tabs }) => {
26+
const PageTitle: React.FC<PageTitleProps> = ({ title, previousPages, headerRight, tabs, sticky }) => {
27+
const theme = useTheme();
28+
2629
return (
2730
<>
28-
<PageBreadcrumbs currentPageTitle={title} previousPages={previousPages} />
29-
<Box sx={{ mb: 2 }}>
31+
<Box mb={sticky ? -1 : 0}>
32+
<PageBreadcrumbs currentPageTitle={title} previousPages={previousPages} />
33+
</Box>
34+
<Box
35+
mb={2}
36+
position={sticky ? 'sticky' : 'initial'}
37+
top={65}
38+
pt={sticky ? 1 : 0}
39+
zIndex={1}
40+
bgcolor={theme.palette.background.default}
41+
>
3042
<Grid container>
3143
<Grid item xs={6} md={8}>
3244
<Typography variant="h4" fontSize={30}>

src/frontend/src/pages/ChangeRequestDetailPage/ChangeRequestDetailsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const ChangeRequestDetailsView: React.FC<ChangeRequestDetailsProps> = ({
164164
<MenuItem
165165
component={RouterLink}
166166
to={`${routes.WORK_PACKAGE_NEW}?crId=${changeRequest.crId}&wbs=${projectWbsPipe(changeRequest.wbsNum)}`}
167-
disabled={!isUserAllowedToImplement}
167+
disabled={!isUserAllowedToImplement || !isProject(changeRequest.wbsNum)}
168168
onClick={handleDropdownClose}
169169
>
170170
<ListItemIcon>

src/frontend/src/pages/ProjectsPage/Projects.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { routes } from '../../utils/routes';
88
import WBSDetails from '../WBSDetails';
99
import CreateProjectForm from '../CreateProjectPage/CreateProjectForm';
1010
import ProjectsPage from './ProjectsPage';
11+
import CreateWorkPackageForm from '../WorkPackageForm/CreateWorkPackageForm';
1112

1213
const Projects: React.FC = () => {
1314
return (
1415
<Switch>
1516
<Route path={routes.PROJECTS_OVERVIEW} component={ProjectsPage} />
1617
<Route path={routes.PROJECTS_ALL} component={ProjectsPage} />
18+
<Route path={routes.WORK_PACKAGE_NEW} component={CreateWorkPackageForm} />
1719
<Route path={routes.PROJECTS_NEW} component={CreateProjectForm} />
1820
<Route path={routes.PROJECTS_BY_WBS} component={WBSDetails} />
1921
<Route path={routes.PROJECTS} component={ProjectsPage} />

src/frontend/src/pages/WorkPackageDetailPage/WorkPackageEditContainer/EditModeOptions.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)