diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 277d6a84948..6b4a70003c9 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -38,7 +38,8 @@ NewAddressBook is a **desktop app built for secondary school teachers** handling * **`list`** : Lists all contacts. - * **`student`**`student n/John Doe p/94629424 e/j77@example.com a/George street, block 123, #01-01 f/3A2 g/M i/Math class em/92696977 m/Asthma` : Adds a student named `John Doe` to NewAddressBook. + * **`student`**` + student n/John Doe p/98765432 e/johnd@example.com g/M a/311, Clementi Ave 2, #02-25 f/3E1 em/999 i/Math class t/naughty ` : Adds a student named `John Doe` to NewAddressBook. * **`delete`**`3` : Deletes the 3rd contact shown in the current list. @@ -116,9 +117,8 @@ A teacher can have any number of tags (including 0), such as whether he/she is a Examples: -* `teacher n/Gabe p/91234567 e/gabe@example.com i/Lunch buddy` -* `teacher n/Lebron p/91234567 e/lbj@example.com a/George street, block 123, #01-01 i/Math HOD -t/relief` +* `teacher n/Gabe p/91234567 e/gabe@example.com g/M o/151 i/Lunch buddy` +* `teacher n/Lebron p/91234567 e/lbj@example.com g/F o/12 i/Math HOD t/relief` ### Adding a medical history to a student: `medical` @@ -285,9 +285,10 @@ _Details coming soon ..._ Action | Format, Examples --------|------------------ **Student** | `student n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS f/FORM_CLASS g/GENDER i/INVOLVEMENT em/EMERGENCY_NUMBER [m/MEDICAL_HISTORY]…​ [t/TAG]…​`
e.g., `student n/James p/94629424 e/j77@example.com a/George street, block 123, #01-01 f/3A2 g/M i/Math class em/92696977 m/asthma t/representative` +**Teacher** | `teacher n/Name p/PHONE_NUMBER e/EMAIL g/GENDER o/OFFICE_TABLE_NUMBER i/INVOLVEMENT [t/TAG]…​`
e.g., `teacher n/Gabe p/91234567 e/gabe@example.com g/M o/151 i/Lunch buddy` **Clear** | `clear` **Delete** | `delete INDEX`
e.g., `delete 3` -**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`
e.g.,`edit 2 n/James Lee e/jameslee@example.com` +**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`
e.g.,`editStudent 2 n/James Lee e/jameslee@example.com` **Find** | `find KEYWORD [MORE_KEYWORDS]`
e.g., `find James Jake` **Copy** | `copy f/FIELD`
e.g., `copy f/email` **List** | `list` diff --git a/src/main/java/seedu/address/logic/commands/student/AddStudentCommand.java b/src/main/java/seedu/address/logic/commands/student/AddStudentCommand.java index d11123335ed..4ca6359a3f5 100644 --- a/src/main/java/seedu/address/logic/commands/student/AddStudentCommand.java +++ b/src/main/java/seedu/address/logic/commands/student/AddStudentCommand.java @@ -40,7 +40,7 @@ public class AddStudentCommand extends Command { + PREFIX_EMAIL + "johnd@example.com " + PREFIX_GENDER + "M " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " - + PREFIX_FORM_CLASS + "3E1" + + PREFIX_FORM_CLASS + "3E1 " + PREFIX_EMERGENCY_CONTACT + "999 " + PREFIX_INVOLVEMENT + "Math class " + PREFIX_TAG + "naughty "; diff --git a/src/main/java/seedu/address/logic/commands/teacher/AddTeacherCommand.java b/src/main/java/seedu/address/logic/commands/teacher/AddTeacherCommand.java index 47bce412546..38edff03366 100644 --- a/src/main/java/seedu/address/logic/commands/teacher/AddTeacherCommand.java +++ b/src/main/java/seedu/address/logic/commands/teacher/AddTeacherCommand.java @@ -36,7 +36,7 @@ public class AddTeacherCommand extends Command { + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + PREFIX_GENDER + "M " - + PREFIX_OFFICE_TABLE + "7" + + PREFIX_OFFICE_TABLE + "7 " + PREFIX_INVOLVEMENT + "Math HOD " + PREFIX_TAG + "Colleague"; diff --git a/src/main/java/seedu/address/model/person/Involvement.java b/src/main/java/seedu/address/model/person/Involvement.java index ed07be1fd07..72170ffcd21 100644 --- a/src/main/java/seedu/address/model/person/Involvement.java +++ b/src/main/java/seedu/address/model/person/Involvement.java @@ -18,7 +18,7 @@ public class Involvement { */ public static final String VALIDATION_REGEX = "[^\\s].*"; - public final String involvement; + public final String value; /** * Constructs a {@code Involvement}. @@ -28,7 +28,7 @@ public class Involvement { public Involvement(String i) { requireNonNull(i); checkArgument(isValidInvolvement(i), MESSAGE_CONSTRAINTS); - involvement = i; + value = i; } /** @@ -40,18 +40,18 @@ public static boolean isValidInvolvement(String test) { @Override public String toString() { - return involvement; + return value; } @Override public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Involvement // instanceof handles nulls - && involvement.equals(((Involvement) other).involvement)); // state check + && value.equals(((Involvement) other).value)); // state check } @Override public int hashCode() { - return involvement.hashCode(); + return value.hashCode(); } } diff --git a/src/main/java/seedu/address/model/person/InvolvementContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/person/InvolvementContainsKeywordsPredicate.java index b08eac42efd..494555479f8 100644 --- a/src/main/java/seedu/address/model/person/InvolvementContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/person/InvolvementContainsKeywordsPredicate.java @@ -18,7 +18,7 @@ public InvolvementContainsKeywordsPredicate(List keywords) { @Override public boolean test(Person person) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getInvolvement().involvement, keyword)); + .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getInvolvement().value, keyword)); } @Override diff --git a/src/main/java/seedu/address/model/person/Student.java b/src/main/java/seedu/address/model/person/Student.java index 753e0d89ba1..0c013bccd80 100644 --- a/src/main/java/seedu/address/model/person/Student.java +++ b/src/main/java/seedu/address/model/person/Student.java @@ -26,7 +26,7 @@ public class Student extends Person { * @param emergencyContact Emergency contact of student * @param formClass Form Class of Student * @param tags Tags associated to student - * @param medicalHistory Medical History of student + * @param medicalHistory Medical History of student */ public Student(Name name, Phone phone, Email email, Gender gender, Involvement involvement, Address address, Phone emergencyContact, FormClass formClass, Set tags, MedicalHistory medicalHistory) { diff --git a/src/main/java/seedu/address/model/person/Teacher.java b/src/main/java/seedu/address/model/person/Teacher.java index dd62c25e074..204aad72e52 100644 --- a/src/main/java/seedu/address/model/person/Teacher.java +++ b/src/main/java/seedu/address/model/person/Teacher.java @@ -58,9 +58,9 @@ public boolean equals(Object other) { return false; } - Teacher otherStudent = (Teacher) other; - return super.equals(otherStudent) - && this.getOfficeTable().equals(otherStudent.getOfficeTable()); + Teacher otherTeacher = (Teacher) other; + return super.equals(otherTeacher) + && this.getOfficeTable().equals(otherTeacher.getOfficeTable()); } @Override diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 97c82cc7b82..032334557df 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -49,7 +49,7 @@ public JsonAdaptedPerson(Person source) { phone = source.getPhone().value; email = source.getEmail().value; gender = source.getGender().value; - involvement = source.getInvolvement().involvement; + involvement = source.getInvolvement().value; tagged.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 7ae79ed4183..1c2e01cedeb 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -31,7 +31,7 @@ public class MainWindow extends UiPart { private Logic logic; // Independent Ui parts residing in this Ui container - private StudentListPanel studentListPanel; + private PersonListPanel personListPanel; private ResultDisplay resultDisplay; private HelpWindow helpWindow; @@ -42,7 +42,7 @@ public class MainWindow extends UiPart { private MenuItem helpMenuItem; @FXML - private StackPane personListPanelPlaceholder; + private StackPane studentListPanelPlaceholder; @FXML private StackPane resultDisplayPlaceholder; @@ -110,8 +110,8 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { * Fills up all the placeholders of this window. */ void fillInnerParts() { - studentListPanel = new StudentListPanel(logic.getFilteredPersonList()); - personListPanelPlaceholder.getChildren().add(studentListPanel.getRoot()); + personListPanel = new PersonListPanel(logic.getFilteredPersonList()); + studentListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); @@ -163,8 +163,8 @@ private void handleExit() { primaryStage.hide(); } - public StudentListPanel getPersonListPanel() { - return studentListPanel; + public PersonListPanel getPersonListPanel() { + return personListPanel; } /** diff --git a/src/main/java/seedu/address/ui/StudentListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java similarity index 58% rename from src/main/java/seedu/address/ui/StudentListPanel.java rename to src/main/java/seedu/address/ui/PersonListPanel.java index cc7bd22b732..4329689acd0 100644 --- a/src/main/java/seedu/address/ui/StudentListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -10,30 +10,31 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.model.person.Person; import seedu.address.model.person.Student; +import seedu.address.model.person.Teacher; /** * Panel containing the list of persons. */ -public class StudentListPanel extends UiPart { +public class PersonListPanel extends UiPart { private static final String FXML = "PersonListPanel.fxml"; - private final Logger logger = LogsCenter.getLogger(StudentListPanel.class); + private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); @FXML - private ListView personListView; + private ListView studentListView; /** - * Creates a {@code PersonListPanel} with the given {@code ObservableList}. + * Creates a {@code StudentListPanel} with the given {@code ObservableList}. */ - public StudentListPanel(ObservableList personList) { + public PersonListPanel(ObservableList personList) { super(FXML); - personListView.setItems(personList); - personListView.setCellFactory(listView -> new StudentListViewCell()); + studentListView.setItems(personList); + studentListView.setCellFactory(listView -> new PersonListViewCell()); } /** * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. */ - class StudentListViewCell extends ListCell { + class PersonListViewCell extends ListCell { @Override protected void updateItem(Person person, boolean empty) { super.updateItem(person, empty); @@ -41,8 +42,10 @@ protected void updateItem(Person person, boolean empty) { if (empty || person == null) { setGraphic(null); setText(null); - } else { + } else if (person instanceof Student) { setGraphic(new StudentCard((Student) person, getIndex() + 1).getRoot()); + } else if (person instanceof Teacher) { + setGraphic(new TeacherCard((Teacher) person, getIndex() + 1).getRoot()); } } } diff --git a/src/main/java/seedu/address/ui/StudentCard.java b/src/main/java/seedu/address/ui/StudentCard.java index 6f1fe98c362..50ed35ca3b1 100644 --- a/src/main/java/seedu/address/ui/StudentCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -14,7 +14,7 @@ */ public class StudentCard extends UiPart { - private static final String FXML = "PersonListCard.fxml"; + private static final String FXML = "StudentListCard.fxml"; /** * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. @@ -52,7 +52,7 @@ public class StudentCard extends UiPart { private Label medicalHistory; /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Creates a {@code StudentCode} with the given {@code Student} and index to display. */ public StudentCard(Student student, int displayedIndex) { super(FXML); @@ -65,7 +65,7 @@ public StudentCard(Student student, int displayedIndex) { formClass.setText(student.getFormClass().value); gender.setText(student.getGender().value); medicalHistory.setText(student.getMedicalHistory().value); - involvement.setText(student.getInvolvement().involvement); + involvement.setText(student.getInvolvement().value); emergencyContact.setText(student.getEmergencyContact().value); student.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) diff --git a/src/main/java/seedu/address/ui/TeacherCard.java b/src/main/java/seedu/address/ui/TeacherCard.java new file mode 100644 index 00000000000..50a34315425 --- /dev/null +++ b/src/main/java/seedu/address/ui/TeacherCard.java @@ -0,0 +1,83 @@ +package seedu.address.ui; + +import java.util.Comparator; + +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import seedu.address.model.person.Teacher; + +/** + * An UI component that displays information of a {@code Teacher}. + */ +public class TeacherCard extends UiPart { + + private static final String FXML = "TeacherListCard.fxml"; + + /** + * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. + * As a consequence, UI elements' variable names cannot be set to such keywords + * or an exception will be thrown by JavaFX during runtime. + * + * @see The issue on AddressBook level 4 + */ + + public final Teacher teacher; + + @FXML + private HBox cardPane; + @FXML + private Label name; + @FXML + private Label id; + @FXML + private Label phone; + @FXML + private Label email; + @FXML + private Label gender; + @FXML + private Label involvement; + @FXML + private Label officeTable; + @FXML + private FlowPane tags; + + /** + * Creates a {@code TeacherCode} with the given {@code Teacher} and index to display. + */ + public TeacherCard(Teacher teacher, int displayedIndex) { + super(FXML); + this.teacher = teacher; + id.setText(displayedIndex + ". "); + name.setText(teacher.getName().fullName); + phone.setText(teacher.getPhone().value); + email.setText(teacher.getEmail().value); + gender.setText(teacher.getGender().value); + officeTable.setText(teacher.getOfficeTable().value); + involvement.setText(teacher.getInvolvement().value); + teacher.getTags().stream() + .sorted(Comparator.comparing(tag -> tag.tagName)) + .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + } + + @Override + public boolean equals(Object other) { + // short circuit if same object + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof TeacherCard)) { + return false; + } + + // state check + TeacherCard card = (TeacherCard) other; + return id.getText().equals(card.id.getText()) + && teacher.equals(card.teacher); + } +} diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 4ebcddda8d9..107acd5718f 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -107,12 +107,19 @@ -fx-background-color: #515658; } -.list-cell:filled:selected { +/*.list-cell:filled:selected {*/ +/* -fx-background-color: #424d5f;*/ +/*}*/ + +.list-cell:filled:selected #studentCardPane { -fx-background-color: #424d5f; + -fx-border-color: #3e7b91; + -fx-border-width: 1; } -.list-cell:filled:selected #cardPane { - -fx-border-color: #3e7b91; +.list-cell:filled:selected #teacherCardPane { + -fx-background-color: #724334; + -fx-border-color: #c07d73; -fx-border-width: 1; } @@ -307,11 +314,16 @@ -fx-padding: 8 1 8 1; } -#cardPane { +#studentCardPane { -fx-background-color: transparent; -fx-border-width: 0; } +#teacherCardPane { + -fx-background-color: rgba(140, 147, 98, 0.48); + -fx-border-width: 0; +} + #commandTypeLabel { -fx-font-size: 11px; -fx-text-fill: #F70D1A; @@ -328,7 +340,7 @@ -fx-text-fill: white; } -#filterField, #personListPanel, #personWebpage { +#filterField, #studentListPanel, #studentWebpage { -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); } @@ -368,3 +380,21 @@ -fx-background-radius: 2; -fx-font-size: 11; } + +#officeTable { + -fx-text-fill: white; + -fx-background-color: #397041; + -fx-padding: 1 3 1 3; + -fx-border-radius: 2; + -fx-background-radius: 2; + -fx-font-size: 11; +} + +#medicalHistory { + -fx-text-fill: white; + -fx-background-color: #bd00f5; + -fx-padding: 1 0 1 0; + -fx-border-radius: 2; + -fx-background-radius: 2; + -fx-font-size: 11; +} diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 32bcf2c8e70..866b7849143 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -47,11 +47,11 @@ - + - + diff --git a/src/main/resources/view/PersonListPanel.fxml b/src/main/resources/view/PersonListPanel.fxml index 8836d323cc5..e6b906fed69 100644 --- a/src/main/resources/view/PersonListPanel.fxml +++ b/src/main/resources/view/PersonListPanel.fxml @@ -4,5 +4,5 @@ - + diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/StudentListCard.fxml similarity index 91% rename from src/main/resources/view/PersonListCard.fxml rename to src/main/resources/view/StudentListCard.fxml index 1bb66d0ad14..5b391c8f02b 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/StudentListCard.fxml @@ -10,7 +10,7 @@ - + @@ -32,11 +32,14 @@