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

Fixed edit task details feature #67

Merged
merged 3 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ void changeTaskDetails(TaskModel task, HBox hbox, String newTaskName,
interactor.changeTaskDetails(changedTask, taskID);

//Creating a TaskViewModel for display purposes
TaskViewModel newTask = new TaskViewModel(task.getName(), taskID, task.getDescription(),
task.getCompletionStatus(), task.getDueDateTime());
TaskViewModel newTask = new TaskViewModel(newTaskName, taskID, newTaskName,
taskStatus, newDueDate);

//Calling a handler to display the final task changes
presenter.displayChangedTaskDetails(taskID, newTask, hbox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javafx.util.Pair;

import java.io.IOException;
import java.time.LocalDate;
import java.util.*;

/**
Expand Down Expand Up @@ -223,18 +224,23 @@ public void displayDeletedColumn(ColumnModel columnModel) {
*/
@Override
public void displayChangedTaskDetails(UUID taskID, TaskViewModel task, HBox hbox) {
String taskUUID = task.getID().toString();
System.out.println("IN PRESENTER");
String taskName = task.getName();
System.out.println("Name of task in displayChangedTaskDetails " + taskName);

//Removing the existing nane from the Hbox
hbox.getChildren().removeAll();

//Creating a new label and adding them in
Label taskLabel = new Label(taskName);
Button taskOptionsButton = new Button("...");
taskOptionsButton.setStyle("-fx-font-size: 8px;");
hbox.getChildren().add(taskLabel);
hbox.getChildren().add(taskOptionsButton);
System.out.println("ID OF ACTUAL TASK" + taskID);
System.out.println("ID OF HBOX UI" + hbox);
for (Node node: hbox.getChildren()) {
System.out.println("ITEM IN HBOX " + node);
if (node instanceof Text) {
System.out.println("FOUND THE TEXT");
((Text) node).setText(taskName);
System.out.println("TEXT UPDATED");
break;
}
}
}

@Override
Expand Down Expand Up @@ -323,8 +329,7 @@ public void displayNewColumn(ColumnModel column) {
MenuItem deleteColumnButton = new MenuItem("Delete Column");

Button addTaskButton = new Button("Add Task");
addTaskButton.setOnAction(event -> controller.presenter.handleAddTaskPopup(columnBox,
controller));
addTaskButton.setOnAction(event -> controller.presenter.handleAddTaskPopup(columnBox));
HBox TaskBtnVBox = new HBox(addTaskButton);

// Add event handler on menu item.
Expand Down Expand Up @@ -416,7 +421,7 @@ void populateTasksForEachColumn(VBox columnBox, List<TaskModel> tasks, ProjectVi
// projectViewingAndModificationController.renameTask(task, hbox);});
//Event handler for the changing task details. Calls another method on this presenter
changeTaskDetailsButton.setOnAction(event -> {
this.handleChangeTaskPopup(task, hbox, controller);
this.handleChangeTaskPopup(task, hbox);
//projectViewingAndModificationController.changeTaskDetails(
//task, hbox);
});
Expand Down Expand Up @@ -545,10 +550,9 @@ private void SetHBoxFeatures(VBox columnBox, HBox hbox) {
* the selected column.
*
* @param columnBox The VBox representing the Column UI where the task will be added.
* @param projectViewingAndModificationController
*/
void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController projectViewingAndModificationController) {
projectViewingAndModificationController.setPresenter();
void handleAddTaskPopup(VBox columnBox) {
controller.setPresenter();
// Create a new stage for the popup
Stage popupStage = new Stage();

Expand All @@ -563,7 +567,6 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController
gridPane.setVgap(10);

// Create labels and input fields for Task Details, Task Due Date, and Task Name

Label nameLabel = new Label("Task Name:");
TextField nameTextField = new TextField();

Expand All @@ -588,12 +591,20 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController

// Handles the action of putting a new task in the correct Column UI.
addTaskToColumnButton.setOnAction(event -> {
// Close the popup when "Submit" button is pressed
popupStage.close();
String taskName = nameTextField.getText().trim();
String taskDetails = detailsTextArea.getText().trim();
LocalDate dueDate = dueDatePicker.getValue();

// Call the method to handle adding the task to the column
projectViewingAndModificationController.handleAddTaskToColumn(columnBox.getId(), nameTextField.getText(),
detailsTextArea.getText(), dueDatePicker.getValue().atStartOfDay());
if (taskName.isEmpty() || taskDetails.isEmpty() || dueDate == null) {
// Show an alert if any of the fields are empty
showAlert("Error", "All fields are required. Please fill in all the details.");
} else {
// Close the popup when "Submit" button is pressed
popupStage.close();

// Call the method to handle adding the task to the column
controller.handleAddTaskToColumn(columnBox.getId(), taskName, taskDetails, dueDate.atStartOfDay());
}
});

// Add the "Add" button to the GridPane
Expand All @@ -613,11 +624,9 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController
* ProjectViewingAndModificationController
* @param task
* @param hbox
* @param projectViewingAndModificationController
*/
void handleChangeTaskPopup(TaskModel task, HBox hbox,
ProjectViewingAndModificationController projectViewingAndModificationController) {
projectViewingAndModificationController.setPresenter();
void handleChangeTaskPopup(TaskModel task, HBox hbox) {
controller.setPresenter();
// Create a new stage for the popup
Stage popupStage = new Stage();

Expand All @@ -632,7 +641,6 @@ void handleChangeTaskPopup(TaskModel task, HBox hbox,
gridPane.setVgap(10);

// Create labels and input fields for Task Details, Task Due Date, and Task Name

Label nameLabel = new Label("Task Name:");
TextField nameTextField = new TextField();

Expand All @@ -657,13 +665,22 @@ void handleChangeTaskPopup(TaskModel task, HBox hbox,

// Handles the action of putting a new task in the correct Column UI.
changeTaskButton.setOnAction(event -> {
// Close the popup when "Submit" button is pressed
popupStage.close();
String taskName = nameTextField.getText().trim();
String taskDetails = detailsTextArea.getText().trim();
LocalDate dueDate = dueDatePicker.getValue();

// Call the method to handle adding the task to the column
projectViewingAndModificationController.changeTaskDetails(task, hbox, nameTextField.getText(),
detailsTextArea.getText(), dueDatePicker.getValue().atStartOfDay());
if (taskName.isEmpty() || taskDetails.isEmpty() || dueDate == null) {
// Show an alert if any of the fields are empty
showAlert("Error", "All fields are required. Please fill in all the details.");
} else {
// Close the popup when "Submit" button is pressed
popupStage.close();

// Call the method to handle changing the task details
controller.changeTaskDetails(task, hbox, taskName, taskDetails, dueDate.atStartOfDay());
}
});

// Add the "Change Task" button to the GridPane
gridPane.add(changeTaskButton, 0, 3, 2, 1);

Expand Down
Loading