-
Notifications
You must be signed in to change notification settings - Fork 320
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
Add support for year-long modules to module planner #2913
base: master
Are you sure you want to change the base?
Add support for year-long modules to module planner #2913
Conversation
Represents year long modules as modules in semester 0. Whenever new modules are added, they are checked for whether they are year long modules. If they are, they are moved to the year long "semester".
Codecov Report
@@ Coverage Diff @@
## master #2913 +/- ##
==========================================
+ Coverage 55.40% 55.57% +0.16%
==========================================
Files 254 255 +1
Lines 5315 5357 +42
Branches 1226 1232 +6
==========================================
+ Hits 2945 2977 +32
- Misses 2370 2380 +10
Continue to review full report at Codecov.
|
Deployment preview for |
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.
This looks great! I do think we might want to change the data structure from the scraper to allow us to do this more naturally. Let me know if you need help with that
website/src/views/planner/PlannerContainer/PlannerContainer.tsx
Outdated
Show resolved
Hide resolved
…eu/nusmods into planner-year-long-support
…eu/nusmods into planner-year-long-support
This pull request is being automatically deployed with Vercel (learn more). nusmods-website – ./website🔍 Inspect: https://vercel.com/nusmodifications/nusmods-website/f9tn1djmd nusmods-export – ./export🔍 Inspect: https://vercel.com/nusmodifications/nusmods-export/ckvmvsxzp |
@ZhangYiJiang How should I proceed with this PR? I really wish to see these changes be incorporated. |
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.
Sorry for not coming back to review this. This looks almost ready - just a few things
- The reducers and actions that are now unused should be removed
- Semester 0 should not be a valid global semester value, instead we can add something specifically for the planner
- Drag and drop ID and module type should be strongly typed instead of just being strings
website/src/views/planner/PlannerContainer/PlannerContainer.tsx
Outdated
Show resolved
Hide resolved
@@ -121,7 +121,7 @@ export function PlannerModuleSelectComponent({ | |||
} else if (inputValue != null) { | |||
// Otherwise we use the input value - this allows the user to | |||
// enter multiple | |||
onSelect(inputValue); | |||
onSelect(modules.find((module) => module.moduleCode === inputValue) ?? null); |
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.
This would break existing functionality where this field allows multiple module codes to be entered at once here
Tip: You can add multiple module at once, eg. copy from your transcript |
The logic for validating module code should be on the parent component, not the child.
onSelect
did have incorrect typing - ModuleCode
should just be string
, sorry about that
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.
Actually, how does the adding multiple module codes part work? Since onSelect(inputValue)
seems to call this:
nusmods/website/src/views/planner/AddModule.tsx
Lines 60 to 69 in 486cca0
onSelectModule = (input: ModuleCode | null) => { | |
if (input) { | |
this.props.onAddModule({ | |
type: 'module', | |
moduleCode: input.trim(), | |
}); | |
} | |
this.onCancel(); | |
}; |
which seems to add only 1 module
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.
It's in this function
onAddModule = (year: string, semester: Semester, module: AddModuleData) => { |
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.
@ZhangYiJiang I changed the logic so that the module code extraction is done in PlannerModuleSelect
, and PlannerContainer.onAddModule
now only handles a single module at a time. i.e. AddModuleData
's type has also been modified. This decision was made because I needed the yearLong
property of every module. And PlannerModuleSelect
does have a reference to modules
from which I can extract ModuleCondensed instances out of.
PlannerModuleSemester represents a semester in the module planner. PlannerSemesterModuleType represents the module type accepted by a PlannerSemester (semester or year long or both).
@jeffsieu is attempting to deploy a commit to the NUSMods Team on Vercel. A member of the Team first needs to authorize it. |
Co-authored-by: Zhang Yi Jiang <[email protected]>
…eu/nusmods into planner-year-long-support
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.
Looking very close! Please revert some of the changes that are outdated, run the linter, and avoid using cast in favor of type guards, and this PR should be good to go
Co-authored-by: Zhang Yi Jiang <[email protected]>
…eu/nusmods into planner-year-long-support
@ZhangYiJiang Most issues should be resolved. There's currently still a circular dependency between types/planner.ts and types/reducers.ts.... I'm not sure how to resolve this without shifting the type declarations over from a file to the other. |
Guys, merge this plox |
Context
Resolves #1912
Implementation
Before adding
After adding
Year long modules are represented as modules in semester 0.
Adding year-long modules
Year-long modules are moved to the year-long module list whenever added from Semester 1 or 2. The year-long semester is hidden unless it is not empty, or being dragged over.
Dragging modules
Upon dragging, their type (year-long or semester-long) is stored as part of their
draggableId
, which is then used to updatePlannerContainer.state.draggedModuleType
. This prompts childrenPlannerYear
components to display their year-long semester containers as drag targets.Misc
type
attribute toDroppable
targets to disallow dragging of modules to the lists of the wrong module type.