Skip to content

Commit

Permalink
Merge pull request #72 from ongkimlai/events-UI
Browse files Browse the repository at this point in the history
Events UI
  • Loading branch information
fredtwt authored Mar 25, 2022
2 parents ad77865 + f8710de commit 508dca7
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 41 deletions.
40 changes: 24 additions & 16 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br>

**For example:** <br>
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.
Expand All @@ -178,8 +178,16 @@ of those deleted, so in order to show them in the same order as the input, all t
**For example:** <br>
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.<br>
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.<br>

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.

Expand Down Expand Up @@ -389,7 +397,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**
````
Expand All @@ -413,7 +421,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**
````
Expand All @@ -431,7 +439,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**
````
Expand All @@ -458,7 +466,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**
````
Expand All @@ -485,7 +493,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**
````
Expand All @@ -494,29 +502,29 @@ 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**
````
1. User requests to find any person using specific fields
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**
````
Expand All @@ -527,7 +535,7 @@ The user wants to find a person that has every field instead.
Use case ends.
````
***Extensions***
**Extensions**
````
2a. The list is empty.
Expand All @@ -549,7 +557,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**
````
Expand All @@ -569,7 +577,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**
````
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,33 @@ 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);
}

/**
* 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, false, false);
}

public String getFeedbackToUser() {
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}
9 changes: 7 additions & 2 deletions src/main/java/seedu/address/model/event/DateTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateTime {
public class DateTime implements Comparable<DateTime> {
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!";
Expand Down Expand Up @@ -47,7 +47,7 @@ public static boolean isValidTime(String test) {
return test.matches(TIME_VALIDATION_REGEX);
}

public String getDateTime() {
public String displayDateTime() {
return value.format(DISPLAY_FORMATTER);
}

Expand All @@ -67,4 +67,9 @@ public boolean equals(Object other) {
public int hashCode() {
return value.hashCode();
}

@Override
public int compareTo(DateTime other) {
return value.compareTo(other.value);
}
}
7 changes: 6 additions & 1 deletion src/main/java/seedu/address/model/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event> {

// Identity fields
private final EventName name;
Expand Down Expand Up @@ -83,4 +83,9 @@ public String toString() {
.append(getParticipants());
return builder.toString();
}

@Override
public int compareTo(Event other) {
return dateTime.compareTo(other.dateTime);
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/EventCardComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public EventCardComponent(Event event, int displayedIndex) {
this.event = event;
id.setText(displayedIndex + ". ");
eventname.setText(event.getEventName().toString());
datetime.setText(event.getDateTime().toString());
datetime.setText(event.getDateTime().displayDateTime());
info.setText("Additional info: " + event.getEventInfo().toString());
event.getParticipants().stream()
.sorted(Comparator.comparing(p -> p.fullName))
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane personListPanelPlaceholder;

@FXML
private StackPane singlePersonPanelPlaceholder;

@FXML
private StackPane resultDisplayPlaceholder;

Expand Down Expand Up @@ -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.
*
Expand All @@ -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();
}
Expand Down
26 changes: 11 additions & 15 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
Expand All @@ -13,7 +14,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>

<fx:root minHeight="665.0" minWidth="840.0" onCloseRequest="#handleExit" title="NUSocials" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<fx:root minHeight="665.0" minWidth="840.0" onCloseRequest="#handleExit" title="NUSocials" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/address_book_32.png" />
</icons>
Expand Down Expand Up @@ -47,24 +48,19 @@
</StackPane>
<SplitPane dividerPositions="0.01" prefWidth="840.0" VBox.vgrow="ALWAYS">
<items>
<AnchorPane minWidth="420.0">
<AnchorPane focusTraversable="true" minWidth="420.0">
<children>
<VBox fx:id="personList" alignment="CENTER" styleClass="pane-with-border">
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS" />
</VBox>
<StackPane fx:id="personListPanelPlaceholder" focusTraversable="true" layoutX="11.0" layoutY="11.0" />
</children>
</AnchorPane>
<AnchorPane minWidth="420.0">
<AnchorPane focusTraversable="true" minWidth="420.0">
<children>
<VBox fx:id="eventList" alignment="CENTER" styleClass="pane-with-border">
<padding>
<Insets bottom="10" left="10" right="10" top="10"/>
</padding>
<StackPane fx:id="eventListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>
<StackPane fx:id="eventListPanelPlaceholder" focusTraversable="true" layoutX="11.0" layoutY="11.0" />
<StackPane fx:id="singlePersonPanelPlaceholder" focusTraversable="true" layoutX="21.0" layoutY="21.0" visible="false">
<children>
<Label text="testing" />
</children>
</StackPane>
</children>
</AnchorPane>
</items>
Expand Down

0 comments on commit 508dca7

Please sign in to comment.