Skip to content

Commit

Permalink
Fix date equality checks; Fix ui
Browse files Browse the repository at this point in the history
  • Loading branch information
vimuthm committed Oct 13, 2021
1 parent 219c9ba commit 7cb1e48
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/java/safeforhall/model/person/LastDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public LastDate(String date) {
* Returns true if a given string is a valid date.
*/
public static boolean isValidDate(String date) {
if (date == DEFAULT_DATE) {
if (date.equals(DEFAULT_DATE)) {
return true;
}
try {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/safeforhall/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public boolean equals(Object other) {
&& otherPerson.getPhone().equals(getPhone())
&& otherPerson.getEmail().equals(getEmail())
&& otherPerson.getVaccStatus().equals(getVaccStatus())
&& otherPerson.getFaculty().equals(getFaculty());
//&& otherPerson.getLastFetDate().equals(getLastFetDate())
//&& otherPerson.getLastCollectionDate().equals(getLastCollectionDate());
&& otherPerson.getFaculty().equals(getFaculty())
&& otherPerson.getLastFetDate().equals(getLastFetDate())
&& otherPerson.getLastCollectionDate().equals(getLastCollectionDate());
}

@Override
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/safeforhall/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javafx.scene.layout.VBox;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import safeforhall.model.person.Email;
import safeforhall.model.person.Faculty;
import safeforhall.model.person.LastDate;
Expand Down Expand Up @@ -59,6 +58,8 @@ public class PersonCard extends UiPart<Region> {
private VBox statusContainer;
@FXML
private VBox labelBox;
@FXML
private VBox labelBoxInterior;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
Expand All @@ -75,14 +76,14 @@ public PersonCard(Person person, int displayedIndex) {

if (person.getLastFetDate().date != DEFAULT_DATE) {
Label textBox = new Label(LastDate.FET_DESC + person.getLastFetDate().date);
textBox.setFont(new Font(3));
labelBox.getChildren().add(textBox);
textBox.getStyleClass().add("cell_small_label");
labelBoxInterior.getChildren().add(textBox);
}

if (person.getLastCollectionDate().date != DEFAULT_DATE) {
Label textBox = new Label(LastDate.COLLECTION_DESC + person.getLastCollectionDate().date);
textBox.setFont(new Font(3));
labelBox.getChildren().add(textBox);
textBox.getStyleClass().add("cell_small_label");
labelBoxInterior.getChildren().add(textBox);
}

if (person.hasMissedDeadline()) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
</Label>
<Label fx:id="name" text="\$first" styleClass="cell_big_label" />
</HBox>
<Label fx:id="room" styleClass="cell_small_label" text="\$room" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="faculty" styleClass="cell_small_label" text="\$faculty" />
<VBox fx:id="labelBoxInterior" styleClass="cell_small_label">
<Label fx:id="room" styleClass="cell_small_label" text="\$room" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="faculty" styleClass="cell_small_label" text="\$faculty" />
</VBox>
</VBox>
<HBox fx:id="informationContainer" alignment="CENTER_RIGHT" minHeight="105">
<VBox fx:id="deadlineContainer" alignment="CENTER">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import static safeforhall.logic.commands.CommandTestUtil.VALID_VACCSTATUS_BOB;
import static safeforhall.logic.parser.CommandParserTestUtil.assertParseFailure;
import static safeforhall.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static safeforhall.testutil.TypicalPersons.AMY;
import static safeforhall.testutil.TypicalPersons.AMY_NO_COLLECTION;
import static safeforhall.testutil.TypicalPersons.AMY_NO_FET;
import static safeforhall.testutil.TypicalPersons.AMY_NO_FET_COLLECTION;
import static safeforhall.testutil.TypicalPersons.BOB;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -106,17 +108,19 @@ public void parse_allFieldsPresent_success() {

@Test
public void parse_optionalFieldsMissing_success() {
Person expectedPerson = new PersonBuilder(AMY).build();
Person expectedPerson = new PersonBuilder(AMY_NO_FET_COLLECTION).build();

// missing lastFetDate and lastCollectionDate
assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ROOM_DESC_AMY
+ VACCSTATUS_DESC_AMY + FACULTY_DESC_AMY, new AddCommand(expectedPerson));

// missing lastFetDate
expectedPerson = new PersonBuilder(AMY_NO_FET).build();
assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ROOM_DESC_AMY
+ VACCSTATUS_DESC_AMY + FACULTY_DESC_AMY + COLLECTION_DESC_AMY, new AddCommand(expectedPerson));

// missing lastCollectionDate
expectedPerson = new PersonBuilder(AMY_NO_COLLECTION).build();
assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ROOM_DESC_AMY
+ VACCSTATUS_DESC_AMY + FACULTY_DESC_AMY + FET_DESC_AMY, new AddCommand(expectedPerson));
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/safeforhall/testutil/PersonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class PersonBuilder {
public static final String DEFAULT_EMAIL = "[email protected]";
public static final String DEFAULT_VACCSTATUS = "T";
public static final String DEFAULT_FACULTY = "SoC";
public static final String DEFAULT_FETDATE = "10-09-2021";
public static final String DEFAULT_COLLECTDATE = "10-09-2021";
public static final String DEFAULT_FETDATE = "";
public static final String DEFAULT_COLLECTDATE = "";

private Name name;
private Room room;
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/safeforhall/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,32 @@ public class TypicalPersons {
.withFet(VALID_FETDATE_AMY)
.withCollection(VALID_COLLECTIONDATE_AMY)
.build();
// Person AMY without FET or COLLECTION
public static final Person AMY_NO_FET_COLLECTION = new PersonBuilder().withName(VALID_NAME_AMY)
.withPhone(VALID_PHONE_AMY)
.withEmail(VALID_EMAIL_AMY)
.withRoom(VALID_ROOM_AMY)
.withFaculty(VALID_FACULTY_AMY)
.withVaccStatus(VALID_VACCSTATUS_AMY)
.build();
// Person AMY without FET
public static final Person AMY_NO_FET = new PersonBuilder().withName(VALID_NAME_AMY)
.withPhone(VALID_PHONE_AMY)
.withEmail(VALID_EMAIL_AMY)
.withRoom(VALID_ROOM_AMY)
.withFaculty(VALID_FACULTY_AMY)
.withVaccStatus(VALID_VACCSTATUS_AMY)
.withCollection(VALID_COLLECTIONDATE_AMY)
.build();
// Person AMY without COLLECTION
public static final Person AMY_NO_COLLECTION = new PersonBuilder().withName(VALID_NAME_AMY)
.withPhone(VALID_PHONE_AMY)
.withEmail(VALID_EMAIL_AMY)
.withRoom(VALID_ROOM_AMY)
.withFaculty(VALID_FACULTY_AMY)
.withVaccStatus(VALID_VACCSTATUS_AMY)
.withFet(VALID_FETDATE_AMY)
.build();
public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB)
.withPhone(VALID_PHONE_BOB)
.withEmail(VALID_EMAIL_BOB)
Expand Down

0 comments on commit 7cb1e48

Please sign in to comment.