-
Notifications
You must be signed in to change notification settings - Fork 4
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
Remove description from Module & Add tests #107
Changes from all commits
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
import static java.util.Objects.requireNonNull; | ||
import static trackitnus.logic.parser.CliSyntax.PREFIX_CODE; | ||
import static trackitnus.logic.parser.CliSyntax.PREFIX_DESC; | ||
import static trackitnus.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static trackitnus.model.Model.PREDICATE_SHOW_ALL_MODULES; | ||
|
||
|
@@ -28,9 +27,8 @@ public class EditModuleCommand extends Command { | |
+ "Parameters: " | ||
+ PREFIX_CODE + "CODE (must be an existing code) " | ||
+ "[" + PREFIX_NAME + "NAME] " | ||
+ "[" + PREFIX_DESC + "DESC] " | ||
+ String.format("Example: %s %s %sCS1231S %sDiscrete Structures %sIntroductory mathematical tools", | ||
Module.TYPE, COMMAND_WORD, PREFIX_CODE, PREFIX_NAME, PREFIX_DESC); | ||
+ String.format("Example: %s %s %sCS1231S %sDiscrete Structures", | ||
Module.TYPE, COMMAND_WORD, PREFIX_CODE, PREFIX_NAME); | ||
|
||
public static final String MESSAGE_EDIT_MODULE_SUCCESS = "Edited Module: %1$s"; | ||
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; | ||
|
@@ -61,9 +59,8 @@ private static Module createEditedModule(Module moduleToEdit, | |
|
||
Code originalCode = moduleToEdit.getCode(); | ||
Name updatedName = editModuleDescriptor.getName().orElse(moduleToEdit.getName()); | ||
String updatedDesc = editModuleDescriptor.getDesc().orElse(moduleToEdit.getDesc()); | ||
|
||
return new Module(originalCode, updatedName, updatedDesc); | ||
return new Module(originalCode, updatedName); | ||
} | ||
|
||
@Override | ||
|
@@ -103,15 +100,21 @@ public boolean equals(Object other) { | |
&& editModuleDescriptor.equals(e.editModuleDescriptor); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EditModuleCommand{" + | ||
"code=" + code + | ||
", editModuleDescriptor=" + editModuleDescriptor + | ||
'}'; | ||
} | ||
|
||
simonteozw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Stores the details to edit the module with. Each non-empty field value will replace the | ||
* corresponding field value of the module. | ||
*/ | ||
public static class EditModuleDescriptor { | ||
|
||
private Code code; | ||
private Name name; | ||
private String desc; | ||
|
||
public EditModuleDescriptor() { | ||
} | ||
|
@@ -120,16 +123,14 @@ public EditModuleDescriptor() { | |
* Copy constructor. | ||
*/ | ||
public EditModuleDescriptor(EditModuleDescriptor toCopy) { | ||
setCode(toCopy.code); | ||
setName(toCopy.name); | ||
setDesc(toCopy.desc); | ||
} | ||
|
||
/** | ||
* Returns true if at least one field is edited. | ||
*/ | ||
public boolean isAnyFieldEdited() { | ||
return CollectionUtil.isAnyNonNull(name, desc); | ||
return CollectionUtil.isAnyNonNull(name); | ||
} | ||
|
||
@Override | ||
|
@@ -147,17 +148,7 @@ public boolean equals(Object other) { | |
// state check | ||
EditModuleDescriptor e = (EditModuleDescriptor) other; | ||
|
||
return getCode().equals(e.getCode()) | ||
&& getName().equals(e.getName()) | ||
&& getDesc().equals(e.getDesc()); | ||
} | ||
|
||
public Optional<Code> getCode() { | ||
return Optional.ofNullable(code); | ||
} | ||
|
||
public void setCode(Code code) { | ||
this.code = code; | ||
return getName().equals(e.getName()); | ||
} | ||
|
||
public Optional<Name> getName() { | ||
|
@@ -168,12 +159,11 @@ public void setName(Name name) { | |
this.name = name; | ||
} | ||
|
||
public Optional<String> getDesc() { | ||
return Optional.ofNullable(desc); | ||
} | ||
|
||
public void setDesc(String desc) { | ||
this.desc = desc; | ||
@Override | ||
public String toString() { | ||
return "EditModuleDescriptor{" + | ||
"name=" + name + | ||
'}'; | ||
Comment on lines
+162
to
+166
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. Why do we need this? And Maybe change to 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. for testing only |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,6 @@ public class ModuleCard extends UiPart<Region> { | |
private Label name; | ||
@FXML | ||
private Label id; | ||
@FXML | ||
private Label desc; | ||
|
||
|
||
/** | ||
|
@@ -45,7 +43,6 @@ public ModuleCard(Module module, int displayedIndex) { | |
id.setText(displayedIndex + ". "); | ||
code.setText(module.getCode().code); | ||
name.setText(module.getName().fullName); | ||
desc.setText(module.getDesc()); | ||
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. maybe can remove the @FXML private Label desc on top too 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. Sure |
||
} | ||
|
||
@Override | ||
|
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.
What does this do?
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.
There is a warning that the operator (like + for string concatenation) must be on a new line, but I haven't found a way to make IntelliJ auto-format for that, and it's really minor so I will just disable it for now
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.
Hmm I think we should enable it before merging right?
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.
Hmm because I haven't been able to get the IntelliJ to conform to this rule, and this is very minor (it's just the position of the operator) so I think it's best to disable it for now (if not forever)
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.
Ok, but I think before we submit v1.3 on Friday we should remove this