Skip to content

Commit

Permalink
Merge branch 'master' into findcommand-update
Browse files Browse the repository at this point in the history
  • Loading branch information
maze508 authored Apr 4, 2024
2 parents c7a9e10 + 068915d commit ea8ff23
Show file tree
Hide file tree
Showing 30 changed files with 587 additions and 101 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
}

shadowJar {
archiveFileName = 'addressbook.jar'
archiveFileName = 'gourmetgrid.jar'
}

run {
Expand Down
85 changes: 76 additions & 9 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa
## **Implementation**

This section describes some noteworthy details on how certain features are implemented.

### Add command

The `add` command allows users to create and add a new contact to the list.

Its process largely follows from the previous address book implementation, but with slight modifications for GourmetGrid's unique functions.
Below is the sequence diagram modelling the process of running an `add` command:

<puml src="diagrams/AddSequenceDiagram.puml" alt="AddSequenceDiagram" />

### Add favourite feature

The `addfav` feature allows users to add suppliers as favourites.
Expand All @@ -181,6 +191,42 @@ Below is the sequence diagram for the `addfav` command process:

<puml src="diagrams/AddFavouriteSequenceDiagram.puml" alt="AddFavouriteSequenceDiagram" />

### Remove favourite feature

The `removefav` feature allows users to remove suppliers from favourites.

#### Implementation
1. **Command Parsing:** The `RemoveFavouriteCommandParser` interprets the user input, extracts the specified indices and creates an instance of `RemoveFavouriteCommand`.
2. **Data Retrieval and Modification:** Upon execution, `RemoveFavouriteCommand` fetches the contacts specified by the indices and removes them from favourites by modifying the `isFavourite` field.
3. **Output Generation:** A summarising message that includes the names of the contacts modified is then displayed to the user.

#### Sequence Diagram

Below is the sequence diagram for the `removefav` command process:

<puml src="diagrams/RemoveFavouriteSequenceDiagram.puml" alt="RemoveFavouriteSequenceDiagram" />

### Show favourite feature

The `showfav` feature allows users to filter the contacts such that only the favourites are shown.

#### Design considerations:

**Aspect: How the end result of filtering manifests:**

- **Alternative 1 (current choice):** The filtering logic follows closely from that of the `find` feature.
- Pros: Simple and easy to implement given the existing `find` feature.
- Cons: May result in some similar functionality between `find` and `showfav` features.

- **Alternative 2:** Favourite contacts can be sorted to be above, with non-favourites below but still visible.
- Pros: Allows users to see all contacts, with favourites at the top for easy access.
- Cons: May result in confusion regarding the ordering of contacts.

#### Sequence Diagram

Below is the sequence diagram for the `showfav` command process:

<puml src="diagrams/ShowFavouriteSequenceDiagram.puml" alt="ShowFavouriteSequenceDiagram" />

### Add order feature

Expand All @@ -206,7 +252,7 @@ Below is the sequence diagram for the `addorder` command process:

### ListOrder Feature

The `listorder` feature allows users to list all orders associated with a person in the address book, sorted by date in ascending order. This is particularly useful for users who wish to track the order history of suppliers efficiently.
The `listorder` feature allows users to list all orders associated with a person in the address book, sorted by date in ascending order first, then sorted by order they were added in if date is the same. This is particularly useful for users who wish to track the order history of suppliers efficiently.

#### Design Considerations

Expand All @@ -232,6 +278,35 @@ Below is the sequence diagram for the `listorder` command process:
- **Sorting by Status:** Introduce functionality to sort orders by their status (e.g., pending, completed), providing users with more flexibility in viewing order information.
- **Filtering Options:** Implement filters to allow users to view orders within a specific date range or with particular characteristics, such as orders over a certain value.

### DeleteOrder Feature

The `deleteorder` feature allows users to delete a specific order from a supplier's list of orders, ensuring accurate and up-to-date record-keeping.

#### Design Considerations

- **Aspect: How order deletion is managed within Person objects**:
-
- **Alternative 1 (current choice):** Directly manage orders within the Person class by removing them from the person's orders list.
- Pros: Utilizes the existing structure of the Person class, allowing for straightforward access and modification of a person's order list.
- Cons: Adds complexity to the Person class, which now handles both personal information and order management.

- **Alternative 2:** Implement a dedicated order management system within the model.
- Pros: Separates concerns, making the system more modular and potentially easier to maintain.
- Cons: Increases system complexity by introducing new components and possibly duplicating list management functionality.

#### Implementation

1. **Command Parsing:** The `DeleteOrderCommandParser` interprets user input to identify the target person and order indices, then creates an instance of `DeleteOrderCommand`.
2. **Data Retrieval and Sorting:** Upon execution, `DeleteOrderCommand` locates the target person in the model, identifies the correct order based on the provided index (accounting for sorting by date, then addition sequence), and removes it from the person's orders.
3. **Output Generation:** A message confirms the successful deletion of the order.

#### Sequence Diagram

Below is the sequence diagram for the `deleteorder` command process:

<puml src="diagrams/DeleteOrderSequenceDiagram.puml" alt="DeleteOrderSequenceDiagram" />


### \[Proposed\] Undo/redo feature

#### Proposed Implementation
Expand Down Expand Up @@ -329,14 +404,6 @@ _{more aspects and alternatives to be added}_

_{Explain here how the data archiving feature will be implemented}_

### Add command

The `add` command allows users to create and add a new contact to the list.

Its process largely follows from the previous address book implementation, but with slight modifications for GourmetGrid's unique functions.
Below is the sequence diagram modelling the process of running an `add` command:



---

Expand Down
73 changes: 56 additions & 17 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ GourmetGrid User Guide
- Adding a person : add
- Listing all persons : list
- Editing a person : edit
- Add Contacts as Favourites : addfav
- Search Contact : find
- Adding contacts as favourites : addfav
- Showing favourite contacts : showfav
- Removing contacts from favourites : removefav
- Searching contact : find
- Adding an order : addorder
- Listing orders : listorder
- Deleting a person : delete
Expand Down Expand Up @@ -67,11 +69,11 @@ This user guide provides in-depth documentation on GourmetGrid installation proc

1. Ensure you have Java `11` or above installed in your Computer.

1. Download the latest `addressbook.jar` from [here](https://github.com/se-edu/addressbook-level3/releases).
1. Download the latest `gourmetgrid.jar` from [here](https://github.com/AY2324S2-CS2103T-T16-3/tp/releases).

1. Copy the file to the folder you want to use as the _home folder_ for your AddressBook.

1. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar addressbook.jar` command to run the application.<br>
1. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar gourmetgrid.jar` command to run the application.<br>
A GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.<br>
![Ui](images/Ui.png)

Expand Down Expand Up @@ -133,7 +135,7 @@ Shows a message explaning how to access the help page.
Format: `help`


### Adding a person: `add`
### Adding a person : `add`

Adds a person to the address book.

Expand All @@ -154,6 +156,9 @@ Shows a list of all persons in the address book.

Format: `list`

**Note:** `list` command is not compatible with further arguments.
</box>

### Editing a person : `edit`

Edits an existing person in the address book.
Expand All @@ -171,13 +176,13 @@ Examples:
* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags.


### Add contacts as favourites `addfav`
### Adding contacts as favourites : `addfav`

- Adds the contacts specified by index as favourites

Format: `addfav [i/INDICES]`
- Adds the contacts at the specified `INDICES` as favourites. The indices refer to comma-separated index numbers (i.e. index, index, index) shown in the displayed person list. Each index **must be a positive integer** 1,2,3, ...
<box type="tip" seamless>
- Adds the contacts at the specified `INDICES` as favourites. The indices refer to comma-separated index numbers (i.e. index, index, index) shown in the displayed person list. Each index **must be a positive integer** 1,2,3, ...
<box type="tip" seamless>

**Note:** Indices corresponding to existing favourite contacts are deemed as invalid indices for `addfav`
</box>
Expand All @@ -191,10 +196,24 @@ Examples:
- `addfav i/` returns an error message as the 'INDICES' field cannot be empty
- `addfav` returns an error message as it must be accompanied by the 'INDICES' field
- `addfav 1 i/ 2, 5` returns an error message as there should not be prefixes before the 'INDICES' field
-
### Showing favourite contacts : `showfav`

- Shows the contacts that are marked as favourites

Format: `showfav`

**Note:** `showfav` command is not compatible with further arguments.
</box>

Examples:
- `showfav` Shows all favourited contacts as expected
- `showfav 1` returns an error message as there should not be arguments after the `showfav` command word
- `showfav hello` returns an error message as there should not be arguments after the `showfav` command word

### Remove contacts from favourites `removefav`
### Removing contacts from favourites : `removefav`

- Remove the contacts specified by index as favourites
- Removes the contacts specified by index as favourites

Format: `removefav [i/INDICES]`
- Removes the contacts at the specified `INDICES` from favourites. The indices refer to comma-separated index numbers (i.e. index, index, index) shown in the displayed person list. Each index **must be a positive integer** 1,2,3, ...
Expand All @@ -214,11 +233,12 @@ Examples:
- `removefav` returns an error message as it must be accompanied by the 'INDICES' field
- `removefav 1 i/ 2, 5` returns an error message as there should not be prefixes before the 'INDICES' field

### Search Contact `find`
### Searching Contact : `find`

- Search feature supports substring search by name and/or tags and/or company **ONLY**.
- Finds all contacts whose names, tags or company matches the substring keyword provided.


General Format: `find FIELD/ KEYWORD FIELD/ KEYWORD ...`
- Where `FIELD` is either `n/` for name or `t/` for tag or `c/` for company.
- `KEYWORD` is the keyword to search for, here are some guidelines:
Expand Down Expand Up @@ -286,7 +306,7 @@ Adds an order to a supplier.
Format: `addorder INDEX d/DATE r/REMARK`

* Adds an order to the supplier at the specified `INDEX`. The index refers to the index number shown in the displayed supplier list. The index **must be a positive integer, starting from 1** (1, 2, 3, …​)
* The date must be in the format `YYYY-MM-DD`. For example, `2020-12-31`.
* The date must be in the format `YYYY-MM-DD`, where `YYYY` is the year (all the digits, i.e. 2012), `MM` is the month (01 to 12) and `DD` is the day (01 to 31). For example, `2020-12-31`.

<box type="tip" seamless>

Expand All @@ -295,19 +315,38 @@ Format: `addorder INDEX d/DATE r/REMARK`

Examples:
* `addorder 1 d/2020-01-01 r/100 chicken wings`
* `addorder 2 r/ 100 chicken wings d/ 2020-12-31`
* `addorder 3 d/2020-01-01 r/100 chicken wings`
* `addorder d/2020-01-01 r/100 chicken wings` returns an error as the index is not specified
* `addorder r/` or `addorder d/` or `addorder r/ d/` returns an error message as the 'KEYWORD' field cannot be empty
* `addorder 1 r/20 * 150g lettuce d/2020-12-31`
* `addorder 2 r/20 tomatoes, 40 apples (green) d/2020-12-31`

### Listing orders : `listorder`

Shows a list of all orders for a supplier in order of Date.
Shows a list of all orders for a supplier, sorted **first by date from the earliest to the latest and then by the order they were added if the dates are the same.

Format: `listorder INDEX`

* Shows a list of all orders for the supplier at the specified `INDEX`. The index refers to the index number shown in the displayed supplier list. The index **must be a positive integer, starting from 1** (1, 2, 3, …​)

### Deleting an order : `deleteorder`

Deletes an order from a particular person.

Format: `deleteorder INDEX o/ORDER_INDEX`

* Deletes a particular order for the supplier at the specified `INDEX`. The index refers to the index number shown in the displayed supplier list. The index **must be a positive integer, starting from 1** (1, 2, 3, …​)
* The ORDER_INDEX refers to the index number shown in the displayed order list. The order index **must be a positive integer, starting from 1** (1, 2, 3, …​)

**Important Note on Order Index**:
The ORDER_INDEX is determined based on the chronological order of the orders' dates from earliest to the latest (if 2 orders have the same date, they will then be sorted in the order they were added), not the sequence in which the orders were added. This means the orders are sorted by their dates, with the earliest orders appearing first. Hence, it is suggested you first list the orders for a supplier to determine the correct order index to delete.

Examples:
* Assuming the 1st supplier has 3 orders that were added in the following order:
* `addorder 1 d/2020-01-01 r/100 chicken wings`
* `addorder 1 d/2020-01-02 r/200 chicken wings`
* `addorder 1 d/2019-12-31 r/300 chicken wings`
* `deleteorder 1 o/1` deletes the 1st order for the 1st supplier in the address book. Which in the above example will remove the order added by `addorder 1 d/2019-12-31 r/300 chicken wings` Since the orders are sorted by date when added to a supplier
* `deleteorder 55 o/1` will return an error message if there is no 55th person in the address book and the index is invalid
* `deleteorder 1 o/55` will return an error message if there is no 55th order for the 1st supplier in the address book and the order index is invalid


### Deleting a person : `delete`

Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/AddFavouriteSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ activate AddFavouriteCommand
AddFavouriteCommand -> Model : getFilteredPersonList()
activate Model

Model --> AddFavouriteCommand : lastShownList
Model --> AddFavouriteCommand
deactivate Model

loop iterate through all indices
Expand Down
3 changes: 3 additions & 0 deletions docs/diagrams/AddSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ deactivate CommandResult
AddCommand --> LogicManager : r
deactivate AddCommand

[<-- LogicManager : r
deactivate LogicManager

@enduml
78 changes: 78 additions & 0 deletions docs/diagrams/DeleteOrderSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":DeleteOrderCommandParser" as DeleteOrderCommandParser LOGIC_COLOR
participant "d:DeleteOrderCommand" as DeleteOrderCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant "m:Model" as Model MODEL_COLOR
end box

[-> LogicManager : execute(args)
activate LogicManager

LogicManager -> AddressBookParser : parseCommand(args)
activate AddressBookParser

create DeleteOrderCommandParser
AddressBookParser -> DeleteOrderCommandParser
activate DeleteOrderCommandParser

DeleteOrderCommandParser --> AddressBookParser
deactivate DeleteOrderCommandParser

AddressBookParser -> DeleteOrderCommandParser : parse(args)
activate DeleteOrderCommandParser

create DeleteOrderCommand
DeleteOrderCommandParser -> DeleteOrderCommand
activate DeleteOrderCommand

DeleteOrderCommand --> DeleteOrderCommandParser :
deactivate DeleteOrderCommand

DeleteOrderCommandParser --> AddressBookParser : d
deactivate DeleteOrderCommandParser
DeleteOrderCommandParser -[hidden]-> AddressBookParser
destroy DeleteOrderCommandParser

AddressBookParser --> LogicManager : d
deactivate AddressBookParser

LogicManager -> DeleteOrderCommand : execute(m)
activate DeleteOrderCommand

DeleteOrderCommand -> Model : getFilteredPersonList()
activate Model
Model --> DeleteOrderCommand : lastShownList
deactivate Model

DeleteOrderCommand -> Model : getSortedOrders(order)
activate Model
Model --> DeleteOrderCommand : sortedOrders
deactivate Model

DeleteOrderCommand -> Model : deleteOrder(person, order)
activate Model
Model --> DeleteOrderCommand
deactivate Model

create CommandResult
DeleteOrderCommand -> CommandResult :
activate CommandResult

CommandResult --> DeleteOrderCommand
deactivate CommandResult

DeleteOrderCommand --> LogicManager : r
deactivate DeleteOrderCommand

[<-- LogicManager : r
deactivate LogicManager
@enduml
Loading

0 comments on commit ea8ff23

Please sign in to comment.