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

39 feature 21 handling change task details #48

Merged
merged 5 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -125,9 +125,7 @@ public void changeTaskDetails(TaskModel task, UUID TaskUIid) {
EditTaskDetails useCase = new EditTaskDetails(task, TaskUIid);
try {
useCase.editTask();
TaskViewModel newTask = new TaskViewModel(task.getName(), TaskUIid, task.getDescription(),
task.getCompletionStatus(), task.getDueDateTime());
presenter.dislayChangedTaskDetails(TaskUIid, newTask);
//Call to presenter here was moved to the controller (changeTaskDetails)
}
catch(Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import b_application_business_rules.entity_models.ColumnModel;
import b_application_business_rules.entity_models.ProjectModel;
import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.factories.TaskFactory;
import b_application_business_rules.use_cases.project_viewing_and_modification_use_cases.ProjectViewingAndModificationInteractor;
import c_interface_adapters.view_models.TaskViewModel;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
Expand Down Expand Up @@ -82,8 +84,32 @@ void deleteTask(TaskModel task, UUID hBoxID, UUID columnBoxID) {
interactor.deleteTask(task, hBoxID, columnBoxID);
}

void changeTaskDetails(TaskModel task, HBox hbox) {
// interactor.changeTaskDetails(task, hbox);
/**
* Receives the user input from the presenter and calls the interactor to make the changes
* to the database. If the action is successful, calls the presenter to display the final
* changes
* @param task
* @param hbox
* @param newTaskName
* @param newTaskDescription
* @param newDueDate
*/
void changeTaskDetails(TaskModel task, HBox hbox, String newTaskName,
String newTaskDescription, LocalDateTime newDueDate) {
UUID taskID = task.getID();
boolean taskStatus = task.getCompletionStatus();

//Creating a new TaskModel based on the user input
TaskModel changedTask = TaskFactory.create(newTaskName, taskID, newTaskDescription, taskStatus, newDueDate);
interactor.changeTaskDetails(changedTask, taskID);

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

//Calling a handler to display the final task changes
presenter.displayChangedTaskDetails(taskID, newTask, hbox);

}

void renameTask(TaskModel task, HBox hbox) {
Expand Down Expand Up @@ -113,11 +139,19 @@ void handleAddTaskToColumn(String columnBoxID, String taskName, String taskDescr
interactor.addNewTask(UUID.fromString(columnBoxID), taskName, taskDescription, dueDate);
}

//void handleChangeTaskDetails(VBox columnBox, String taskName, String taskDescription,
//LocalDateTime dueDate) {

//interactor.changeTaskDetails();

//}

/**
* Populates the project details on the UI, including the project name.
*
* @param project The Project instance representing the current project.
*/

private void populateProjectDetails(ProjectModel project) {

projectName.setText(project.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,27 @@ public void displayDeletedColumn(ColumnModel columnModel) {

}

@Override
public void dislayChangedTaskDetails(UUID taskID, TaskViewModel task) {
/**
* This method renames the existing task and changes the task description and shows the final
* changes on the screen
*
* @param taskID
* @param task
* @param hbox
*/
public void displayChangedTaskDetails(UUID taskID, TaskViewModel task, HBox hbox) {
String taskUUID = task.getID().toString();
String taskName = task.getName();

//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);
}

@Override
Expand Down Expand Up @@ -394,9 +412,13 @@ void populateTasksForEachColumn(VBox columnBox, List<TaskModel> tasks, ProjectVi
// Add event handlers.
renameTaskButton.setOnAction(event -> {
projectViewingAndModificationController.renameTask(task, hbox);});
//Event handler for the changing task details. Calls another method on this presenter
changeTaskDetailsButton.setOnAction(event -> {
projectViewingAndModificationController.changeTaskDetails(
task, hbox);});
this.handleChangeTaskPopup(task, hbox, controller);
//projectViewingAndModificationController.changeTaskDetails(
//task, hbox);
});

deleteTaskButton.setOnAction(event -> {
projectViewingAndModificationController.deleteTask(task, UUID.fromString(hbox.getId()),
UUID.fromString(columnBox.getId()));});
Expand Down Expand Up @@ -584,6 +606,73 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController
popupStage.showAndWait();
}

/**
* Creates a popup screen once the changeTaskDetail button is pressed. Takes in user input
* on the task name, task description and due date and then calls the
* ProjectViewingAndModificationController
* @param task
* @param hbox
* @param projectViewingAndModificationController
*/
void handleChangeTaskPopup(TaskModel task, HBox hbox,
ProjectViewingAndModificationController projectViewingAndModificationController) {
projectViewingAndModificationController.setPresenter();
// Create a new stage for the popup
Stage popupStage = new Stage();

// Stops all other stages from functioning until popupStage is closed.
popupStage.initModality(Modality.APPLICATION_MODAL);

popupStage.setTitle("Change Task Details");

// Create the GridPane layout for the popup
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
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();

Label detailsLabel = new Label("Task Details:");
TextArea detailsTextArea = new TextArea();
detailsTextArea.setPrefRowCount(3);

Label dueDateLabel = new Label("Task Due Date:");
DatePicker dueDatePicker = new DatePicker();

// Add the components to the GridPane. The number provided implies
// which position in the gridPane (i.e. column 0, row 0 is top left).
gridPane.add(nameLabel, 0, 0);
gridPane.add(nameTextField, 1, 0);
gridPane.add(detailsLabel, 0, 1);
gridPane.add(detailsTextArea, 1, 1);
gridPane.add(dueDateLabel, 0, 2);
gridPane.add(dueDatePicker, 1, 2);

// Create the "Change Task" button for submitting the task
Button changeTaskButton = new Button("Submit");

// 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();

// Call the method to handle adding the task to the column
projectViewingAndModificationController.changeTaskDetails(task, hbox, nameTextField.getText(),
detailsTextArea.getText(), dueDatePicker.getValue().atStartOfDay());
});
// Add the "Change Task" button to the GridPane
gridPane.add(changeTaskButton, 0, 3, 2, 1);

// Create the scene and set it on the stage
Scene popupScene = new Scene(gridPane, 800, 200);
popupStage.setScene(popupScene);

// Show the popup
popupStage.showAndWait();
}

public String displayAddColumnPopup() {
// Create a new stage for the popup
Expand Down
Loading