Skip to content
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

fix: Keep module state when editing students #64

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static class EditStudentDescriptor {
private Address address;
private Set<Tag> tags;

private List<ModuleCode> modules = new ArrayList<>();
private List<ModuleCode> modules;

private List<ModuleTiming> moduleTimings = new ArrayList<>();

Expand All @@ -167,7 +167,7 @@ public EditStudentDescriptor(EditStudentDescriptor toCopy) {
}

public void setModules(List<ModuleCode> modules) {
this.modules = new ArrayList<>(modules);
this.modules = (modules != null) ? new ArrayList<>(modules) : null;
}

public void setModuleTimings(List<ModuleTiming> modules) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public void parseCommand_delete() throws Exception {
public void parseCommand_edit() throws Exception {
Student student = new StudentBuilder().build();
EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(student).build();
// (taufiq): I have to set this to null because we need to differentiate
// between presence/absence of module input
descriptor.setModules(null);
EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " "
+ INDEX_FIRST_STUDENT.getOneBased() + " " + StudentUtil.getEditStudentDescriptorDetails(descriptor));
assertEquals(new EditCommand(INDEX_FIRST_STUDENT, descriptor), command);
Expand Down
Loading