Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default remark showing up in UI #215

Merged
merged 7 commits into from
Nov 7, 2024
2 changes: 0 additions & 2 deletions src/main/java/seedu/address/model/client/Remark.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

import seedu.address.logic.commands.CommandCommons;


/**
* Represents a Client's remarks in the address book, as added by a user.
* Guarantees: immutable;
*/

public class Remark {

public static final String MESSAGE_CONSTRAINTS = "Remark must contain only ASCII characters.";
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/seedu/address/ui/ClientCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ClientCard extends UiPart<Region> {
private FlowPane assignedStatus;
@FXML
private VBox cardFields;

/**
* Creates a {@code ClientCode} with the given {@code Client} and index to display.
*/
Expand All @@ -57,20 +58,25 @@ public ClientCard(Client client, int displayedIndex) {
createStatus();
createTier();
}

private void createFields() {
name.setText(client.getName().fullName);
phone.setFields(ClientCardField.ICON_LITERAL_PHONE, client.getPhone().value);
address.setFields(ClientCardField.ICON_LITERAL_ADDRESS, client.getAddress().value);
email.setFields(ClientCardField.ICON_LITERAL_EMAIL, client.getEmail().value);
job.setFields(ClientCardField.ICON_LITERAL_JOB, client.getJob().value);
income.setFields(ClientCardField.ICON_LITERAL_INCOME, client.getIncome().toString());
String clientRemark = client.getRemark().value.trim().toLowerCase();
if (clientRemark.equalsIgnoreCase(CommandCommons.DEFAULT_REMARK)) {
String clientRemark = client.getRemark().value.trim();
setRemarkField(clientRemark);
cardFields.getChildren().addAll(phone, address, email, job, income, remark);
}

private void setRemarkField(String remarkText) {
if (remarkText.equalsIgnoreCase(CommandCommons.DEFAULT_REMARK)) {
remark.setFields(ClientCardField.ICON_LITERAL_REMARK, "");
} else {
remark.setFields(ClientCardField.ICON_LITERAL_REMARK, client.getRemark().value);
remark.setFields(ClientCardField.ICON_LITERAL_REMARK, remarkText);
}
cardFields.getChildren().addAll(phone, address, email, job, income, remark);
}

private void createTier() {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/seedu/address/ui/ClientDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.CommandCommons;
import seedu.address.model.client.Client;
import seedu.address.model.status.Status;

Expand Down Expand Up @@ -128,7 +129,7 @@ public void setClientDetails(Client client) {
setLabelText(incomeLabel, String.valueOf(client.getIncome()));
setTier(client.getTier().getValue());
setStatus(client.getStatus());
setLabelText(remarkLabel, client.getRemark().value);
setRemarkText(client.getRemark().value);
tagsGroup.getChildren().clear();
setTier(client.getTier().getValue());
setStatus(client.getStatus());
Expand All @@ -151,6 +152,15 @@ private void setLabelText(Label label, String text) {
}
}

private void setRemarkText(String remarkText) {
Label remarkLabel = new Label(remarkText);
if (remarkText.equalsIgnoreCase(CommandCommons.DEFAULT_REMARK)) {
setLabelText(remarkLabel, "");
} else {
setLabelText(remarkLabel, remarkText);
}
}

/**
* Sets the tier display in the detail panel.
* Creates a new styled label for the tier and adds it to the tier pane.
Expand Down