From 50b1ab9f8eb864baaa5ba7d4517f128195cf8349 Mon Sep 17 00:00:00 2001 From: Ong Kim Lai Date: Thu, 24 Mar 2022 20:20:10 +0800 Subject: [PATCH 1/3] Cosmetic changes to DG --- docs/DeveloperGuide.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 556167bdda4..c7b2817c5f0 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -389,7 +389,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli (For all use cases below, the **System** is the `NUSocials` and the **Actor** is the `user`, unless specified otherwise) -###**Use case 1: Delete a person** +### Use case 1: Delete a person **MSS** ```` @@ -413,7 +413,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli Use case resumes at step 2. ```` -###**Use case 2: Add a person** +### Use case 2: Add a person **MSS** ```` @@ -431,7 +431,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli Use case resumes at step 1. ```` -###**Use case 3: Tag a person** +### Use case 3: Tag a person **MSS** ```` @@ -458,7 +458,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli Use case resumes at step 2. ```` -###**Use case 4: Edit a person** +### Use case 4: Edit a person **MSS** ```` @@ -485,7 +485,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli Use case resumes at step 2. ```` -###**Use case 5: Viewing all persons** +### Use case 5: Viewing all persons **MSS** ```` @@ -494,7 +494,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli Use case ends. ```` -###**Use case 6: Finding a person (any field)** +### Use case 6: Finding a person (any field) **MSS** ```` @@ -502,21 +502,21 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli 2. NUSocials shows a list of persons matching any fields Use case ends. ```` -***Extensions*** +**Extensions** ```` 2a. The given find command is invalid. - 2a1. NUSocials shows an error message. Use case resumes at step 1. ```` -###**Use case 7: Finding a person (all fields)** +### Use case 7: Finding a person (all fields) ```` Similar to Use case 6, except now: The user wants to find a person that has every field instead. ```` -###**Use case 8: Removing specific tags** +### Use case 8: Removing specific tags **MSS** ```` @@ -527,7 +527,7 @@ The user wants to find a person that has every field instead. Use case ends. ```` -***Extensions*** +**Extensions** ```` 2a. The list is empty. @@ -549,7 +549,7 @@ The user wants to find a person that has every field instead. Use case resumes at step 2. ```` -###**Use case 9: Delete multiple persons** +### Use case 9: Delete multiple persons **MSS** ```` @@ -569,7 +569,7 @@ The user wants to delete multiple persons instead. Use case resumes at step 2. ```` -###**Use case 10: Adding events** +### Use case 10: Adding events **MSS** ```` From 939be417251e5c5e088c7a3a2d3dc1b2aed32cfc Mon Sep 17 00:00:00 2001 From: Ong Kim Lai Date: Thu, 24 Mar 2022 23:58:01 +0800 Subject: [PATCH 2/3] Events sorted chronologically Created 2 stackpanes for eventList and future view single contact card. They are toggled whenever a list or view (not yet implemented) command is used. Toggled by setting visibility to true/false accordingly. --- .../address/logic/commands/CommandResult.java | 24 +++++++++++++++-- .../address/logic/commands/ListCommand.java | 6 +++-- .../seedu/address/model/event/DateTime.java | 8 +++++- .../java/seedu/address/model/event/Event.java | 7 ++++- .../seedu/address/model/person/Person.java | 4 +-- .../java/seedu/address/ui/MainWindow.java | 17 ++++++++++++ src/main/resources/view/MainWindow.fxml | 26 ++++++++----------- 7 files changed, 69 insertions(+), 23 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/CommandResult.java b/src/main/java/seedu/address/logic/commands/CommandResult.java index 92f900b7916..ca4e651102e 100644 --- a/src/main/java/seedu/address/logic/commands/CommandResult.java +++ b/src/main/java/seedu/address/logic/commands/CommandResult.java @@ -17,13 +17,25 @@ public class CommandResult { /** The application should exit. */ private final boolean exit; + /** The application should toggle visibility of right panel to events. */ + private final boolean isListCommand; + + /** The application should toggle visibility of right panel to events. */ + private final boolean isViewCommand; + /** * Constructs a {@code CommandResult} with the specified fields. */ - public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) { + public CommandResult(String feedbackToUser, boolean showHelp, boolean exit, boolean isList, boolean isView) { this.feedbackToUser = requireNonNull(feedbackToUser); this.showHelp = showHelp; this.exit = exit; + this.isListCommand = isList; + this.isViewCommand = isView; + } + + public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) { + this(feedbackToUser, showHelp, exit, false, false); } /** @@ -31,7 +43,7 @@ public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) { * and other fields set to their default value. */ public CommandResult(String feedbackToUser) { - this(feedbackToUser, false, false); + this(feedbackToUser, false, false, false, false); } public String getFeedbackToUser() { @@ -46,6 +58,14 @@ public boolean isExit() { return exit; } + public boolean isListCommand() { + return isListCommand; + } + + public boolean isViewCommand() { + return isViewCommand; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 6ab277ac190..0d6ede62e6d 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -1,6 +1,7 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_EVENTS; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; import seedu.address.model.Model; @@ -12,14 +13,15 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; - public static final String MESSAGE_SUCCESS = "Listed all persons"; + public static final String MESSAGE_SUCCESS = "Listed all persons and upcoming events"; @Override public CommandResult execute(Model model) { requireNonNull(model); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + model.updateFilteredEventList(PREDICATE_SHOW_ALL_EVENTS); // TODO: change predicate to after current time - return new CommandResult(MESSAGE_SUCCESS); + return new CommandResult(MESSAGE_SUCCESS, false, false, true, false); } } diff --git a/src/main/java/seedu/address/model/event/DateTime.java b/src/main/java/seedu/address/model/event/DateTime.java index 425bcc91fa6..c2555b3cc76 100644 --- a/src/main/java/seedu/address/model/event/DateTime.java +++ b/src/main/java/seedu/address/model/event/DateTime.java @@ -5,7 +5,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -public class DateTime { +public class DateTime implements Comparable { public static final String DATETIME_MESSAGE_CONSTRAINTS = "Date and Time has to be valid!"; public static final String DATE_MESSAGE_CONSTRAINTS = "Date has to be in the format of yyyy-MM-DD!"; public static final String TIME_MESSAGE_CONSTRAINTS = "Time has to be in the format of HH:mm!"; @@ -46,6 +46,7 @@ public static boolean isValidTime(String test) { return test.matches(TIME_VALIDATION_REGEX); } + @Override public String toString() { return value.format(DATE_TIME_FORMATTER); @@ -62,4 +63,9 @@ public boolean equals(Object other) { public int hashCode() { return value.hashCode(); } + + @Override + public int compareTo(DateTime other) { + return value.compareTo(other.value); + } } diff --git a/src/main/java/seedu/address/model/event/Event.java b/src/main/java/seedu/address/model/event/Event.java index b0559ef4c8d..74c544e4c98 100644 --- a/src/main/java/seedu/address/model/event/Event.java +++ b/src/main/java/seedu/address/model/event/Event.java @@ -11,7 +11,7 @@ * Represents an Event in the address book. * Guarantees: details are present and not null, field values are validated, immutable. */ -public class Event { +public class Event implements Comparable { // Identity fields private final EventName name; @@ -83,4 +83,9 @@ public String toString() { .append(getParticipants()); return builder.toString(); } + + @Override + public int compareTo(Event other) { + return dateTime.compareTo(other.dateTime); + } } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 00f04a0b9bf..4d3a7a71943 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -196,7 +196,7 @@ public String toString() { } @Override - public int compareTo(Person o) { - return name.fullName.compareToIgnoreCase(o.getName().fullName); + public int compareTo(Person other) { + return name.fullName.compareToIgnoreCase(other.getName().fullName); } } diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 76bb9702dcd..a9242eb6fd4 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -45,6 +45,9 @@ public class MainWindow extends UiPart { @FXML private StackPane personListPanelPlaceholder; + @FXML + private StackPane singlePersonPanelPlaceholder; + @FXML private StackPane resultDisplayPlaceholder; @@ -174,6 +177,16 @@ public PersonListPanel getPersonListPanel() { return personListPanel; } + private void showEventsInRightPanel(boolean isList) { + if (isList) { + eventListPanelPlaceholder.setVisible(true); + singlePersonPanelPlaceholder.setVisible(false); + } else { + eventListPanelPlaceholder.setVisible(false); + singlePersonPanelPlaceholder.setVisible(true); + } + } + /** * Executes the command and returns the result. * @@ -185,6 +198,10 @@ private CommandResult executeCommand(String commandText) throws CommandException logger.info("Result: " + commandResult.getFeedbackToUser()); resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser()); + if (commandResult.isListCommand() || commandResult.isViewCommand()) { + showEventsInRightPanel(commandResult.isListCommand()); + } + if (commandResult.isShowHelp()) { handleHelp(); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 1561580b587..bb86581ef95 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -3,6 +3,7 @@ + @@ -13,7 +14,7 @@ - + @@ -47,24 +48,19 @@ - + - - - - - - + - + - - - - - - + + + + + From f8710de453977f848e0186c3565ae623a32c55ac Mon Sep 17 00:00:00 2001 From: Ong Kim Lai Date: Fri, 25 Mar 2022 10:09:34 +0800 Subject: [PATCH 3/3] Update DG for delete multiple and cosmetic changes Also serves as a dummy commit as github actions was down, causing CI checks to not run. --- docs/DeveloperGuide.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index c7b2817c5f0..8c6f1658ddf 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -160,14 +160,14 @@ This section describes some noteworthy details on how certain features are imple ### Delete multiple persons enhancement -### Original implementation +#### Original implementation Originally, the idea was to simply call `deletePerson` on each integer, but this will not work as the indexes of each person in the contact list might change depending on the order of deletion.
**For example:**
In a list with only 3 contacts, `delete 1 2 3` will not be allowed as there is no longer an index 3 during the 3rd deletion. -### Current implementation +#### Current implementation The delete command now has to accept multiple indexes as a valid input. The ParserUtil class can easily facilitate this behaviour by extending the validity checks on the entire string of input. @@ -178,8 +178,16 @@ of those deleted, so in order to show them in the same order as the input, all t **For example:**
Similarly, in a list with only 3 contacts, `delete 1 2 3` will now be allowed. -First, information about Person 1, Person 2 and Person 3 will be extracted according to the last shown list.
-Then, Person 3 gets deleted first followed by Person 2, then Person 1. This ensures correctness in the deletion process. +Step 1. User enters `delete 1 2 3` and `LogicManager` would execute it. + +Step 2. `LogicManager` would pass the arguments to `AddressBookParser` to parse the command as a `DeleteCommand`. + +Step 3. The arguments `1 2 3` would be passed into `DeleteCommandParser` to detect if the deletion is for multiple persons using `ParserUtil`. + +Step 4. Information about Person 1, Person 2 and Person 3 will be extracted according to the last shown list.
+ +Step 5. The deletion process starts sequentially. Person 3 gets deleted followed by Person 2, then Person 1. This ensures correctness in the deletion process. + The Sequence Diagram below illustrates the interactions within the Logic component for the `execute("delete 1 2 3")` API call.