-
Notifications
You must be signed in to change notification settings - Fork 75
Add logic for displaying Y session courses in the course modal #1740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: y-course-refactor
Are you sure you want to change the base?
Changes from all commits
cf949fe
dc460de
f8ea373
aa12db7
e21e084
3a2ebe7
bc71bea
61112ab
4921e7c
70767e4
150bafe
2bac4c6
432042e
14b37a4
95edff2
a46556b
35a47ad
07281cf
8358a26
fd7c78c
4129868
97b1fa0
ba03e3e
87f08d6
3f3894e
5807048
9fb3f60
69b0aab
56e925d
94819cd
c445897
ded4583
31a48ae
054afb9
2a568d4
fca3906
112ebfb
5b8463c
81d6fb0
4fbfb9d
d06db08
886a85e
65528f6
881bfec
09375f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,8 +133,12 @@ class CourseModal extends React.Component { | |
| } | ||
| } | ||
|
|
||
| /* Generate the data needed for each row of the timetable based on course meeting times for | ||
| * each session F, S, Y. | ||
| /** | ||
| * Generate the data needed for the course modal table based on the meeting times corresponding | ||
| * to a course in a given session. | ||
| * @param allMeetingTimes An array of MeetTime' objects corresponding to a particular course. | ||
| * @param session The session (F, S, Y) to query. | ||
| * @returns A map containing the table data that will appear in the course modal. | ||
| */ | ||
| getTable(allMeetingTimes, session) { | ||
| const sessions = allMeetingTimes.filter(lec => lec.meetData.session === session) | ||
|
|
@@ -144,6 +148,7 @@ class CourseModal extends React.Component { | |
|
|
||
| return sortedSessions.map(lecture => { | ||
| const occurrences = { times: [], locations: [] } | ||
| const yearOccurrences = {fallTimes: [], fallLocations: [], winterTimes: [], winterLocations: []} | ||
| const sortedTimeData = lecture.timeData.sort((occ1, occ2) => | ||
| occ1.weekDay > occ2.weekDay ? 1 : -1 | ||
| ) | ||
|
|
@@ -152,14 +157,42 @@ class CourseModal extends React.Component { | |
| if (occurrence.timeLocation !== null && occurrence.timeLocation !== undefined) { | ||
| location = occurrence.timeLocation.buildingCode | ||
| } | ||
| occurrences.locations.push(location) | ||
| occurrences.times.push( | ||
| DAY_TO_INT[occurrence.weekDay] + | ||
| " " + | ||
| occurrence.startHour + | ||
| " - " + | ||
| occurrence.endHour | ||
| ) | ||
|
|
||
| // Time and location formatting for Y session courses | ||
| if (session === "Y") { | ||
| if (occurrence.timeSession.endsWith("9")) { | ||
| yearOccurrences.fallLocations.push(location) | ||
| yearOccurrences.fallTimes.push( | ||
| DAY_TO_INT[occurrence.weekDay].substring(0, 3) + | ||
| " " + | ||
| occurrence.startHour + | ||
| " - " + | ||
| occurrence.endHour | ||
| ) | ||
| } | ||
| else { | ||
| yearOccurrences.winterLocations.push(location) | ||
| yearOccurrences.winterTimes.push( | ||
| DAY_TO_INT[occurrence.weekDay].substring(0, 3) + | ||
| " " + | ||
| occurrence.startHour + | ||
| " - " + | ||
| occurrence.endHour | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // Time and location formatting for F/S courses | ||
| else { | ||
| occurrences.locations.push(location) | ||
| occurrences.times.push( | ||
| DAY_TO_INT[occurrence.weekDay] + | ||
| " " + | ||
| occurrence.startHour + | ||
| " - " + | ||
| occurrence.endHour | ||
| ) | ||
| } | ||
| }) | ||
| const rowData = { | ||
| activity: lecture.meetData.section, | ||
|
|
@@ -169,10 +202,14 @@ class CourseModal extends React.Component { | |
| lecture.meetData.enrol + | ||
| " of " + | ||
| lecture.meetData.cap + | ||
| " available", | ||
| (session === "Y" ? "" : " available"), // Account for shortened column width for Y courses | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't shorten this column text. We can play with the width of the modal to make it wider |
||
| waitList: lecture.meetData.wait + " students", | ||
| time: occurrences.times, | ||
| location: occurrences.locations, | ||
| fallTime: yearOccurrences.fallTimes, | ||
| fallLocation: yearOccurrences.fallLocations, | ||
| winterTime: yearOccurrences.winterTimes, | ||
| winterLocation: yearOccurrences.winterLocations | ||
| } | ||
|
|
||
| return rowData | ||
|
|
@@ -269,10 +306,12 @@ class Description extends React.Component { | |
| <AgGridReact | ||
| rowData={this.props.sessions[session]} | ||
| columnDefs={[ | ||
| { field: "activity", width: 130 }, | ||
| { field: "instructor", width: 190 }, | ||
| { field: "availability", width: 180 }, | ||
| { field: "waitList", width: 130 }, | ||
| { field: "activity", width: session === "Y" ? 100 : 130 }, | ||
| { field: "instructor", width: session === "Y" ? 172 : 190 }, | ||
| { field: "availability", width: session === "Y" ? 130 : 180 }, | ||
| { field: "waitList", width: session === "Y" ? 120 : 130 }, | ||
|
|
||
| /* Single-session occurrence columns */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my above comment, use one set of columns ( You can make the column header names conditional on whether a fall/winter or full-year session is being displayed by using the |
||
| { | ||
| field: "time", | ||
| cellStyle: { | ||
|
|
@@ -284,6 +323,7 @@ class Description extends React.Component { | |
| valueFormatter: col => col.data.time.join("\n"), | ||
| width: 180, | ||
| autoHeight: true, | ||
| hide: session === "Y", | ||
| }, | ||
| { | ||
| field: "location", | ||
|
|
@@ -296,6 +336,71 @@ class Description extends React.Component { | |
| valueFormatter: col => col.data.location.join("\n"), | ||
| width: 128, | ||
| autoHeight: true, | ||
| hide: session === "Y" | ||
| }, | ||
|
|
||
| /* Y session occurrence columns */ | ||
| { | ||
| field: "fallTime", | ||
| cellStyle: { | ||
| whiteSpace: "pre", | ||
| lineHeight: "1.8", | ||
| paddingTop: "7px", | ||
| paddingBottom: "6px", | ||
| }, | ||
| valueFormatter: col => col.data.fallTime.join("\n"), | ||
| width: 115, | ||
| autoHeaderHeight: false, | ||
| autoHeight: true, | ||
| wrapHeaderText: true, | ||
| autoHeaderHeight: true, | ||
| hide: session !== "Y", | ||
| }, | ||
| { | ||
| field: "fallLocation", | ||
| cellStyle: { | ||
| whiteSpace: "pre", | ||
| lineHeight: "1.8", | ||
| paddingTop: "7px", | ||
| paddingBottom: "6px", | ||
| }, | ||
| valueFormatter: col => col.data.fallLocation.join("\n"), | ||
| width: 93, | ||
| autoHeaderHeight: false, | ||
| autoHeight: true, | ||
| wrapHeaderText: true, | ||
| autoHeaderHeight: true, | ||
| hide: session !== "Y", | ||
| }, | ||
| { | ||
| field: "winterTime", | ||
| cellStyle: { | ||
| whiteSpace: "pre", | ||
| lineHeight: "1.8", | ||
| paddingTop: "7px", | ||
| paddingBottom: "6px", | ||
| }, | ||
| valueFormatter: col => col.data.winterTime.join("\n"), | ||
| width: 115, | ||
| autoHeight: true, | ||
| wrapHeaderText: true, | ||
| autoHeaderHeight: true, | ||
| hide: session !== "Y", | ||
| }, | ||
| { | ||
| field: "winterLocation", | ||
| cellStyle: { | ||
| whiteSpace: "pre", | ||
| lineHeight: "1.8", | ||
| paddingTop: "7px", | ||
| paddingBottom: "6px", | ||
| }, | ||
| valueFormatter: col => col.data.winterLocation.join("\n"), | ||
| width: 93, | ||
| autoHeight: true, | ||
| wrapHeaderText: true, | ||
| autoHeaderHeight: true, | ||
| hide: session !== "Y", | ||
| }, | ||
| ]} | ||
| domLayout="autoHeight" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use two different variables (
occurrencesandyearOccurrences). Stick with one object with keystimes1,locations1,times2,locations2. Use justtimes1andlocations1for fall and winter courses, and both locations for year-long courses.This will let you simplify the logic below (
times1/locations1are updated in all cases except whensession === "Y" && occurences.timeSession.endsWith("1")