Skip to content

Commit

Permalink
Merge branch 'master' into bug-timetable-peD
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaduong authored Apr 8, 2023
2 parents cecc5e7 + 01e9a47 commit 6bc18c0
Show file tree
Hide file tree
Showing 16 changed files with 243 additions and 131 deletions.
65 changes: 45 additions & 20 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
3. System shows total earnings, monthly earnings,
weekly earnings, daily earnings and top customers visited.
Use case ends.

<b>Extensions</b>
* 2a. The list is empty.
Use case ends.
Expand Down Expand Up @@ -504,7 +503,6 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
3. User requests to delete a specific job in the list.
4. System deletes the job.
Use case ends.

<b>Extensions</b>
* 2a. The list is empty.
Use case ends.
Expand All @@ -524,7 +522,6 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
4. User fill in and submit the changes.
4. System update the job and list the new information.
Use case ends.

<b>Extensions</b>
* 2a. The list is empty.
Use case ends.
Expand All @@ -543,7 +540,6 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
3. User requests search for a job with options.
4. System displays search results that matches the query.
Use case ends.

<b>Extensions</b>
* 3a. Invalid search option given.
* 3a1. System shows an error message.
Expand Down Expand Up @@ -585,23 +581,21 @@ If yes, it will count and alert the user through the notification feature.
4. System runs in the background to only check the timetable for upcoming jobs.
System will repeat step 2 every hour, 20 mins before the next timetable slot.
Use case ends.

<b>Extensions:</b>
* 3a. If the current time is within 20 mins before the next timetable slot
* 3a1. System will check the next timetable slot and count number of upcoming jobs.
* 3a2. Alert the user through the notification feature.
* 3b. If the current time is before the first timetable slot.
* 3b1. System will check in the first timetable slot and count number of upcoming jobs.
* 3b1. System will check in the first timetable slot and count number of upcoming jobs.
* 3b2. Alert the user through the notification feature.
* 3c. If the current time is after the last timetable slot
* 3c1. System will not check for any or upcoming scheduled jobs.
Use case resumes from step 4.

Use case resumes from step 4.
</pre>
</details>

<details>
<summary><b>[RE1] Alert reminders</b></summary>
<summary><b>[RE2] Alert reminders</b></summary>
<pre>
<b>MSS</b>
1. User starts up System.
Expand All @@ -612,39 +606,36 @@ specified in a reminder, System will count it as an active reminder.
5. System runs in the background to check against the list of reminders after every minute.
System will repeat the check at step 3.
Use case ends.

<b>Extensions:</b>
* 4a. User can dismiss the reminder. Doing will prevent the app from showing anymore notifications.
* 4a1. A new reminder is activated.
Use case resumes from step 4.
Use case resumes from step 4.
* 4a2. No new reminder is activated.
Use case resumes from step 5
Use case resumes from step 5
</pre>
</details>

<details>
<summary><b>[RE2] Add reminders</b></summary>
<summary><b>[RE3] Add reminders</b></summary>
<pre>
<b>MSS</b>
1. User details the description, date and time of a reminder to the System.
2. System adds the reminder into the reminder list.
Use case ends.

<b>Extensions:</b>
* 2a. date and time of reminder is not provide.
* 2a1. System will prompt user again.
Use case resumes from step 1.
* 2a1. System will promopt user again.
Use case resumes from step 1.
</pre>
</details>

<details>
<summary><b>[RE3] Delete reminders</b></summary>
<summary><b>[RE4] Delete reminders</b></summary>
<pre>
<b>MSS</b>
1. User specifies a reminder to be deleted based on its index number.
2. System finds the corresponding reminder, and deletes it from the reminder list.
Use case ends.

<b>Extensions:</b>
* 2a. Index provided by user is not found in reminder list.
* 2a1. System will prompt user again.
Expand All @@ -653,7 +644,7 @@ Use case resumes from step 5
</details>

<details>
<summary><b>[RE4] List reminders</b></summary>
<summary><b>[RE5] List reminders</b></summary>
<pre>
<b>MSS</b>
1. User request System to show all reminders in reminder list.
Expand Down Expand Up @@ -714,14 +705,48 @@ testers are expected to do more *exploratory* testing.
1. Prerequisites: List all persons in Customers Window using the `list` command. Multiple persons in the list.

1. Test case: `delete 1`<br>
Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated.
Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message.

1. Test case: `delete 0`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.

1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
Expected: Similar to previous.

### Adding a delivery job

1. Add a job through command

1. Prerequisites: User is in the main window. Valid recipient and sender id.

1. Test case: `add_job si/DAVSAM ri/CHASAM earn/1`<br>
Expected: A delivery job is created without delivery schedule.
The sender should be DAVSAM and recipient should be CHASAM.
With earning value of $1.

1. Test case: `add_job si/DAVSAM ri/CHASAM earn/1 date/2024-05-01 slot/1`<br>
Expected: A delivery job is created with delivery schedule.
Similar to previous.

1. Other incorrect add job commands to try:
- `add_job si/invalid_id ri/invalid_id earn/empty` invalid argument supply.
- `add_job si/... ri/... earn/... [date/...] [slot/...]` with either date or slot given.

1. Add a job through GUI

1. Prerequisites: User have access to GUI. Access `menu` > `Delivery Job System` > `Create Job`.

1. Test case: fill in mandatory fields only (recipient/sender/earning)<br>
Expected: Similar to `1.ii`

1. Test case: fill in all fields<br>
Expected: Similar to `1.iii`

1. Other incorrect approach to try:
- `sender/recipient`, invalid person id.
- `earning`, multiple decimal points.
- `date`, invalid date.

### Notifications

1. Display a notification for a reminder
Expand Down
5 changes: 3 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Adds a delivery job to the delivery job system.
* Slot 1: 10AM - 11AM, Slot 2: 11AM - 12PM, Slot 3: 1PM - 2PM, Slot 4: 2PM - 3PM, Slot 5: 3PM - 4PM.
* Delivery slots must start from 1 (i.e. `slot/1` - delivery slots only start from 10AM), however, could also be larger than 5 (i.e. `slot/6`).
* Delivery slots larger than 5 (outside valid range, i.e. `slot/6`) will be classified as "Extra hours (4PM++)". These delivery slots are still considered invalid slots.
* Earning **must be a double** and could contain more than 2 decimal inputs.
* Earning **must be a double** and could contain more than 2 decimal inputs, Earning cannot be larger than 99999 (validation not configured as of v1.4).

Examples:
* `add_job si/ALESAM ri/DAVSAM earn/1.1`
Expand Down Expand Up @@ -286,7 +286,8 @@ or `edit_job ji/JOB_ID [si/SENDER_ID] [ri/RECEIPIENT_ID] [date/DELIVERY_DATE] [s
* Edits the delivery job at the specified `INDEX` or `JOB_ID` provided by user.
* The index refers to the index number shown in the displayed job list.
* The index **must be a positive integer** 1, 2, 3, …​
* Refer to `list_job` for argument constrains.
* Editing a completed job will reset the job to pending status.
* Refer to `add_job` for argument constrains.

Examples:
* `edit_job 1 slot/4`
Expand Down
Binary file modified docs/images/Completedjobs.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 modified docs/images/Inputcommands.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 modified docs/images/Unscheduledjobs.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 modified docs/images/reminderListWindow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/team/c0j0s.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Given below are my contributions to the project.
* Developer Guide:
* Update diagram for `Model` and `Storage`.
* Added use case for `list delivery job detail`, `delete job`, `edit job` and `find job`.
* Added implementation details foe delivery job system in developer guide.

* **Community**:
* Review PRs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static DeliveryJob createEditedDeliveryJob(DeliveryJob deliveryJobToEdit
}, () -> {
deliveryJobToEdit.getDeliveryDate().ifPresent(val -> {
editjobDescriptor.ifClearDeliveryDate(()-> {
toEdit.setDeliveryDate(DeliveryDate.placeholder().date);
toEdit.clearDeliveryDate();
}, () -> {
toEdit.setDeliveryDate(val.date);
});
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/jobs/DeliveryDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DeliveryDate {
/**
* Represents invalid date in storage.
*/
private static final String PLACEHOLDER = "0000-00-00";
private static final String PLACEHOLDER = "9999-12-31";

public final String date;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ public int compare(DeliveryJob a, DeliveryJob b) {
* Sorts by date
*/
private int compareByDate(DeliveryJob a, DeliveryJob b) {
if (a.getDate().compareTo(b.getDate()) == 0) {
return a.getSlot() - b.getSlot();
if (a.getDeliveryDate().isPresent() && b.getDeliveryDate().isPresent()) {
if (a.getDate().compareTo(b.getDate()) == 0) {
return a.getSlot() - b.getSlot();
} else {
return a.getDate().compareTo(b.getDate());
}
} else {
return a.getDate().compareTo(b.getDate());
return 0;
}
}
}
59 changes: 27 additions & 32 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.function.Consumer;
import java.util.logging.Logger;

import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -94,10 +93,10 @@ public class MainWindow extends UiPart<Stage> {

private Consumer<DeliveryJob> completeDeliveryJobHandler = (job) -> {
try {
logger.info("[completeDeliveryJobHandler] complete: " + job.getJobId());
CommandResult commandResult = logic
.execute(new CompleteDeliveryJobCommand(job.getJobId(), !job.getDeliveredStatus()));
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());
refreshDeliveryJobDetailPane();
} catch (ParseException | CommandException e) {
logger.warning(e.getMessage());
} catch (FileNotFoundException | IllegalArgumentException e) {
Expand All @@ -106,31 +105,32 @@ public class MainWindow extends UiPart<Stage> {
};

private Consumer<DeliveryJob> editDeliveryJobHandler = (job) -> {
logger.info("[editDeliveryJobHandler] edit: " + job.getJobId());
if (addDeliveryJobWindow != null) {
addDeliveryJobWindow.hide();
}
addDeliveryJobWindow = new AddDeliveryJobWindow(new Stage(), logic, job, commandResult -> {
addDeliveryJobWindow = new AddDeliveryJobWindow(new Stage(), logic, job);
addDeliveryJobWindow.setResultHandler(commandResult -> {
logger.info("[editDeliveryJobHandler] edit complete: " + job.getJobId());
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());
refreshDeliveryJobDetailPane();
});
addDeliveryJobWindow.show();
addDeliveryJobWindow.fillInnerParts();
};

private Consumer<DeliveryJob> deleteDeliveryJobHandler = job -> {
try {
deliveryJobListPanel.selectAvailable();
logger.info("[deleteDeliveryJobHandler] delete: " + job.getJobId());
CommandResult commandResult = logic.execute(new DeleteDeliveryJobCommand(job.getJobId()));
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());
refreshDeliveryJobDetailPane();
} catch (ParseException | CommandException | FileNotFoundException | IllegalArgumentException e) {
logger.warning(e.getMessage());
}
};

private BiConsumer<Integer, DeliveryJob> selectDeliveryJobHandler = (idx, job) -> {
logger.info("[JobListView] select: " + idx);
deliveryJobDetailPlaceholder.getChildren().clear();
logger.info("[selectDeliveryJobHandler] select: " + idx);
refreshDeliveryJobListView();

if (idx >= 0) {
DeliveryJobDetailPane detailPane = new DeliveryJobDetailPane(job);
Expand All @@ -141,11 +141,10 @@ public class MainWindow extends UiPart<Stage> {
detailPane.setDeleteHandler(deleteDeliveryJobHandler);
return;
}

emptyDeliveryJobListPanelPlaceholder.setVisible(true);
};

private BiFunction<DeliverySortOption, Boolean, ObservableList<DeliveryJob>> sortDeliveryJobHandler = (by, asc) -> {
logger.info("[sortDeliveryJobHandler] sort: " + by);
String feedback = "List empty!";
if (deliveryJobListPanel.size() > 0) {
switch (by) {
Expand All @@ -168,6 +167,7 @@ public class MainWindow extends UiPart<Stage> {
};

private Consumer<DeliveryFilterOption> filterDeliveryJobHandler = by -> {
logger.info("[filterDeliveryJobHandler] filter: " + by);
switch (by) {
case COM:
logic.updateFilteredDeliveryJobList(job -> job.getDeliveredStatus());
Expand Down Expand Up @@ -259,7 +259,7 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
}

private void refreshDeliveryJobListView() {
logger.info("[JobListView] Refresh List: " + deliveryJobListPanel.size());
logger.info("[refreshDeliveryJobListView] Refresh List (size): " + deliveryJobListPanel.size());
if (deliveryJobListPanel.size() > 0) {
emptyDeliveryJobListPanelPlaceholder.setVisible(false);
} else {
Expand All @@ -268,23 +268,19 @@ private void refreshDeliveryJobListView() {
}
}

private void refreshDeliveryJobDetailPane() {
logger.info("[JobListView] Refresh Detail");
deliveryJobListPanel.refresh();
}

/**
* Fills up all the placeholders of this window.
*/
void fillInnerParts() {
// Append views
deliveryJobListPanel = new DeliveryJobListPanel(logic.getFilteredDeliveryJobList(), selectDeliveryJobHandler,
completeDeliveryJobHandler,
deleteDeliveryJobHandler);
deliveryJobListPanel = new DeliveryJobListPanel(logic.getFilteredDeliveryJobList());
deliveryJobListPanel.setSelectHandler(selectDeliveryJobHandler);
deliveryJobListPanel.setCheckHandler(completeDeliveryJobHandler);
deliveryJobListPanel.setDeleteHandler(deleteDeliveryJobHandler);
deliveryJobListPanel.setOrderByHandler(sortDeliveryJobHandler);
deliveryJobListPanel.setFilterHandler(filterDeliveryJobHandler);
deliveryJobListPanelPlaceholder.getChildren().add(deliveryJobListPanel.getRoot());
deliveryJobListPanel.selectItem(0);
deliveryJobListPanel.selectDefault();

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());
Expand All @@ -295,15 +291,11 @@ void fillInnerParts() {
CommandBox commandBox = new CommandBox(this::executeCommand);
commandBoxPlaceholder.getChildren().add(commandBox.getRoot());

// Attach listeners
logic.getFilteredDeliveryJobList().addListener(new ListChangeListener<DeliveryJob>() {
@Override
public void onChanged(Change<? extends DeliveryJob> c) {
refreshDeliveryJobListView();
}
});
// Set default ordering
logic.updateSortedDeliveryJobListByComparator(new SortbyDate(true));

// Initialise detail panel
refreshDeliveryJobListView();
}

/**
Expand Down Expand Up @@ -480,6 +472,10 @@ private void handleDeliveryJobSystemCreateAction() {
addDeliveryJobWindow.hide();
}
addDeliveryJobWindow = new AddDeliveryJobWindow(new Stage(), logic);
addDeliveryJobWindow.setResultHandler(commandResult -> {
logger.info("[editDeliveryJobHandler] add complete.");
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());
});
addDeliveryJobWindow.show();
addDeliveryJobWindow.fillInnerParts();
}
Expand All @@ -489,11 +485,11 @@ private void handleDeliveryJobSystemCreateAction() {
*/
@FXML
private void handleDeliveryJobSystemImportAction() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Files");
File selectedFile = fileChooser.showOpenDialog(new Stage());

try {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Files");
File selectedFile = fileChooser.showOpenDialog(new Stage());

logic.execute(new ImportDeliveryJobCommand(selectedFile));
} catch (ParseException | CommandException e) {
logger.warning("[Event] importDeliveryJob" + e.getMessage());
Expand Down Expand Up @@ -578,7 +574,6 @@ private CommandResult executeCommand(String commandText)
handleExit();
}

refreshDeliveryJobDetailPane();
return commandResult;
} catch (CommandException | ParseException | IllegalArgumentException e) {
logger.info("Invalid command: " + commandText);
Expand Down
Loading

0 comments on commit 6bc18c0

Please sign in to comment.