Skip to content

Commit

Permalink
Merge branch 'master' into filter-command-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JYL27 authored Nov 7, 2024
2 parents c5fdd76 + a914940 commit 1302875
Show file tree
Hide file tree
Showing 43 changed files with 445 additions and 129 deletions.
39 changes: 25 additions & 14 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,38 +71,49 @@ The **API** of this component is specified in [`Ui.java`](https://github.com/se-

<puml src="diagrams/UiClassDiagram.puml" alt="Structure of the UI Component"/>

The UI is managed by the `UiManager` class, which serves as the main controller for managing the UI in EduContacts.
The UI is managed by the `UiManager` class, which serves as the main controller for managing the UI in EduContacts.
It serves as the interface layer between the application's backend logic and the JavaFX UI components, ensuring a smooth
and consistent user experience.

The UI consists of a `MainWindow` that is made up of the following parts:
The UI consists of a `MainWindow` that is made up of the following parts:
* `CommandBox`
* Where the user types in his desired command
* Where the user types in his desired command
* Integrates with [`CommandHistory`](#commandhistory-integration) to provide an efficient command-tracking mechanism, allowing users to navigate
through previously entered commands using the `UP` and `DOWN` arrow keys.
* `ResultDisplay`
* Where the resulting confirmation of the latest command sent or any corresponding error messages is shown to the user
* Where the resulting confirmation of the latest command sent or any corresponding error messages is shown to the user
* `PersonListPanel`
* The panel which holds the list of persons in EduContacts, each person represented by a `PersonCard`
* The panel which holds the list of persons in EduContacts, each person represented by a `PersonCard`
* `StatusBarFooter`
* Designed to show the save location of EduContacts' data
* `PersonDetails`
* A section of the UI that renders when a `FindCommand` is run, showing the resulting person's full details
* Designed to show the save location of EduContacts' data
* `PersonDetails`
* A section of the UI that renders when a `FindCommand` is run, showing the resulting person's full details
* `PersonCard`
* Shows simple and brief details about a person
* Shows simple and brief details about a person
* `HelpWindow`
* Displayed by clicking the "Help" button at the top right hand of the screen
* Displayed by clicking the "Help" button at the top right hand of the screen

All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between
All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between
classes that represent parts of the visible GUI.

The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that
are in the `src/main/resources/view` folder. For example, the layout of the [`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java) is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/resources/view/MainWindow.fxml)
The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that
are in the `src/main/resources/view` folder. For example, the layout of the
[`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java)
is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/resources/view/MainWindow.fxml)

The `UI` component,
**The `UI` component,**

* executes user commands using the `Logic` component.
* listens for changes to `Model` data so that the UI can be updated with the modified data.
* keeps a reference to the `Logic` component, because the `UI` relies on the `Logic` to execute commands.
* depends on some classes in the `Model` component, as it displays `Person` object residing in the `Model`.

#### `CommandHistory` Integration

The `CommandHistory` class, located in `seedu.address.ui.util`, is responsible for tracking user-entered commands.
It enhances the `CommandBox` functionality by allowing users to navigate through their command history with the
`UP` and `DOWN` arrow keys. This design keeps the command history encapsulated and separate from other UI components,
promoting modularity and adhering to good OOP practices.

The stylesheet used for the UI can be found in `src/main/java/resources/view/LightTheme.css`.
### Logic component
Expand Down
93 changes: 86 additions & 7 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c

<br>
<!-- * Table of Contents -->
<page-nav-print />

## Table of Contents
1. [Quick start](#quick-start)
2. [Features](#features)
- [Viewing help : `help`](#viewing-help-help)
- [Adding a person: `add`](#adding-a-person-add)
- [Listing all persons : `list`](#listing-all-persons-list)
- [Editing a person : `edit`](#editing-a-person-edit)
- [Grading a person : `grade`](#grading-a-person-grade)
- [Listing students by certain attributes : `filter`](#listing-students-by-certain-attributes-filter)
- [Adding a module to a student: `module`](#adding-a-module-to-a-student-module)
- [Deleting a person : `delete`](#deleting-a-person-delete)
- [Clearing all entries : `clear`](#clearing-all-entries-clear)
- [Exiting the program : `exit`](#exiting-the-program-exit)
3. [FAQ](#faq)
4. [Known issues](#known-issues)
5. [Command summary](#command-summary)

---

--------------------------------------------------------------------------------------------------------------------
<div style="page-break-after: always;"></div>

## Quick start

Expand Down Expand Up @@ -99,6 +99,7 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c
1. Refer to the [Features](#features) below for details of each command.

--------------------------------------------------------------------------------------------------------------------
<div style="page-break-after: always;"></div>

## Features

Expand Down Expand Up @@ -131,6 +132,10 @@ help
```
![help message](images/helpMessage.png)

Alternatively, you can click the button on the top right hand corner as indicated here:
![alternative_help](images/alternativeHelp.png)

<br>

### Adding a person: `add`

Expand All @@ -142,10 +147,13 @@ add ID n/NAME p/PHONE e/EMAIL a/ADDRESS c/COURSE t/TAG
```

Examples:
* `add 87654321 n/Betsy Crowe t/ Student e/[email protected] a/Blk 30 Geylang Street 29, #06-40 p/1234567 c/Business Analytics`
* `add 87654321 n/Betsy Crowe t/Student e/[email protected] a/Blk 30 Geylang Street 29, #06-40 p/1234567 c/Business Analytics`
* `add 12345678 n/John Doe p/98981212 e/[email protected] a/123 Jane Doe Road c/Computer Science t/Student`
* `add 71271222 n/Benson Boon p/89229191 e/[email protected] a/Blk 12 Benson Street c/Economics t/Student`
![result for 'add command result'](images/addCommandResult.png)

<br>

### Listing all persons : `list`

Shows a list of all persons in EduContacts.
Expand All @@ -154,6 +162,9 @@ Format:
```bash
list
```
![result for 'list command result'](images/listCommandResult.png)

<div style="page-break-after: always;"></div>

### Editing a person : `edit`

Expand All @@ -164,13 +175,35 @@ Format:
edit ID [FIELD_TO_EDIT_PREFIX] [NEW_VALUE]
```


* Edits a student's details according to the fields specified.
* At least one of the optional fields must be provided.
* Existing values will be updated to the input values.
Examples:
* To edit the module CS2103T to CS2101 of a student with ID 12345678, type `edit 12345678 m/CS2103T CS2101` utilizing the `m/` prefix for modules
* To edit the course of a student with ID 12121212 to Computer Science type `edit 12121212 c/Computer Science`
![result for 'edit command result'](images/editCommandResult.png)
<br>
### Adding a grade : `grade`
Adds a grade to a person's module

```bash
grade ID m/MODULE g/GRADE
```

* Adds a grade to a person according to the specified ID and Module
* Module specified must exist prior to execution grade command
* Acceptable grades: `A+, A, A-, B+, B, B-, C+, C, D+, D, F`
* Existing grade will be updated to the input grade

Examples:
* `grade 23876767 m/CS2103T g/A` will assign an A grade to the CS2103T module of a Person whose ID is 23876767

<br>

### Listing students by certain attributes : `filter`

Expand Down Expand Up @@ -216,6 +249,23 @@ Examples:

![result for 'find alex david'](images/filterAlexDavidResult.png)

<div style="page-break-after: always;"></div>

### Adding a module to a student: `module`

Adds a module to a specific student using their ID.

Format:
```bash
module ID m/MODULE
```

Examples:
* `module 12345678 m/CS2103T`
![result for 'add module result'](images/addModule.png)

<br>

### Deleting a person : `delete`

Deletes the specified person from EduContacts.
Expand All @@ -228,7 +278,23 @@ delete ID
* Deletes student with the specified `ID`.

Examples:
* `delete 12345678` will delete student contact with `ID: 12345678`.
* `delete 71271222` will delete student contact with `ID: 71271222`.
![result for 'delete_71271222'](images/filterAlexDavidResult.png)

<br>

### Finding a person : `find`

Finds the specified person from EduContacts and displays their details.

Format: `find ID`

* Finds student with the specified `ID`.

Examples:
* `find 12345678` will find student contact with `ID: 12345678` and display their details.

<div style="page-break-after: always;"></div>

### Clearing all entries : `clear`

Expand All @@ -246,6 +312,8 @@ The `clear` command will erase all contacts from the system. Please ensure that

</box>

<br>

### Exiting the program : `exit`

Exits the program.
Expand All @@ -261,10 +329,14 @@ exit
Use the UP and DOWN arrow keys to scroll through previous commands in the Command Box. This feature helps you reuse recent commands without retyping, making it faster to correct or repeat commands.
</box>

<br>

### Saving the data

EduContacts data are saved in the hard disk automatically after any command that changes the data. There is no need to save manually.

<br>

### Editing the data file

EduContacts data are saved automatically as a JSON file `[JAR file location]/data/educontacts.json`. Advanced users are welcome to update data directly by editing that data file.
Expand All @@ -276,11 +348,14 @@ If your changes to the data file makes its format invalid, EduContacts will disc
Furthermore, certain edits can cause the EduContacts to behave in unexpected ways (e.g., if a value entered is outside the acceptable range). Therefore, edit the data file only if you are confident that you can update it correctly.
</box>

<br>

### Archiving data files `[coming in v2.0]`

_Details coming soon ..._

--------------------------------------------------------------------------------------------------------------------
<div style="page-break-after: always;"></div>

## FAQ

Expand All @@ -304,6 +379,7 @@ _Details coming soon ..._
2. **If you minimize the Help Window** and then run the `help` command (or use the `Help` menu, or the keyboard shortcut `F1`) again, the original Help Window will remain minimized, and no new Help Window will appear. The remedy is to manually restore the minimized Help Window.

--------------------------------------------------------------------------------------------------------------------
<div style="page-break-after: always;"></div>

## Command summary

Expand All @@ -313,6 +389,9 @@ Action | Format, Examples
**Clear** | `clear`
**Delete** | `delete ID`<br> e.g., `delete 12345678`
**Edit** | `edit ID [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/COURSE] [t/TAG]…​`<br> e.g.,`edit 12345678 p/91234567 e/[email protected]`
**Filter** | `find [n/NAME] [c/COURSE] [m/MODULE]`<br> e.g., `find n/James Jake`
**Grade** | `grade ID m/MODULE g/GRADE` <br> e.g. `grade 12345678 m/CS2103T g/A`
**Add Module** | `module ID [m/MODULE]` <br> e.g., `add 12345678 m/CS2103T`
**Filter** | `filter [n/NAME] [c/COURSE] [m/MODULE]`<br> e.g., `filter n/James Jake`
**Find** | `find ID`<br> e.g., `find 12345678`
**List** | `list`
**Help** | `help`
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/addCommandResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/addModule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/alternativeHelp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/deleteCommandResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/editCommandResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/helpMessage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/listCommandResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/site.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"baseUrl": "",
"titlePrefix": "EduContacts",
"titleSuffix": "AddressBook Level-3",
"faviconPath": "images/SeEduLogo.png",
"style": {
"codeTheme": "light"
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AddCommand extends Command {


public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in EduContacts";
public static final String MESSAGE_DUPLICATE_PERSON = "A person with this studentID already exists in EduContacts";

private final Person toAdd;

Expand Down
34 changes: 31 additions & 3 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();
Person toDelete = null;
boolean PersonDetailsDeleted = false;

for (Person person : lastShownList) {
if (person.getStudentId().equals(studentId)) {
Expand All @@ -83,14 +84,41 @@ public CommandResult execute(Model model) throws CommandException {
}

if (module != null) {
if (!toDelete.hasModule(module)) {
Module moduleToDelete = null;
for (Module currModule : toDelete.getModules()) {
if (currModule.equals(module)) {
moduleToDelete = currModule;
break;
}
}

if (moduleToDelete == null) {
throw new CommandException(String.format(MESSAGE_MODULE_NOT_FOUND, toDelete.getStudentId()));
}
model.deleteModule(toDelete, module);
return new CommandResult(String.format(MESSAGE_DELETE_MODULE_SUCCESS, module.toString()));

model.deleteModule(toDelete, moduleToDelete);
if (toDelete.isSamePerson(model.getPersonToDisplay())) {
for (Person person : lastShownList) {
if (person.getStudentId().equals(studentId)) {
toDelete = person;
break;
}
}
model.setPersonToDisplay(toDelete);
return new CommandResult(String.format(MESSAGE_DELETE_MODULE_SUCCESS, moduleToDelete), true);
}
return new CommandResult(String.format(MESSAGE_DELETE_MODULE_SUCCESS, moduleToDelete));
}

if (toDelete.isSamePerson(model.getPersonToDisplay())) {
model.setPersonToDisplay(null);
PersonDetailsDeleted = true;
}

model.deletePerson(toDelete);
if (PersonDetailsDeleted) {
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(toDelete)), true);
}
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(toDelete)));
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}


model.setPerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);

if (personToEdit.isSamePerson(model.getPersonToDisplay())) {
model.setPersonToDisplay(editedPerson);
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)), true);
}
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)));
}

Expand All @@ -118,12 +124,12 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
Module newModule = editPersonDescriptor.newModule;

boolean isModuleRenamed = false;
if (updatedModules.stream().anyMatch(m -> m.value.equals(newModule.value))) {
if (updatedModules.stream().anyMatch(m -> m.value.toUpperCase().equals(newModule.value.toUpperCase()))) {
throw new CommandException(EditCommand.MESSAGE_DUPLICATE_MODULE);
}

for (int i = 0; i < updatedModules.size(); i++) {
if (updatedModules.get(i).value.equals(oldModule.value)) {
if (updatedModules.get(i).value.toUpperCase().equals(oldModule.value.toUpperCase())) {
Module updatedModule = new Module(newModule.value);
if (updatedModules.get(i).hasGrade()) {
updatedModule.setGrade(updatedModules.get(i).getGrade());
Expand Down
Loading

0 comments on commit 1302875

Please sign in to comment.