Skip to content

Commit

Permalink
Merge pull request #258 from Jayne1010/master
Browse files Browse the repository at this point in the history
Update DG implementation for UI and show command
  • Loading branch information
Jayne1010 authored Apr 14, 2024
2 parents c06b964 + e703a37 commit 8637fae
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 12 deletions.
111 changes: 108 additions & 3 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ The following activity diagram summarizes what happens when a user executes a ne

**Aspect: How to add:**

* **Alternative 1 (current choice):** Requires all the relevant fields (e.g. name, phone, email, ic number, age, sex, address).
* **Alternative 1 (current choice):** Requires all the relevant fields (e.g. name, phone, email, IC number, age, sex, address).
* Pros:
* Able to have complete contacts.
* For long time users: Do not need to use this command as often (mitigate cons that it is very long to type).
Expand All @@ -223,7 +223,7 @@ The following activity diagram summarizes what happens when a user executes a ne
* Might not have all the relevant information of all patients. Messy to keep track.

**Aspect: Display of new contact when command is successful:**
* Current choice: Displays the new contact with relevant patient information in the addressbook.
* Current choice: Displays the new contact with relevant patient information in ClinicMate.
* Rationale: Users will be able to view the patient and the information added easily.

**Aspect: Display of error message when command is unsuccessful:**
Expand Down Expand Up @@ -388,7 +388,15 @@ The following activity diagram summarizes what happens when a user executes a ne

The edit mechanism is facilitated by `AddressBook`. It implements `AddressBook#setPerson(Person target, Person editedPerson)` which allow users to edit patient’s details in the addressbook.

These operations are exposed in the `Model` interface as `Model#setPerson(Person target, Person editedPerson)`
These operations are exposed in the `Model` interface as `Model#setPerson(Person target, Person editedPerson)`.

The `edit` feature has the following operations in `ModelManager` which implements the `Model` interface:

- Model#setPerson: Replaces the given person target with `editedPerson`. Target must exist in the address book. The person identity of `editedPerson` must not be the same as another existing person in the address book.

- Model#hasPerson: Returns true if a person with the same identity as person exists in the address book.

- Model#updateFilteredPersonList: Updates the filter of the filtered person list to filter by the given predicate.

Given below is an example usage scenario and how the edit note mechanism behaves at each step.

Expand Down Expand Up @@ -428,6 +436,103 @@ The following activity diagram summarizes what happens when a user executes a ne
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format).
* Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful.

### Show feature

#### Implementation

The `show` mechanism is facilitated by `ModelManager`. It implements
- `ModelManager#setDisplayNote(Person person)` - which allows users to display
the notes of selected contacts on the `NoteDisplay`.
- `ModelManager#clear()` - which clears the notes in `NoteDislay`.

The `ShowCommandParser` parses the user input and implements `ShowCommand#createClearCommand()` if input is an empty string, else,
it implements `ShowCommand#createShowCommad(IdentityCardNumberMatchesPredicate icPredicate)`.

Given below is an example usage scenario and how the `show` mechanism behaves at each step.

Step 1: The user launches the application. The `AddressBook` will be initialized with the initial address book state.

Step 2:

- Scenario 1: The user executes `show T0123456A ...` to show the notes of the person in the address book with the unique IC number of `T0123456A`.
The `show` command calls `ModelManager#setDisplayNote(Person person)`, causing the modified state of the address book after the `show T0123456A ...` command executes to be displayed.

- Scenario 2: The user executes `show` to clear the notes of the person in patient notes display of the address book.
The `show` command calls `ModelManager#clear()`, causing the modified state of the address book after the `show` command executes to be displayed.

The following sequence diagram illustrates how a `show` operation goes through the `Logic` component and sets the patient notes display.

<puml src="diagrams/ShowSequenceDiagram.puml" alt="FindSequenceDiagram" />

<box type="info" seamless>

**Note:** The lifeline for `ShowCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</box>

The following activity diagram summarizes what happens when a user executes a `show` command:
<div style="text-align: center;">
<puml src="diagrams/ShowCommandActivityDiagram.puml" width="600"/>
</div>

#### Design Considerations & Alternatives Considered

**Aspect: How to show the notes of patient on patient notes display.**

- **Alternative 1 (Current Choice):** Show patient's notes in one command using `IC_NUMBER`.

- Pros: Users are able to view specific user's notes.

- Cons: Only allow for one parameter which is `IC_NUMBER`.

- **Alternative 2:** Only show the patient notes which was last searched for.
- Pros: Easy to implement.

- Cons: Brings inconvenience to users if they only want to view a specific user's notes.

**Aspect: How to clear the notes of patient on patient notes display.**

- **Alternative 1 (Current Choice):** Clears patient's notes on patient notes display using one command.
- Pros: Easy to implement. Users do not need to remember so many commands.

- Cons: The command might not be intuitive.

- **Alternative 2:** Clears patient's notes on patient notes display with another command.

- Pros: The command is more intuitive.

- Cons: Users are required to know an extra command, which reduces usability of application.

### NoteDisplay (UI Component)

The `NoteDisplay` allows the users to view the notes of the selected patient in the patient list. All notes are displayed in the `Person Card`.

#### Implementation

`NoteDisplay` inherits `UIPart` and is used to display the notes section of the patient details. More details of the class implementation can be seen in the class diagram below.

<div style="text-align: center;">
<puml src="diagrams/NoteDisplayClassDiagram.puml" width="450"/>
</div>

`NoteDisplay` has a private field `noteDisplay` which is of type `TextArea`. The `NoteDisplay` has a method called `setNoteToUser` which takes in a string input and changes the `noteDisplay` through its `settext` method.
The notes will then be display in a section which is a FXML `VBox`.

#### Design Consideration & Alternatives Considered

**Aspect: How the notes of the patient are displayed**

- **Alternative 1 (Current Choice):** Display the notes of the patients in a separate panel.
- Pros: The information of patient is more well organised. It allows users to have a more comprehensive view of their patient notes.

- Cons: One additional command is needed to view the notes of the patients.

- **Alternative 2:** Display the notes of the patients in the `PersonCard` with the rest the of the details.

- Pros: The user does not need to enter an extra command to view the notes of the patients.

- Cons: It is very difficult to view the notes of the individual patient as there is too much information displayed on the `PersonCard`.

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

## **Documentation, logging, testing, configuration, dev-ops**
Expand Down
23 changes: 23 additions & 0 deletions docs/diagrams/NoteDisplayClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@startuml
!include style.puml
skinparam arrowThickness 1.1
skinparam arrowColor UI_COLOR_T4
skinparam classBackgroundColor UI_COLOR

package UI <<Rectangle>>{
Class MainWindow
Class NoteDisplay {
setNoteToUser(note: String) : void
}
Class "{abstract}\nUiPart" as UiPart
}
package Model <<Rectangle>> {
Class HiddenModel #FFFFFF
}

MainWindow *-right-> "1" NoteDisplay
NoteDisplay -right..> Model
MainWindow -down-|> UiPart
NoteDisplay -down-|> UiPart

@enduml
14 changes: 5 additions & 9 deletions docs/diagrams/ShowCommandActivityDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ start
'Since the beta syntax does not support placing the condition outside the
'diamond we place it as the true branch instead.

if () then ([command successful])
:Displays contact in
side window;
else ([command unsuccessful])
:Error messages;
:Edit command
accordingly;
:Successfully displays
contact in side window;
if () then ([show `IC_NUMBER` command])
:Updates notes of specific patient in Patient Notes Display;
else ([show command])
:Clears notes in Patient Notes Display;

endif
stop
@enduml
71 changes: 71 additions & 0 deletions docs/diagrams/ShowSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@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 ":ShowCommandParser" as ShowCommandParser LOGIC_COLOR
participant "s:ShowCommand" as ShowCommand 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("show T0123456A")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("show T0123456A")
activate AddressBookParser

create ShowCommandParser
AddressBookParser -> ShowCommandParser
activate ShowCommandParser

ShowCommandParser --> AddressBookParser
deactivate ShowCommandParser

AddressBookParser -> ShowCommandParser : parse("T0123456A")
activate ShowCommandParser

create ShowCommand
ShowCommandParser -> ShowCommand : new ShowCommand.createShowCommand(i)
activate ShowCommand

ShowCommand --> ShowCommandParser :
deactivate ShowCommand

ShowCommandParser --> AddressBookParser : s
deactivate ShowCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
ShowCommandParser -[hidden]-> AddressBookParser
destroy ShowCommandParser

AddressBookParser --> LogicManager : s
deactivate AddressBookParser

LogicManager -> ShowCommand : execute(m)
activate ShowCommand

ShowCommand -> Model : setDisplayNote(T0123456A)
activate Model

Model --> ShowCommand
deactivate Model

create CommandResult
ShowCommand -> CommandResult
activate CommandResult

CommandResult --> ShowCommand
deactivate CommandResult

ShowCommand --> LogicManager : r
deactivate ShowCommand
destroy ShowCommand

[<--LogicManager
deactivate LogicManager
@enduml

0 comments on commit 8637fae

Please sign in to comment.