Skip to content

Commit

Permalink
Merge pull request #5 from YeoBohShin/master
Browse files Browse the repository at this point in the history
Extract tag function and Edit AboutUs
  • Loading branch information
YeoBohShin authored Oct 3, 2023
2 parents 5517080 + 2a231a7 commit 4f81c9e
Show file tree
Hide file tree
Showing 21 changed files with 482 additions and 25 deletions.
40 changes: 20 additions & 20 deletions docs/AboutUs.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@ You can reach us at the email `seer[at]comp.nus.edu.sg`

## Project team

### John Doe
### Kieron Seven Lee Jun Wei

<img src="images/johndoe.png" width="200px">
<img src="images/cikguseven.png" width="200px">

[[homepage](http://www.comp.nus.edu.sg/~damithch)]
[[github](https://github.com/johndoe)]
[[portfolio](team/johndoe.md)]
[[github](https://github.com/cikguseven)]
[[portfolio](team/cikguseven.md)]

* Role: Project Advisor

### Jane Doe
### Liang Wenzhong

<img src="images/johndoe.png" width="200px">
<img src="images/lwz19.png" width="200px">

[[github](http://github.com/johndoe)]
[[portfolio](team/johndoe.md)]
[[github](http://github.com/lwz19)]
[[portfolio](team/lwz19.md)]

* Role: Team Lead
* Responsibilities: UI

### Johnny Doe
### Lim Ngee Yong

<img src="images/johndoe.png" width="200px">
<img src="images/ngeeyonglim.png" width="200px">

[[github](http://github.com/johndoe)] [[portfolio](team/johndoe.md)]
[[github](http://github.com/ngeeyonglim)]
[[portfolio](team/ngeeyonglim.md)]

* Role: Developer
* Responsibilities: Data

### Jean Doe
### Qian Changru

<img src="images/johndoe.png" width="200px">
<img src="images/changruhenryqian.png" width="200px">

[[github](http://github.com/johndoe)]
[[portfolio](team/johndoe.md)]
[[github](http://github.com/changruhenryqian)]
[[portfolio](team/changruhenryqian.md)]

* Role: Developer
* Responsibilities: Dev Ops + Threading

### James Doe
### Yeo Boh Shin

<img src="images/johndoe.png" width="200px">
<img src="images/yeobohshin.png" width="200px">

[[github](http://github.com/johndoe)]
[[portfolio](team/johndoe.md)]
[[github](http://github.com/yeobohshin)]
[[portfolio](team/yeobohshin.md)]

* Role: Developer
* Responsibilities: UI
Binary file added docs/images/changruhenryqian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/cikguseven.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lwz19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ngeeyonglim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/yeobohshin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions docs/team/changruhenryqian.md
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
2 changes: 1 addition & 1 deletion docs/team/cikguseven.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class Manager 2023 aims to provide fast access to CS2103T TAs who need help in m

Given below are my contributions to the project:

* **Code contributed**: to be added soon
* **Code contributed**: [Individual Dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=cikguseven&breakdown=true)

* **Enhancements implemented**: to be added soon

Expand Down
2 changes: 1 addition & 1 deletion docs/team/lwz19.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Given below are my contributions to the project.
<br/><br/>

* **Code contributed**:
* _To be added soon_
* [Individual Dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=lwz19&breakdown=true)
<br/><br/>

* **Project management**:
Expand Down
18 changes: 18 additions & 0 deletions docs/team/ngeeyonglim.md
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
18 changes: 18 additions & 0 deletions docs/team/yeobohshin.md
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 src/main/java/seedu/address/logic/commands/TagCommand.java
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.TagCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand Down Expand Up @@ -77,6 +78,9 @@ public Command parseCommand(String userInput) throws ParseException {
case HelpCommand.COMMAND_WORD:
return new HelpCommand();

case TagCommand.COMMAND_WORD:
return new TagCommandParser().parse(arguments);

default:
logger.finer("This user input caused a ParseException: " + userInput);
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class CliSyntax {
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_ADDRESS = new Prefix("a/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_TAGS = new Prefix("/t");

}
77 changes: 77 additions & 0 deletions src/main/java/seedu/address/logic/parser/TagCommandParser.java
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAGS;
import static seedu.address.testutil.Assert.assertThrows;

import java.util.ArrayList;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class CommandTestUtil {
public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3";
public static final String VALID_TAG_HUSBAND = "husband";
public static final String VALID_TAG_FRIEND = "friend";
public static final String VALID_TAG_FRIENDS = "friends";

public static final String NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY;
public static final String NAME_DESC_BOB = " " + PREFIX_NAME + VALID_NAME_BOB;
Expand All @@ -47,13 +49,14 @@ public class CommandTestUtil {
public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB;
public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND;
public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND;

public static final String LABEL_DESC_FRIEND = " " + PREFIX_TAGS + VALID_TAG_FRIEND;
public static final String LABEL_DESC_HUSBAND = " " + PREFIX_TAGS + VALID_TAG_HUSBAND;
public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names
public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones
public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol
public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses
public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags

public static final String INVALID_LABEL_DESC = " " + PREFIX_TAGS + "hubby*"; // '*' not allowed in tags
public static final String PREAMBLE_WHITESPACE = "\t \r \n";
public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble";

Expand Down
Loading

0 comments on commit 4f81c9e

Please sign in to comment.