Skip to content

Commit b4ebcfe

Browse files
authored
Merge pull request #2679 from Northeastern-Electric-Racing/Show-Design-Reviews-On-Gantt-Chart
Show Design Reviews on Gantt Chart
2 parents 86fe01c + e7695b8 commit b4ebcfe

14 files changed

Lines changed: 187 additions & 21 deletions

File tree

src/backend/src/prisma-query-args/projects.query-args.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getDescriptionBulletQueryArgs } from './description-bullets.query-args'
55
import { getTeamQueryArgs } from './teams.query-args';
66
import { getMaterialQueryArgs, getAssemblyQueryArgs } from './bom.query-args';
77
import { getTaskQueryArgs } from './tasks.query-args';
8+
import { getDesignReviewQueryArgs } from './design-reviews.query-args';
89

910
export type ProjectQueryArgs = ReturnType<typeof getProjectQueryArgs>;
1011

@@ -58,7 +59,8 @@ export const getProjectQueryArgs = (organizationId: string) =>
5859
where: { dateDeleted: null },
5960
...getAssemblyQueryArgs(organizationId)
6061
},
61-
blocking: { where: { wbsElement: { dateDeleted: null } }, include: { wbsElement: true } }
62+
blocking: { where: { wbsElement: { dateDeleted: null } }, include: { wbsElement: true } },
63+
designReviews: { where: { dateDeleted: null }, ...getDesignReviewQueryArgs(organizationId) }
6264
}
6365
},
6466
blockedBy: { where: { dateDeleted: null } }

src/backend/src/prisma-query-args/work-packages.query-args.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Prisma } from '@prisma/client';
22
import { getUserQueryArgs } from './user.query-args';
33
import { getTaskQueryArgs } from './tasks.query-args';
44
import { getDescriptionBulletQueryArgs } from './description-bullets.query-args';
5+
import { getDesignReviewQueryArgs } from './design-reviews.query-args';
56

67
export type WorkPackageQueryArgs = ReturnType<typeof getWorkPackageQueryArgs>;
78

@@ -29,7 +30,8 @@ export const getWorkPackageQueryArgs = (organizationId: string) =>
2930
},
3031
blocking: { where: { wbsElement: { dateDeleted: null } }, include: { wbsElement: true } },
3132
tasks: { where: { dateDeleted: null }, ...getTaskQueryArgs(organizationId) },
32-
descriptionBullets: { where: { dateDeleted: null }, ...getDescriptionBulletQueryArgs(organizationId) }
33+
descriptionBullets: { where: { dateDeleted: null }, ...getDescriptionBulletQueryArgs(organizationId) },
34+
designReviews: { where: { dateDeleted: null }, ...getDesignReviewQueryArgs(organizationId) }
3335
}
3436
},
3537
blockedBy: { where: { dateDeleted: null } }

src/backend/src/services/notifications.services.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export default class NotificationsService {
4141
},
4242
status: {
4343
not: 'DONE'
44-
}
44+
},
45+
dateDeleted: null
4546
},
4647
include: {
4748
assignees: {

src/backend/src/transformers/projects.transformer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { assemblyTransformer, materialTransformer } from './material.transformer
1717
import { userTransformer } from './user.transformer';
1818
import { ProjectQueryArgs } from '../prisma-query-args/projects.query-args';
1919
import teamTransformer from './teams.transformer';
20+
import { designReviewTransformer } from './design-reviews.transformer';
2021

2122
const projectTransformer = (project: Prisma.ProjectGetPayload<ProjectQueryArgs>): Project => {
2223
const { wbsElement } = project;
@@ -87,6 +88,7 @@ const projectTransformer = (project: Prisma.ProjectGetPayload<ProjectQueryArgs>)
8788
materials: workPackage.wbsElement?.materials.map(materialTransformer),
8889
assemblies: workPackage.wbsElement?.assemblies.map(assemblyTransformer),
8990
blocking: workPackage.wbsElement.blocking.map((blocking) => wbsNumOf(blocking.wbsElement)),
91+
designReviews: workPackage.wbsElement.designReviews.map(designReviewTransformer),
9092
deleted: workPackage.wbsElement.dateDeleted !== null
9193
};
9294
})

src/backend/src/transformers/work-packages.transformer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import descriptionBulletTransformer from '../transformers/description-bullets.tr
44
import { convertStatus, wbsNumOf } from '../utils/utils';
55
import { userTransformer } from './user.transformer';
66
import { WorkPackageQueryArgs } from '../prisma-query-args/work-packages.query-args';
7+
import { designReviewTransformer } from './design-reviews.transformer';
78

89
const workPackageTransformer = (wpInput: Prisma.Work_PackageGetPayload<WorkPackageQueryArgs>): WorkPackage => {
910
const wbsNum = wbsNumOf(wpInput.wbsElement);
@@ -37,6 +38,7 @@ const workPackageTransformer = (wpInput: Prisma.Work_PackageGetPayload<WorkPacka
3738
projectName: wpInput.project.wbsElement.name,
3839
stage: (wpInput.stage as WorkPackageStage) || undefined,
3940
blocking: wpInput.wbsElement.blocking.map((wp) => wbsNumOf(wp.wbsElement)),
41+
designReviews: wpInput.wbsElement.designReviews.map(designReviewTransformer),
4042
deleted: wpInput.wbsElement.dateDeleted !== null
4143
};
4244
};

src/frontend/src/apis/transformers/work-packages.transformers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { WorkPackage } from 'shared';
77
import { implementedChangeTransformer } from './change-requests.transformers';
8+
import { designReviewTransformer } from './design-reviews.tranformers';
89
import { descriptionBulletTransformer } from './projects.transformers';
910

1011
/**
@@ -20,6 +21,7 @@ export const workPackageTransformer = (workPackage: WorkPackage): WorkPackage =>
2021
startDate: new Date(workPackage.startDate),
2122
endDate: new Date(workPackage.endDate),
2223
descriptionBullets: workPackage.descriptionBullets.map(descriptionBulletTransformer),
23-
changes: workPackage.changes.map(implementedChangeTransformer)
24+
changes: workPackage.changes.map(implementedChangeTransformer),
25+
designReviews: workPackage.designReviews.map(designReviewTransformer)
2426
};
2527
};

src/frontend/src/pages/GanttPage/GanttChartComponents/GanttChartColorLegend.tsx

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
*/
55

66
import { Box, Card, Tooltip, Typography } from '@mui/material';
7-
import { WbsElementStatus, WorkPackageStage } from 'shared';
8-
import { GanttWorkPackageStageColorPipe, GanttWorkPackageTextColorPipe } from '../../../utils/gantt.utils';
9-
import { WbsElementStatusTextPipe, WorkPackageStageTextPipe } from '../../../utils/enum-pipes';
7+
import { DesignReviewStatus, WbsElementStatus, WorkPackageStage } from 'shared';
8+
import {
9+
GanttDesignReviewStatusColorPipe,
10+
GanttWorkPackageStageColorPipe,
11+
GanttWorkPackageTextColorPipe
12+
} from '../../../utils/gantt.utils';
13+
import { DesignReviewStatusTextPipe, WbsElementStatusTextPipe, WorkPackageStageTextPipe } from '../../../utils/enum-pipes';
1014

1115
const LEGEND_POPUPS_MAP = new Map<WorkPackageStage, JSX.Element>();
1216

@@ -48,6 +52,43 @@ Object.values(WorkPackageStage).map((stage) =>
4852
)
4953
);
5054

55+
const DesignReviewToolTipPopUp = () => {
56+
return (
57+
<Card
58+
sx={{
59+
display: 'flex',
60+
flexDirection: 'column',
61+
gap: 1,
62+
px: 2,
63+
py: 1
64+
}}
65+
>
66+
{
67+
// map through all the Wbs Element Statuses
68+
[DesignReviewStatus.UNCONFIRMED, DesignReviewStatus.SCHEDULED].map((status) => {
69+
return (
70+
<Box
71+
sx={{
72+
backgroundColor: GanttDesignReviewStatusColorPipe(status),
73+
height: '2rem',
74+
width: '8rem',
75+
borderRadius: 1,
76+
display: 'flex',
77+
justifyContent: 'center',
78+
alignItems: 'center'
79+
}}
80+
>
81+
<Typography variant="body1" sx={{ color: 'white' }}>
82+
{DesignReviewStatusTextPipe(status)}
83+
</Typography>
84+
</Box>
85+
);
86+
})
87+
}
88+
</Card>
89+
);
90+
};
91+
5192
const GanttChartColorLegend = () => {
5293
return (
5394
<Box
@@ -103,6 +144,32 @@ const GanttChartColorLegend = () => {
103144
);
104145
})
105146
}
147+
<Box
148+
sx={{
149+
background: `linear-gradient(90deg, ${GanttDesignReviewStatusColorPipe(
150+
DesignReviewStatus.UNCONFIRMED
151+
)} 0%, ${GanttDesignReviewStatusColorPipe(DesignReviewStatus.CONFIRMED)} 100%)`,
152+
display: 'flex',
153+
flexDirection: 'column',
154+
height: '2rem',
155+
width: '8.25rem',
156+
borderRadius: 1,
157+
justifyContent: 'center',
158+
alignItems: 'center',
159+
px: 1
160+
}}
161+
>
162+
<Tooltip
163+
title={<DesignReviewToolTipPopUp />}
164+
slotProps={{
165+
tooltip: { sx: { background: 'transparent', width: 'fit-content' } }
166+
}}
167+
>
168+
<Typography variant="body2" sx={{ color: 'white', overflow: 'hidden', textWrap: 'nowrap' }}>
169+
Design Review
170+
</Typography>
171+
</Tooltip>
172+
</Box>
106173
</Box>
107174
);
108175
};

src/frontend/src/pages/GanttPage/GanttChartComponents/GanttTaskBar/GanttTaskBarDisplay.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { grey } from '@mui/material/colors';
33
import { ArrowDropDownIcon } from '@mui/x-date-pickers';
44
import { useHistory } from 'react-router-dom';
55
import {
6+
GanttDesignReviewStatusColorPipe,
67
GanttTask,
78
isHighlightedChangeOnGanttTask,
89
RequestEventChange,
10+
transformDesignReviewToGanttTask,
911
transformWorkPackageToGanttTask
1012
} from '../../../../utils/gantt.utils';
1113
import { routes } from '../../../../utils/routes';
12-
import { wbsPipe } from 'shared';
14+
import { addWeeksToDate, DesignReview, wbsPipe } from 'shared';
1315
import {
1416
ganttTaskBarBackgroundStyles,
1517
ganttTaskBarContainerStyles,
@@ -19,6 +21,7 @@ import {
1921
} from './GanttTaskBarDisplayStyles';
2022
import { CSSProperties } from 'react';
2123
import { ArcherElement } from 'react-archer';
24+
import { datePipe } from '../../../../utils/pipes';
2225

2326
interface GanttTaskBarDisplayProps {
2427
days: Date[];
@@ -87,6 +90,20 @@ const GanttTaskBarDisplay = ({
8790
};
8891
};
8992

93+
const ganttTaskBarDesignReviewOverlayStyles = (designReview: DesignReview): CSSProperties => {
94+
return {
95+
gridColumnStart: getStartCol(designReview.dateScheduled),
96+
gridColumnEnd: getEndCol(addWeeksToDate(designReview.dateScheduled, 1)),
97+
height: '2rem',
98+
border: `1px solid ${theme.palette.divider}`,
99+
borderRadius: '0.25rem',
100+
backgroundColor: GanttDesignReviewStatusColorPipe(designReview.status),
101+
cursor: 'pointer',
102+
gridRow: 1,
103+
zIndex: 2
104+
};
105+
};
106+
90107
const highlightedChangeBoxStyles = (highlightedChange: RequestEventChange): CSSProperties => {
91108
return {
92109
paddingTop: '2px',
@@ -159,6 +176,24 @@ const GanttTaskBarDisplay = ({
159176
/>
160177
);
161178
})}
179+
{task.designReviews.map((designReview) => {
180+
return (
181+
<div
182+
style={ganttTaskBarDesignReviewOverlayStyles(designReview)}
183+
onMouseOver={(e) => handleOnMouseOver(e, transformDesignReviewToGanttTask(designReview))}
184+
onMouseLeave={handleOnMouseLeave}
185+
onClick={() => history.push(`${routes.CALENDAR}/${designReview.designReviewId}`)}
186+
>
187+
<Typography
188+
variant="body1"
189+
sx={taskNameContainerStyles(task)}
190+
onClick={() => history.push(`${routes.CALENDAR}/${designReview.designReviewId}`)}
191+
>
192+
{datePipe(designReview.dateScheduled, false)}
193+
</Typography>
194+
</div>
195+
);
196+
})}
162197
{highlightedChange && isHighlightedChangeOnGanttTask(highlightedChange, task) && (
163198
<div id="proposedChange" style={highlightedChangeBoxStyles(highlightedChange)}>
164199
<Typography

src/frontend/src/pages/GanttPage/GanttChartComponents/GanttTaskBar/GanttTaskBarEditView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const GanttTaskBarEditView = ({
115115
changes: [],
116116
materials: [],
117117
assemblies: [],
118+
designReviews: [],
118119
deleted: false
119120
};
120121
addWorkPackage(workPackage);

src/frontend/src/tests/test-support/test-data/work-packages.stub.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export const exampleResearchWorkPackage: WorkPackage = {
5454
materials: [],
5555
assemblies: [],
5656
blocking: [],
57-
teamTypes: []
57+
teamTypes: [],
58+
designReviews: []
5859
};
5960

6061
export const exampleDesignWorkPackage: WorkPackage = {
@@ -98,7 +99,8 @@ export const exampleDesignWorkPackage: WorkPackage = {
9899
materials: [],
99100
assemblies: [],
100101
blocking: [],
101-
teamTypes: []
102+
teamTypes: [],
103+
designReviews: []
102104
};
103105

104106
export const exampleManufacturingWorkPackage: WorkPackage = {
@@ -133,7 +135,8 @@ export const exampleManufacturingWorkPackage: WorkPackage = {
133135
materials: [],
134136
assemblies: [],
135137
blocking: [],
136-
teamTypes: []
138+
teamTypes: [],
139+
designReviews: []
137140
};
138141

139142
export const exampleInstallWorkPackage: WorkPackage = {
@@ -167,8 +170,9 @@ export const exampleInstallWorkPackage: WorkPackage = {
167170
materials: [],
168171
assemblies: [],
169172
blocking: [],
170-
deleted: false,
171-
teamTypes: []
173+
teamTypes: [],
174+
designReviews: [],
175+
deleted: false
172176
};
173177

174178
export const exampleWorkPackage5: WorkPackage = {
@@ -202,7 +206,8 @@ export const exampleWorkPackage5: WorkPackage = {
202206
materials: [],
203207
assemblies: [],
204208
blocking: [],
205-
teamTypes: []
209+
teamTypes: [],
210+
designReviews: []
206211
};
207212

208213
export const exampleAllWorkPackages: WorkPackage[] = [

0 commit comments

Comments
 (0)