Skip to content

Commit

Permalink
Merge pull request #162 from ljy0422/BugFix
Browse files Browse the repository at this point in the history
Fix 4 bugs
  • Loading branch information
ChuaZenKhoon authored Apr 9, 2024
2 parents 67dd0b8 + 042b75c commit d8ad470
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 357 deletions.
33 changes: 0 additions & 33 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import seedu.address.model.Model;
import seedu.address.model.person.Id;
import seedu.address.model.person.Person;
import seedu.address.ui.ConfirmationBox;
import seedu.address.ui.Prompt;

/**
* Deletes a person identified using the email id from the address book.
Expand All @@ -33,22 +31,6 @@ public class DeleteCommand extends Command {
private final Id targetId;

private Person personToDelete;
private Prompt confirmationBox;

/**
* Creates a {@code DeleteCommand} with the specified target ID and a custom {@code Prompt}
* for displaying confirmation dialogs. This constructor is primarily intended for use in
* scenarios where dependency injection is desired, such as unit testing, allowing for
* the replacement of the confirmation dialog with a fake implementation.
*
* @param targetId The ID of the person to be deleted.
* @param confirmationBox The {@code Prompt} implementation to be used for displaying
* confirmation dialogs.
*/
public DeleteCommand(Id targetId, Prompt confirmationBox) {
this.targetId = targetId;
this.confirmationBox = confirmationBox;
}

/**
* Creates a {@code DeleteCommand} with the specified target ID and no custom {@code Prompt}.
Expand All @@ -60,7 +42,6 @@ public DeleteCommand(Id targetId, Prompt confirmationBox) {
*/
public DeleteCommand(Id targetId) {
this.targetId = targetId;
this.confirmationBox = null;
}

@Override
Expand All @@ -72,20 +53,6 @@ public CommandResult execute(Model model) throws CommandException {
String deletedInformation = "";
for (Person person : lastShownList) {
if (person.getId().equals(this.targetId)) {
boolean isConfirmed;
if (confirmationBox == null) {
isConfirmed = new ConfirmationBox().display("Confirmation",
"Are you sure you want to delete this person?");
} else {
// This branch is designed for tests only.
// In actual use this branch will not be visited.
isConfirmed = confirmationBox.display("test", "test");
}
if (!isConfirmed) {
throw new CommandException(MESSAGE_DELETION_CANCELLED);
}
assert isConfirmed;

personToDelete = person;
model.deletePerson(personToDelete);
isAnyRecordDeleted = true;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public CommandResult execute(Model model) throws CommandException {
List<Person> lastShownList = model.getFilteredPersonList();

boolean isPersonExist = false;
Person personToEdit = new Person(new Name("test"),
personToEdit = new Person(new Name("test"),
new Id("test"), new Phone("123"), new HashSet<Tag>());

for (int i = 0; i < lastShownList.size(); i++) {
Expand Down Expand Up @@ -205,7 +205,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone);
return CollectionUtil.isAnyNonNull(name, phone, tags);
//email, address, tags);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class EditCommandParser implements Parser<EditCommand> {
public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE);
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_TAG);
//PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG

Id id;
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/seedu/address/ui/ConfirmationBox.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/seedu/address/ui/FakeConfirmationBox.java

This file was deleted.

80 changes: 0 additions & 80 deletions src/main/java/seedu/address/ui/LoginFormController.java

This file was deleted.

39 changes: 0 additions & 39 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package seedu.address.ui;

import java.io.IOException;
import java.util.logging.Logger;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextInputControl;
import javafx.scene.input.KeyCombination;
Expand Down Expand Up @@ -240,41 +236,6 @@ private void handleRedo() throws AccountException, CommandException, ParseExcept
}
}

@FXML
private void handleRegister() {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/view/RegisterForm.fxml"));
RegisterFormController controller = new RegisterFormController(accountManager);
loader.setController(controller);
Parent root = loader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}

@FXML
private void handleLogin() {
try {
if (accountManager.getLoginStatus()) {
resultDisplay.setFeedbackToUser("You have already logged in.");
return;
}

FXMLLoader loader = new FXMLLoader(getClass().getResource("/view/LoginForm.fxml"));
LoginFormController controller = new LoginFormController(accountManager, this);
loader.setController(controller);
Parent root = loader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}

@FXML
private void handleLogout() {
if (!accountManager.getLoginStatus()) {
Expand Down
73 changes: 0 additions & 73 deletions src/main/java/seedu/address/ui/RegisterFormController.java

This file was deleted.

25 changes: 0 additions & 25 deletions src/main/resources/view/LoginForm.fxml

This file was deleted.

Loading

0 comments on commit d8ad470

Please sign in to comment.