forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from YeoBohShin/master
Extract tag function and Edit AboutUs
- Loading branch information
Showing
21 changed files
with
482 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Class Manager 2023 | ||
|
||
*Class Manager 2023 aims to provide fast access to CS2103S TAs who need help in maintaining student information across multiple classes. It also aims to help TAs visualize data across and within classes.* | ||
|
||
## Summary of Contributions | ||
to be added soon | ||
|
||
### Code Contributed | ||
[Individual Dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=changruhenryqian&breakdown=true) | ||
|
||
### Enhancements Implemented | ||
to be added soon | ||
|
||
### Contributions to the UG | ||
to be added soon | ||
|
||
### Contributions beyond the Project | ||
to be added soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Class Manager 2023 | ||
|
||
*Class Manager 2023 aims to provide fast access to CS2103S TAs who need help in maintaining student information across multiple classes. It also aims to help TAs visualize data across and within classes.* | ||
|
||
## Summary of Contributions | ||
to be added soon | ||
|
||
### Code Contributed | ||
[Individual Dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=ngeeyonglim&breakdown=true) | ||
|
||
### Enhancements Implemented | ||
to be added soon | ||
|
||
### Contributions to the UG | ||
to be added soon | ||
|
||
### Contributions beyond the Project | ||
to be added soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Class Manager 2023 | ||
|
||
*Class Manager 2023 aims to provide fast access to CS2103S TAs who need help in maintaining student information across multiple classes. It also aims to help TAs visualize data across and within classes.* | ||
|
||
## Summary of Contributions | ||
to be added soon | ||
|
||
### Code Contributed | ||
[Individual Dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=yeobohshin&breakdown=true) | ||
|
||
### Enhancements Implemented | ||
to be added soon | ||
|
||
### Contributions to the UG | ||
to be added soon | ||
|
||
### Contributions beyond the Project | ||
to be added soon |
104 changes: 104 additions & 0 deletions
104
src/main/java/seedu/address/logic/commands/TagCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; | ||
import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.commons.util.ToStringBuilder; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Person; | ||
import seedu.address.model.tag.Tag; | ||
|
||
|
||
/** | ||
* Changes the tags of an existing person in the address book. | ||
*/ | ||
public class TagCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "tag"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Edits the tags of the person identified " | ||
+ "by the student number. " | ||
+ "Existing tags will be overwritten by the input.\n" | ||
+ "Parameters: Student number (must be exist in address book) " | ||
+ "/t [LABEL]\n" | ||
+ "Example: " + COMMAND_WORD + " A1234567N " | ||
+ "/t smart."; | ||
public static final String MESSAGE_ADD_TAG_SUCCESS = "Added tag to Person: %1$s"; | ||
public static final String MESSAGE_DELETE_TAG_SUCCESS = "Removed tag from Person: %1$s"; | ||
public static final String MESSAGE_TAG_FAILED = COMMAND_WORD | ||
+ ": There was an issue tagging the student.\n Please check " | ||
+ "that the index of the student exists or each label has " | ||
+ "the “/t ” prefix."; | ||
private final Index index; | ||
private final Set<Tag> tags; | ||
|
||
/** | ||
* @param index of the person in the filtered person list to edit the remark | ||
* @param tags of the person to be updated to | ||
*/ | ||
public TagCommand(Index index, Set<Tag> tags) { | ||
requireAllNonNull(index, tags); | ||
|
||
this.index = index; | ||
this.tags = tags; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
List<Person> lastShownList = model.getFilteredPersonList(); | ||
|
||
if (index.getZeroBased() >= lastShownList.size()) { | ||
throw new CommandException(MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
} | ||
|
||
Person personToEdit = lastShownList.get(index.getZeroBased()); | ||
Person editedPerson = new Person( | ||
personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(), | ||
personToEdit.getAddress(), this.tags); | ||
|
||
model.setPerson(personToEdit, editedPerson); | ||
model.updateFilteredPersonList(Model.PREDICATE_SHOW_ALL_PERSONS); | ||
|
||
return new CommandResult(generateSuccessMessage(editedPerson)); | ||
} | ||
|
||
/** | ||
* Generates a command execution success message based on whether | ||
* the tag is added to or removed from | ||
* {@code personToEdit}. | ||
*/ | ||
private String generateSuccessMessage(Person personToEdit) { | ||
String message = !tags.isEmpty() ? MESSAGE_ADD_TAG_SUCCESS : MESSAGE_DELETE_TAG_SUCCESS; | ||
return String.format(message, Messages.format(personToEdit)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof TagCommand)) { | ||
return false; | ||
} | ||
|
||
TagCommand e = (TagCommand) other; | ||
return index.equals(e.index) | ||
&& tags.equals(e.tags); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this) | ||
.add("tags", tags) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/seedu/address/logic/parser/TagCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAGS; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.commons.exceptions.IllegalValueException; | ||
import seedu.address.logic.commands.TagCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.tag.Tag; | ||
|
||
/** | ||
* Parses input arguments and creates a new TagCommand object | ||
*/ | ||
public class TagCommandParser implements Parser<TagCommand> { | ||
|
||
private Set<Tag> tags; | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the TagCommand | ||
* and returns an TagCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public TagCommand parse(String args) throws ParseException { | ||
requireNonNull(args); | ||
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, | ||
PREFIX_TAGS); | ||
|
||
Index index; | ||
try { | ||
index = ParserUtil.parseIndex(argMultimap.getPreamble()); | ||
} catch (IllegalValueException ive) { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
TagCommand.MESSAGE_USAGE), ive); | ||
} | ||
|
||
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAGS)).ifPresent(this::setTags); | ||
|
||
if (this.tags == null) { | ||
throw new ParseException(TagCommand.MESSAGE_TAG_FAILED); | ||
} | ||
|
||
return new TagCommand(index, this.tags); | ||
} | ||
|
||
/** | ||
* Parses {@code Collection<String> tags} into a {@code Set<Tag>} if {@code tags} is non-empty. | ||
* If {@code tags} contain only one element which is an empty string, it will be parsed into a | ||
* {@code Set<Tag>} containing zero tags. | ||
*/ | ||
private Optional<Set<Tag>> parseTagsForEdit(Collection<String> tags) throws ParseException { | ||
assert tags != null; | ||
|
||
if (tags.isEmpty()) { | ||
return Optional.empty(); | ||
} | ||
|
||
Collection<String> tagSet = tags.size() == 1 && tags.contains("") ? Collections.emptySet() : tags; | ||
|
||
return Optional.of(ParserUtil.parseTags(tagSet)); | ||
} | ||
|
||
/** | ||
* Sets {@code tags} to this object's {@code tags}. | ||
* A defensive copy of {@code tags} is used internally. | ||
*/ | ||
public void setTags(Set<Tag> tags) { | ||
this.tags = (tags != null) ? new HashSet<>(tags) : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.