Skip to content

Commit

Permalink
Fix task filter bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsieu committed Nov 2, 2021
1 parent b864110 commit 955f192
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.UndoableCommand;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.AddressBookParser;
Expand Down Expand Up @@ -132,17 +134,17 @@ public void setGuiSettings(GuiSettings guiSettings) {
@Override
public CommandResult undoCommand() {
try {
return this.execute("undo");
} catch (CommandException | ParseException e) {
return executeCommand(new UndoCommand());
} catch (CommandException e) {
return new CommandResult(e.getMessage());
}
}

@Override
public CommandResult redoCommand() {
try {
return this.execute("redo");
} catch (CommandException | ParseException e) {
return executeCommand(new RedoCommand());
} catch (CommandException e) {
return new CommandResult(e.getMessage());
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Contact;
import seedu.address.model.task.Task;
import seedu.address.model.task.filters.TagTaskFilter;
import seedu.address.model.task.filters.TaskFilter;
import seedu.address.model.task.filters.TaskFilters;
import seedu.address.storage.CommandHistory;
Expand Down Expand Up @@ -116,6 +117,7 @@ public Path getAddressBookFilePath() {
public void setAddressBookFilePath(Path addressBookFilePath) {
requireNonNull(addressBookFilePath);
userPrefs.setAddressBookFilePath(addressBookFilePath);
userPrefs.setAddressBookFilePath(addressBookFilePath);
}

//=========== AddressBook ================================================================================
Expand Down Expand Up @@ -334,7 +336,8 @@ private void updateTaskFilters() {
recomputeAvailableTaskFilters();

// If removing or editing the task removed a tag, remove all filters associated with that tag
if (selectedTaskFilters.removeIf(filter -> !availableTaskFilters.contains(filter))) {
if (selectedTaskFilters.removeIf(filter -> filter instanceof TagTaskFilter
&& !availableTaskFilters.contains(filter))) {
recalculateFilteredTaskList();
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/seedu/address/ui/TaskListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public TaskListPanel(
placeholder.getStyleClass().add("italics");
filterComboBox.setPlaceholder(placeholder);
filterComboBox.setItems(selectableTaskFilters);
// Workaround: Close menu when mouse down to prevent mouse up from selecting another item
filterComboBox.setOnAction(e -> filterComboBox.hide());
filterComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
addTaskFilter.accept(newValue);

// When a filter is selected, reset the combo box's current selection
Platform.runLater(filterComboBox.getSelectionModel()::clearSelection);
Platform.runLater(() -> {
filterComboBox.getSelectionModel().clearSelection();
filterComboBox.hide();
addTaskFilter.accept(newValue);
});
}
});

Expand Down

0 comments on commit 955f192

Please sign in to comment.