Skip to content

Commit

Permalink
Merge pull request #255 from sopa301/branch-code-slap
Browse files Browse the repository at this point in the history
Update UG and improve SLAP
  • Loading branch information
sopa301 authored Nov 11, 2023
2 parents ed176dc + 4c6aac4 commit 8e76317
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
2 changes: 2 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ initialised with the focus on the `confirm` button. This makes it possible for a
twice and wipe the contact book anyway, bypassing the defence mechanism entirely. We plan to make the command more
resistant to mistakes by having the user key in a specific phrase, or to initialise the window with the focus on the
`cancel` button instead.
8. Currently, long names for `tags` and `financial plans` may not be fully visible in the UI. We plan to restrict the
length of such values so that we can ensure that these values will always be fully visible.

*{More to be added}*

Expand Down
17 changes: 10 additions & 7 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Component | Purpose
e.g. in `add n/NAME`, `NAME` is a parameter which can be used as `add n/John Doe`.

* Items in square brackets are optional.<br>
e.g `n/NAME [t/TAG]` can be used as `n/John Doe t/friend` or as `n/John Doe`.
e.g. `n/NAME [t/TAG]` can be used as `n/John Doe t/friend` or as `n/John Doe`.

* Unless explicitly allowed, blank inputs or inputting any number of spaces as an argument for a field is invalid.

Expand Down Expand Up @@ -170,8 +170,9 @@ number) into contact book.

Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS nk/NEXT_KIN nkp/NEXT_KIN_PHONE [fp/FINANCIAL_PLAN]… [t/TAG]…​`

* Adding a person with the exact same name (case-sensitive) as a person currently in the contact book will cause the
command to fail.
* Adding a person with the exact same name (case-sensitive) as a person currently in the contact book counts as a
duplicate and will cause the command to fail. Duplicate information in other ways does not count as a duplicate
person.
* To prevent accidentally adding duplicates, you can use [Find](#locating-persons-by-name-financial-plan-andor-tag--find)
to check if you have already added the person already.

Expand Down Expand Up @@ -223,8 +224,9 @@ Format: `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [nk/NEXT_KIN
* At least one of the optional fields must be provided.
* Existing values will be updated to the input values.
* Editing the name of a person to be the exact same name as another person currently in the contact book
(case-sensitive) will cause the command to fail.
* When editing financial plans or tags, the existing financial plans or tags of the person will be removed i.e adding
(case-sensitive) counts as a duplicate and will cause the command to fail. Duplicate information in other ways does
not count as a duplicate person.
* When editing financial plans or tags, the existing financial plans or tags of the person will be removed i.e. adding
of tags is not cumulative.
* You can remove all the person’s tags by typing `t/` without specifying any tags after it.
* You can remove all the person’s financial plans by typing `fp/` without
Expand Down Expand Up @@ -285,7 +287,7 @@ Format: `gather fp/FINANCIAL PLAN` or `gather t/TAG`

* Generates a list of emails separated by spaces, making it convenient for copying and pasting into the recipient input of an email application.
* Either **Financial Plan or Tag** can be searched at once, but **not both**.
* The search is case-insensitive. e.g `financial` will match `FINANCIAL` or `Financial`.
* The search is case-insensitive e.g. `financial` will match `FINANCIAL` or `Financial`.
* A person's email will be gathered if the prompt matches a substring of their financial plan or tag.

Acceptable Values: Refer to [Argument Summary](#argument-summary).
Expand Down Expand Up @@ -334,7 +336,7 @@ Format: `schedule INDEX ap/APPOINTMENT_NAME d/APPOINTMENT_DATE_TIME`

- Schedules appointment with the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list.
- **Both appointment name and date-time** must be provided.
- Upon successful execution of the command, the scheduled appointment details will be updated in the **Contacts list**. The appointment details will also be updated in the **Appointments list**.
- Upon successful execution of the command, the scheduled appointment details will be updated in the **Contacts list**. The appointment details will also be updated in the **Appointments list**.

<div markdown="span" class="alert alert-primary">:information_source:
If there is an existing appointment with the person when the command is executed, you can replace it with a new appointment by **clicking confirm** or **pressing the enter key** when the prompt is given.
Expand Down Expand Up @@ -451,6 +453,7 @@ _Details coming soon ..._
1. **When using multiple screens**, if you move the application to a secondary screen, and later switch to using only the primary screen, the GUI will open off-screen. The remedy is to delete the `preferences.json` file created by the application before running the application again.
2. **Long names** for Financial Plans and Tags may not be fully visible.
3. **When sorting the list**, we have chosen to not implement returning sorted list to original ordering due to the lack of necessity. However, due to feedback, we will implement this in the next release to enable users to return list to original order should they wish to.
4. It is possible to add appointments with dates before the current date and time.

--------------------------------------------------------------------------------------------------------------------

Expand Down
71 changes: 38 additions & 33 deletions src/main/java/seedu/address/logic/parser/EditCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,7 @@ public EditCommand parse(String args) throws ParseException {
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_NEXT_OF_KIN_NAME, PREFIX_NEXT_OF_KIN_PHONE);

EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();

if (argMultimap.getValue(PREFIX_NAME).isPresent()) {
editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
}
if (argMultimap.getValue(PREFIX_PHONE).isPresent()) {
editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
}
if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
}
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
if (argMultimap.getValue(PREFIX_NEXT_OF_KIN_NAME).isPresent()) {
editPersonDescriptor.setNextOfKinName(ParserUtil.parseNextOfKinName(argMultimap
.getValue(PREFIX_NEXT_OF_KIN_NAME)
.get()));
}
if (argMultimap.getValue(PREFIX_NEXT_OF_KIN_PHONE).isPresent()) {
editPersonDescriptor.setNextOfKinPhone(ParserUtil.parseNextOfKinPhone(argMultimap
.getValue(PREFIX_NEXT_OF_KIN_PHONE)
.get()));
}

parseFinancialPlansForEdit(argMultimap.getAllValues(PREFIX_FINANCIAL_PLAN))
.ifPresent(editPersonDescriptor::setFinancialPlans);

parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);

if (!editPersonDescriptor.isAnyFieldEdited()) {
throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
}
EditPersonDescriptor editPersonDescriptor = makeEditPersonDescriptor(argMultimap);

return new EditCommand(index, editPersonDescriptor);
}
Expand Down Expand Up @@ -120,4 +88,41 @@ private Optional<Set<Tag>> parseTagsForEdit(Collection<String> tags) throws Pars
return Optional.of(ParserUtil.parseTags(tagSet));
}

/**
* Creates a EditPersonDescriptor with a given ArgumentMultimap that contains the inputs.
*
* @param argMultimap Multimap to get values from.
* @return Descriptor to pass to the EditCommand.
* @throws ParseException If no fields are edited or there are invalid multimap values.
*/
private EditPersonDescriptor makeEditPersonDescriptor(ArgumentMultimap argMultimap) throws ParseException {
EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();
if (argMultimap.getValue(PREFIX_NAME).isPresent()) {
editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
}
if (argMultimap.getValue(PREFIX_PHONE).isPresent()) {
editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
}
if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
}
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
if (argMultimap.getValue(PREFIX_NEXT_OF_KIN_NAME).isPresent()) {
editPersonDescriptor.setNextOfKinName(ParserUtil.parseNextOfKinName(argMultimap
.getValue(PREFIX_NEXT_OF_KIN_NAME).get()));
}
if (argMultimap.getValue(PREFIX_NEXT_OF_KIN_PHONE).isPresent()) {
editPersonDescriptor.setNextOfKinPhone(ParserUtil.parseNextOfKinPhone(argMultimap
.getValue(PREFIX_NEXT_OF_KIN_PHONE).get()));
}
parseFinancialPlansForEdit(argMultimap.getAllValues(PREFIX_FINANCIAL_PLAN))
.ifPresent(editPersonDescriptor::setFinancialPlans);
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);
if (!editPersonDescriptor.isAnyFieldEdited()) {
throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
}
return editPersonDescriptor;
}
}

0 comments on commit 8e76317

Please sign in to comment.