Skip to content

Commit

Permalink
Merge branch 'master' into convertlead
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxunn committed Oct 25, 2023
2 parents 5d53ddb + 1ed7500 commit 928e16d
Show file tree
Hide file tree
Showing 37 changed files with 619 additions and 63 deletions.
101 changes: 74 additions & 27 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,74 @@ Here are some descriptions of the words we use throughout the User Guide:

![Ui1](images/Ui1.png)

## Lead features

### Add lead [Coming soon]
### Add lead

- What it does: Add potential leads and their basic information, e.g. name, age, year of study, major, etc.
- Command format: `add --name <name> --age <age> --year <year of study> --major <major>`.
- Example usage: `add --name Dave --age 22 --year 2 --major Psychology`.
- Command format: `addlead n/NAME p/PHONE e/EMAIL a/ADDRESS [t/TAG]...`.
- Example usage: `Example: addlead n/John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/classmate`.
- Acceptable values for each parameter:
- `NAME`: can contain any character.
- `PHONE`: any valid 8-digit integer.
- `EMAIL`: a string of the format `local-part@domain`
- `ADDRESS`: can contain any character.
- `TAG`: can contain any character.
- Precise expected outputs when the command succeeds:

<div align="center">
<img src="./images/addlead.png" width="500" />
<p>After using addlead command</p>
</div>

- Precise expected outputs when the command fails:

```
Invalid command format!
addlead: Adds a lead to the address book. Parameters: n/NAME p/PHONE e/EMAIL a/ADDRESS [t/TAG]...
Example: addlead n/John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/classmate
```

### Add Client
- What it does: Add potential clients and their basic information, e.g. name, age, year of study, major, etc.
- Command format: `addclient n/NAME p/PHONE e/EMAIL a/ADDRESS [t/TAG]...`.
- Example usage: `Example: addclient n/John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/classmate`.
- Acceptable values for each parameter:
- `name`: can contain any character, up to 100 characters long.
- `age`: any integer between `1` and `100` inclusive.
- `year`: any integer between `1` and `5` inclusive.
- `major`: can contain any character, up to 50 characters long.
- `NAME`: can contain any character.
- `PHONE`: any valid 8-digit integer.
- `EMAIL`: a string of the format `local-part@domain`
- `ADDRESS`: can contain any character.
- `TAG`: can contain any character.
- Precise expected outputs when the command succeeds:

`Lead added. <lead details>`
<div align="center">
<img src="./images/addclient.png" width="500" />
<p>After using addclient command</p>
</div>

- Precise expected outputs when the command fails:

`Lead failed to add. Please enter a valid command`
```
Invalid command format!
addclient: Adds a client to the address book. Parameters: n/NAME p/PHONE e/EMAIL a/ADDRESS [t/TAG]...
Example: addclient n/John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/classmate
```

### View all clients

- What it does: View all clients you have stored, including their basic information and index in the list of leads, e.g. id, name, age, gender, occupation, etc.
- What it does: View all clients you have stored, including their basic information and index in the list of clients, e.g. id, name, age, gender, occupation, etc.
- Command: `listclient`.
- Precise expected outputs when the command succeeds:

In output section of the
`List of all clients`

- Precise expected outputs when the command fails:
<h4>Examples of usage:</h4>

`Failed to view all clients. Please enter a valid command`
<div align="center">
<img src="./images/List.png" width="500" />
<p>List of leads and clients</p>
<img src="./images/Listclient.png" width="500" />
<p>After using listclient command</p>
</div>

### View all leads

Expand All @@ -81,36 +118,46 @@ Here are some descriptions of the words we use throughout the User Guide:

`List of all leads`

- Precise expected outputs when the command fails:
<h4>Example usage:<h4>

<div align="center">
<img src="./images/List.png" width = "500"/>
<p>List of leads and clients</p>
<img src="./images/Listlead.png" width = "500"/>
<p>After using listlead command</p>
</div>

`Failed to view all leads. Please enter a valid command`

### Delete lead [Coming soon]
### Delete [Coming soon]

- What it does: Deletes a lead from your list of leads.
- Command format: `delete --id <id>`.
- Example usage: `delete --id 1`.
- Acceptable values for `id` parameter:
- Command format: `delete INDEX`.
- Example usage: `delete 1`.
- Acceptable values for `INDEX` parameter:
- Must be an integer from `1` to the last index of the leads list
- Precise expected outputs when the command succeeds:

`Lead deleted: <lead details>`

- Precise expected outputs when the command fails:

`Lead failed to delete. Please enter a valid lead id`
```
Invalid command format!
delete: Deletes the person identified by the index number used in the displayed person list.
Parameters: INDEX (must be a positive integer)
```

### Add meeting time for lead [Coming soon]
### Add meeting time [Coming soon]

- What it does: Adds a meeting time for a lead
- Command format: `addmeeting --lead <lead_id> --dt <datetime>`
- Example usage: `addmeeting --lead 1 --dt 23/9/2023 5:30PM`
- Command format: `addmeetingtime INDEX m/MEETING_TIME`
- Example usage: `addmeetingtime 1 m/12/12/2020 12:00`
- Acceptable values for each parameter:
- `lead`: Any integer from `1` to the last index of the leads list
- `dt`: A valid DateTime String with the format dd/M/yyyy hh:mma.
- `INDEX`: Any integer from `1` to the last index of the leads list.
- `MEETING_TIME`: A string of format `dd/MM/yyyy HH:mm`.
- Precise expected outputs when the command succeeds:

`Meeting time added to <lead> : <meeting datetime>`
`Meeting time added to <lead/client> : <meeting datetime>`

- Precise expected outputs when the command fails:

Expand Down
Binary file added docs/images/List.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/Listclient.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/Listlead.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/addclient.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/addlead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@ public class CommandResult {
/** The application should exit. */
private final boolean exit;

private String state;

/**
* Constructs a {@code CommandResult} with the specified fields.
*/
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit, String state) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.state = state;
}

/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser},
* and other fields set to their default value.
*/
public CommandResult(String feedbackToUser) {
this(feedbackToUser, false, false);
this(feedbackToUser, false, false, "null");
}

public String getFeedbackToUser() {
Expand All @@ -48,6 +51,10 @@ public boolean isExit() {
return exit;
}

public String checkState() {
return state;
}

@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ExitCommand extends Command {

@Override
public CommandResult execute(Model model) {
return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true);
return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true, "exit");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class HelpCommand extends Command {

@Override
public CommandResult execute(Model model) {
return new CommandResult(SHOWING_HELP_MESSAGE, true, false);
return new CommandResult(SHOWING_HELP_MESSAGE, true, false, "help");
}
}
2 changes: 0 additions & 2 deletions src/main/java/seedu/address/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class ListCommand extends Command {
public static final String COMMAND_WORD = "list";

public static final String MESSAGE_SUCCESS = "Listed all persons";


@Override
public CommandResult execute(Model model) {
requireNonNull(model);
Expand Down
70 changes: 70 additions & 0 deletions src/main/java/seedu/address/logic/commands/ViewCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;

import java.util.logging.Logger;

import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;

/**
* Views specified person based on input index.
*/
public class ViewCommand extends Command {

public static final String COMMAND_WORD = "view";

public static final String MESSAGE_SUCCESS = "Viewed Person Successfully";
private static final String state = "view";


public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Views the person identified by the index number used.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

private static final Logger logger = LogsCenter.getLogger(ViewCommand.class);

private final Index targetIndex;

public ViewCommand(Index targetIndex) {
this.targetIndex = targetIndex;
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);


if (targetIndex.getZeroBased() < 0 || targetIndex.getZeroBased() >= model.getFilteredPersonList().size()) {
logger.info(targetIndex.getZeroBased() + "+ " + model.getFilteredPersonList().size());
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person personToView = model.getFilteredPersonList().get(targetIndex.getZeroBased());
model.view(personToView);

logger.info("Target Index: " + targetIndex.getZeroBased());
logger.info("Client to View: " + personToView);
return new CommandResult(MESSAGE_SUCCESS, false, false, "view");
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}

if (other == null || getClass() != other.getClass()) {
return false;
}

ViewCommand that = (ViewCommand) other;

return targetIndex.equals(that.targetIndex);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import seedu.address.logic.commands.ListClientCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.ListLeadCommand;
import seedu.address.logic.commands.ViewCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand Down Expand Up @@ -90,13 +91,16 @@ public Command parseCommand(String userInput) throws ParseException {

case ListLeadCommand.COMMAND_WORD:
return new ListLeadCommand();

case ConvertLeadToClientCommand.COMMAND_WORD:
return new ConvertLeadToClientCommandParser().parse(arguments);

case ConvertClientToLeadCommand.COMMAND_WORD:
return new ConvertClientToLeadCommandParser().parse(arguments);

case ViewCommand.COMMAND_WORD:
return new ViewCommandParser().parse(arguments);

default:
logger.finer("This user input caused a ParseException: " + userInput);
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/seedu/address/logic/parser/ViewCommandParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seedu.address.logic.parser;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.ViewCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
* Parses input arguments and creates a new ViewCommand object
*/
public class ViewCommandParser implements Parser<ViewCommand> {

/**
* Parses the given {@code String} of arguments in the context of the ViewCommand
* and returns a ViewCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public ViewCommand parse(String args) throws ParseException {
try {
Index index = ParserUtil.parseIndex(args);
return new ViewCommand(index);
} catch (ParseException pe) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE), pe);
}
}

}
1 change: 0 additions & 1 deletion src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public boolean equals(Object other) {
AddressBook otherAddressBook = (AddressBook) other;
return persons.equals(otherAddressBook.persons);
}

@Override
public int hashCode() {
return persons.hashCode();
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* The API of the Model component.
*/
public interface Model {
/** {@code Predicate} that always evaluate to true */
/**
* {@code Predicate} that always evaluate to true
*/
Predicate<Person> PREDICATE_SHOW_ALL_PERSONS = unused -> true;

/**
Expand Down Expand Up @@ -51,7 +53,9 @@ public interface Model {
*/
void setAddressBook(ReadOnlyAddressBook addressBook);

/** Returns the AddressBook */
/**
* Returns the AddressBook
*/
ReadOnlyAddressBook getAddressBook();

/**
Expand Down Expand Up @@ -82,12 +86,20 @@ public interface Model {
*/
void setPerson(Person target, Person editedPerson);

/** Returns an unmodifiable view of the filtered person list */
/**
* Returns an unmodifiable view of the filtered person list
*/
ObservableList<Person> getFilteredPersonList();

/**
* Updates the filter of the filtered person list to filter by the given {@code predicate}.
*
* @throws NullPointerException if {@code predicate} is null.
*/
void updateFilteredPersonList(Predicate<Person> predicate);

/**
* Updates the filter of the filtered person list to just the specified person {@code predicate}.
*/
void view(Person clientToView);
}
Loading

0 comments on commit 928e16d

Please sign in to comment.