Skip to content

Commit

Permalink
Merge pull request #127 from FionaQY/update-delete-documentation
Browse files Browse the repository at this point in the history
Update delete documentation
  • Loading branch information
FionaQY authored Oct 23, 2024
2 parents 6f823cd + 6cc4cba commit 33b4ad1
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 11 deletions.
8 changes: 6 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,16 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

**Use case: U1 - Delete a person**

<img src="images/DeleteActivityDiagram.png" width="550" />

**MSS**

1. User requests to list persons.
2. AgentAssist shows a list of persons.
3. User requests to delete a specific person in the list.
4. AgentAssist deletes the person.
3. User requests to delete a specific person in the list.
4. AgentAssist asks user for confirmation.
5. User confirms.
6. AgentAssist deletes the person.

Use case ends.

Expand Down
27 changes: 23 additions & 4 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ delete <INDEX>
```
* Mandatory Field: `<INDEX>`
* Note: The provided `<INDEX>` must be **greater than 0 and less than the total number of customers in the list**.
* After entering the command, you will be asked for confirmation (y/yes) before deletion occurs.
For detailed explanations of each flag and acceptable arguments, refer to Sections [4.3 Flags](#43-flags) and [4.4 Arguments](#44-arguments)
Expand All @@ -447,13 +448,22 @@ For detailed explanations of each flag and acceptable arguments, refer to Sectio
```
delete 12
```
Confirmation prompt:
```
This will permanently delete this contact. Are you sure you want to execute this command? (y/n)
```
**What to Expect:**
- **On Success:**
- **On Success (after confirming with y/yes):**
- Message:
```
Customer <INDEX> has been deleted.
```
- **On Cancellation (if confirmation is declined):**
- Message:
```
Command has been cancelled.
```
- **On Error:**
- Invalid index error message:
```
Expand All @@ -474,19 +484,28 @@ For detailed explanations of each flag and acceptable arguments, refer to Sectio
```
clear
```
Confirmation prompt:
```
This will permanently clear all contacts. Are you sure you want to execute this command? (y/n)
```
**What to Expect:**
- **On Success:**
- **On Success (after confirming with y/yes):**
- Message:
```
Address book has been cleared!
```
The application will remove all client data from the list, effectively resetting the client database.
- **On Cancellation (if confirmation is declined):**
- Message:
```
Command has been cancelled.
```
- **On Error:**
- This command does not typically produce errors but will have no effect if there are no clients in the database to clear.
> ⛔ **Danger:**
> The `clear` command is **irreversible** and does not provide a confirmation message before clearing all records. Once executed, all client data is **permanently deleted**.
> The `clear` command is **irreversible**. Once executed, all client data is **permanently deleted**.
>
> It is highly recommended to **avoid using this command** unless absolutely necessary.
Expand Down Expand Up @@ -678,7 +697,7 @@ The data in AgentAssist is automatically saved as a [JSON](https://developer.moz
Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous AddressBook home folder.
### How do I change the remarks or credit card tier of an existing customer?
Use the [`edit` command](#feature-4-edit-the-existing-customer), and specify the `t/` flag for the credit card tier, and `rn/` or `ra/` for remarks.
Use the [`edit` command](#feature-4-edit-the-existing-customer), and specify the `t/` flag for the credit card tier, and `rn/` or `ra/` for remarks. If you wish to remove the assigned tier of a contact, simply use the `t/` flag without indicating a tier.
### Why am I getting an error when trying to edit the remark of an existing customer?
Ensure that the command syntax is correct, and note that the `rn/` and `ra/` flags cannot be used together. The `rn/` flag replaces the existing remark, while `ra/` appends to the current remark.
Expand Down
20 changes: 20 additions & 0 deletions docs/diagrams/DeleteActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@startuml
title Delete Activity Diagram
start
:Delete command is given;
if () then ([index within range])
:User is prompted
for confirmation;
if () then ([User confirms])
:Delete contact
at specified index;
else ([else])
:Show command
cancelled message;
endif
else ([else])
:Show error message;
endif

stop
@enduml
Binary file added docs/images/DeleteActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public CommandResult execute(Model model, Boolean confirmationReceived) {
if (confirmationReceived.equals(requiresConfirmation)) {
return this.execute(model);
}
return new CommandResult(MESSAGE_CLEAR_CONFIRMATION, false, false, true, null, false);
return new CommandResult(MESSAGE_CLEAR_CONFIRMATION, false, false, false, null, true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public CommandResult execute(Model model, Boolean confirmationReceived) throws C
if (confirmationReceived.equals(requiresConfirmation)) {
return this.execute(model);
}
return new CommandResult(MESSAGE_DELETE_CONFIRMATION, false, false, true, null, false);
return new CommandResult(MESSAGE_DELETE_CONFIRMATION, false, false, false, null, true);
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.logic;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;
import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY;
Expand Down Expand Up @@ -73,15 +74,13 @@ public void execute_cancelDeleteCommand_success() throws CommandException, Parse
assertCommandSuccess(deleteCommand[0], MESSAGE_DELETE_CONFIRMATION, expectedModel);
}

/*
@Test
public void execute_commandExecutionError_throwsCommandException() throws CommandException, ParseException {
String[] deleteCommand = {"delete 9", "y"};
assertCommandSuccess(deleteCommand[0], MESSAGE_DELETE_CONFIRMATION, model);
logic.execute(deleteCommand[0]);
assertThrows(CommandException.class, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX, () ->
logic.execute(deleteCommand[1]));
}
*/

@Test
public void execute_validCommand_success() throws Exception {
Expand Down

0 comments on commit 33b4ad1

Please sign in to comment.