Skip to content

Commit

Permalink
Merge pull request #132 from maze508/ug-updates
Browse files Browse the repository at this point in the history
UG and DG Enhancements and Fix Find Command
  • Loading branch information
guanquann authored Apr 11, 2024
2 parents 3f6d8a0 + d674709 commit 16b798b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
3 changes: 3 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,6 @@ to view their newly added order. We plan to show a preview of the order added. F
3. **Raise error when an outdated order date is added:** The current date validation does not check if the
order date is outdated when `addorder` command is called. We plan to raise an error when an outdated order date
is added. For example: `Order date cannot be in the past`.

4. **Improve Search Functionality**: The current implementation of the find command allows users to search for contacts based on their names, tags, or company names. However, it does not support searching by address, email, or phone number. We acknowledge that the ability to search by these fields can significantly enhance user experience by providing more flexibility and efficiency in locating contact information. The initial decision to exclude address, email, and phone number from the search criteria was based on a focus on the most commonly used identifiers for quick search and to maintain simplicity in the search interface. We also considered the privacy implications and the less frequent necessity of searching by personal information such as phone numbers or addresses. However, in order to enhance the utility of our contact management system, we are planning to introduce expanded search capabilities. This will include the ability to search for contacts by their phone numbers, email addresses, and physical addresses. This enhancement aims to provide a comprehensive search functionality that meets the needs of all users, making the tool more versatile and efficient for locating specific entries.

36 changes: 20 additions & 16 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,46 +235,50 @@ Examples:
- 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 ...`
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:
- Each `FIELD` is optional BUT at least one `FIELD` and `KEYWORD` pair must be provided.
- `KEYWORD` is the keyword to search for, here are some rules:
- Name and Company should contain alphanumeric characters, spaces, hyphens and/or apostrophes only.
- Tags should contain alphanumeric characters only.
- The search is case-insensitive.
- Teh search will find contacts containing the provided keyword as a substring within the specified field(s)
- Multiple Search Fields are treated as a **Logical AND (&&)**. Therefore, a contact must match all specified keywords across any mentioned fields to appear in the search results.


#### Search Guidelines

* 'KEYWORD' cannot be empty.
* e.g. `find n/` will **NOT** work as 'KEYWORD' cannot be empty.


* 'KEYWORD' and next 'FIELD' should be separated by a space.
* e.g. `find n/John t/friends` will find all instances of John that have the tag friends
* but `find n/Johnt/tfriends` will instead return an error since it assumes you are searching for 'Johnt/tfriends'
* and there should not be non-alphabetic characters in the 'KEYWORD' field.
* e.g. `find n/John t/friends` will find all instances of John that have the tag friends, but `find n/Johnt/tfriends` will instead return an error since it assumes you are searching for 'Johnt/tfriends' and there should not be non-alphabetic characters in the 'KEYWORD' field.


* Multiple Search 'FIELD's will be treated as a **Logical AND (&&)**.
* e.g. `find n/John n/Doe` will return all instances of John and Doe.
* e.g. `find n/John t/friends c/ Meat` will return all instances of John that are tagged as friends and have Meat in their company name. This means if there exists a contact with the name John that is tagged as friends but has a company Mat, it will not be returned.
* e.g. `find n/Ale n/le` can return contacts such as ["Alex Lew", "Alexis Lebrun", "Alec"]


* 'KEYWORD' should **NOT** be empty and there should be at least one 'FIELD' and 'KEYWORD' pair.
* e.g. `find n/ t/` and `find ` will **NOT** work.


* There should not be prefixes before the first 'FIELD' and 'KEYWORD' pair.
* e.g. `find testing123 n/John` will **NOT** work.


* The search is case-insensitive.
* e.g. `find n/hans` will match `Hans Niemann` and `Hans Zimmer`


* The order of the keywords does not matter.
* e.g. Results of `find n/Hans n/Bo` will match the results of`find n/Bo n/Hans`


* You can have multiple of the same 'FIELD's.
* e.g. `find n/J n/Do` will match names with `J` AND `Do`, like `John Doe` or `Dohnut Jibs`


Examples:
* `find n/Joh` returns `john`, `John Doe` and `Johnann Sebastian Bach`

Expand Down Expand Up @@ -317,32 +321,32 @@ Examples:

### Listing orders : `listorder`

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.
Shows a list of all orders for a contact, 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, …​)
* Shows a list of all orders for the contact at the specified `INDEX`. The index refers to the index number shown in the displayed contact 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, …​)
* Deletes a particular order for the contact at the specified `INDEX`. The index refers to the index number shown in the displayed contact 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.
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 contact to determine the correct order index to delete.

Examples:
* Assuming the 1st supplier has 3 orders that were added in the following order:
* Assuming the 1st contact 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 1 o/1` deletes the 1st order for the 1st contact 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 contact
* `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
* `deleteorder 1 o/55` will return an error message if there is no 55th order for the 1st contact in the address book and the order index is invalid

### Deleting a person : `delete`

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ public class FindCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Finds all persons whose names, tags or company names contain all of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: n/KEYWORD [MORE_KEYWORDS]... t/KEYWORD [MORE_KEYWORDS]... c/KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " n/alice t/friends c/Meat \n"
+ "Note: Multiple keywords (name, tag or company) are treated with a logical AND.";
+ "Parameters: [n/NAME_KEYWORDS] [t/TAG_KEYWORDS] [c/COMPANY_KEYWORDS]\n"
+ "Each field is optional, "
+ "but at least one must be provided. All Keywords are combined using logical AND (&&).\n"
+ "Example: " + COMMAND_WORD + " n/alice t/friends c/Meat - "
+ "Finds all persons named 'alice' AND tagged as 'friends' AND who's company name is "
+ "associated with 'Meat'.\n";


private final SearchPredicate predicate;

Expand Down

0 comments on commit 16b798b

Please sign in to comment.