Skip to content

Commit

Permalink
Fix Status UI
Browse files Browse the repository at this point in the history
  • Loading branch information
choaticman committed Oct 25, 2024
1 parent 4294d27 commit 4d0ebfa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/main/java/seedu/hireme/logic/commands/StatusCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import static java.util.Objects.requireNonNull;

import java.util.List;
import java.util.function.Predicate;

import javafx.collections.transformation.FilteredList;
import seedu.hireme.commons.core.index.Index;
import seedu.hireme.logic.Messages;
import seedu.hireme.logic.commands.exceptions.CommandException;
Expand Down Expand Up @@ -64,15 +65,20 @@ public StatusCommand(Index targetIndex, Status newStatus) {
@Override
public CommandResult execute(Model<InternshipApplication> model) throws CommandException {
requireNonNull(model);
List<InternshipApplication> lastShownList = model.getFilteredList();
FilteredList<InternshipApplication> lastShownList =
(FilteredList<InternshipApplication>) model.getFilteredList();
Predicate prevPredicate = lastShownList.getPredicate() == null
? Model.PREDICATE_SHOW_ALL : lastShownList.getPredicate();

if (targetIndex.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_INTERNSHIP_APPLICATION_DISPLAYED_INDEX);
}

InternshipApplication internshipApplicationToUpdate = lastShownList.get(targetIndex.getZeroBased());
internshipApplicationToUpdate.setStatus(newStatus);
model.updateFilteredList(Model.PREDICATE_SHOW_ALL);
InternshipApplication updatedInternshipApplication = internshipApplicationToUpdate.deepCopy();
updatedInternshipApplication.setStatus(newStatus);
model.setItem(internshipApplicationToUpdate, updatedInternshipApplication);
model.updateFilteredList(prevPredicate);
return new CommandResult(String.format(MESSAGE_STATUS_CHANGE_SUCCESS,
Messages.format(internshipApplicationToUpdate), newStatus.getValue()));
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/hireme/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import seedu.hireme.commons.core.index.Index;
import seedu.hireme.commons.util.StringUtil;
import seedu.hireme.logic.commands.AddCommand;
import seedu.hireme.logic.commands.SortCommand;
import seedu.hireme.logic.parser.exceptions.ParseException;
import seedu.hireme.logic.validator.DateValidator;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/seedu/hireme/ui/InternshipApplicationCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class InternshipApplicationCard extends UiPart<Region> {
private Label email;
@FXML
private Label status;
@FXML
private Label statusTest;

/**
* Creates a {@code InternshipApplicationCard} with the given {@code InternshipApplication} and index to display.
Expand All @@ -51,7 +49,6 @@ public InternshipApplicationCard(InternshipApplication internshipApplication, in
email.setText(internshipApplication.getCompany().getEmail().getValue());
role.setText(internshipApplication.getRole().getValue());
date.setText(internshipApplication.getDateOfApplication().getValue().toString());
statusTest.setText(internshipApplication.getStatus().getValue().toString().toUpperCase());

String statusValue = internshipApplication.getStatus().getValue().toUpperCase();
status.setText(statusValue);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/view/InternshipApplicationListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="role" styleClass="cell_small_label" text="\$role" />
<Label fx:id="date" styleClass="cell_small_label" text="\$date" />
<Label fx:id="statusTest" styleClass="cell_small_label" text="\$statusTest" />
<Label fx:id="status" styleClass="status-label" />
</VBox>
</GridPane>
Expand Down

0 comments on commit 4d0ebfa

Please sign in to comment.