Skip to content

Commit

Permalink
Merge pull request #75 from rui-han-crh/Update-UI
Browse files Browse the repository at this point in the history
Update UI
  • Loading branch information
rui-han-crh authored Oct 27, 2022
2 parents 2591db4 + 321fd3e commit ebf4ec9
Show file tree
Hide file tree
Showing 66 changed files with 1,883 additions and 218 deletions.
64 changes: 44 additions & 20 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ Examples:
* `findTag Finance` returns `John`, `Caroline` and `Bob`
![result for 'findTag Finance'](images/findTagFinance.png)


### Inspecting a person : `inspect`

Updates the inspect panel with the basic information and loan history of the person inspected.

![help message](images/helpMessage.png)

Format: `inspect <INDEX> or <NAME>`


### Editing loan of a person: `editLoan`

Edits an existing club member's loan amount in the SectresBook.
Expand Down Expand Up @@ -330,12 +340,12 @@ Format: `listNote`

Edits an existing specified note in the SectresBook.

Format: `editNote INDEX [title/TITLE] [content/CONTENT] [tag/TAG]...`
Format: `editNote INDEX <OR> TITLE [title/TITLE] [content/CONTENT] [tag/TAG]...`

Example of usage:

* `editNote 1 content/Second club meeting` can be used to easily update the first note's contents.
* `editeNote 2 title/2020 alumni meeting` can be used to easily update the second note's title.
* `editNote alumni title/2020 alumni meeting` can be used to amend a note with the title "2020 alumni mtg", only if it is the only note containing "2021" in its title.

### Locating a note by title: `findNote`

Expand Down Expand Up @@ -371,6 +381,17 @@ Format: `deleteNote INDEX`
Examples:
* `listNote` followed by `deleteNote 2` deletes the 2nd note in the SectresBook.

### Hiding notes panel : `hideNotes`

Hides the notes panel to the right side of the screen if visible, otherwise, no operation is performed.

Format: `hideNotes`

### Showing notes panel : `showNotes`

Slides the notes panel into view if hidden, otherwise, no operation is performed.

Format: `showNotes`

### Exiting the program : `exit`

Expand Down Expand Up @@ -435,25 +456,28 @@ Word | Definition

### AddressBook Commands

Action | Format | Examples
--------|-------------------------------------------------------------------------------------------------------|--------
**Add** | `add name/NAME phone/PHONE_NUMBER email/EMAIL home/ADDRESS bday/BIRTHDAY [tag/TAG]…​` | `add name/James Ho phone/22224444 email/[email protected] home/123, Clementi Rd, 1234665 bday/01/01/2000 tag/friend tag/colleague`
**Clear** | `clear` | `clear`
**Delete** | `delete INDEX`<br>`delete NAME` | `delete 3` <br> `delete Jane`
Action | Format | Examples
--------|------------------------------------------------------------------------------------------------------|--------
**Add** | `add name/NAME phone/PHONE_NUMBER email/EMAIL home/ADDRESS bday/BIRTHDAY [tag/TAG]…​` | `add name/James Ho phone/22224444 email/[email protected] home/123, Clementi Rd, 1234665 bday/01/01/2000 tag/friend tag/colleague`
**Clear** | `clear` | `clear`
**Delete** | `delete INDEX`<br>`delete NAME` | `delete 3` <br> `delete Jane`
**Edit** | `edit INDEX [name/NAME] [phone/PHONE_NUMBER] [email/EMAIL] [home/ADDRESS] [bday/BIRTHDAY][tag/TAG]…​` | `edit 2 name/James Lee email/[email protected]`
**Find** | `find KEYWORD [MORE_KEYWORDS]` <br> `find NUMBER` | `find James Jake` <br> `find 8651`
**Find Tag** | `findTag TAG [MORE_TAGS]` | `findTag Operations Outreach`
**Edit Loan** | `editLoan INDEX AMOUNT REASON` | `editLoan 1 -20 Buy Logistics`
**List** | `list` | `list`
**Help** | `help` | `help`
**Exit** | `exit` | `exit`
**Find** | `find KEYWORD [MORE_KEYWORDS]` <br> `find NUMBER` | `find James Jake` <br> `find 8651`
**Find Tag** | `findTag TAG [MORE_TAGS]` | `findTag Operations Outreach`
**Edit Loan** | `editLoan INDEX AMOUNT REASON` | `editLoan 1 -20 Buy Logistics`
**List** | `list` | `list`
**Inspect** | `inspect NAME <OR> INDEX` | `inspect 1` or `inspect Alex`
**Show Notes Panel** | `showNotes` | `showNotes`
**Hide Notes Panel** | `hideNotes` | `hideNotes`
**Help** | `help` | `help`
**Exit** | `exit` | `exit`

### Note Commands

Action | Format | Examples
--------|---------------------------|-------------
**Add Note** | `addNote title/TITLE content/CONTENT [tag/TAG]...` | `addNote title/Create Excel Sheet content/Create sheet for blockchain department`
**Edit Note** | `editNote INDEX [title/TITLE] [content/CONTENT] [tag/TAG]...` | `editNote 1 title/Check meeting availability tag/president`
**Delete Note** | `deleteNote INDEX` | `deleteNote 1`
**List Notes** | `listNote` | `listNote`
**Find Note** | `findNote KEYWORD [MORE_KEYWORDS]` | `findNote meeting`
Action | Format | Examples
--------|--------------------------------------------------------------------------|-------------
**Add Note** | `addNote title/TITLE content/CONTENT [tag/TAG]...` | `addNote title/Create Excel Sheet content/Create sheet for blockchain department`
**Edit Note** | `editNote INDEX <OR> TITLE [title/TITLE] [content/CONTENT] [tag/TAG]...` | `editNote 1 title/Check meeting availability tag/president`
**Delete Note** | `deleteNote INDEX` | `deleteNote 1`
**List Notes** | `listNote` | `listNote`
**Find Note** | `findNote KEYWORD [MORE_KEYWORDS]` | `findNote meeting`
36 changes: 36 additions & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import java.io.IOException;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Logger;

import javafx.application.Application;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import seedu.address.commons.core.Config;
import seedu.address.commons.core.LogsCenter;
Expand Down Expand Up @@ -51,6 +53,8 @@ public void init() throws Exception {
logger.info("=============================[ Initializing AddressBook ]===========================");
super.init();

loadFonts();

AppParameters appParameters = AppParameters.parse(getParameters());
config = initConfig(appParameters.getConfigPath());

Expand All @@ -68,6 +72,38 @@ public void init() throws Exception {
ui = new UiManager(logic);
}

private void loadFonts() {
Font.loadFont(
Objects.requireNonNull(MainApp.class.getResource("/fonts/MinionPro-Bold.otf")).toExternalForm(),
10
);

Font.loadFont(
Objects.requireNonNull(MainApp.class.getResource("/fonts/MinionPro-Medium.otf")).toExternalForm(),
10
);

Font.loadFont(
Objects.requireNonNull(MainApp.class.getResource("/fonts/MinionPro-Semibold.otf")).toExternalForm(),
10
);

Font.loadFont(
Objects.requireNonNull(MainApp.class.getResource("/fonts/Bender.otf")).toExternalForm(),
10
);

Font.loadFonts(
Objects.requireNonNull(MainApp.class.getResource("/fonts/Bender-Bold.otf")).toExternalForm(),
10
);

Font.loadFonts(
Objects.requireNonNull(MainApp.class.getResource("/fonts/Bender-Light.otf")).toExternalForm(),
10
);
}

/**
* Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code userPrefs}. <br>
* The data from the sample address book will be used instead if {@code storage}'s address book is not found,
Expand Down
36 changes: 34 additions & 2 deletions src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
package seedu.address.commons.core;

import seedu.address.logic.parser.CliSyntax;

/**
* Container for user visible messages.
*/
public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";

public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";

public static final String MESSAGE_INVALID_AMBIGUOUS_TITLE = "There is more than 1 note with %s in their title!\n"
+ "Please use a more unique specifier or use indices to edit.";

public static final String MESSAGE_INVALID_TITLE = "There are no notes with %s in their titles in the list!";

public static final String MESSAGE_INVALID_NOTE_DISPLAYED_INDEX = "The note index provided is invalid";

public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";

public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";

public static final String MESSAGE_NOTES_LISTED_OVERVIEW = "%1$d notes listed!";

public static final String MESSAGE_NUMBER_TOO_SHORT = "Number to check must be at least 2 digits";

public static final String MESSAGE_INVALID_KEYWORD = "Keyword is invalid,keyword cannot contain special characters";
public static final String MESSAGE_INVALID_AMBIGUOUS_NAME = "There is more than 1 person with %s in their name!";
public static final String MESSAGE_INVALID_NAME = "There is no one with the name %s in the list!";

public static final String MESSAGE_INVALID_AMBIGUOUS_NAME = "There is more than 1 person with %s in their name!\n"
+ "Please use a more unique specifier or use indices to edit.";

public static final String MESSAGE_INVALID_NAME = "There is no one with the name %s found!";

public static final String AMOUNT_NOT_SPECIFIED = "No amount to was specified to edit the loan with.\n"
+ "Please use " + CliSyntax.PREFIX_LOAN_AMOUNT + " to specify a change in loan amount!";

public static final String REASON_NOT_SPECIFIED = "A reason must be given to change loan amounts.\n"
+ "Please use " + CliSyntax.PREFIX_LOAN_REASON + " to specify a reason to change the loan value!";

public static final String OUT_OF_BOUNDS = "The index given to be inspected must be within "
+ "the bounds of the list!";

public static final String NOT_AN_INTEGER = "The index given was not an integer value";

public static final String AMBIGUOUS_NAME_INSPECT_FIRST = "There was more than one person of that name found.\n"
+ "Showing the first person matching the given name.\n"
+ "Note that inspection works on the currently filtered list, "
+ "perhaps you would like to filter away some persons first?";
}
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_BIRTHDAY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LOAN;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
Expand All @@ -25,13 +26,15 @@ public class AddCommand extends Command {
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_BIRTHDAY + "BIRTHDAY "
+ "[" + PREFIX_TAG + "TAG]..."
+ "[" + PREFIX_LOAN + "10]\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_BIRTHDAY + "28/10/2000 "
+ PREFIX_TAG + "friends "
+ PREFIX_LOAN + "50";

Expand Down
66 changes: 42 additions & 24 deletions src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,59 @@

import static java.util.Objects.requireNonNull;

import java.util.Arrays;
import java.util.Objects;

/**
* Represents the result of a command execution.
*/
public class CommandResult {

private final String feedbackToUser;
/**
* Enum describing the state of the UI to trigger actions
*/
public enum UiState {
ShowHelp,
Exit,
Inspect,
HideNotes, ShowNotes, None
}

private final UiState state;

/** Help information should be shown to the user. */
private final boolean showHelp;
private final String[] args;

/** The application should exit. */
private final boolean exit;
private final String feedbackToUser;

/**
* Constructs a {@code CommandResult} with the specified fields.
* Constructs a {@code CommandResult} with the no additional state.
*/
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
public CommandResult(String feedbackToUser) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.state = UiState.None;
this.args = new String[0];
}

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

public String getFeedbackToUser() {
return feedbackToUser;
public CommandResult(String feedbackToUser, UiState state, String... args) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.state = state;
this.args = args;
}

public boolean isShowHelp() {
return showHelp;
/**
* Constructs a {@code CommandResult} with the specified state.
*/
public CommandResult(String feedbackToUser, UiState state) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.state = state;
this.args = new String[0];
}

public boolean isExit() {
return exit;
public String getFeedbackToUser() {
return feedbackToUser;
}

@Override
Expand All @@ -59,13 +70,20 @@ public boolean equals(Object other) {

CommandResult otherCommandResult = (CommandResult) other;
return feedbackToUser.equals(otherCommandResult.feedbackToUser)
&& showHelp == otherCommandResult.showHelp
&& exit == otherCommandResult.exit;
&& getUiState() == otherCommandResult.getUiState()
&& Arrays.equals(getArgs(), otherCommandResult.getArgs());
}

@Override
public int hashCode() {
return Objects.hash(feedbackToUser, showHelp, exit);
return Objects.hash(feedbackToUser, getUiState(), Arrays.hashCode(getArgs()));
}

public UiState getUiState() {
return state;
}

public String[] getArgs() {
return args;
}
}
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditLoanCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public CommandResult execute(Model model) throws CommandException {
editedPerson.getTags().forEach(tag -> tag.addPerson(editedPerson));

model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
return new CommandResult(String.format(MESSAGE_EDIT_LOAN_SUCCESS, editedPerson));
int index = model.getFilteredPersonList().indexOf(editedPerson);

return new CommandResult(String.format(MESSAGE_EDIT_LOAN_SUCCESS, editedPerson),
CommandResult.UiState.Inspect, String.valueOf(index + 1));
}


Expand All @@ -99,13 +102,17 @@ private static Person createEditedPerson(Person personToEdit, EditLoanDescriptor
Address updatedAddress = personToEdit.getAddress();
Birthday updatedBirthday = personToEdit.getBirthday();
Set<Tag> updatedTags = personToEdit.getTags();

double val = editLoanDescriptor.getLoan().get().getAmount() + personToEdit.getLoan().getAmount();

Loan updatedLoan = new Loan(String.valueOf(val));
List<LoanHistory> updatedLoanHistory = new ArrayList<>();

for (LoanHistory his : personToEdit.getHistory()) {
updatedLoanHistory.add(his);
}
updatedLoanHistory.add(editLoanDescriptor.getHistory().get());

editLoanDescriptor.getHistory().ifPresent(updatedLoanHistory::add);

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress,
updatedBirthday, updatedTags, updatedLoan, updatedLoanHistory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class EditNoteCommand extends Command {
public static final String COMMAND_WORD = "editNote";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the Note identified "
+ "by the index number used in the displayed note list. "
+ "by the index number or the title used in the displayed note list. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer)"
+ "Parameters: INDEX (must be a positive integer) <OR> TITLE (matches by substring) "
+ "[" + PREFIX_NOTES_TITLE + "TITLE] "
+ "[" + PREFIX_NOTES_CONTENT + "CONTENT] "
+ "[" + PREFIX_TAG + "TAG]...\n"
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, CommandResult.UiState.Exit);
}

}
Loading

0 comments on commit ebf4ec9

Please sign in to comment.